Robot Operating System
Provides quick access and useful resources for ROS.
First, make sure which version of ROS is preferred. (i.e., ROS 1 or ROS 2)
In most cases, if the version is not specified in a open source project, it means ROS 1.
Then, decide which distribution you want to use.
- ROS distributions
As of 2021,
Noeticis the newest release, and
Melodicare used in most open source projects.
- ROS 2 distributions
As of 2021,
Galacticis the newest release, and
Foxyhas the latest End-Of-Life date.
Quick Start for ROS 2
If you want to use ROS 2, follow the installation guide.
The rest of this article focus on ROS 1 only.
I strongly suggest not to use Windows 10, unless you are entirely sure that all packages are supported. This is due to the fact that many open source projects only supports Ubuntu/Debian. If you do use Windows, you may refer to ms-iot/ROSOnWindows for further information.
The rest of this article focus on ROS 1 on Ubuntu only.
- Open the installation page.
- Choose the preferred distribution.
- Select the preferred platform.
- Follow the installation instructions.
- Follow the tutorials until
13. Examining the Simple Publisher and Subscriber.
You should now know how to communicate using ROS between nodes.
For more details, see the tutorial.
To access ROS, make sure to run:
# ROS source /opt/ros/<distro>/setup.bash # For your ROS workspace source devel/setup.bash
Execute the followings:
sudo apt update sudo apt install python3-catkin-pkg-modules python3-rospkg-modules python3-empy python-catkin-tools mkdir -p ./catkin_ws/src; cd ./catkin_ws catkin_make source devel/setup.bash sudo apt install -y virtualenv virtualenv venv -p python3 source venv/bin/activate python3 -m pip install pyyaml rospkg # Put sources under src/ # For example, opencv: # # git clone -b melodic https://github.com/ros-perception/vision_opencv.git src/vision_opencv # rosdep install --from-paths src --ignore-src -y -r catkin_make --cmake-args \ -DCMAKE_BUILD_TYPE=Release \ -DPYTHON_EXECUTABLE=/usr/bin/python3.6 \ -DPYTHON_INCLUDE_DIR=/usr/include/python3.6m \ -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.6m.so catkin config \ -DPYTHON_EXECUTABLE=./venv/bin/python \ -DPYTHON_INCLUDE_DIR=/usr/include/python3.6m \ -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.6m.so catkin config --install
I’m not sure whether the last
PYTHON_EXECUTABLE environment variable correctly install the package for the virtual environment…
Further references: this, this, and this.
Note: This method does not work if you need to
catkin_make a Python package.
By default, ROS uses Python2. To change it to Python3, first
cd into your workspace, then:
# ROS source /opt/ros/<distro>/setup.bash # For your ROS workspace source devel/setup.bash sudo apt install -y virtualenv virtualenv venv -p python3 source venv/bin/activate # For ROS in Python3 pip install pyyaml rospkg
# ROS source /opt/ros/<distro>/setup.bash # For your ROS workspace source devel/setup.bash # For ROS in Python3 python3 -m pip install pyyaml rospkg # And simply use python3 afterwards
Run Across Multiple Machines
Assume you have two machines: machine
192.168.50.101) and machine
A is the master which will run
roscore on port
- On machine
systemctl stop ros.service roscore # keep this process running rosrun rospy_tutorials listener.py
- On machine
# Make machine `B` know the address of machine `A` export ROS_MASTER_URI=http://192.168.50.101:11311 # Make machine `A` know the address of machine `B` export ROS_HOSTNAME=192.168.50.102 # You may want to use ROS_IP instead: http://wiki.ros.org/ROS/EnvironmentVariables # But since ROS_HOSTNAME has higher precedence, we use it here. rosrun rospy_tutorials talker.py
If you want to connect with host names, see this post for more details.
Publish & Subscribe Long Latency Issue
This happens when you have a fast publisher (e.g., 60Hz) transfering a large image to a slow subscriber (e.g., 1Hz).
Sometimes the latency becomes extremely large even if the
queue_size is set to
1 according to the article Choosing a good queue size.
The issue may reside on the
buff_size in the Subscriber API being too small. The solution is to increase the
buff_size to slightly larger than
queue_size * max_message_size as mentioned in the API description.
More discussions on this issue can be found on this GitHub issue.
- In the Tutorials
6. Understanding ROS Topics, using
Ctrl+Cto terminate the turtle node may not perform cleanup successfully, you should close the window by clicking the
Xbutton instead. (See this post)
- Topics vs. Services vs. Actions
- Make sure your
/etc/hostscontains the correct IP (
- Make sure you are running
ros.serviceif you are using
roslaunchdoes not need
rostopiccommand to quickly isolate where the issue resides.
- Solution to Security issue on ROS build farm
- Solution to ROS GPG Key Expiration Incident
- If you encountered
XXX Package not found, run
apt-get install ros-<distro>-<package>
- Manually inspect and run the setup scripts to ensure no error occurs.
- Here is the solution to the Gazebo issue:
The following packages have unmet dependencies: libgazebo9-dev : Depends: libgazebo9 (= 9.19.0-1~bionic) but it is not going to be installed Depends: gazebo9-plugin-base (= 9.19.0-1~bionic) but it is not going to be installed
Some commands for troubleshooting:
roswtfto quickly find potential issues.
rostopic listto list all topics.
rostopic echo /topic_nameto subscribe to a topic.
rostopic pub /topic_name std_msgs/String helloto publish to a topic.
rostopic listto list all topics.
dmesg -wHto check the USB port connection.
ping -c1 <hostname/IP>to check if the host is responsive.
sudo nmap -sn -PE -T5 -n <IP-CIDR>to ping multiple hosts at once.
More troubleshooting techniques: