7 #define NSEC_2_SECS(A) ((float)A / 1000000000.0) 9 int main(
int argc,
char **argv)
21 ROS_INFO(
"Please specifie name \nrosrun simple_velocity_controller velocity_controller [name]");
29 robot_names_(
std::vector<
std::string>({
"robot0"}))
33 std::string robot_names_string =
"";
34 n_param_.
param(
"robot_names_str", robot_names_string, robot_names_string);
36 ROS_ERROR(
"The parameters nr_of_robots or robot_names_string need to be defined");
39 ROS_ERROR(
"One one of the parameters nr_of_robots or robot_names_string need to be defined");
41 if (robot_names_string.size() > 0)
43 robot_names_string.erase(std::remove(robot_names_string.begin(), robot_names_string.end(),
' '), robot_names_string.end());
44 std::istringstream stringStr(robot_names_string);
47 while (std::getline(stringStr, result,
','))
71 float default_radius = 0.3;
72 n_param_.
param(
"robot_default_radius", default_radius, default_radius);
94 n.getParam(
"goal_radius",
goal_r_);
131 int sleep_count_robot_info = 0;
136 sleep_count_robot_info++;
137 if(sleep_count_robot_info > update_rate_) {
139 sleep_count_robot_info = 0;
147 const nav_msgs::Odometry_<std::allocator<void>>::ConstPtr &odom = _event.
getMessage();
151 pt.
x = odom->pose.pose.position.x;
152 pt.
y = odom->pose.pose.position.y;
154 tf::Quaternion q(odom->pose.pose.orientation.x, odom->pose.pose.orientation.y, odom->pose.pose.orientation.z, odom->pose.pose.orientation.w);
156 double roll, pitch, yaw;
157 m.
getRPY(roll, pitch, yaw);
176 geometry_msgs::Twist msg;
190 c.updatePrecondition(pc);
196 const tuw_multi_robot_msgs::Route_<std::allocator<void>>::ConstPtr &path = _event.
getMessage();
198 std::vector<PathPoint> localPath;
200 if (path->segments.size() == 0)
203 for (
const tuw_multi_robot_msgs::RouteSegment &seg : path->segments)
207 pt.
x = seg.end.position.x;
208 pt.
y = seg.end.position.y;
210 double roll, pitch, yaw;
211 tf::Quaternion q(seg.end.orientation.x, seg.end.orientation.y, seg.end.orientation.z, seg.end.orientation.w);
215 for (
const tuw_multi_robot_msgs::RoutePrecondition &pc : seg.preconditions)
220 pt.precondition.push_back(p);
223 localPath.push_back(pt);
226 controller[_topic].setPath(std::make_shared<std::vector<PathPoint>>(localPath));
227 ROS_INFO(
"Multi Robot Controller: Got Plan");
243 const std_msgs::String_<std::allocator<void>>::ConstPtr &
cmd = _event.
getMessage();
244 std::string
s = cmd->data;
246 ROS_INFO(
"Multi Robot Controller: received %s", s.c_str());
248 if (s.compare(
"run") == 0)
252 else if (s.compare(
"stop") == 0)
256 else if (s.compare(
"step") == 0)
270 tuw_multi_robot_msgs::RobotInfo ri;
275 ri.shape = ri.SHAPE_CIRCLE;
278 ri.sync.current_route_segment =
controller[i].getCount();
279 ri.mode = ri.MODE_NA;
282 ri.status = ri.STATUS_DRIVING;
284 ri.status = ri.STATUS_STOPPED;
286 ri.good_id = ri.GOOD_NA;
LocalMultiRobotControllerNode(ros::NodeHandle &n)
Construct a new Multi Segment Controller Node object.
void publish(const boost::shared_ptr< M > &message) const
void publishRobotInfo()
publish the robot info of each robot
std::string robot_prefix_
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
std::string topic_cmdVel_
int findRobotId(std::string robot_name)
void subCtrlCb(const ros::MessageEvent< std_msgs::String const > &_event, int _topic)
std::vector< ros::Subscriber > subOdom_
void subRouteCb(const ros::MessageEvent< tuw_multi_robot_msgs::Route const > &_event, int _topic)
std::vector< ros::Publisher > pubCmdVel_
std::vector< ros::Subscriber > subCtrl_
ros::Publisher pubRobotInfo_
void getRPY(tfScalar &roll, tfScalar &pitch, tfScalar &yaw, unsigned int solution_number=1) const
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
std::vector< bool > active_robots
std::vector< ros::Subscriber > subRoute_
void subOdomCb(const ros::MessageEvent< nav_msgs::Odometry const > &_event, int _topic)
std::vector< std::string > robot_names_
std::vector< geometry_msgs::PoseWithCovariance > robot_pose_
std::string topic_robot_info_
ros::NodeHandle n_param_
Node handler to the current node.
TFSIMD_FORCE_INLINE const tfScalar & w() const
int main(int argc, char **argv)
std::vector< SegmentController > controller
ROSCPP_DECL void spinOnce()
boost::shared_ptr< M > getMessage() const
std::vector< float > robot_radius_