wiki page - Wilbus/ROS-catkin_ws GitHub Wiki
ROS (Robot Operating System) is software that gives developers tools to control data flow between different systems within a larger system (usually robots). ROS uses the concept of Nodes which can either be publishers or subscribers. Publisher nodes "broadcast" over a topic (which can be int, double, arrays, etc). Subscriber nodes "subscribe" or listen over the topic to receive the data from publisher nodes. ROS uses the catkin_ws workspace convention. To create a package, we run catkin_create_pkg -packagename- -dependency1- -dependency2- ... in ~/catkin_ws/src. Each package has a CMakeLists.txt and package.xml file. The package.xml file specifies which dependencies the package has. For example, in this implementation, we are using roscpp and std_msgs. The CMakeLists.txt is the makefile for the package. It specifies which files to build and output. To build a package, we run catkin_make in ~/catkin_ws, which will build any packages in the src folder. This github contains an implementation of a simple Publisher/Subscriber system in ROS. In this implementation, the talker is the publisher node, and the listener is the subscriber node. We will call Node A the publisher, and Node B the subscriber. We want Node A to publish ROS datatypes of Int64, String, and Float64Array. In C++, these ROS datatypes hold ints, strings, and a vector of doubles. Node A will publish ints to the topic Int64, strings to the topic String, and a vector of doubles to the topic Float64MultiArray. The method advertise("Topic_Name", int n) sets up a Publisher object within a Node to publish to the Topic_Name and a buffer size of n before it throws away messages. To publish a message, the Publisher::publish(data) command will publish the data over the publisher's topic name specified from advertise(). At Node B, we set up Subscriber objects, which can be done using the subscribe("Topic_Name", int n, f) which listens over the Topic_Name, with buffer size n and a callbackfunction f that will be called when there is a message heard in this implementation. There is a topic for each datatype, and each topic has a callbackfunction that is called and simply echos what was sent from Node A. To run the the program, we first have to source ./devel/setup.bash, start the master ROS server using the command roscore, then rosrun -packagename- -filename-. Since this implementation contains Node A and B, we use rosrun in two separate terminals to see the outputs.