Ask Your Question
0

how to rostopic pub msg with array members

asked 2017-08-28 01:16:31 -0600

peigong gravatar image

When i want to publish msg like this:

Header header
  uint32 seq
  time stamp
  string frame_id
Point point
  float64 x
  float64 y
  float64 z

i can use the following cmd:

rostopic pub pt geometry_msgs/PointStamped '{stamp: now, frame_id: base_link}' '[1.0, 2.0, 3.0]'

or rostopic pub pt geometry_msgs/PointStamped '{stamp: now, frame_id: base_link}' '[1.0, 2.0, 3.0]'

what command should i use to publish msgs with array members like:

std_msgs/Header header
string[] joint_names
trajectory_msgs/MultiDOFJointTrajectoryPoint[] points 
       geometry_msgs/Transform[] transforms
       geometry_msgs/Twist[] velocities
       geometry_msgs/Twist[] accelerations
       duration time_from_start
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-08-28 02:22:06 -0600

rbbg gravatar image

You can do it just as you filled the Point. For instance, if you want to fill the joint_names of a MultiDofJointTrajectory:

rostopic pub mdjt trajectory_msgs/MultiDOFJointTrajectory  '{joint_names:[name1, name2]}'

have a look at this answer. It is a bit clunky (especially when the vectors you are trying to fill aren't simple types), so it's probably useful to play around a bit in a text editor. For a slightly more intricate example:

rostopic pub mdjt trajectory_msgs/MultiDOFJointTrajectory  '{joint_names:[name1, name2, name3], points:[{time_from_start: {secs: 1, nsecs: 100}}, {time_from_start: {secs: 100, nsecs: 300}}]}'

Good luck.

edit flag offensive delete link more

Comments

Thank you for your kind reply.

it works.

peigong gravatar imagepeigong ( 2017-08-28 04:00:12 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

3 followers

Stats

Asked: 2017-08-28 01:16:31 -0600

Seen: 1,726 times

Last updated: Aug 28 '17