MmVi
MmVi

Reputation: 21

display lidar data from gazebo simulation

Recently, I have been trying to display a Lidar in Gazebo. However, I am completely new to ROS, so it is difficult for me to understand everything. With the help of several tutorials, trial and error, and other resources, I have managed to display a small vehicle with a Lidar on it in Gazebo. For further analysis, I also want to generate measurements and displays. I saw in a GitHub repository of the Livox Laser scanner that it is displayed using RVIZ.

So, my question is: How can I display the point cloud of my simulated Lidar (e.g., in RViz) and possibly measure distances or other parameters?

If necessary, I can post my code for it.

Thank you!

Im running Ros 18.04 - melodic ; gazebo version 9.0.0 ; rviz version 1.13.29

I tried to write a proper plugin to get those "Topics" needed in RViz. However, neither my robot_model, nor my lidarscan is shown in RViz.

Also i tried to write a .launch-file for launching both gazebo and Rviz simultaneously, but i coundn't get this to work as well. I was hoping that through the parallel launch I could select and display the different topics.

Upvotes: 0

Views: 1559

Answers (1)

A-T
A-T

Reputation: 356

LIDAR modules are simulated in Gazebo using sensor plugins. These sensor plugins are often published by the manufacturer of the LIDAR module. These plugins are essentially .so files that are executed when the plugin is added to a URDF or SDF file and then loaded to Gazebo. Such plugins are already available for most common LIDARs such as the Hokuyo, Velodyne, SICK and as you've mentioned the LIVOX. Check out a few sample launch and URDF files in these repositories and you will gain a better understanding.

With respect to launching both Gazebo and RVIZ together, what is the problem you are facing exactly? Here is an example launch file you can use to launch both Gazebo and RVIZ together.

<?xml version="1.0" encoding="UTF-8"?>

<launch>  
    <!-- Arguments -->
    <arg name="robot" default="robot_name"/>
    <arg name="debug" default="false"/>
    <arg name="gui" default="true"/>
    <arg name="headless" default="false"/>
    <arg name="pause" default="false"/>
    <arg name="rvizconfig" default="$(find package_name)/rviz/your_rviz_settings_file.rviz" />
    <arg name="rviz" default="true" />  

    <!-- Start Gazebo world -->
    <include file="$(find gazebo_ros)/launch/empty_world.launch">
        <arg name="world_name" value="$(find package_name)/worlds/gazebo_world_name.world"/>
        <arg name="debug" value="$(arg debug)" />
        <arg name="gui" value="$(arg gui)" />
        <arg name="paused" value="$(arg pause)"/>
        <arg name="use_sim_time" value="true"/>
        <arg name="headless" value="$(arg headless)"/>
    </include>

    <!-- Launch rviz visualization -->
    <node if="$(arg rviz)" name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" />

</launch>

Make sure you replace the 'package_name' with the name of the corresponding ROS package where your RVIZ settings and Gazebo world file are located. Please replace 'your_rviz_settings_file' with your rviz settings file name. Please replace 'gazebo_world_name' with the name of your actual world file.

If you do not have an RVIZ settings file already, on a new terminal run rviz with rosrun rviz rviz and set up RVIZ the way you would want it to look. After you are happy with how it looks, select the 'Save Config as' option and save your file wherever you want. This is then going to be your .rviz file moving forward.

Upvotes: 0

Related Questions