-
Notifications
You must be signed in to change notification settings - Fork 1
Home
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)
If you plan to install Ubuntu on Windows using WSL2 instead of setting up a native Ubuntu system, follow these steps. Otherwise, you can skip this section.
-
Download and Install WSL
Ensure that WSL (Windows Subsystem for Linux) is installed on your system. You can do this using PowerShell. -
Set WSL to Use Version 2
Open PowerShell with administrator privileges and run the following command to set WSL2 as the default:wsl --set-default-version 2
-
Install Ubuntu 22.04
Install the Ubuntu 22.04, by running:wsl --install -d Ubuntu-22.04
-
Proceed to the Next Section
After completing the setup, you're ready to move on to the next section.
- Clone this repo
- Build the dev container
- Run
ifconfigin a terminal on the host to obtain the desired network interface
- It should be something like
eth0orenp39s0for ethernet connections, orwlan0for wireless connections
- Replace
eth0incyclonedds.xmlwith 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 gzclientand/orpkill -9 gzserverin the terminal before restarting the simulation
-
If Rviz does not load and display the map correctly, the following may help:
- Stop Rviz
- Run
sudo gedit /opt/ros/humble/share/turtlebot3_navigation2/param/burger.yamland replacerobot_model_type: "differential"withrobot_model_type: "nav2_amcl::DifferentialMotionModel" - Save the YAML file and restart Rviz
-
If you installed Docker Desktop (on Ubuntu 22.04) rather than Docker Server directly and encountered errors during the Docker build, the following might help:
- Uninstall Docker Desktop completely
- Install Docker Server directly, clean the build cache, and rebuild
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-installsource 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.xmlis correct