ROS Commands

From irlab
Jump to: navigation, search

This is a temporary page which is intended to store relevant things regarding communicating with both simulated robots in Player/Stage, and actual robots (once we get round to that).

Passing commands to a robot simulated in Stage

First, it is necessary to run start up roscore (just type roscore into the terminal), and then run stage with the following command.

$ roscd stage
$ ./bin/stageros world/willow-erratic.world

This should start up an instance of Stage with a default world provided by ROS. You should now be able to publish commands to the simulated robot (default name 'era') with commands such as the following. This should move the robot forwards a small distance. To move backwards, input a negative value.

$ rostopic pub /cmd_vel geometry_msgs/Twist '[1.0,0.0,0.0]' '[0.0,0.0,0.0]'

To make the robot turn, publish something like the following. Positive values turn the robot left, negative ones turn it right.

$ rostopic pub /cmd_vel geometry_msgs/Twist '[0.0,0.0,0.0]' '[0.0,0.0,1.0]'

rostopic pub publishes data to the topic cmd_vel, which controls the movement of the robot. The input that the topic is expecting is a type called geometry_msgs/Twist. The type that a topic is expecting can be found by using rostopic info TOPIC_NAME. For example, if you wanted to see what the laser data (base_scan) looks like:

$ rostopic list
/base_pose_ground_truth
/base_scan
/clock
/cmd_vel
/odom
/robot_driver
/rosout
/rosout_agg
/tf
$ rostopic info base_scan
Type: sensor_msgs/LaserScan
 
Publishers: 
 * /stageros (http://Michal-LTP-Ubuntu:54763/)
 
Subscribers: 
 * /laserlistener (http://Michal-LTP-Ubuntu:39586/)

If you wanted to get more specific details on exactly what 'sensor_msgs/LaserScan' is, then you can do the following:

$ rosmsg show sensor_msgs/LaserScan
Header header
  uint32 seq
  time stamp
  string frame_id
float32 angle_min
float32 angle_max
float32 angle_increment
float32 time_increment
float32 scan_time
float32 range_min
float32 range_max
float32[] ranges
float32[] intensities

This gives you all the data that you can get out of the LaserScan object. The float32[] ranges contains all the scans from the laser (1081 in total).

Personal tools