Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forward sdf ros remappings to loaded controllers #80

Merged
merged 1 commit into from
Jun 14, 2021

Conversation

jonatanolofsson
Copy link
Contributor

Currently, the loaded controllers do not receive the remappings and namespace info from the sdf. This commit adds this information to the generated argument list so that they are forwarded to subsequently started nodes.

@@ -200,6 +200,35 @@ void GazeboRosControlPlugin::Load(gazebo::physics::ModelPtr parent, sdf::Element
// So we have to parse the plugin file manually and set it to the node's context.
auto rcl_context = impl_->model_nh_->get_node_base_interface()->get_context()->get_rcl_context();
std::vector<std::string> arguments = {"--ros-args", "--params-file", impl_->param_file_.c_str()};
if (sdf->HasElement("ros")) {
sdf = sdf->GetElement("ros");
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will allow the following

<plugin>
  <namespace></namespace>
  <remapping></remapping>
  ...
</plugin>

and

<plugin>
  <ros>
    <namespace></namespace>
    <remapping></remapping>
    ...
 </ros>
</plugin>

I think we should only go with the second option

@jonatanolofsson
Copy link
Contributor Author

jonatanolofsson commented Jun 11, 2021 via email

@jonatanolofsson
Copy link
Contributor Author

jonatanolofsson commented Jun 11, 2021 via email

@jonatanolofsson
Copy link
Contributor Author

@ahcorde Could you please advice if I should update the PR or not, based on the argument above?

@ahcorde
Copy link
Collaborator

ahcorde commented Jun 14, 2021

@jonatanolofsson yes, please I would prefer to update the PR

@jonatanolofsson
Copy link
Contributor Author

@ahcorde Done!

@ahcorde ahcorde merged commit 1b90ab1 into ros-controls:master Jun 14, 2021
@cco-seasony
Copy link

Hi @jonatanolofsson ,
I am trying to test this feature but for some reason things are not loading correctly.
When testing the namespace tag this is what I am encountering:

  • I can load the plugin under the given namespace. I can see the services have the correct names.
  • When trying to call ros2 control load_start_controller velocity_controller to start the velocity controller it does not work since that cmd is trying to use the service /controller_manager/load_and_start_controller which it does not exist since the namespace is prefixed to all the services. Hence, /<namespace>/controller_manager/load_and_start_controller is the one that this cmdros2 control load_start_controller velocity_controller should be calling.

I can manually call the service ros2 service call /<namespace>/controller_manager/load_and_start_controller controller_manager_msgs/srv/LoadStartController "{name: velocity_controller}" and it works fine. This loads the controller and creates the command topic under the same namespace.
I was wondering if this is the right way to do it or am I doing something wrong along the way?

Thanks in advance for the help.
Kind regards,
Carlos

@jonatanolofsson
Copy link
Contributor Author

@cco-seasony If you're using spawner.py, you can use the -c parameter to change which controller_manager it talks to. There might be a similar (same?) parameter for the ros2 control interface

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants