• Diff for "ROS/Tutorials/UsingRxconsoleRoslaunch"
Differences between revisions 28 and 29
Revision 28 as of 2009-09-09 23:18:21
Size: 3759
Editor: MeloneeWise
Comment:
Revision 29 as of 2009-09-09 23:21:38
Size: 3895
Editor: MeloneeWise
Comment:
Deletions are marked like this. Additions are marked like this.
Line 63: Line 63:
In your `beginner tutorials` package let's make a launch directory and create a launch file: First we must make a launch file. In your `beginner tutorials` package let's make a launch directory and create a launch file:
Line 100: Line 100:
Now we close the xml tag for the launch file. This closes the xml tag for the launch file.

Now let's `roslaunch` the launch file:
{{{
$ roslaunch beginner_tutorials turtlemimic.launch
}}}

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++)

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:

rxloggerlevel.png

rxconsole(start).png

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:

rxconsole(turtlesimstart).png

Now let's change the logger level to error by refreshing the nodes in the rxloggerlevel window and selecting error as shown below:

rxloggerlevel(error).png

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

rxconsole(turtlesimerror).png

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.

Usage:

$ roslaunch [package] [filename.launch]

First we must make 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:

Toggle line numbers
   1 <launch>
   2 
   3   <group ns="turtlesim1">
   4     <node pkg="turtlesim" name="sim" type="turtlesim"/>
   5   </group>
   6 
   7   <group ns="turtlesim2">
   8     <node pkg="turtlesim" name="sim" type="turtlesim"/>
   9   </group>
  10         
  11   <node pkg="turtlesim" name="mimic" type="mimic" args="input:=turtlesim1 output:=turtlesim2"/>
  12 
  13 </launch>

The Launch File Explained

Now, let's break the launch xml down.

Toggle line numbers
   1 <launch>

Here we start the launch file with the launch tag, so that the file is identified as a launch file.

Toggle line numbers
   3   <group ns="turtlesim1">
   4     <node pkg="turtlesim" name="sim" type="turtlesim_node"/>
   5   </group>
   6 
   7   <group ns="turtlesim2">
   8     <node pkg="turtlesim" name="sim" type="turtlesim_node"/>
   9   </group>

Here we start two groups with a namespace tag of turtlesim1 and turtlesim2 with a turtlesim node with a name of sim. This allows us to start two simulators without having name conflicts.

Toggle line numbers
  11   <node pkg="turtlesim" name="mimic" type="mimic">
  12     <remap from="input" to="turtlesim1/turtle1"/>

Here we start the mimic node with the topics input and output renamed to turtlesim1 and turtlesim2. This renaming will cause turtlesim2 to mimic turtlesim1.

Toggle line numbers
  13     <remap from="output" to="turtlesim2/turtle1"/>

This closes the xml tag for the launch file.

Now let's roslaunch the launch file:

$ roslaunch beginner_tutorials turtlemimic.launch

Wiki: ROS/Tutorials/UsingRxconsoleRoslaunch (last edited 2013-04-09 20:27:22 by IsaacSaito)