ros源码分析(6)—roslaunch Commandline Tools

roslaunch

roslaunch is an important tool that manages the start and stop of ROS nodes. It takes one or more .launch files as arguments.

Launch syntax

Most roslaunch command require the name of a launch file. You can either specify the file path of the launch file, or you can specify a package name and launch file in that package, e.g.

$ roslaunch roslaunch example.launch

or

$ roscd roslaunch
$ roslaunch example.launch

具体的命令的使用方法如下,

执行package-name包下的launch文件

roslaunch <package-name> <launch-filename> [args]

    #Launch <launch-filename> located in <package-name>

    #e.g.:
    $ roslaunch rospy_tutorials talker_listener.launch

    roslaunch will find a file with the matching name inside the specified package and 
    run it.

执行绝对或者相对路径下的launch文件,

roslaunch <launch-file-paths...> [args]

    #Launch the file(s) specified by relative or absolute paths,
    #e.g.
    roslaunch pr2_robot/pr2_bringup/pr2.launch

从标准输入中读取roslaunch xml,

roslaunch - [args]

    #Launch the roslaunch XML passed as standard input,
    #e.g.
    $ rosrun package generate_launch | roslaunch -

指定运行的端口号,

-p port

    #If you launched roscore on a different port using the -p option, you need to pass 
    in the -p flag to roslaunch as well,
    #e.g.
    $ roslaunch -p 1234 package filename.launch 
    # This will dynamically override the port setting in your ROS_MASTER_URI.

等roscore启动后才进行本次launch,

--wait

    #Delay the launch until a roscore is detected.

只launch本机的node,

--local

    #Launch of the local nodes only. Nodes on remote machines will not be run.

一些debug选项,

--screen

    #Force all node output to screen. Useful for node debugging.
-v

    #Enable verbose printing. Useful for tracing roslaunch file parsing.

--dump-params

    #Print parameters in launch file in YAML format.

Passing in args

If the file you are launching specifies args(关于launch 文件的格式规定后续有介绍) that require setting, you can do so using an identical syntax to ROS remapping arguments, e.g.:

roslaunch my_file.launch arg:=value

Non-launch options

The following options provide information about a launch file without actually doing a launch. These options use the same launch-file resolution as the regular roslaunch command. You can either specify the file path of the launch file, or you can specify a package name and launch file in that package, e.g. for the example.launch file in the roslaunch package, you can use:

roslaunch --nodes roslaunch $ROS_ROOT/tools/roslaunch/example.launch

or

roslaunch --nodes roslaunch example.launch

下面是这些non-launch选项的介绍,

列出launch 文件中的node,

--nodes <package-name> <launch-file>
--nodes <launch-file>

    #List nodes by 'name' that are in <launch-file>. This is useful for figuring out the 
    node name to pass to --args.

获取某个node launch时的参数,

--args <node-name> <package-name> <launch-file>
--args <node-name> <launch-file>

    #Display the command-line arguments that roslaunch uses when launching the node in 
    <launch-file> named <node-name>. This is handy if you just want to launch that 
    particular node for debugging, e.g. 

    $ roslaunch --args my_node file.launch | bash

    #You can also use this option with substitution args (for bash, you have to be 
    careful to use single-quotes instead of double-quotes):

    $ roslaunch --args '$(anon my_node)' file.launch

找到node所处的launch文件,

--find <node-name> <package-name> <launch-file> 
--find <node-name> <launch-file>

    #Print name of launch file that the node named <node-name> is defined in. Launch 
    files often have many includes, which can make it difficult to find where an actual 
     <node> definition resides. For example: 

    $ roslaunch --find /included/talker roslaunch example.launch
--files <filename>

    #Print all files included in processing <filename>, including the file itself. This 
    is useful for passing to other command line tools, e.g.

    $ roslaunch --files foo.launch | xargs grep stuff

打印出launch中需要的参数,必须参数或者可选参数,

--ros-args

    #Display command-line arguments for this launch file

    <launch>
  <!-- ros_args.launch -->
  <arg name="foo" default="true" doc="I pity the foo'."/>
  <arg name="bar" doc="Someone walks into this."/>
  <arg name="baz" default="false"/>
  <arg name="nop"/>
  <arg name="fix" value="true"/>
    </launch>

    $> roslaunch --ros-args ros_args.launch
    Required Arguments:
      bar: Someone walks into this.
      nop: undocumented
    Optional Arguments:
      baz (default "false"): undocumented
      foo (default "true"): I pity the foo'.

Internal-use only options

roslaunch uses several command-line options that are for internal use only, including -c, -u, and –core.
例如启动roscore时的参数就是–core。

Environment Variables (advanced users)

NOTE: this section is intended for advanced users only

ROSLAUNCH_SSH_UNKNOWN
When launching on remote machines, SSH requires that the remote machine’s key be stored in the local known_hosts file. You can set roslaunch to ignore this constraint and allow connections to machines for which you don’t have keys established. This is a dangerous option as it introduces a security hole and should only be used if you understand the consequences.

roslaunch-deps

roslaunch-deps reports which ROS Packages a .launch file depends on. It can also track down command build problems, such as missing dependencies in package manifests or syntax errors.

(NOT recommended if you’re using newer ROS than Groovy) With old rosmake command, one command you may wish to run is to build all the packages necessary for a launch file:

rosmake `roslaunch-deps file.launch`

To get warnings about dependencies missing in manifest files, run with the -w warn option:

$ roslaunch-deps -w file.launch

To get more verbose output to help track where a dependency is coming from, run with the -v verbose option:

$ roslaunch-deps -v file.launch

roslaunch-logs

Roslaunch stores log files for a particular run together in a subdirectory of the ROS log directory ( ROSROOT/logor ROS_LOG_DIR). In general, logs files are stored in ROS_LOG_DIR/run_id, where run_id is a unique ID associated with a particular run of a roscore.

roslaunch-logs is meant to be used together with the ‘cd’ command, e.g.

cd `roslaunch-logs`

You can type this command to quickly go to the directory with the log files for your nodes.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值