Setting up the environment for ROS 2
At this point, open a Terminal and run the following command:
$ ros2 ros2: command not found
You will get an error message saying that the ros2
command can’t be found. As we will see later, ros2
is a command-line tool we can use to run and test our programs from the Terminal. If this command isn’t working, it means that ROS 2 hasn’t been set up correctly.
Even if ROS 2 is installed, there’s one more thing you need to do in every new session (or Terminal) where you want to use ROS 2: you need to source it in the environment.
Sourcing ROS 2 in the environment
To do that, source this bash script from where ROS 2 is installed:
$ source /opt/ros/<distro>/setup.bash
Replace <distro>
with the current distribution name you are using. For ROS Jazzy, run the following command:
$ source /opt/ros/jazzy/setup.bash
After you run this, try executing the ros2
command again. This time, you should get...