-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Mo Chen edited this page Jan 6, 2025
·
10 revisions
Welcome to the ROS2 Tutorial wiki!
- In ROS2, different nodes that represent software packages that perform things like sensor processing and planning.
- Nodes communicate with each other through topics, services, and actions
-
ros2 run ...
will run a single node -
ros2 launch ...
will run multiple nodes at once from a launch file; launch files can be nested
Typically, there will be at least two computers running during robotics experiments. These computers constantly communicate with each other
- A host computer (e.g. a laptop or desktop computer) preferably running Ubuntu (virtual machines highly discouraged)
- Normally, lots of things need to be installed on the computer, and often packages will not on a different computer with different things installed.
- Virtual/Conda environments would normally be the solution, but unfortunately ROS2 does not work well with those
- To make sure code is able to be run on different computers, we will be using a dev container (this repo) with all the right things installed. The dev container will run on the host computer, and anything ROS-related will be run inside the dev container
- A computer in a robot
- Everything ROS-related on robot is installed on the host (i.e. we do not run a dev container on the robot)
- Clone this repo
- Build the dev container
- Run
ifconfig
in a terminal on the host to obtain the desired network interface
- It should be something like
eth0
orenp39s0
for ethernet connections, orwlan0
for wireless connections
- Replace
eth0
incyclonedds.xml
with the correct network interface obtained from the above - Run turtlebot3 simulation:
ros2 launch nav2_bringup tb3_simulation_launch.py headless:=False
- If Gazebo does not load correctly (e.g. the turtlebot is not found), the following may help
- Stop the simulation (Ctrl + C in terminal) and restart the simulation
- Run
pkill -9 gzclient
and/orpkill -9 gzserver
in the terminal before restarting the simulation
Installing packages that come with the dev container (including ones we may create as part of a project)
- Build and source packages
colcon build --symlink-install
source install/setup.bash
- Optional: Test a dummy ROS2 launch file in this repo:
ros2 launch controller experiment.launch.py
- Make sure to have the following in
~/.bashrc
:
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
export ROS_DOMAIN_ID=5 # This domain ID should be the same as the computer's
export CYCLONEDDS_URI=~/ros2_ws/cyclonedds.xml # Make sure the workspace directory is correct
- Install cyclonedds if needed:
sudo apt install ros-humble-rmw-cyclonedds-cpp
- Make sure the the network interface in
cyclonedds.xml
is correct