lib/uav_optimal_coverage.cpp
Go to the documentation of this file.
2 
3 uav_optimal_coverage::uav_optimal_coverage (double altitude) : pos(altitude)
4 {
5  NodeHandle nh;
6 
7  // read parameters
8  int queue_size;
9  nh.param(this_node::getName() + "/queue_size", queue_size, 1);
10 
11  // publishers, subscribers, and service clients
12  wp_getter = nh.serviceClient<cpswarm_msgs::GetWaypoint>("coverage_path/waypoint");
14 
15  // initialize waypoint
16  waypoint = pos.get_pose().position;
17 }
18 
20 {
21 }
22 
24 {
25  // update position information
26  spinOnce();
27 
28  // reached current waypoint of path
29  if (pos.reached()) {
30  // get next waypoint of path
31  get_wp.request.position = pos.get_pose().position;
32  get_wp.request.tolerance = pos.get_tolerance();
33  if (wp_getter.call(get_wp) == false) {
34  ROS_ERROR("Failed to get waypoint, cannot perform coverage!");
35  return STATE_ABORTED;
36  }
37 
38  // finished path
39  if (get_wp.response.valid == false) {
40  ROS_INFO("Path completely traversed, stop coverage!");
41  return STATE_ABORTED;
42  }
43 
44  waypoint = get_wp.response.point;
45  ROS_INFO("Move to waypoint [%.2f, %.2f]", waypoint.x, waypoint.y);
46  }
47 
48  // convert waypoint to pose
49  geometry_msgs::Pose goal = pos.get_pose();
50  goal.position.x = waypoint.x;
51  goal.position.y = waypoint.y;
52 
53  // move to new position
54  pos.move(goal);
55 
56  // return state to action server
57  return STATE_ACTIVE;
58 }
59 
61 {
62  pos.stop();
63 }
ServiceClient serviceClient(const std::string &service_name, bool persistent=false, const M_string &header_values=M_string())
geometry_msgs::Point waypoint
Current waypoint to navigate to.
uav_optimal_coverage(double altitude)
Constructor that initializes the private member variables.
bool move(geometry_msgs::Pose pose)
bool reached()
bool call(MReq &req, MRes &res)
geometry_msgs::Pose get_pose() const
double get_tolerance() const
bool waitForExistence(ros::Duration timeout=ros::Duration(-1))
#define ROS_INFO(...)
bool param(const std::string &param_name, T &param_val, const T &default_val) const
ServiceClient wp_getter
Service client to get the current waypoint to navigate to.
~uav_optimal_coverage()
Destructor that deletes the private member objects.
void stop()
behavior_state_t step()
Move the swarm member to a new position.
cpswarm_msgs::GetWaypoint get_wp
Service message to get the current waypoint.
behavior_state_t
An enumeration for the state of the behavior algorithm.
ROSCPP_DECL void spinOnce()
#define ROS_ERROR(...)
position pos
A helper object for position related tasks.


uav_optimal_coverage
Author(s): Micha Sende
autogenerated on Sat Feb 6 2021 03:11:39