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

Problems when adding lidar and camera sensors to the same robot on Ignition #1473

Closed
lucaslbmp opened this issue May 4, 2022 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@lucaslbmp
Copy link

lucaslbmp commented May 4, 2022

Environment

  • OS Version:
  • Source or binary build?: Binary, igntion-gazebo-6.8.0

Description

Trying to spawn a simple 2-wheeled robot model (named "r2d2" here) in Ignition containing both lidar and camera sensor.

  • Expected behavior: The model is spawned and their respective topics are available, just what happens if the model is spawned with only one of the sensors.
  • Actual behavior: The simulator crashes and an error message is displayed.

Steps to reproduce

  1. In the main xacro of a mode (in this case teste_bot), add tags for each sensor
<gazebo reference="cam_front">
        <sensor name='${name}' type='camera'>
            <pose>${body_dim_x/2} 0 ${body_dim_z/2} 0 0 0</pose>
            <visualize>true</visualize>
            <update_rate>5</update_rate>
            <topic>${name}/camera_image</topic>
            <camera>
                <!-- <horizontal_fov>1.047</horizontal_fov> -->
                <image>
                    <!-- <width>320</width>
                    <height>240</height> -->
                    <width>640</width>
                    <height>420</height>
                    <!-- <format>B8G8R8</format> -->
                </image>
                <!-- <clip>
                    <near>0.1</near>
                    <far>100</far>
                </clip> -->
            </camera>


               <plugin filename="libignition-gazebo-sensors-system.so" name="ignition::gazebo::systems::Sensors">
          <render_engine>ogre</render_engine>
            </plugin>
        </sensor>
    </gazebo>
<gazebo reference="base_lidar">
        <sensor name="${name}" type='gpu_lidar'>
            <pose>0 0 ${body_height*0.6} 0 0 0</pose>
            <!-- <pose>0 0 1.0 0 0 0</pose> -->
            <topic>${name}/lidar</topic>
            <update_rate>10</update_rate>
            <ray>
                <scan>
                    <horizontal>
                        <!-- <samples>90</samples> -->
                        <samples>10</samples>
                        <resolution>1</resolution>
                        <min_angle>${-radians(20)}</min_angle>
                        <max_angle>${radians(20)}</max_angle>
                    </horizontal>
                    <vertical>
                        <samples>10</samples>
                        <resolution>1</resolution>
                        <min_angle>${-radians(10)}</min_angle>
                        <max_angle>${radians(10)}</max_angle>
                    </vertical>
                </scan>
                <range>
                    <!-- <min>0.08</min> -->
                    <min>0.1</min>
                    <max>2.0</max>
                    <resolution>0.01</resolution>
                </range>
            </ray>
            <always_on>1</always_on>
            <visualize>true</visualize>

            <plugin filename="libignition-gazebo-sensors-system.so" name="ignition::gazebo::systems::Sensors">
                <render_engine>ogre</render_engine>
            </plugin>
        </sensor>
    </gazebo>
  1. Build the workspace: colcon build
  2. Launch the simulator: ign gazebo empty.sdf --render-engine ogre
  3. Spawn the robot: ign service -s /world/empty/create --reqtype ignition.msgs.EntityFactory --reptype ignition.msgs.Boolean --timeout 300 --req 'sdf_filename: "/home/lucas/ros2_ntu_ws/src/ntu_gazebo/models/teste_bot/urdf/teste_bot.urdf" '

Output

The simulator crashes and the following message is displayed:

WhatsApp Image 2022-05-04 at 13 18 34

@lucaslbmp lucaslbmp added the bug Something isn't working label May 4, 2022
@lucaslbmp
Copy link
Author

I found out the problem: the plugin "ignition::gazebo::systems::Sensors" should be called only once, even though it is used by both sensors.

@chapulina
Copy link
Contributor

I found out the problem: the plugin "ignition::gazebo::systems::Sensors" should be called only once, even though it is used by both sensors.

Glad to hear it! It would be interesting to add some safety check to that plugin that prevents 2 instantiations.

@msminirobot
Copy link

This is actually also very important for multi-robot simulations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants