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

Multiple IMU sensors with imu_sensor_broadcaster #191

Closed
delihus opened this issue Nov 28, 2023 · 4 comments
Closed

Multiple IMU sensors with imu_sensor_broadcaster #191

delihus opened this issue Nov 28, 2023 · 4 comments

Comments

@delihus
Copy link
Contributor

delihus commented Nov 28, 2023

During making an example with multiple ROSbots I cannot separate IMU sensors for each robot. Ignition system of 2 robots reads the value of the imu from one sensor. How to create multiple sensors with imu_sensor_broadcaster?
This is URDF where namespace_ext is rosbot1/ or rosbot2/:

 <ros2_control name="${namespace_ext}imu" type="sensor">
    <hardware>
      <plugin>rosbot_hardware_interfaces/RosbotImuSensor</plugin>
      <param name="connection_timeout_ms">120000</param>
      <param name="connection_check_period_ms">500</param>
    </hardware>

    <sensor name="${namespace_ext}imu">
      <state_interface name="orientation.x" />
      <state_interface name="orientation.y" />
      <state_interface name="orientation.z" />
      <state_interface name="orientation.w" />
      <state_interface name="angular_velocity.x" />
      <state_interface name="angular_velocity.y" />
      <state_interface name="angular_velocity.z" />
      <state_interface name="linear_acceleration.x" />
      <state_interface name="linear_acceleration.y" />
      <state_interface name="linear_acceleration.z" />
    </sensor>
  </ros2_control>

  <gazebo reference="imu_link">
    <sensor name="${namespace_ext}imu" type="imu">
      <plugin filename="ignition-gazebo-imu-system" name="ignition::gazebo::systems::Imu"></plugin>
      <always_on>true</always_on>
      <update_rate>25</update_rate>
      <topic>imu/data_raw</topic>
      <visualize>false</visualize>
      <enable_metrics>false</enable_metrics>
      <frame_id>imu_link</frame_id>
      <ignition_frame_id>imu_link</ignition_frame_id>
      <ros>
        <namespace>${namespace}</namespace>
      </ros>
    </sensor>
  </gazebo>

Configuration

ROS 2 Humble

Reproduce

The example you can run from here https://github.com/husarion/rosbot_ros/tree/add-namespaces following the README and then run in terminal 1:

ros2 launch rosbot_gazebo simulation.launch.py namespace:=rosbot1

In the second terminal:

ros2 launch rosbot_gazebo spawn.launch.py namespace:=rosbot2 y:=2 x:=1

Here is the video with the issue. On the right side you can see the plots with orientation w and z. When the second robot spawns the values of the /rosbot1/imu_broadcaster are shadowed.
Screencast from 28.11.2023 16:18:00.webm

@azeey
Copy link
Contributor

azeey commented Nov 30, 2023

The IMU system/plugin should not be initialized for each robot. You just need one <plugin filename="ignition-gazebo-imu-system" name="ignition::gazebo::systems::Imu"></plugin> in the world .sdf file and remove the <plugin> tags from each <sensor>.

@delihus
Copy link
Contributor Author

delihus commented Dec 5, 2023

The IMU system/plugin should not be initialized for each robot. You just need one <plugin filename="ignition-gazebo-imu-system" name="ignition::gazebo::systems::Imu"></plugin> in the world .sdf file and remove the <plugin> tags from each <sensor>.

Thank you for that. I will check that!

The other question is how spawn properly multiple robots where the plugin configs are in the robot's urdf?

@azeey
Copy link
Contributor

azeey commented Dec 12, 2023

The other question is how spawn properly multiple robots where the plugin configs are in the robot's urdf?

Plugins such as DiffDrive are meant to be specific to a robot, so you should be okay spawning multiple robots each with it's own plugin. But plugins such as IMU are meant to be initialized at the world level.

@delihus
Copy link
Contributor Author

delihus commented Dec 29, 2023

I have added the plugin loading to worlds and it worked.
husarion/husarion_gz_worlds@461dafa

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