Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions hebiros_gazebo_plugin/include/hebiros_gazebo_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class HebirosGazeboPlugin: public ModelPlugin {
private:

physics::ModelPtr model;
bool first_sim_iteration{true};
event::ConnectionPtr update_connection;
std::map<std::string, std::shared_ptr<HebirosGazeboGroup>> hebiros_groups;
std::map<std::string, std::shared_ptr<HebirosGazeboJoint>> hebiros_joints;
Expand Down
14 changes: 9 additions & 5 deletions hebiros_gazebo_plugin/plugin/hebiros_gazebo_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ void HebirosGazeboPlugin::Load(physics::ModelPtr _model, sdf::ElementPtr _sdf) {
char **argv = NULL;
ros::init(argc, argv, "hebiros_gazebo_plugin_node");

this->add_group_srv =
this->n->advertiseService<AddGroupFromNamesSrv::Request, AddGroupFromNamesSrv::Response>(
"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<std::string>();
Expand All @@ -31,6 +26,15 @@ void HebirosGazeboPlugin::Load(physics::ModelPtr _model, sdf::ElementPtr _sdf) {

//Update the joints at every simulation iteration
void HebirosGazeboPlugin::OnUpdate(const common::UpdateInfo & _info) {

if (this->first_sim_iteration) {
this->first_sim_iteration = false;
this->add_group_srv =
this->n->advertiseService<AddGroupFromNamesSrv::Request, AddGroupFromNamesSrv::Response>(
"/hebiros_gazebo_plugin/add_group", boost::bind(
&HebirosGazeboPlugin::SrvAddGroup, this, _1, _2));
}

ros::Time current_time = ros::Time::now();

for (auto group_pair : hebiros_groups) {
Expand Down