lib/uav_local_coverage.cpp
Go to the documentation of this file.
2 
4 {
5  // read parameters
6  NodeHandle nh;
7  nh.param(this_node::getName() + "/altitude", altitude, 5.0);
8  nh.param(this_node::getName() + "/fov_hor", fov_hor, 1.236);
9  nh.param(this_node::getName() + "/fov_ver", fov_ver, 0.970);
10  nh.param(this_node::getName() + "/local_steps", max_steps, 20);
11 
12  // init number of search steps
13  steps = 0;
14 
15  // init local coordinate origin
16  // it is the center of the circle that defines the involute
17  double distance, direction;
18  compute_involute(distance, direction);
19  // invert direction to reach origin from current pose
20  // the current pose is the 0th step on the involute (x = radius a, y = 0)
21  direction += M_PI;
22  origin = pos.get_pose();
23 }
24 
26 {
27  // update position information
28  spinOnce();
29 
30  // next search step
31  ++steps;
32 
33  // next goal
34  geometry_msgs::Pose goal;
35 
36  // reached maximum number of steps, stop local coverage
37  if (steps >= max_steps)
38  return STATE_ABORTED;
39 
40  // compute new goal
41  else {
42  goal = select_goal();
43 
44  // reached environment boundary, stop local coverage
45  if (pos.out_of_bounds(goal))
46  return STATE_ABORTED;
47  }
48 
49  // move to new goal
50  if (pos.move(goal) == false)
51  return STATE_ABORTED;
52 
53  // return state to action server
54  return STATE_ACTIVE;
55 }
56 
57 void uav_local_coverage::compute_involute (double &distance, double &direction)
58 {
59  // parameters for circle involute
60  double a = altitude * tan(fov_hor / 2) / M_PI; // radius
61  double b = altitude * tan(fov_ver / 2) * 2; // step size
62 
63  // compute local coordinates using involute
64  double s = b * steps; // arc length
65  double t = sqrt(2 * s / a); // tangential angle
66  double x = a * (cos(t) + t * sin(t));
67  double y = a * (sin(t) - t * cos(t));
68 
69  // compute distance and heading from local origin
70  distance = hypot(x, y);
71  direction = atan2(y, x);
72 }
73 
74 geometry_msgs::Pose uav_local_coverage::select_goal ()
75 {
76  // compute heading and distance for current step
77  double distance, direction;
78  compute_involute(distance, direction);
79 
80  // compute gps coordinats of goal position
81  return pos.compute_goal(origin, distance, direction);
82 }
unsigned int steps
Number of steps performed in the local search.
double fov_hor
Horizontal camera field of view in radian.
geometry_msgs::Pose select_goal()
Compute goal position.
double altitude
The altitude of the UAV above ground.
double fov_ver
Vertical camera field of view in radian.
behavior_state_t step()
Move the swarm member to a new position.
geometry_msgs::Pose origin
Center of the spiral movement search pattern.
void compute_involute(double &distance, double &direction)
Compute local coordinates on circle involute for current step.
behavior_state_t
An enumeration for the state of the behavior algorithm.
position pos
A helper object for position related tasks.
uav_local_coverage()
Constructor that initializes the private member variables.
int max_steps
Maximum number of steps to do in the local search.


uav_local_coverage
Author(s): Micha Sende
autogenerated on Sun Dec 29 2019 10:25:43