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

rosbridge: populating trajectory_msgs/JointTrajectoryPoint fields in JSON

asked 2018-09-06 10:15:47 -0500

bastiann gravatar image

updated 2018-09-06 14:34:34 -0500

gvdhoorn gravatar image

How do I publish correctly to the trajectory_msgs/JointTrajectoryPoint through rosbridge?

I guess I am doing something wrong in creating the trajectory_msgs/JointTrajectoryPoint Message. Here the python code for creating the message:

import json

topic = "goal"

data = {
  "op":"publish",
  "topic":topic,
"goal":{
    "trajectory":{
        "header":{
            "seq":(0),
            "stamp":(),
                "secs":(0),
                "nsecs":(0),
                "frame_id":("")
                },
        "joint_names":[
          "shoulder_pan_joint",
          "shoulder_lift_joint",
          "elbow_joint",
          "wrist_1_joint",
          "wrist_2_joint",
          "wrist_3_joint"
            ],
        "points":{
            "positions:":[0.293,-0.514,0.125,0.2647,1.8632,-1.5809],
            "velocities":[0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            #"positions:":[0.2,-0.5,0.0,0.1,1.9,-1.7],
            #"velocities":[0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
            }
}
}
}
print(data)

R = json.dumps(data)

It arrives in the topic though the fields joint_names and points stay empty.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-09-06 14:38:48 -0500

gvdhoorn gravatar image

updated 2018-09-07 07:35:15 -0500

I believe the issue is that points in your case created as a map, instead of a list. It is a list.

See the documentation for JointTrajectory here:

trajectory_msgs/JointTrajectoryPoint[] points

So in YAML, I would expect this to look something like this:

points : [
  {
     positions : [..],
     velocities : [..],
     accelerations : [..],
     effort : [..],
     time_from_start : ...
  },
  {
     positions : [..],
     velocities : [..],
     accelerations : [..],
     effort : [..],
     time_from_start : ...
  },
  ...
]
edit flag offensive delete link more

Comments

Did this work?

gvdhoorn gravatar image gvdhoorn  ( 2018-09-12 08:19:53 -0500 )edit

Question Tools

Stats

Asked: 2018-09-06 10:15:47 -0500

Seen: 666 times

Last updated: Sep 07 '18