9 nh.param<
int>(
"/rng_seed", seed, 0);
11 ROS_INFO(
"Using seed %d for random number generation.", seed);
12 rng =
new random_numbers::RandomNumberGenerator(seed);
15 rng =
new random_numbers::RandomNumberGenerator();
19 bound_client = nh.serviceClient<cpswarm_msgs::ClosestBound>(
"area/closest_bound");
21 clear_sector_client = nh.serviceClient<cpswarm_msgs::GetSector>(
"obstacle_detection/get_clear_sector");
26 ROS_INFO(
"Initial direction %.2f",
direction);
30 nh.param(this_node::getName() +
"/step_size",
step_size, 3.0);
48 if (
pos.out_of_bounds(goal)) {
55 if (
pos.move(goal) ==
false)
69 cpswarm_msgs::GetSector clear;
71 ROS_ERROR(
"Failed to get clear sector");
75 ROS_DEBUG(
"Clear [%.2f, %.2f] size %.2f", clear.response.min, clear.response.max, clear.response.max - clear.response.min);
78 geometry_msgs::Pose goal;
80 direction =
rng->uniformReal(clear.response.min, clear.response.max);
82 ROS_DEBUG_THROTTLE(1,
"Checking goal [%.2f, %.2f, %.2f] in direction %.2f...", goal.position.x, goal.position.y, goal.position.z,
direction);
83 }
while (
pos.out_of_bounds(goal));
85 ROS_INFO(
"Changing direction %.2f",
direction);
93 geometry_msgs::Point b1;
94 geometry_msgs::Point b2;
95 cpswarm_msgs::ClosestBound cb;
96 cb.request.point =
pos.get_pose().position;
98 b1 = cb.response.coords[0];
99 b2 = cb.response.coords[1];
102 ROS_ERROR(
"Failed to get area boundary");
109 ROS_INFO(
"Changing direction %.2f",
direction);
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.
ServiceClient bound_client
Service client for determining closest mission area boundary to the current UGV position.
bool reflect()
Compute new direction as reflection from wall.
double step_size
The distance that the UGV travels in one step.
bool new_direction()
Compute new direction using rng.
behavior_state_t step()
Move the swarm member to a new position.
ugv_random_walk()
Constructor that initializes the private member variables.
position pos
A helper object for position related tasks.
~ugv_random_walk()
Destructor that deletes the private member objects.
ServiceClient clear_sector_client
Service client for determining the sector clear of obstacles.
geometry_msgs::Pose select_goal()
Compute goal position from direction.
double direction
The direction in which the UGV is traveling. It is measured in radian, clockwise starting from north...