ros-simulation / gazebo_ros_pkgs

Wrappers, tools and additional API's for using ROS with Gazebo
http://wiki.ros.org/gazebo_ros_pkgs
752 stars 771 forks source link

RaySensor plugin namespace #1484

Open MatteoCarlone opened 1 year ago

MatteoCarlone commented 1 year ago

ROS2 Humble, Ubuntu 22.04,

i'm dealing with a simulation in gazebo 11 with two namespaced robot. I want to add on both a 2d lidar and I'm adding to the robot description with the following xacro script:

<?xml version="1.0" encoding="utf-8"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">

    <xacro:macro name="lidar_sensor" params="gazebo namespace">

        <material name="black">
            <color rgba="0 0 0 1"/>
        </material>

        <link name="lidar_link">
            <inertial>
                <mass value="0.0001"/>
                <origin xyz="0 0 0"/>
                <inertia ixx="0.0001" ixy="0.0" ixz="0.0" iyy="0.0001" iyz="0.0" izz="0.0001"/>
            </inertial>
            <visual>
                <origin xyz="0 0 0.008" rpy="0 0 1.57"/>
                <geometry>
                    <mesh filename="package://irobot_create_description/meshes/turtlebot4/rplidar.dae"/>
                </geometry>
                <material name="black"/>
            </visual>
        </link>

        <joint name="lidar_joint" type="fixed">
            <parent link="base_link"/>
            <child link="lidar_link"/>
            <origin xyz="-0.05 0 0.175" rpy="0 0 0"/>
        </joint>

        <gazebo reference="lidar_joint">
            <preserveFixedJoint>true</preserveFixedJoint>   
        </gazebo>

        <gazebo reference="lidar_link">
            <material>Gazebo/Black</material>
            <sensor type="ray" name="lidar_link">
                <always_on>true</always_on>
                <visualize>false</visualize>
                <pose>0.0 0 0 0 0 0</pose>
                <update_rate>10</update_rate>
                <ray>
                    <scan>
                        <horizontal>
                            <samples>360</samples>
                            <resolution>1.000000</resolution>
                            <min_angle>-3.14</min_angle>
                            <max_angle>3.14</max_angle>
                        </horizontal>
                    </scan>
                    <range>
                        <min>0.3</min>
                        <max>12.0</max>
                        <resolution>0.01</resolution>
                    </range>
                    <noise>
                        <type>gaussian</type>
                        <mean>0.0</mean>
                        <stddev>0.01</stddev>
                    </noise>
                </ray>
                <xacro:if value="${gazebo == 'classic'}">
                    <plugin name="gazebo_lidar" filename="libgazebo_ros_ray_sensor.so">
                        <ros>
                            <namespace>${namespace}</namespace>
                            <remapping>~/out:=scan</remapping>
                        </ros>
                        <output_type>sensor_msgs/LaserScan</output_type>
                        <frame_name>lidar_link</frame_name>
                    </plugin>
                </xacro:if>
            </sensor>
        </gazebo>
    </xacro:macro>
</robot>

and in the robot description just:

<xacro:include filename="$(find irobot_create_description)/urdf/sensors/lidar_sensor.xacro"/>
<xacro:lidar_sensor gazebo="$(arg gazebo)" namespace="$(arg namespace)"></xacro:lidar_sensor>

I have the following issue:

The first robot that I spawn has the lidar with the /robot1/scan topic visible and working correctly, once I add the second robot to the simulation, it spawn with the lidar visuals but there's no /robot2/scan topic published.

is this a known issue? or am I missing something? Thanks a lot in advance for your help!

pky404 commented 1 month ago

Hi @MatteoCarlone , I am getting the same issue. Have you managed to resolve the issue?