Simulate a mobile robot equipped with a 3D LiDAR sensor in Gazebo Classic, using ROS2 for seamless integration. This project allows the robot to navigate a simulated environment while capturing detailed 3D point cloud data, which can be visualized in real-time using RViz.
- ROS2 Humble (tested)
- Gazebo Classic (tested)
- Should also work with ROS2 Foxy
-
Source ROS2 environment:
source /opt/ros/humble/setup.bash
-
Create a ROS2 workspace:
mkdir -p ~/ros2_ws/src cd ~/ros2_ws/src
-
Clone the necessary repositories:
git clone https://github.com/louislelay/mobile-3d-lidar-sim.git git clone https://bitbucket.org/DataspeedInc/velodyne_simulator.git cd velodyne_simulator git checkout foxy-devel
-
Build the workspace:
cd ~/ros2_ws colcon build
-
Source the workspace setup file:
source install/setup.bash
-
Launch the robot in Gazebo:
To run the default simulation:
ros2 launch my_bot launch_sim.launch.py
To run the simulation in a custom world:
ros2 launch my_bot launch_sim.launch.py world:=./src/mobile-3d-lidar-sim/my_bot/worlds/obstacles.world
-
Control the robot:
In a new terminal, run the following to control the robot using your keyboard:
ros2 run teleop_twist_keyboard teleop_twist_keyboard
-
Visualize the simulation in RViz:
In a third terminal, run:
rviz2
-
Add visualization elements:
- Add a
RobotModel
. - Add a
PointCloud2
.
- Add a
-
Configure visualization:
- In
Global Options
, changeFixed Frame
toodom
. - In
RobotModel
, change theDescription Topic
to/robot_description
. - In
PointCloud2
, change theTopic
to/velodyne2/velodyne_points2
.
- In
-
This project simulates a mobile robot equipped with a Velodyne 3D LiDAR, offering a complete setup for testing sensor data processing and visualization using ROS2 and Gazebo Classic. The robot can be controlled using teleoperation, and all data can be visualized in RViz for easy analysis.