Source: this legend
In order to learn ROS, you need to know in advance how to program in C++ or Python. Also, you need to be comfortable using the Linux shell.
In order to run ROS nodes, you need to type roscore into one of the terminals. Prior to that, you should make sure that you sourced these two directories in ~/.bashrc in order to make sure you can use your code with ROS functionalities:
If you want to develop such nodes, ROS works on a subscriber/publisher basis ros_architecture. Everything takes place in the catkin_ws directory.
catkin_ws directory
In order to create a ROS package, we need to call in catkins_ws/src:
catkin_create_pkg package_name rospy[or roscpp] ros_packagesfor example:
catkin_create_pkg my_robot_controller rospy turtlesimwhich will return:![]()
If we want to add other packages later, we can simply add them in package.xml. To run, we would need to type in another terminal
rosrun my_robot_controller script.py
In order to build the new ROS package we just created, we call
catkin_makeinside /catkin_ws Also, in order to run the node throughrosrun, you need to make the script executable withchmod +x script.pyAlso, for the script to work, it needs to have#!/usr/bin/env python3as first line in order to know the interpreter
ROS useful commands
Question
rosnode listshows all active nodesrosnode kill node_namekills any active noderqt_graphopens up a GUI that shows the relationships between active nodes.rostopic info /node_namegives details about the type, publishers and subscribers.![]()
rosmsg show![]()
rostopic echogives real-time data of a topic