This tutorial introduces ROS using rqt_console and rqt_logger_level for debugging and roslaunch for starting many nodes at once. If you use ROS fuerte or ealier distros whererqt isn't fully available, please see this page withthis page that uses old rx based tools.
Using rqt_console and rqt_logger_level
rqt_console attaches to ROS's logging framework to display output from nodes.rqt_logger_level allows us to change the verbosity level (DEBUG, WARN, INFO, and ERROR) of nodes as they run.
Now let's look at the turtlesim output in rqt_console and switch logger levels in rqt_logger_level as we use turtlesim. Before we start the turtlesim,in two new terminals start rqt_console andrqt_logger_level:
$ rosrun rqt_console rqt_console
$ rosrun rqt_logger_level rqt_logger_level这里面就可以看到正在运行的node的信息，message内容等 。
logger level工具可以查看报警信息，注意logger level是有层级的，Fatal has the highest priority andDebug has the lowest. By setting the logger level, you will get all messages of that priority level or higher。
Logging levels are prioritized in the following order:
Fatal Error Warn Info Debug
$ roslaunch [package] [filename.launch]
$ roslaunch beginner_tutorials turtlemimic.launch关于launch file :
位置：在package根目录下，有 src, include, launch文件夹，package.xml文件， 在launch文件夹下，建立finename.launch文件。
这里有个问题是，roslaunch运行了这个文件以后，出来俩跟随的turtle。只能使用rostopic pub来驱动，为何不能用rosrun turtlesim turtle_teleop_key来驱动？
$ rostopic pub /turtlesim1/turtle1/cmd_vel geometry_msgs/Twist -r 1 -- '[2.0, 0.0, 0.0]' '[0.0, 0.0, -1.8]'
$ rosrun turtlesim turtle_teleop_key
The Launch File
Now let's create a launch file called turtlemimic.launch and paste the following:
1 <launch> 2 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> 10 11 <node pkg="turtlesim" name="mimic" type="mimic"> 12 <remap from="input" to="turtlesim1/turtle1"/> 13 <remap from="output" to="turtlesim2/turtle1"/> 14 </node> 15 16 </launch>
The Launch File Explained
Now, let's break the launch xml down.
Here we start the launch file with the launch tag, so that the file is identified as a launch file.
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.
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.
2. Using rosed
rosed is part of the rosbash suite. It allows you to directly edit a file within a package by using the package name rather than having to type the entire path to the package.
$ rosed [package_name] [filename]
$ rosed roscpp Logger.msg
This example demonstrates how you would edit the Logger.msg file within the roscpp package.
If the filename is not uniquely defined within the package, a menu will prompt you to choose which of the possible files you want to edit.
Using rosed with tab completion
This way you can easily see and optionally edit all files from a package without knowing its exact name.
$ rosed [package_name] <tab><tab>
$ rosed roscpp <tab><tab>
Empty.srv package.xml GetLoggers.srv roscpp-msg-extras.cmake Logger.msg roscpp-msg-paths.cmake SetLoggerLevel.srv roscpp.cmake genmsg_cpp.py roscppConfig-version.cmake gensrv_cpp.py roscppConfig.cmake msg_gen.py
The default editor for rosed is vim. The more beginner-friendly editor nano is included with the default Ubuntu install. You can use it by editing your ~/.bashrc file to include:
export EDITOR='nano -w'
To set the default editor to emacs you can edit your ~/.bashrc file to include:
export EDITOR='emacs -nw'
NOTE: changes in .bashrc will only take effect for new terminals. Terminals that are already open will not see the new environmental variable.
Open a new terminal and see if EDITOR is defined:
$ echo $EDITOR