diff --git a/hebiros/src/hebiros.cpp b/hebiros/src/hebiros.cpp index 96e7711..8788592 100644 --- a/hebiros/src/hebiros.cpp +++ b/hebiros/src/hebiros.cpp @@ -29,12 +29,12 @@ HebirosNode::HebirosNode (int argc, char **argv) { } if (use_gazebo) { - HebirosParameters::setBool("/use_sim_time", true); + HebirosParameters::setBool("use_sim_time", true); services_gazebo.registerNodeServices(); clients.registerNodeClients(); } else { - HebirosParameters::setBool("/use_sim_time", false); + HebirosParameters::setBool("use_sim_time", false); services_physical.registerNodeServices(); } @@ -47,7 +47,7 @@ void HebirosNode::cleanup() { } void HebirosNode::loop() { - ros::Rate loop_rate(HebirosParameters::getInt("/hebiros/node_frequency")); + ros::Rate loop_rate(HebirosParameters::getInt("hebiros/node_frequency")); while(ros::ok()) { ros::spinOnce(); diff --git a/hebiros/src/hebiros_actions.cpp b/hebiros/src/hebiros_actions.cpp index d318535..391f9e5 100644 --- a/hebiros/src/hebiros_actions.cpp +++ b/hebiros/src/hebiros_actions.cpp @@ -14,7 +14,7 @@ void HebirosActions::registerGroupActions(std::string group_name) { trajectory_actions[group_name] = std::make_shared< actionlib::SimpleActionServer>( - *HebirosNode::n_ptr, "/hebiros/"+group_name+"/trajectory", + *HebirosNode::n_ptr, "hebiros/"+group_name+"/trajectory", boost::bind(&HebirosActions::trajectory, this, _1, group_name), false); trajectory_actions[group_name]->start(); @@ -75,7 +75,7 @@ void HebirosActions::trajectory(const TrajectoryGoalConstPtr& goal, std::string double loop_duration; TrajectoryFeedback feedback; - ros::Rate loop_rate(HebirosParameters::getInt("/hebiros/action_frequency")); + ros::Rate loop_rate(HebirosParameters::getInt("hebiros/action_frequency")); ROS_INFO("Group [%s]: Executing trajectory", group_name.c_str()); previous_time = ros::Time::now().toSec(); diff --git a/hebiros/src/hebiros_clients.cpp b/hebiros/src/hebiros_clients.cpp index a1df994..b6d29c2 100644 --- a/hebiros/src/hebiros_clients.cpp +++ b/hebiros/src/hebiros_clients.cpp @@ -9,30 +9,30 @@ std::map HebirosClients::clients; void HebirosClients::registerNodeClients() { - clients["/hebiros_gazebo_plugin/add_group"] = - HebirosNode::n_ptr->serviceClient("/hebiros_gazebo_plugin/add_group"); + clients["hebiros_gazebo_plugin/add_group"] = + HebirosNode::n_ptr->serviceClient("hebiros_gazebo_plugin/add_group"); } void HebirosClients::registerGroupClients(std::string group_name) { - clients["/hebiros_gazebo_plugin/set_command_lifetime/"+group_name] = + clients["hebiros_gazebo_plugin/set_command_lifetime/"+group_name] = HebirosNode::n_ptr->serviceClient( - "/hebiros_gazebo_plugin/set_command_lifetime/"+group_name); + "hebiros_gazebo_plugin/set_command_lifetime/"+group_name); - clients["/hebiros_gazebo_plugin/set_feedback_frequency/"+group_name] = + clients["hebiros_gazebo_plugin/set_feedback_frequency/"+group_name] = HebirosNode::n_ptr->serviceClient( - "/hebiros_gazebo_plugin/set_feedback_frequency/"+group_name); + "hebiros_gazebo_plugin/set_feedback_frequency/"+group_name); - clients["/hebiros_gazebo_plugin/acknowledge/"+group_name] = + clients["hebiros_gazebo_plugin/acknowledge/"+group_name] = HebirosNode::n_ptr->serviceClient( - "/hebiros_gazebo_plugin/acknowledge/"+group_name); + "hebiros_gazebo_plugin/acknowledge/"+group_name); } bool HebirosClients::addGroup(AddGroupFromNamesSrv::Request &req) { AddGroupFromNamesSrv srv; srv.request = req; - return clients["/hebiros_gazebo_plugin/add_group"].call(srv); + return clients["hebiros_gazebo_plugin/add_group"].call(srv); } bool HebirosClients::setCommandLifetime(SetCommandLifetimeSrv::Request &req, @@ -40,7 +40,7 @@ bool HebirosClients::setCommandLifetime(SetCommandLifetimeSrv::Request &req, SetCommandLifetimeSrv srv; srv.request = req; - return clients["/hebiros_gazebo_plugin/set_feedback_frequency/"+group_name].call(srv); + return clients["hebiros_gazebo_plugin/set_feedback_frequency/"+group_name].call(srv); } bool HebirosClients::setFeedbackFrequency(SetFeedbackFrequencySrv::Request &req, @@ -48,7 +48,7 @@ bool HebirosClients::setFeedbackFrequency(SetFeedbackFrequencySrv::Request &req, SetFeedbackFrequencySrv srv; srv.request = req; - return clients["/hebiros_gazebo_plugin/set_feedback_frequency/"+group_name].call(srv); + return clients["hebiros_gazebo_plugin/set_feedback_frequency/"+group_name].call(srv); } bool HebirosClients::acknowledge(std_srvs::Empty::Request &req, @@ -56,5 +56,5 @@ bool HebirosClients::acknowledge(std_srvs::Empty::Request &req, std_srvs::Empty srv; srv.request = req; - return clients["/hebiros_gazebo_plugin/acknowledge/"+group_name].call(srv); + return clients["hebiros_gazebo_plugin/acknowledge/"+group_name].call(srv); } diff --git a/hebiros/src/hebiros_parameters.cpp b/hebiros/src/hebiros_parameters.cpp index 8ed9dfd..abe8927 100644 --- a/hebiros/src/hebiros_parameters.cpp +++ b/hebiros/src/hebiros_parameters.cpp @@ -4,27 +4,27 @@ std::map HebirosParameters::bool_parameters_default = - {{"/use_sim_time", false}}; + {{"use_sim_time", false}}; std::map HebirosParameters::bool_parameters; std::map HebirosParameters::int_parameters_default = - {{"/hebiros/node_frequency", 200}, - {"/hebiros/action_frequency", 200}, - {"/hebiros/feedback_frequency", 100}, - {"/hebiros/command_lifetime", 100}}; + {{"hebiros/node_frequency", 200}, + {"hebiros/action_frequency", 200}, + {"hebiros/feedback_frequency", 100}, + {"hebiros/command_lifetime", 100}}; std::map HebirosParameters::int_parameters; void HebirosParameters::setNodeParameters() { - loadInt("/hebiros/node_frequency"); - loadInt("/hebiros/action_frequency"); - loadInt("/hebiros/feedback_frequency"); - loadInt("/hebiros/command_lifetime"); + loadInt("hebiros/node_frequency"); + loadInt("hebiros/action_frequency"); + loadInt("hebiros/feedback_frequency"); + loadInt("hebiros/command_lifetime"); ROS_INFO("Parameters:"); - ROS_INFO("/hebiros/node_frequency=%d", getInt("/hebiros/node_frequency")); - ROS_INFO("/hebiros/action_frequency=%d", getInt("/hebiros/action_frequency")); - ROS_INFO("/hebiros/feedback_frequency=%d", getInt("/hebiros/feedback_frequency")); - ROS_INFO("/hebiros/command_lifetime=%d", getInt("/hebiros/command_lifetime")); + ROS_INFO("hebiros/node_frequency=%d", getInt("hebiros/node_frequency")); + ROS_INFO("hebiros/action_frequency=%d", getInt("hebiros/action_frequency")); + ROS_INFO("hebiros/feedback_frequency=%d", getInt("hebiros/feedback_frequency")); + ROS_INFO("hebiros/command_lifetime=%d", getInt("hebiros/command_lifetime")); } void HebirosParameters::loadBool(std::string name) { diff --git a/hebiros/src/hebiros_publishers.cpp b/hebiros/src/hebiros_publishers.cpp index 14524cd..ecdc73f 100644 --- a/hebiros/src/hebiros_publishers.cpp +++ b/hebiros/src/hebiros_publishers.cpp @@ -10,30 +10,30 @@ std::map HebirosPublishers::publishers; void HebirosPublishers::registerGroupPublishers(std::string group_name) { - publishers["/hebiros/"+group_name+"/feedback"] = - HebirosNode::n_ptr->advertise("/hebiros/"+group_name+"/feedback", 100); + publishers["hebiros/"+group_name+"/feedback"] = + HebirosNode::n_ptr->advertise("hebiros/"+group_name+"/feedback", 100); - publishers["/hebiros/"+group_name+"/feedback/joint_state"] = + publishers["hebiros/"+group_name+"/feedback/joint_state"] = HebirosNode::n_ptr->advertise( - "/hebiros/"+group_name+"/feedback/joint_state", 100); + "hebiros/"+group_name+"/feedback/joint_state", 100); - publishers["/hebiros/"+group_name+"/feedback/joint_state_urdf"] = + publishers["hebiros/"+group_name+"/feedback/joint_state_urdf"] = HebirosNode::n_ptr->advertise( - "/hebiros/"+group_name+"/feedback/joint_state_urdf", 100); + "hebiros/"+group_name+"/feedback/joint_state_urdf", 100); - publishers["/hebiros/"+group_name+"/command/joint_state"] = + publishers["hebiros/"+group_name+"/command/joint_state"] = HebirosNode::n_ptr->advertise( - "/hebiros/"+group_name+"/command/joint_state", 100); + "hebiros/"+group_name+"/command/joint_state", 100); } void HebirosPublishers::feedback(FeedbackMsg feedback_msg, std::string group_name) { - publishers["/hebiros/"+group_name+"/feedback"].publish(feedback_msg); + publishers["hebiros/"+group_name+"/feedback"].publish(feedback_msg); } void HebirosPublishers::feedbackJointState(sensor_msgs::JointState joint_state_msg, std::string group_name) { - publishers["/hebiros/"+group_name+"/feedback/joint_state"].publish(joint_state_msg); + publishers["hebiros/"+group_name+"/feedback/joint_state"].publish(joint_state_msg); feedbackJointStateUrdf(joint_state_msg, group_name); } @@ -48,12 +48,11 @@ void HebirosPublishers::feedbackJointStateUrdf(sensor_msgs::JointState joint_sta joint_state_msg.name[i] = group->joint_full_names[joint_state_msg.name[i]]; } - publishers["/hebiros/"+group_name+"/feedback/joint_state_urdf"].publish(joint_state_msg); + publishers["hebiros/"+group_name+"/feedback/joint_state_urdf"].publish(joint_state_msg); } } void HebirosPublishers::commandJointState(sensor_msgs::JointState joint_state_msg, std::string group_name) { - publishers["/hebiros/"+group_name+"/command/joint_state"].publish(joint_state_msg); + publishers["hebiros/"+group_name+"/command/joint_state"].publish(joint_state_msg); } - diff --git a/hebiros/src/hebiros_publishers_gazebo.cpp b/hebiros/src/hebiros_publishers_gazebo.cpp index 233090a..da8f7c0 100644 --- a/hebiros/src/hebiros_publishers_gazebo.cpp +++ b/hebiros/src/hebiros_publishers_gazebo.cpp @@ -7,15 +7,15 @@ using namespace hebiros; void HebirosPublishersGazebo::registerGroupPublishers(std::string group_name) { - publishers["/hebiros_gazebo_plugin/command/"+group_name] = + publishers["hebiros_gazebo_plugin/command/"+group_name] = HebirosNode::n_ptr->advertise( - "/hebiros_gazebo_plugin/command/"+group_name, 100); + "hebiros_gazebo_plugin/command/"+group_name, 100); HebirosPublishers::registerGroupPublishers(group_name); } void HebirosPublishersGazebo::command(CommandMsg command_msg, std::string group_name) { - publishers["/hebiros_gazebo_plugin/command/"+group_name].publish(command_msg); + publishers["hebiros_gazebo_plugin/command/"+group_name].publish(command_msg); } diff --git a/hebiros/src/hebiros_services.cpp b/hebiros/src/hebiros_services.cpp index dfceb88..5f829a7 100644 --- a/hebiros/src/hebiros_services.cpp +++ b/hebiros/src/hebiros_services.cpp @@ -8,9 +8,9 @@ std::map HebirosServices::services; void HebirosServices::registerModelServices(const std::string& model_name) { - services["/hebiros/"+model_name+"/fk"] = + services["hebiros/"+model_name+"/fk"] = HebirosNode::n_ptr->advertiseService( - "/hebiros/"+model_name+"/fk", + "hebiros/"+model_name+"/fk", boost::bind(&HebirosServices::fk, this, _1, _2, model_name)); } @@ -124,13 +124,13 @@ bool HebirosServices::size( if (!registry.hasGroup(group_name)) { res.size = -1; - ROS_INFO("/hebiros/%s not found; could not get size", group_name.c_str()); + ROS_INFO("hebiros/%s not found; could not get size", group_name.c_str()); return false; } res.size = registry.getGroup(group_name)->size; - ROS_INFO("/hebiros/%s size=%d", group_name.c_str(), res.size); + ROS_INFO("hebiros/%s size=%d", group_name.c_str(), res.size); return true; } @@ -139,7 +139,7 @@ bool HebirosServices::setFeedbackFrequency( SetFeedbackFrequencySrv::Request &req, SetFeedbackFrequencySrv::Response &res, std::string group_name) { - ROS_INFO("/hebiros/%s feedback_frequency=%d", group_name.c_str(), req.feedback_frequency); + ROS_INFO("hebiros/%s feedback_frequency=%d", group_name.c_str(), req.feedback_frequency); return true; } @@ -148,7 +148,7 @@ bool HebirosServices::setCommandLifetime( SetCommandLifetimeSrv::Request &req, SetCommandLifetimeSrv::Response &res, std::string group_name) { - ROS_INFO("/hebiros/%s command_lifetime=%d", group_name.c_str(), req.command_lifetime); + ROS_INFO("hebiros/%s command_lifetime=%d", group_name.c_str(), req.command_lifetime); return true; } diff --git a/hebiros/src/hebiros_services_gazebo.cpp b/hebiros/src/hebiros_services_gazebo.cpp index 6ef137f..f0c28d0 100644 --- a/hebiros/src/hebiros_services_gazebo.cpp +++ b/hebiros/src/hebiros_services_gazebo.cpp @@ -6,42 +6,42 @@ void HebirosServicesGazebo::registerNodeServices() { - services["/hebiros/entry_list"] = HebirosNode::n_ptr->advertiseService( - "/hebiros/entry_list", &HebirosServicesGazebo::entryList, this); + services["hebiros/entry_list"] = HebirosNode::n_ptr->advertiseService( + "hebiros/entry_list", &HebirosServicesGazebo::entryList, this); - services["/hebiros/add_group_from_names"] = HebirosNode::n_ptr->advertiseService( - "/hebiros/add_group_from_names", &HebirosServicesGazebo::addGroupFromNames, this); + services["hebiros/add_group_from_names"] = HebirosNode::n_ptr->advertiseService( + "hebiros/add_group_from_names", &HebirosServicesGazebo::addGroupFromNames, this); - services["/hebiros/add_group_from_urdf"] = HebirosNode::n_ptr->advertiseService( - "/hebiros/add_group_from_urdf", &HebirosServicesGazebo::addGroupFromURDF, this); + services["hebiros/add_group_from_urdf"] = HebirosNode::n_ptr->advertiseService( + "hebiros/add_group_from_urdf", &HebirosServicesGazebo::addGroupFromURDF, this); - services["/hebiros/add_model_from_urdf"] = HebirosNode::n_ptr->advertiseService( - "/hebiros/add_model_from_urdf", &HebirosServicesGazebo::addModelFromURDF, this); + services["hebiros/add_model_from_urdf"] = HebirosNode::n_ptr->advertiseService( + "hebiros/add_model_from_urdf", &HebirosServicesGazebo::addModelFromURDF, this); } void HebirosServicesGazebo::registerGroupServices(std::string group_name) { - services["/hebiros/"+group_name+"/size"] = + services["hebiros/"+group_name+"/size"] = HebirosNode::n_ptr->advertiseService( - "/hebiros/"+group_name+"/size", + "hebiros/"+group_name+"/size", boost::bind(&HebirosServicesGazebo::size, this, _1, _2, group_name)); - services["/hebiros/"+group_name+"/set_feedback_frequency"] = + services["hebiros/"+group_name+"/set_feedback_frequency"] = HebirosNode::n_ptr->advertiseService( - "/hebiros/"+group_name+"/set_feedback_frequency", + "hebiros/"+group_name+"/set_feedback_frequency", boost::bind(&HebirosServicesGazebo::setFeedbackFrequency, this, _1, _2, group_name)); - services["/hebiros/"+group_name+"/set_command_lifetime"] = + services["hebiros/"+group_name+"/set_command_lifetime"] = HebirosNode::n_ptr->advertiseService( - "/hebiros/"+group_name+"/set_command_lifetime", + "hebiros/"+group_name+"/set_command_lifetime", boost::bind(&HebirosServicesGazebo::setCommandLifetime, this, _1, _2, group_name)); - services["/hebiros/"+group_name+"/send_command_with_acknowledgement"] = + services["hebiros/"+group_name+"/send_command_with_acknowledgement"] = HebirosNode::n_ptr->advertiseService( - "/hebiros/"+group_name+"/send_command_with_acknowledgement", + "hebiros/"+group_name+"/send_command_with_acknowledgement", boost::bind(&HebirosServicesGazebo::sendCommandWithAcknowledgement, this, _1, _2, group_name)); } diff --git a/hebiros/src/hebiros_services_physical.cpp b/hebiros/src/hebiros_services_physical.cpp index ada26a8..83979d2 100644 --- a/hebiros/src/hebiros_services_physical.cpp +++ b/hebiros/src/hebiros_services_physical.cpp @@ -6,42 +6,42 @@ void HebirosServicesPhysical::registerNodeServices() { - services["/hebiros/entry_list"] = HebirosNode::n_ptr->advertiseService( - "/hebiros/entry_list", &HebirosServicesPhysical::entryList, this); + services["hebiros/entry_list"] = HebirosNode::n_ptr->advertiseService( + "hebiros/entry_list", &HebirosServicesPhysical::entryList, this); - services["/hebiros/add_group_from_names"] = HebirosNode::n_ptr->advertiseService( - "/hebiros/add_group_from_names", &HebirosServicesPhysical::addGroupFromNames, this); + services["hebiros/add_group_from_names"] = HebirosNode::n_ptr->advertiseService( + "hebiros/add_group_from_names", &HebirosServicesPhysical::addGroupFromNames, this); - services["/hebiros/add_group_from_urdf"] = HebirosNode::n_ptr->advertiseService( - "/hebiros/add_group_from_urdf", &HebirosServicesPhysical::addGroupFromURDF, this); + services["hebiros/add_group_from_urdf"] = HebirosNode::n_ptr->advertiseService( + "hebiros/add_group_from_urdf", &HebirosServicesPhysical::addGroupFromURDF, this); - services["/hebiros/add_model_from_urdf"] = HebirosNode::n_ptr->advertiseService( - "/hebiros/add_model_from_urdf", &HebirosServicesPhysical::addModelFromURDF, this); + services["hebiros/add_model_from_urdf"] = HebirosNode::n_ptr->advertiseService( + "hebiros/add_model_from_urdf", &HebirosServicesPhysical::addModelFromURDF, this); } void HebirosServicesPhysical::registerGroupServices(std::string group_name) { - services["/hebiros/"+group_name+"/size"] = + services["hebiros/"+group_name+"/size"] = HebirosNode::n_ptr->advertiseService( - "/hebiros/"+group_name+"/size", + "hebiros/"+group_name+"/size", boost::bind(&HebirosServicesPhysical::size, this, _1, _2, group_name)); - services["/hebiros/"+group_name+"/set_feedback_frequency"] = + services["hebiros/"+group_name+"/set_feedback_frequency"] = HebirosNode::n_ptr->advertiseService( - "/hebiros/"+group_name+"/set_feedback_frequency", + "hebiros/"+group_name+"/set_feedback_frequency", boost::bind(&HebirosServicesPhysical::setFeedbackFrequency, this, _1, _2, group_name)); - services["/hebiros/"+group_name+"/set_command_lifetime"] = + services["hebiros/"+group_name+"/set_command_lifetime"] = HebirosNode::n_ptr->advertiseService( - "/hebiros/"+group_name+"/set_command_lifetime", + "hebiros/"+group_name+"/set_command_lifetime", boost::bind(&HebirosServicesPhysical::setCommandLifetime, this, _1, _2, group_name)); - services["/hebiros/"+group_name+"/send_command_with_acknowledgement"] = + services["hebiros/"+group_name+"/send_command_with_acknowledgement"] = HebirosNode::n_ptr->advertiseService( - "/hebiros/"+group_name+"/send_command_with_acknowledgement", + "hebiros/"+group_name+"/send_command_with_acknowledgement", boost::bind(&HebirosServicesPhysical::sendCommandWithAcknowledgement, this, _1, _2, group_name)); } diff --git a/hebiros/src/hebiros_subscribers_gazebo.cpp b/hebiros/src/hebiros_subscribers_gazebo.cpp index 99c4672..3cb312e 100644 --- a/hebiros/src/hebiros_subscribers_gazebo.cpp +++ b/hebiros/src/hebiros_subscribers_gazebo.cpp @@ -7,18 +7,18 @@ using namespace hebiros; void HebirosSubscribersGazebo::registerGroupSubscribers(std::string group_name) { - subscribers["/hebiros/"+group_name+"/command"] = - HebirosNode::n_ptr->subscribe("/hebiros/"+group_name+"/command", 100, + subscribers["hebiros/"+group_name+"/command"] = + HebirosNode::n_ptr->subscribe("hebiros/"+group_name+"/command", 100, boost::bind(&HebirosSubscribersGazebo::command, this, _1, group_name)); - subscribers["/hebiros/"+group_name+"/command/joint_state"] = + subscribers["hebiros/"+group_name+"/command/joint_state"] = HebirosNode::n_ptr->subscribe( - "/hebiros/"+group_name+"/command/joint_state", 100, + "hebiros/"+group_name+"/command/joint_state", 100, boost::bind(&HebirosSubscribersGazebo::jointCommand, this, _1, group_name)); - subscribers["/hebiros_gazebo_plugin/feedback/"+group_name] = + subscribers["hebiros_gazebo_plugin/feedback/"+group_name] = HebirosNode::n_ptr->subscribe( - "/hebiros_gazebo_plugin/feedback/"+group_name, 100, + "hebiros_gazebo_plugin/feedback/"+group_name, 100, boost::bind(&HebirosSubscribersGazebo::feedback, this, _1, group_name)); } diff --git a/hebiros/src/hebiros_subscribers_physical.cpp b/hebiros/src/hebiros_subscribers_physical.cpp index 3d57f47..8f34f64 100644 --- a/hebiros/src/hebiros_subscribers_physical.cpp +++ b/hebiros/src/hebiros_subscribers_physical.cpp @@ -7,13 +7,13 @@ using namespace hebi; void HebirosSubscribersPhysical::registerGroupSubscribers(std::string group_name) { - subscribers["/hebiros/"+group_name+"/command"] = - HebirosNode::n_ptr->subscribe("/hebiros/"+group_name+"/command", 100, + subscribers["hebiros/"+group_name+"/command"] = + HebirosNode::n_ptr->subscribe("hebiros/"+group_name+"/command", 100, boost::bind(&HebirosSubscribersPhysical::command, this, _1, group_name)); - subscribers["/hebiros/"+group_name+"/command/joint_state"] = + subscribers["hebiros/"+group_name+"/command/joint_state"] = HebirosNode::n_ptr->subscribe( - "/hebiros/"+group_name+"/command/joint_state", 100, + "hebiros/"+group_name+"/command/joint_state", 100, boost::bind(&HebirosSubscribersPhysical::jointCommand, this, _1, group_name)); // TODO: replace with better abstraction later @@ -31,9 +31,9 @@ void HebirosSubscribersPhysical::registerGroupSubscribers(std::string group_name }); group->setFeedbackFrequency( - HebirosParameters::getInt("/hebiros/feedback_frequency")); + HebirosParameters::getInt("hebiros/feedback_frequency")); group->setCommandLifetime( - HebirosParameters::getInt("/hebiros/command_lifetime")); + HebirosParameters::getInt("hebiros/command_lifetime")); } void HebirosSubscribersPhysical::command(const boost::shared_ptr data, diff --git a/hebiros_gazebo_plugin/include/hebiros_gazebo_group.cpp b/hebiros_gazebo_plugin/include/hebiros_gazebo_group.cpp index 11b7728..b1072f9 100644 --- a/hebiros_gazebo_plugin/include/hebiros_gazebo_group.cpp +++ b/hebiros_gazebo_plugin/include/hebiros_gazebo_group.cpp @@ -11,22 +11,22 @@ HebirosGazeboGroup::HebirosGazeboGroup(std::string name, this->prev_time = current_time; this->prev_feedback_time = current_time; - this->command_sub = n->subscribe("/hebiros_gazebo_plugin/command/"+name, 100, + this->command_sub = n->subscribe("hebiros_gazebo_plugin/command/"+name, 100, boost::bind(&HebirosGazeboGroup::SubCommand, this, _1)); this->acknowledge_srv = n->advertiseService( - "/hebiros_gazebo_plugin/acknowledge/"+name, boost::bind( + "hebiros_gazebo_plugin/acknowledge/"+name, boost::bind( &HebirosGazeboGroup::SrvAcknowledge, this, _1, _2)); this->command_lifetime_srv = n->advertiseService( - "/hebiros_gazebo_plugin/set_command_lifetime/"+name, boost::bind( + "hebiros_gazebo_plugin/set_command_lifetime/"+name, boost::bind( &HebirosGazeboGroup::SrvSetCommandLifetime, this, _1, _2)); this->feedback_frequency_srv = n->advertiseService( - "/hebiros_gazebo_plugin/set_feedback_frequency/"+name, boost::bind( + "hebiros_gazebo_plugin/set_feedback_frequency/"+name, boost::bind( &HebirosGazeboGroup::SrvSetFeedbackFrequency, this, _1, _2)); } diff --git a/hebiros_gazebo_plugin/include/hebiros_gazebo_joint.cpp b/hebiros_gazebo_plugin/include/hebiros_gazebo_joint.cpp index 167677e..841c650 100644 --- a/hebiros_gazebo_plugin/include/hebiros_gazebo_joint.cpp +++ b/hebiros_gazebo_plugin/include/hebiros_gazebo_joint.cpp @@ -10,7 +10,7 @@ HebirosGazeboJoint::HebirosGazeboJoint(std::string name, this->name = name; this->imu_subscriber = n->subscribe( - "/hebiros_gazebo_plugin/imu/"+name, + "hebiros_gazebo_plugin/imu/"+name, 100, boost::bind(&HebirosGazeboJoint::SubIMU, this, _1)); } diff --git a/hebiros_gazebo_plugin/include/hebiros_gazebo_plugin.h b/hebiros_gazebo_plugin/include/hebiros_gazebo_plugin.h index 6ec767e..0c37271 100644 --- a/hebiros_gazebo_plugin/include/hebiros_gazebo_plugin.h +++ b/hebiros_gazebo_plugin/include/hebiros_gazebo_plugin.h @@ -40,6 +40,7 @@ class HebirosGazeboPlugin: public ModelPlugin { std::map> hebiros_groups; std::map> hebiros_joints; + std::string robot_namespace; std::shared_ptr n; ros::Subscriber command_sub; ros::ServiceServer add_group_srv; diff --git a/hebiros_gazebo_plugin/plugin/hebiros_gazebo_plugin.cpp b/hebiros_gazebo_plugin/plugin/hebiros_gazebo_plugin.cpp index 27213c1..cc0a346 100644 --- a/hebiros_gazebo_plugin/plugin/hebiros_gazebo_plugin.cpp +++ b/hebiros_gazebo_plugin/plugin/hebiros_gazebo_plugin.cpp @@ -14,13 +14,22 @@ void HebirosGazeboPlugin::Load(physics::ModelPtr _model, sdf::ElementPtr _sdf) { int argc = 0; char **argv = NULL; ros::init(argc, argv, "hebiros_gazebo_plugin_node"); - this->n.reset(new ros::NodeHandle); this->add_group_srv = this->n->advertiseService( - "/hebiros_gazebo_plugin/add_group", boost::bind( + "hebiros_gazebo_plugin/add_group", boost::bind( &HebirosGazeboPlugin::SrvAddGroup, this, _1, _2)); + this->robot_namespace = ""; + if (_sdf->HasElement("robotNamespace")) { + this->robot_namespace = _sdf->GetElement("robotNamespace")->Get(); + } + if (this->robot_namespace == "") { + this->n.reset(new ros::NodeHandle); + } else { + this->n.reset(new ros::NodeHandle(this->robot_namespace)); + } + this->update_connection = event::Events::ConnectWorldUpdateBegin ( boost::bind(&HebirosGazeboPlugin::OnUpdate, this, _1)); @@ -162,7 +171,7 @@ bool HebirosGazeboPlugin::SrvAddGroup(AddGroupFromNamesSrv::Request &req, hebiros_group->feedback.gyro.resize(size); hebiros_group->feedback_pub = this->n->advertise( - "/hebiros_gazebo_plugin/feedback/"+req.group_name, 100); + "hebiros_gazebo_plugin/feedback/"+req.group_name, 100); hebiros_group->group_added = true;