Robot Operating System - GarethG/ProjectRinzler GitHub Wiki
Robot Operating System
Robot Operating System (ROS) is the name of the operating system we will be using during this project. The main reasoning behind using an operating system such as ROS is it allows hardware to become an abstract within the software. Various nodes can be configured within ROS which act as accessible functions, these nodes can be easily accessed over the network by other nodes. This means simplicity when using multiple machines, such as our roboard and ITX.
#Installing ROS
The ROS website does have a great guide for installing ROS, which can be found here. If you are configuring it for the roboard I suggest installing the minimal install due to the space limitations. If you have room however it is worth picking the full fat install.
Once the install has completed run;
echo "export ROS_PACKAGE_PATH=~/ProjectRinzler:$ROS_PACKAGE_PATH" >> ~/.bashrc
. ~/.bashrc
This tells ROS to search within our git directory for programs and folders. Using this does mean the git hub must be initialised at the root of your home directory. Else you will need to modify the path to reflect this decision.
##Configuring Network
To allow nodes to communicate with one another over the network ROS needs to know two things. First the IP of the host computer must be configured, this can be performed with the following command.
echo "export ROS_MASTER_URI=http:192.168.1.3:11311" >> ~/.bashrc
. ~/.bashrc
The IP address listed above is the address of the roboard, note that this should be changed to the IP of the master for whatever you are working on at the time. The port number is arbitrary, try not to pick anything below 5,000 as these tend to be used by the operating system.
Secondly ROS needs to know the IP address of the current machine. This is quite simple also, the IP of the machine can be found running;
ifconfig
This should provide you with the current machines IP address. Then finally the command;
echo "export ROS_IP=192.168.1.4" >> ~/.bashrc
. ~/.bashrc
The example IP is that of the ITX, at least it will be, so swap out the IP address for the IP of any machine that is under use.
#Git
Git is the website you are on currently, it is our change log system which we use to control our software development. This website contains a fantastic cheat sheet to explain the git process. To initalise the git repository;
cd
git init
git clone [email protected]:GarethG/ProjectRinzler.git
git checkout master
git pull
git branch
Following the above steps should download the git repository to ~/ProjectRinzler/ and git branch should now return master, ensuring you have downloaded the correct software.
#Using ROS
##ROS Core
ROS Core is the central focus for ROS. It is essentially the primary node which regulates all other nodes. This must be run on the master machine else the nodes will have no ability to co-ordinate. Starting ROS core is very straight forward;
roscore
This will boot the core, this will perform all configurations required for the network. Note that the ROS_IP and ROS_MASTER_URI indicators should be setup as per the installation process else network communication will likely not operate correctly.
##roscd
roscd [node name]
Above is the command which will allow you to jump to a nodes directory. This is particularly useful when you don't know where in the path a node is located. Simply provide the name of the node after roscd.
##rosls
rosls
Will return the files located within a nodes directory.
##rospack
rospack find [node name]
Highlights the path to a node.
rospack profile
Using profile updates the ROS directories and paths.
##roscreate
Roscreate is used to create a new ROS node. Simply specify the node name and the various dependencies which it uses.
roscreate-pkg [package_name] [depend1] [depend2] [depend3]
It is often worthwhile updating the rospack profile at this point.
##rosdep
Rosdep allows a user to install ROS packages, such as libraries and drivers.
rosdep install [package]
##rosmake
rosmake [package]
Rosmake is the command which will build a node. We can also build multiple nodes in one hit.
rosmake [package1] [package2] [package3]
##Messages and Services
###msg
ROS Messages are the system which ROS uses to broadcast data between nodes. This data is arranged in structs. See the previous link for more details.
###srv
ROS Services are how ROS sends and receives messages between nodes.
###Viewing Messages and Services
You can view the structure for a message using
rosmsg show [msg]
You can view a service with
rossrv show [srv]
###CMake Alterations
If using messages and services you need to make some alterations to the CMakeLists.txt file. For messages remove the # from;
#rosbuild_genmsg()
And for services remove the # from;
#rosbuild_gensrv()
##Rosnode list
rosnode list
Returns a list of running nodes
##Rosnode info
rosnode info /[node]
Returns information of a running node including data it publishes and depends upon.
##rosrun
rosrun [node name1] [node name2]
Rosrun runs a node, or multiple nodes
rosrun [node name] __name:=new_name
Runs a node and assigns it a new name.
##rosnode ping
rosnode ping [node_name]
Pings a node to identify if it is running, and if there are any bottle necks in traffic.
##rxgraph
rxgraph
Creates a graph which represents the interaction of the running system.
##rostopic
rostopic echo /[node_name]/[variable_name]
Will print out the value of variable_name.
rostopic pub -1 /[node_name]/[variable_name] [node_name]/[variable_name2] -- 2.0 1.8
Will directly inject that values of 2.0 and 1.8 into variable_name and variable_name2. Adding -r [num] will update the node many times at a rate of num Hz.
rostopic hz [topic]
Will return how quickly the node topic is updating.
##rxplot
rxplot /[node_name]/[variable_name],/[node_name]/[variable_name2]
Will create a live graph of variable_name and variable_name2. Using a space instead of a comma will draw the two values on separate graphs.
#Creating a basic node to read and write data
[http://www.ros.org/wiki/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29] (http://www.ros.org/wiki/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29)
#Running nodes across the network http://www.ros.org/wiki/ROS/Tutorials/MultipleMachines