lib/uav_simple_tracking.cpp
Go to the documentation of this file.
2 
4 {
5  this->target.id = target;
6  NodeHandle nh;
7  int queue_size;
8  nh.param(this_node::getName() + "/queue_size", queue_size, 1);
9  target_sub = nh.subscribe("target_update", queue_size, &uav_simple_tracking::target_callback, this);
10 }
11 
13 {
14  // update position information
15  spinOnce();
16 
17  // target left the area
18  if (pos.out_of_bounds(target.pose.pose)) {
19  return STATE_SUCCEEDED;
20  }
21 
22  // target is still inside area
23  else {
24  // move to target position
25  if (pos.move(target.pose.pose) == false)
26  return STATE_ABORTED;
27  }
28 
29  // return state to action server
30  return STATE_ACTIVE;
31 }
32 
33 void uav_simple_tracking::target_callback (const cpswarm_msgs::TargetPositionEvent::ConstPtr& msg)
34 {
35  // update information for this target
36  if (target.id == msg->id)
37  target = *msg;
38 }
void target_callback(const cpswarm_msgs::TargetPositionEvent::ConstPtr &msg)
Callback function to receive target position updates.
behavior_state_t step()
Execute one cycle of the tracking algorithm.
cpswarm_msgs::TargetPositionEvent target
The target being tracked by this UAV.
Subscriber target_sub
Subscriber to receive target position updates.
position pos
A helper object for position related tasks.
int target
The ID of the target being tracked.
uav_simple_tracking(unsigned int target)
Constructor that initializes the private member variables.
behavior_state_t
An enumeration for the state of the behavior algorithm.


uav_simple_tracking
Author(s): Micha Sende
autogenerated on Sun Dec 29 2019 10:26:16