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

Simulated laser scanner does not respect namespace/prefix #65

Closed
matthias-mayr opened this issue Sep 16, 2020 · 1 comment
Closed

Simulated laser scanner does not respect namespace/prefix #65

matthias-mayr opened this issue Sep 16, 2020 · 1 comment

Comments

@matthias-mayr
Copy link
Contributor

We are using our MIR in the namespace mir_ and initially had some issues with the navigation in simulation.

More precisely, the laser scan results on /scan are still in the frame front_laser_link rather than mir_front_laser_link and later on in the navigation stack this causes amcl to not publish the transformation between mir_odom_comb and map.

These messages are published by Gazebo using the libgazebo_ros_laser plugin. To work with a prefixed MIR, we had to change the frame configuration of the plugin to this:

<!-- no prefix, plugin always uses a tf_prefix (if none is set it uses robotNamespace) -->
<frameName>${prefix}${link}</frameName>

to make it use the prefix for the frame in the published messages.

Is this, how it's supposed to be or is there another, better way to resolve this?

@mintar
Copy link
Member

mintar commented Sep 18, 2020

This was surprisingly tricky so solve. It took me 2 hours to figure out what the heck my colleague meant by the comment above, and more importantly, how to solve it:

<!-- no prefix, plugin always uses a tf_prefix (if none is set it uses robotNamespace) -->

But finally I figured it out. So the problem is that the gazebo_ros_laser plugin does the following:

  • If the ROS parameter 'tf_prefix' is set, it prepends the tf_prefix in front of the frameName.
  • Otherwise, it prepends the robotNamespace. (see here)

The robotNamespace gets automatically set if you start the spawn_model node inside a namespace. In this case, if we just add ${prefix} in front of the frameName, as you did, we would end up with two namespaces. Since use namespaces in our robot, that would be bad. :)

I have just pushed a couple of commits that allow you to properly set the tf prefix. You can try it like this:

roslaunch mir_gazebo mir_maze_world.launch tf_prefix:=mir

If you want to enable that behavior in your own launch file, just use the xacro arg with the catchy name of prepend_prefix_to_laser_frame, like this:

https://github.com/dfki-ric/mir_robot/blob/ba02a68e7bc0fcdd6942e385c61ca2b33e9d00e4/mir_description/launch/upload_mir_urdf.launch#L6

And as a demonstration of what I mean with the "pushing into namespaces" problem, I've pushed this commit to my personal fork (just for demonstration purposes, I'm not going to merge it):

mintar@c91a543

This is the line where I make sure not to prepend the prefix twice:

mintar@c91a543#diff-025925fc4708d226851d15a6422fb336R43

... because we're operating inside a namespace:

mintar@c91a543#diff-025925fc4708d226851d15a6422fb336R30

Feel free to reopen this issue if it's not solved by those commits.

mintar added a commit that referenced this issue May 12, 2021
In gazebo_plugins 2.9.2, the behavior of the gazebo_ros_laser plugin was
changed in this commit:

ros-simulation/gazebo_ros_pkgs@34b2c27

It now no longer prepends the robotNamespace if the parameter tf_prefix
is empty. Since tf_prefix has been deprecated for a long time, we always
leave it empty.

The change in gazebo_plugins means that #65 no longer happens, and we
have to prepend the prefix ourselves (just like with the other plugins).

This reverts commit ba02a68 and applies the following additional diff:

-          <!-- no prefix, plugin always uses a tf_prefix (if none is set it uses robotNamespace) -->
-          <frameName>${link}</frameName>
+          <frameName>${prefix}${link}</frameName>
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

No branches or pull requests

2 participants