8 nh.param(this_node::getName() +
"/step_size_min",
step_size_min, 1.0);
9 nh.param(this_node::getName() +
"/step_size_max",
step_size_max, 3.0);
13 nh.param<
int>(
"/rng_seed", seed, 0);
15 rng =
new random_numbers::RandomNumberGenerator(seed);
18 rng =
new random_numbers::RandomNumberGenerator();
22 clear_sector_client = nh.serviceClient<cpswarm_msgs::GetSector>(
"obstacle_detection/get_clear_sector");
28 ROS_INFO(
"Initial direction %.2f",
direction);
46 if (
pos.out_of_bounds(goal)) {
51 for (
int i = 0; i <= 10; ++i) {
59 if (!
pos.out_of_bounds(goal))
64 if (
pos.out_of_bounds(goal)) {
72 if (
pos.occupied(goal)) {
73 ROS_ERROR(
"Obstacle ahead!");
81 if (
pos.move(goal) ==
false)
96 cpswarm_msgs::GetSector clear;
98 ROS_ERROR(
"Failed to get clear sector");
102 ROS_DEBUG(
"Clear [%.2f, %.2f] size %.2f", clear.response.min, clear.response.max, clear.response.max - clear.response.min);
105 geometry_msgs::Pose goal;
107 direction =
rng->uniformReal(clear.response.min, clear.response.max);
109 ROS_DEBUG_THROTTLE(1,
"Checking goal [%.2f, %.2f, %.2f] in direction %.2f...", goal.position.x, goal.position.y, goal.position.z,
direction);
110 }
while (
pos.out_of_bounds(goal));
112 ROS_INFO(
"Changing direction %.2f",
direction);
~uav_random_direction()
Destructor that deletes the private member objects.
behavior_state_t
An enumeration for the state of the behavior algorithm.
random_numbers::RandomNumberGenerator * rng
The random number generator used for selecting a random direction.
position pos
A helper object for position related tasks.
double direction
The direction in which the drone is travling. It is measured in radian, clockwise starting from north...
geometry_msgs::Pose select_goal()
Compute goal position from direction.
bool new_direction()
Compute new direction using rng.
uav_random_direction()
Constructor that initializes the private member variables.
behavior_state_t step()
Move the swarm member to a new position.
double step_size_max
The maximum distance that a UAV travels in one step.
ServiceClient clear_sector_client
Service client for determining the sector clear of obstacles.
double distance
The distance which the drone is traveling.
double step_size_min
The minimum distance that a UAV travels in one step.