ROS基础——命令

Filesystem Command-line Tools

命令作用
rospack/rosstackA tool inspecting packages/stacks.
roscdChanges directories to a package or stack.
roslsLists package or stack information.
roscreate-pkgCreates a new ROS package.
roscreate-stackCreates a new ROS stack.
rosdepInstalls ROS package system dependen-cies.
rosmakeBuilds a ROS package.
roswtfDisplays a errors and warnings about a running ROS system or launch le.
rxdepsDisplays package structure and depen-dencies.

Usage:

  • rospack find [package]
  • roscd [package[/subdir]]
  • rosls [package[/subdir]]
  • roscreate-pkg [package name]
  • rosmake [package]
  • rosdep install [package]
  • roswtf or roswtf [file]
  • rxdeps [options]

Common Command-line Tools

roscore

A collection of nodes and programs that are pre-requisites of a ROS-based system. You must have a roscore running in order for ROS nodes to communicate.

roscore is currently defi ned as:

  • master
  • parameter server
  • rosout

Usage:

  • roscore

rosmsg/rossrv

rosmsg/rossrv displays Message/Service (msg/srv) data structure defi nitions.

命令作用
rosmsg showDisplay the fields in the msg.
rosmsg usersSearch for code using the msg.
rosmsg md5Display the msg md5 sum.
rosmsg packageList all the messages in a package.
rosnode packagesList all the packages with messages.

Examples:

# Display the Pose msg
rosmsg show Pose

# List the messages in nav_msgs
rosmsg package nav_msgs

# List the files using sensor_msgs/CameraInfo
rosmsg users sensor_msgs/CameraInfo

rosrun

rosrun allows you to run an executable in an arbitrary package without having to cd (or roscd) there fi rst.

Usage:

rosrun package executable

Example:

# Run turtlesim
rosrun turtlesim turtlesim_node

rosnode

Displays debugging information about ROS nodes, including publications, subscriptions and connections.

命令作用
rosnode pingTest connectivity to node.
rosnode listList active nodes.
rosnode infoPrint information about a node.
rosnode machineList nodes running on a particular machine.
rosnode killKills a running node.

Examples:

# Kill all nodes
rosnode kill -a
# List nodes on a machine
rosnode machine aqy.local
# Ping all nodes
rosnode ping --all

roslaunch

Starts ROS nodes locally and remotely via SSH, as well as setting parameters on the parameter server.

Examples:

# Launch on a different port
roslaunch -p 1234 package filename.launch
# Launch a file in a package
roslaunch package filename.launch
# Launch on the local nodes
roslaunch --local package filename.launch

rostopic

A tool for displaying debug information about ROS topics, including publishers, subscribers, publishing rate, and messages.

命令作用
rostopic bwDisplay bandwidth used by topic.
rostopic echoPrint messages to screen.
rostopic hzDisplay publishing rate of topic.
rostopic listPrint information about active topics.
rostopic pubPublish data to topic.
rostopic typePrint topic type.
rostopic findFind topics by type.

Examples:

# Publish hello at 10 Hz
rostopic pub -r 10 /topic_name std msgs/String hello
# Clear the screen after each message is published
rostopic echo -c /topic_name
# Display messages that match a given Python expression
rostopic echo --filter "m.data=='foo'" /topic_name
# Pipe the output of rostopic to rosmsg to view the msg type
rostopic type /topic_name | rosmsg show

rosparam

A tool for getting and setting ROS parameters on the parameter server using YAML-encoded files.

命令作用
rosparam setSet a parameter.
rosparam getGet a parameter.
rosparam loadLoad parameters from a fi le.
rosparam dumpDump parameters to a fi le.
rosparam deleteDelete a parameter.
rosparam listList parameter names.

Examples:

# List all the parameters in a namespace
rosparam list /namespace
# Setting a list with one as a string, integer, and float
rosparam set /foo "['1', 1, 1.0]"
# Dump only the parameters in a specific namespace to file
rosparam dump dump.yaml /namespace

rosservice

A tool for listing and querying ROS services.

命令作用
rosservice listPrint information about active services.
rosservice nodePrint the name of the node providing a service.
rosservice callCall the service with the given args.
rosservice argsList the arguments of a service.
rosservice typePrint the service type.
rosservice uriPrint the service ROSRPC uri.
rosservice findFind services by service type.

Examples:

# Call a service from the command-line
rosservice call /add_two_ints 1 2
# Pipe the output of rosservice to rossrv to view the srv type
rosservice type add_two_ints | rossrv show
# Display all services of a particular type
rosservice find rospy_tutorials/AddTwoInts

Logging Command-line Tools

rosbag

This is a set of tools for recording from and playing back to ROS topics. It is intended to be high performance and avoids deserialization and reserializationof the messages.

rosbag record will generate a “.bag” fi le (so named for historical reasons) with the contents of all topics that you pass to it.

Examples:

# Record all topics
rosbag record -a
# Record select topics
rosbag record topic1 topic2

rosbag play will take the contents of one or more bag file, and play them back in a time-synchronized fashion.

Examples:

# Replay all messages without waiting
rosbag play -a demo log.bag
# Replay several bag files at once
rosbag play demo1.bag demo2.bag

tf Command-line Tools

tf echo

A tool that prints the information about a particular transformation between a source frame and a target frame.

Usage:

rosrun tf tf echo <source_frame> <target_frame>

Examples:

# To echo the transform between /map and /odom:
rosrun tf tf echo /map /odom

view frames

A tool for visualizing the full tree of coordinate transforms.

Usage:

rosrun tf view_frames
evince frames.pdf

版权声明:本文为Kalenee原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。