2 #include <ros/console.h> 3 #include <actionlib/server/simple_action_server.h> 4 #include <cpswarm_msgs/CoverageAction.h> 5 #include <cpswarm_msgs/TargetPositionEvent.h> 23 typedef actionlib::SimpleActionServer<cpswarm_msgs::CoverageAction>
action_server_t;
36 nh.param(this_node::getName() +
"/loop_rate", loop_rate, 5.0);
39 ROS_INFO(
"Executing coverage");
47 ROS_DEBUG(
"Coverage step");
57 ROS_INFO(
"Coverage succeeded, found target %d at [%f, %f]",
result.target_id,
result.target_pose.pose.position.x,
result.target_pose.pose.position.y);
64 ROS_INFO(
"Coverage aborted");
70 ROS_INFO(
"Coverage preempted");
82 result.target_id = msg->id;
83 result.target_pose = msg->pose;
92 int main (
int argc,
char** argv)
95 init(argc, argv,
"uav_coverage");
99 if (console::set_logger_level(ROSCONSOLE_DEFAULT_NAME, console::levels::Info)) {
100 console::notifyLoggerLevelsChanged();
103 ROS_ERROR(
"Could not set logger level!");
108 nh.param(this_node::getName() +
"/queue_size", queue_size, 1);
110 nh.param(this_node::getName() +
"/single_target", single_target,
true);
111 Subscriber found_sub;
113 found_sub = nh.subscribe(
"target_found", queue_size,
found_callback);
void found_callback(const cpswarm_msgs::TargetPositionEvent::ConstPtr &msg)
Callback function to receive details of a target that has been detected.
behavior_state_t
An enumeration for the state of the behavior algorithm.
actionlib::SimpleActionServer< cpswarm_msgs::CoverageAction > action_server_t
An action server type that allows to start and stop the coverage task.
cpswarm_msgs::CoverageResult result
The target found during execution of the coverage algorithm.
behavior_state_t state
The state of the behavior algorithm.
behavior_state_t step()
Move the swarm member to a new position.
void ActionCallback(const cpswarm_msgs::CoverageGoalConstPtr &goal, action_server_t *as)
Callback of the action server which executes the coverage task until it is preempted or finished...
int main(int argc, char **argv)
Main function to be executed by ROS.
A class that allows to cover a given area with the random direction algorithm. The random direction i...