Skip to content

ubc-systopia/cps-gazebo-sim

Repository files navigation

cps-gazebo-sim

Included packages

  • multi_arm_lab_sim_description - holds the sdf description of the simulated system and any other assets.

  • multi_arm_lab_sim_gazebo - holds gazebo specific code and configurations. Namely this is where systems end up.

  • multi_arm_lab_sim_application - holds ros2 specific code and configurations.

  • multi_arm_lab_sim_bringup - holds launch files and high level utilities.

Requirements

  • Ubuntu Jammy 22.04
  • CMake version >= 3.5
  • Python 3.10

Installation

  1. ROS2 Humble Hawksbill

    For convenience, add the following line to .bashrc. Other possible values are setup.sh, setup.zsh

    source /opt/ros/humble/setup.bash
  2. Dependencies:

    cd ~/cps-gazebo-sim
    source /opt/ros/humble/setup.bash
    sudo rosdep init
    rosdep update
    rosdep install --from-paths src --ignore-src -r -i -y --rosdistro humble
  3. Gazebo Fortress

  4. ros-gz package which includes the necessary bridges and interfaces between ROS2 Humble and Gazebo Fortress

    sudo apt-get install ros-humble-ros-gz
  5. Install Interbotix robot packages https://docs.trossenrobotics.com/interbotix_xsarms_docs/ros_interface/ros2/software_setup.html#amd64-architecture (instead of 6. maybe edit the github source links for repos that I modified. in the xsarm_amd64_install.sh script)

  6. Update sources by running (insert my script which updates remote urls to my customized repos)

  7. MoveIt2

sudo apt install ros-humble-moveit

Drivers for Robots

Robot Installation Link
ViperX 300s https://docs.trossenrobotics.com/interbotix_xsarms_docs/ros_interface/ros2/software_setup.html
UR3e series https://github.com/UniversalRobots/Universal_Robots_ROS2_Driver/tree/humble

To run

Build

cd ~/cps-gazebo-sim
colcon build --cmake-args -DBUILD_TESTING=ON

Run

# source the workspace
. ~/cps-gazebo-sim/install/setup.sh
# launch the simulation and visualize in RViz
ros2 launch multi_arm_lab_sim_bringup ur3e.launch.py

Communication between ROS2 and Gazebo

Gazebo→ROS2

ros2 run ros_gz_bridge parameter_bridge /TOPIC@ROS_MSG@IGN_MSG

The ROS message type is followed by an @, [, or ] symbol where:

  • @ is a bidirectional bridge.
  • [ is a bridge from Ignition to ROS.
  • ] is a bridge from ROS to Ignition.

source: https://gazebosim.org/docs/fortress/ros2_integration#bidirectional-communication

More info on message types and bridge communication

For example,

ros2 run ros_gz_bridge parameter_bridge /diff_drive/cmd_vel@geometry_msgs/msg/Twist]ignition.msgs.Twist
ros2 topic pub /diff_drive/cmd_vel geometry_msgs/Twist "linear: { x: 0.1 }"
# list topics in the Ignition simulation environment
ign topic -l
# list topics in a ROS 2 system
ros2 topic list
# print messages published to a topic
ros2 topic echo /TOPIC

Testing

sudo apt install ros-humble-launch-testing

Compile and run tests:

colcon test --ctest-args tests [package_selection_args]

See test results:

colcon test-result --all

Add --verbose flag to see failing test cases.

Documentation

Documentation for this repo is generated with Sphinx. To update documentation: cd docs, make necessary edits, then run make html. View the output _build/html/index.html in a web browser.

Extra: Google slides presentation from Summer 2024 Intern/UG Event.

Sources

Gotchas

  • ufw firewall must be disabled for Gazebo to run