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

JointTrajectory Python interface

asked 2017-12-20 08:43:11 -0600

Fiddle gravatar image

updated 2017-12-21 06:20:28 -0600

Hi, I am trying to make my own environment that will be used for reinforcement learning training, with the help of gym-gazebo. I want to train a floating gripper to pick up an object from ground. The problem is, that I want to control the hardware interfaces through python, but the implementation seems unclear to me. In the gym-gazebo turtlebot camera implementation it seems simple(although they are using Twist from geometry msgs).

How do I use JointTrajectory in the same way? When i try to run an example code like below, i get an error message that says:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/topics.py", line 886, in publish
    raise ROSSerializationException(str(e))
rospy.exceptions.ROSSerializationException: field joint_names must be a list or tuple type. Only uint8[] can be a string

I've allowed the interface to affect only one joint, by adding allow_partial_joints_goal: true to the yaml file, because I want to move only one joint with each action and it seemed a simpler solution. Also, is there anything that is also needed for this to work? I guess at first I was thinking this could be written as:

vel_pub = rospy.Publisher('/gripper/joint_trajectory_controller/command', JointTrajectory, queue_size=5)

# rest of the code
if action == 0: #DOWN
            vel_cmd = JointTrajectory()
            vel_cmd.joint_names = "gripper_dummy_prismatic_joint"
            vel_cmd.points = JointTrajectoryPoint()
            vel_cmd.points.velocities = 0.1
            self.vel_pub.publish(vel_cmd)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-12-21 07:21:24 -0600

gvdhoorn gravatar image

updated 2017-12-21 07:25:11 -0600

rospy.exceptions.ROSSerializationException: field joint_names must be a list or tuple type.

Even if you want to create trajectories for single joints, joint_names must still be a list - it'll just contain only a single element. Same goes for all the fields in JointTrajectoryPoint: they are always lists (except time_from_start of course).

So something like the following should work:

vel_cmd.joint_names = [ "gripper_dummy_prismatic_joint" ]

# create a JTP instance and configure it
jtp = JointTrajectoryPoint()
jtp.velocities = [0.1]
# setup the rest of the pt

vel_cmd.points.append(jtp)

etc.

edit flag offensive delete link more

Comments

Thanks! That works, but now I started to wonder, if this interface is adequate, if I'd like to use continuous actions when using the RL algorithms (DDPG for example)- the implementations in the gym-gazebo are using discrete actions. Maybe this is a topic for a separate question...

Fiddle gravatar image Fiddle  ( 2017-12-21 12:20:55 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-12-20 08:43:11 -0600

Seen: 1,950 times

Last updated: Dec 21 '17