-
Notifications
You must be signed in to change notification settings - Fork 0
Installing Gazebo for ROS 2 Humble
To Install the Default Gazebo/ROS Pairing just use:
sudo apt-get install ros-${ROS_DISTRO}-ros-gz
You can try Gazebo using a demo. In this case, simulating a simple differential drive robot in Gazebo that is defined in one of the world examples of Gazebo, called visualize_lidar.sdf. To run this example, execute:
ign gazebo -v 4 -r visualize_lidar.sdf
To enable communication between the simulation and ROS 2, you need to use a package called ros_gz_bridge, which can be installed by running:
sudo apt-get install ros-humble-ros-ign-bridge
Then to launch a bridge from ROS to Gazebo (in this case, the bridge is for the topic /model/vehicle_blue/cmd_vel
), run:
source /opt/ros/humble/setup.bash
ros2 run ros_gz_bridge parameter_bridge /model/vehicle_blue/cmd_vel@geometry_msgs/msg/Twist]ignition.msgs.Twist
Once the bridge is running, will be able to follow your motor commands. There are two options to send a command:
• Send a command to the topic using ros2 topic pub
:
ros2 topic pub /model/vehicle_blue/cmd_vel geometry_msgs/Twist "linear: { x: 0.1 }"
• Use the keyboard by installing the teleop_twist_keyboard
package:
sudo apt-get install ros-humble-teleop-twist-keyboard
In this case, simply type:
source /opt/ros/humble/setup.bash
ros2 run teleop_twist_keyboard teleop_twist_keyboard --ros-args -r /cmd_vel:=/model/vehicle_blue/cmd_vel
To send the data generated by Gazebo to ROS 2, you need to launch another bridge. In the case the data from the lidar is provided in the Gazebo Transport topic /lidar2, which you are going to remap in the bridge. This topic then will be available under the topic /lidar_scan
:
source /opt/ros/humble/setup.bash
ros2 run ros_gz_bridge parameter_bridge /lidar2@sensor_msgs/msg/LaserScan[ignition.msgs.LaserScan --ros-args -r /lidar2:=/laser_scan
Then, use Rviz2 to visualize the data:
source /opt/ros/humble/setup.bash
rviz2
After that, configure the fixed frame
camp to vehicle_blue/lidar_link/gpu_lidar
and click the “Add” button to include a display for visualizing the lidar data inside Rviz2.
By now you should see the data from the lidar in Rviz2:
If more information is needed, you can consult the ROS documentation at: