ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

how to publish a complex msg via launch file?

asked 2017-07-08 22:52:37 -0500

ZhuZulun gravatar image

updated 2017-07-09 02:29:04 -0500

NEngelhard gravatar image

I set a msg named NavigationPoint and its definition is that:

std_msgs/Header header
geometry_msgs/Pose pose
time arrival_time
int32 formation
int32[] parameters.

And now I want to publish the msg via launch file like that :

 <node pkg="rostopic" type="rostopic" name="rostopic" args="   pub /robot_0/move_base_simple/goal decide_softbus_msgs/NavigationPoint
  0
 {0,0}
 'map'
 {50.0, 50.0, 0.0}
 {0.0, 0.0, 0.0, 1.0}
 {0, 0}
  0
 [0]"
  output="screen">
  </node>

But I think the format is not correct .If anyone know the true format I'll always appreciate that!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2017-07-09 08:10:51 -0500

lucasw gravatar image

updated 2017-07-09 08:21:10 -0500

Try typing

rostopic pub /foo decide_softbus_msgs/NavigationPoint

on the command line and then pressing tab for an example.

Here is an example CameraInfo:

$ rosmsg show CameraInfo
[sensor_msgs/CameraInfo]:
std_msgs/Header header
  uint32 seq
  time stamp
  string frame_id
uint32 height
uint32 width
string distortion_model
float64[] D
float64[9] K
float64[9] R
float64[12] P
uint32 binning_x
uint32 binning_y
sensor_msgs/RegionOfInterest roi
  uint32 x_offset
  uint32 y_offset
  uint32 height
  uint32 width
  bool do_rectify

Then see what tab complete does:

$ rostopic pub /foo sensor_msgs/CameraInfo "header:
  seq: 0
  stamp: {secs: 0, nsecs: 0}
  frame_id: ''
height: 0
width: 0
distortion_model: ''
D: [0]
K: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
R: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
P: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
binning_x: 0
binning_y: 0
roi: {x_offset: 0, y_offset: 0, height: 0, width: 0, do_rectify: false}"

I don't like the spaces & newline delimiting, I'd rather use the comma + angle bracket format:

<node name="camera_info" pkg="rostopic" type="rostopic"
  args="pub camera_info sensor_msgs/CameraInfo
 '{header: {seq: 0, stamp: {secs: 0, nsecs: 0}, frame_id: 'camera1'},
  height: 480, width: 640, distortion_model: 'plumb_bob',
  D: [0],
  K: [500.0, 0.0, 320, 0.0, 500.0, 240.0, 0.0, 0.0, 1.0],
  R: [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0],
  P: [500.0, 0.0, 320, 0.0, 0.0, 500, 240, 0.0, 0.0, 0.0, 1.0, 0.0],
  binning_x: 0, binning_y: 0,
  roi: {x_offset: 0, y_offset: 0, height: 480, width: 640, do_rectify: false}}' -r 2"/>

( https://github.com/lucasw/rviz_camera... )

I also had to replace double quotes with single quotes- but escaping the double quotes is possible #q12812.

(It looks like the tab-complete format uses angle brackets for compound messages within messages, so one approach to generating that would be to make a custom message that contains the desired message as a field and then tab-completing that, though that is a lot of work.)

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2017-07-08 22:52:37 -0500

Seen: 3,035 times

Last updated: Jul 09 '17