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");
60 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);
67 ROS_INFO(
"Coverage aborted");
73 ROS_INFO(
"Coverage preempted");
85 result.target_id = msg->id;
86 result.target_pose = msg->pose;
95 int main (
int argc,
char** argv)
98 init(argc, argv,
"uav_coverage");
102 if (console::set_logger_level(ROSCONSOLE_DEFAULT_NAME, console::levels::Info)) {
103 console::notifyLoggerLevelsChanged();
106 ROS_ERROR(
"Could not set logger level!");
111 nh.param(this_node::getName() +
"/queue_size", queue_size, 1);
113 nh.param(this_node::getName() +
"/single_target", single_target,
true);
114 Subscriber found_sub;
116 found_sub = nh.subscribe(
"target_found", queue_size,
found_callback);
actionlib::SimpleActionServer< cpswarm_msgs::CoverageAction > action_server_t
An action server type that allows to start and stop the coverage task.
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...
behavior_state_t state
The state of the behavior algorithm.
cpswarm_msgs::CoverageResult result
The target found during execution of the coverage algorithm.
int main(int argc, char **argv)
Main function to be executed by ROS.
void found_callback(const cpswarm_msgs::TargetPositionEvent::ConstPtr &msg)
Callback function to receive details of a target that has been detected.
behavior_state_t step()
Move the swarm member to a new position.
behavior_state_t
An enumeration for the state of the behavior algorithm.
A class that allows to cover a given area optimally with a swarm of cyber physical systems (CPSs)...