3 #include "tuw_geometry/utils.h" 33 ROS_INFO (
"nr_of_robots: %i", (
int ) nr_of_robots );
37 ROS_ERROR(
"nr_of_robots must be equal or less then nr_of_avaliable_robots" );
42 ROS_INFO(
"nr_of_avaliable_robots < 0 and therefore ignored" );
43 for (
size_t i = 0; i < nr_of_robots; i++ ) {
48 std::set<std::string> avaliable_robots;
52 for (
size_t i = 0; i < nr_of_robots; i++ ) {
54 int offset = rand() % avaliable_robots.size();
55 std::set<std::string>::iterator it = avaliable_robots.begin();
56 std::advance(it,offset);
57 robot_check_points.robot_name = *it;
58 avaliable_robots.erase(it);
82 std::random_device rd;
83 std::mt19937 gen ( rd() );
84 std::uniform_real_distribution<> dis_x (
map_.min_x(),
map_.max_x() );
85 std::uniform_real_distribution<> dis_y (
map_.min_y(),
map_.max_y() );
86 std::uniform_real_distribution<> dis_alpha ( -M_PI, M_PI );
88 int total_retries = 0;
93 bool valid_pose =
false;
95 pw.set ( dis_x ( gen ), dis_y ( gen ), 0 );
103 total_retries += retries;
105 pw.theta() = dis_alpha ( gen );
107 robot.destinations.resize ( 1 );
109 geometry_msgs::Pose &p = robot.destinations[0];
110 pw.copyToROSPose ( p );
112 ROS_WARN (
"Max retries on finding new free space for goals for robot: %s", robot.robot_name.c_str() );
114 if ( max_retries < retries ) {
115 max_retries = retries;
125 ROS_INFO (
"Goal msg published: %i max retries and %i total retries on finding free space ", max_retries, total_retries );
129 int main (
int argc,
char **argv ) {
130 ros::init ( argc, argv,
"RandomGoalGenerator" );
ros::Publisher pub_goals_
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
double distance_between_robots_
parameter [m]
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int nr_of_avaliable_robots_
retries/max_resample steps to find a free spot for a goal [m]
void callback(const nav_msgs::OccupancyGrid::ConstPtr &msg)
publishes the motion commands
tuw_multi_robot_msgs::RobotGoalsArray robot_goals_array_
parameter
nav_msgs::OccupancyGrid msg_map_goals_
RadomGoalGeneratorNode(ros::NodeHandle &n)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
tuw::GridMap< int8_t > map_goals_
std::string robot_name_prefix_
parameter [m]
void updateNrOfRobots(size_t nr_of_robots)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ros::Publisher pub_map_goals_
void publish()
Constructor.
std::string frame_id_
parameter
tuw::GridMap< int8_t > map_
bool getParam(const std::string &key, std::string &s) const
ROSCPP_DECL void shutdown()
nav_msgs::OccupancyGrid::ConstPtr msg_map_
double distance_to_map_border_
parameter [m]
double distance_boundary_
parameter count
int main(int argc, char **argv)