Note:This tutorial assumes that you have completed the previous tutorial, understanding ROS services and parameters. |
Using rxconsole and roslaunch
Description: This tutorial introduces ROS using rxconsole and rxloggerlevel for debugging and roslaunch for starting many nodes at once.
Tutorial Level: BEGINNER
Next Tutorial: Writing a simple publisher and subscriber (python) (c++)
Contents
Using rxconsole and rxloggerlevel
rxconsole can attaches to ROS's logging framework to display output from nodes. rxloggerlevel allows us to change the verbosity level (DEBUG, WARN, INFO, and ERROR) of nodes as they run. First we need to make rxtools:
$ rosmake rxtools
Now let's look at the turtlesim output in rxconsole and switch logger levels in rxloggerlevel as we use tutrlesim. Before we start the turtlesim, new terminals let's start rxconsole and rxloggerlevel:
$ rxloggerlevel $ rxconsole
You will see two windows popup:
Now let's start turtlesim in a new terminal:
$ rosrun turtlesim turtlesim
Since the default logger level is INFO you will see any info that the turtlesim publishes when it starts up, which should look like:
Now let's change the logger level to error by refreshing the nodes in the rxloggerlevel window and selecting error as shown below:
Now let's run our turtle into the wall and see what is displayed in our rxconsole:
rostopic pub command_velocity turtlesim/Velocity -r 1 -- 90.0 0.0
Let's Crtl-C our turtlesim and let's use rosluanch to bring up multiple turltlesims and a mimicing node to cause one turtlesim to mimic another:
Using roslaunch
roslaunch starts nodes as defined in a launch file. In your beginner tutorials package let's make a launch directory and create a launch file:
$ roscd beginner_tutorials $ mkdir launch $ cd launch
The Launch File
Now let's create a launch file called turtlemimic.launch and paste the following:
<launch>
<group ns="turtlesim1">
<node pkg="turtlesim" name="sim" type="turtlesim"/>
</group>
<group ns="turtlesim2">
<node pkg="turtlesim" name="sim" type="turtlesim"/>
</group>
<node pkg="turtlesim" name="mimic" type="mimic" args="input:=turtlesim1 output:=turtlesim2"/>
</launch>
The Launch File Explained
Error: No code_block found