ROS is the ultimate SDK for robot application development. It provides a distributed architecture and contains state-of-the art algorithms implemented and maintained by experts in the field. Everything with a permissive license that just in a few years changed the landscape of robotics and has been widely adopted by academia and industry.
Note that nodes in ROS do not have to be on the same system (multiple computers) or even of the same architecture! You could have a Erle-Brain publishing messages, a laptop subscribing to them. ROS is also open source, maintained by many people. This makes ROS really flexible and adaptable to the needs of the user.
ROS is released under the terms of the BSD (Berkeley Software Distribution) license and is an open source software. It is free for commercial and research use
ROS promotes code reutilization so that the robotics developers and scientists do not have to reinvent the wheel all the time. With ROS, you can do this and more. You can take the code from the repositories, improve it, and share it again.
A node must have a unique name in the system. This name is used to permit the node to communicate with another node using its name without ambiguity. A node can be written using different libraries such as roscpp and rospy; roscpp is for C++ and rospy is for Python.
ROS has tools to handle nodes and give us information about it such as rosnode. The tool rosnode is a command-line tool for displaying information about nodes, such as listing the currently running nodes.
Each topic is strongly typed by the ROS message type used to publish it, and nodes can only receive messages from a matching type. A node can subscribe to a topic only if it has the same message type.
The topics in ROS can be transmitted using TCP/IP and UDP. The TCP/IP-based transport is known as TCPROS and uses the persistent TCP/IP connection. This is the default transport used in ROS.
The UDP-based transport is known as UDPROS and is a low-latency, lossy transport. So, it is best suited for tasks such as teleoperation.
ROS has a tool to work with topics called rostopic. It is a command-line tool that gives us information about the topic or publishes data directly on the network.
The services are developed by the user, and standard services don’t exist for nodes. The files with the source code of the messages are stored in the srv folder.
With rosservice, we can list and query services. The commands supported are as follows:
ROS has the rosparam tool to work with the Parameter Server. The supported parameters are as follows:
To move between the packages and their folders and files, ROS gives us a very useful package called rosbash, which provides some commands very similar to the Linux commands. The following are a few examples:
Erle-Brain:
export ROS_MASTER_URI=http://192.168.7.2:11311 export ROS_IP=192.168.7.2
Laptop or PC:
export ROS_MASTER_URI=http://192.168.7.2:11311 export ROS_IP=192.168.7.1
roscore roscore: command not found
You will see this message because your system does not know where to search for the commands. To solve it, type the following command in a shell:
source /opt/ros/indigo/setup.bash
Then, type the roscore command once again, and you will see the following output:
... Press Ctrl-C to interrupt started roslaunch server http://192.168.7.2:52131/ ros_comm version 1.11.10 SUMMARY ======== PARAMETERS * /rosdistro: indigo * /rosversion: 1.11.10 NODES auto-starting new master process[master]: started with pid [5437] ROS_MASTER_URI=http://192.168.7.2:11311/ setting /run_id to 8e8dcaf5-fd39-11e4-bff2-6c400899ab38 process[rosout-1]: started with pid [5440] started core service [/rosout]
This means that your system knows where to find the commands to run ROS. Note that if you open another shell and type roscore, it will not work. This is because it is necessary to add this script within the .bashrc file. So, every time you start a new shell, the scripts will run because .bashrc always runs when a shell runs. Use the following commands to add the script:
echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc source ~/.bashrc
Being an image, we cannot use rostopic echo /camera because the amount of information in plain text would be very huge and also difficult to analyze. For this you will need two terminals. On the first terminal, launch roscore:
roscore
On the second terminal, create a launch file called “usb_cam-test.launch” with the following content (be sure to customize the value of video_device to match your system):
<launch> <node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" > <param name="video_device" value="/dev/video0" /> <param name="image_width" value="640" /> <param name="image_height" value="480" /> <param name="pixel_format" value="mjpeg" /> <param name="camera_frame_id" value="usb_cam" /> <param name="io_method" value="mmap"/> </node> </launch>
roslaunch usb_cam-test.launch
if you want to visualize the image run in another terminal:
rosrun image_view image_view image:=/camera
Another important utility that ROS gives to the user is the possibility to calibrate the camera. It has a calibration interface built on top of the OpenCV calibration API. This tool is very simple to use; so, once the camera is running, we only have to show some views of a calibration pattern (usually a checkerboard) using this:
rosrun camera_calibration cameracalibrator.py --size 8x6 --square 0.108 image:=/camera/image_raw camera:=/camera