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

Problem to set custom namespace when to try to spawn a robot on gazebo #182

Open
federicociresola opened this issue Mar 3, 2022 · 0 comments

Comments

@federicociresola
Copy link

Hi guys,
while I was working on my project on ROS2 with Galatic version, I found a little problem while trying to set a custom namespace when calling the launch spawn_turtlebot3.launch.py for Gazebo. My aim is to set a custom namespace as the prefix on the topics published by the node of turtlebot3.

In the initial step, I tried to use the GroupAction to set the namespace through the method PushRosNamespace but it doesn't work in the correct way and I am still trying to figure out the why of this.

So I decided to modify the file and I added the following code:

  • Add the new launch parameter here
    ns = LaunchConfiguration('ns',default='')
    dec_ns = DeclareLaunchArgument(
        'ns', 
        default_value   = '',
        description     = 'robot namespace')
  • Add new parameter when the spawn Node is called, here:
    start_gazebo_ros_spawner_cmd = Node(
        package = 'gazebo_ros',
        executable = 'spawn_entity.py',
        arguments = [
            '-entity', model_robot,
            '-file', urdf_path,
            '-x', x_pose,
            '-y', y_pose,
            '-z', '0.01',
            '-robot_namespace', ns,
        ],
        output = 'screen',
    )
  • Add the new parameter on LaunchDescription here:
 ld.add_action(dec_ns)

In this way, when somebody calls the launch file from CLI, or from another Launch file, the custom namespace can be set in easy way.

Is it normal that i have to go through all of these steps to achieve the result i want? Is there a better way to do this, which doesn't involve modifying the file in this repository? If there is not, maybe these changes can be included, maybe with a pull request by me? Thanks your understanding

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

1 participant