假设我们正在运行的机器人中安装了laser,首先找到这个laser的topic:
$rostopic list
结果显示如下
/camera/depth/camera_info
/camera/depth/image_raw
/camera/depth/points
/camera/parameter_descriptions
/camera/parameter_updates
/camera/rgb/camera_info
/camera/rgb/image_raw
/camera/rgb/image_raw/compressed
/camera/rgb/image_raw/compressed/parameter_descriptions
/camera/rgb/image_raw/compressed/parameter_updates
/camera/rgb/image_raw/compressedDepth
/camera/rgb/image_raw/compressedDepth/parameter_descriptions
/camera/rgb/image_raw/compressedDepth/parameter_updates
/camera/rgb/image_raw/theora
/camera/rgb/image_raw/theora/parameter_descriptions
/camera/rgb/image_raw/theora/parameter_updates
/clock
/cmd_vel_mux/parameter_descriptions
/cmd_vel_mux/parameter_updates
/gazebo/link_states
/gazebo/model_states
/gazebo/parameter_descriptions
/gazebo/parameter_updates
/gazebo/set_link_state
/gazebo/set_model_state
/joint_states
/mobile_base/commands/motor_power
/mobile_base/commands/reset_odometry
/mobile_base/commands/velocity
/mobile_base/events/bumper
/mobile_base/events/cliff
/mobile_base/sensors/bumper_pointcloud
/mobile_base/sensors/core
/mobile_base/sensors/imu_data
/mobile_base_nodelet_manager/bond
/odom
/rosout
/rosout_agg
/scan
/tf
/tf_static
然后查找/scan所对应的msseage type是什么
$rostopic info /scan
结果显示
Type: sensor_msgs/LaserScan
Publishers:
* /gazebo (http://zhw:45449/)Subscribers:
* /gym_25918_1515401087711 (http://zhw:38997/)
因此,查看这个message的具体内容
$rosmsg show sensor_msgs/LaserScan
结果显示
std_msgs/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
好,下面我们查看具体的laser返回的值:
rostopic echo /scan -n1
结果显示
header:
seq: 32370
stamp:
secs: 5
nsecs: 20000000
frame_id: “sonar2_link”
angle_min: -2.3561899662
angle_max: 2.3561899662
angle_increment: 0.248019993305
time_increment: 0.0
scan_time: 0.0
range_min: 0.0599999986589
range_max: 20.0
ranges: [1.2339355945587158, 1.0650805234909058, 0.9900428056716919, 0.9810356497764587, 1.035231113433838, 1.1723015308380127, 1.455497145652771, 2.0952160358428955, 3.882453203201294, 3.763927936553955, 1.9585617780685425, 0.9657376408576965, 0.6733431816101074, 0.5433849692344666, 0.48050957918167114, 0.4558892846107483, 0.4606136977672577, 0.49619361758232117, 0.5759042501449585, 0.7397385835647583]
intensities: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
即图像的宽和高分别为640和480
假设我们正在运行的机器人中安装了camera,首先找到这个camera的topic:
$rostopic list
结果显示如下
/camera/depth/camera_info
/camera/depth/image_raw
/camera/depth/points
/camera/parameter_descriptions
/camera/parameter_updates
/camera/rgb/camera_info
/camera/rgb/image_raw
/camera/rgb/image_raw/compressed
/camera/rgb/image_raw/compressed/parameter_descriptions
/camera/rgb/image_raw/compressed/parameter_updates
/camera/rgb/image_raw/compressedDepth
/camera/rgb/image_raw/compressedDepth/parameter_descriptions
/camera/rgb/image_raw/compressedDepth/parameter_updates
/camera/rgb/image_raw/theora
/camera/rgb/image_raw/theora/parameter_descriptions
/camera/rgb/image_raw/theora/parameter_updates
/clock
/cmd_vel_mux/parameter_descriptions
/cmd_vel_mux/parameter_updates
/gazebo/link_states
/gazebo/model_states
/gazebo/parameter_descriptions
/gazebo/parameter_updates
/gazebo/set_link_state
/gazebo/set_model_state
/joint_states
/mobile_base/commands/motor_power
/mobile_base/commands/reset_odometry
/mobile_base/commands/velocity
/mobile_base/events/bumper
/mobile_base/events/cliff
/mobile_base/sensors/bumper_pointcloud
/mobile_base/sensors/core
/mobile_base/sensors/imu_data
/mobile_base_nodelet_manager/bond
/odom
/rosout
/rosout_agg
/scan
/tf
/tf_static
然后查找/camera/rgb/image_raw所对应的msseage type是什么
$rostopic info /camera/rgb/image_raw
结果显示
Type: sensor_msgs/Image
Publishers:
* /gazebo (http://zhw:45449/)
Subscribers: None
因此,查看这个message的具体内容
$rosmsg show sensor_msgs/Image
结果显示
std_msgs/Header header
uint32 seq
time stamp
string frame_id
uint32 height
uint32 width
string encoding
uint8 is_bigendian
uint32 step
uint8[] data
好,下面我们查看具体的camera返回的值
我们想看到camera的大小:
rostopic echo /camera/rgb/image_raw/width -n1
rostopic echo /camera/rgb/image_raw/height -n1
结果显示
640
480
即图像的宽和高分别为640和480
https://www.youtube.com/watch?v=q3Dn5U3cSWk