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

confuse about the Baxter joint trajectory program

asked 2016-06-13 03:04:16 -0500

Zero gravatar image

updated 2016-06-13 03:07:28 -0500

Hi, everyone

I currently was learning use simple Joint trajectory way to control the robot arm. The example shows in the Baxter wiki there the explain was a bit confuse for me. Here is the program:

def add_point(self, positions, time):
        point = JointTrajectoryPoint()
        point.positions = copy(positions)
        point.time_from_start = rospy.Duration(time)

this is the link of the example: Joint Trajectory Client

By the way, the example they had missing some of the code lines which was:

    print("Initializing node... ")
    rospy.init_node("rsdk_joint_trajectory_client_%s" % (limb,))
    print("Getting robot state... ")
    rs = baxter_interface.RobotEnable(CHECK_VERSION)
    print("Enabling robot... ")
    print("Running. Ctrl-c to quit")
    positions = {
        'left':  [-0.11, -0.62, -1.15, 1.32,  0.80, 1.27,  2.39],
        'right':  [0.11, -0.62,  1.15, 1.32, -0.80, 1.27, -2.39],

And my question is why in the add_point() there have to use copy(positions) and at the end of function still have to use append() to add the point into the list again?

Thank you so much!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-06-14 22:51:53 -0500

janindu gravatar image

Lets take add_point() line by line.

point = JointTrajectoryPoint()

Get a new JointTrajectroty point.

point.positions = copy(positions)

Copy the arg positions into the newly created point's positions attribute.

point.time_from_start = rospy.Duration(time)

Set time_from_start of point


Append this newly created point to the list self._goal.trajectory.points

copy(positions) is used to simply copy the lists to the new JointTrajectory point. You can't append() positions directly to self._goal.trajectory.points. You can only append() points.

Hope it's clear!

edit flag offensive delete link more


Hi Janindu, Frist of all, thank you for your replying. After your explain it really help me to understand how to use the copy() and append(), but in the end, you mention that I can only append() points, that points which one are you refer to? Are you referring to the point.positions ? Thanks

Zero gravatar image Zero  ( 2016-06-14 23:46:37 -0500 )edit

So, self._goal.trajectory.points is simply a list of JointTrajectory points. ie : self._goal.trajectory.points = [p1, p2, p3] where p1, p2, p3 are of type JointTrajectory.

continued in the next comment.

janindu gravatar image janindu  ( 2016-06-15 00:15:38 -0500 )edit

... Each p ( point) looks like this :

float64[] positions
float64[] velocities
float64[] accelerations
float64[] effort
duration time_from_start

Now using copy() you copy the positions passed as arguments to the point.


janindu gravatar image janindu  ( 2016-06-15 00:17:24 -0500 )edit

... positions look like this:

positions = {
        'left':  [-0.11, -0.62, -1.15, 1.32,  0.80, 1.27,  2.39],
        'right':  [0.11, -0.62,  1.15, 1.32, -0.80, 1.27, -2.39],

You can't append positions to self._goal.trajectory.points when that list expects point


janindu gravatar image janindu  ( 2016-06-15 00:18:45 -0500 )edit

... You can only append point to self._goal.trajectory.points, which is what's being done by append().

Hope it's clear!

janindu gravatar image janindu  ( 2016-06-15 00:19:32 -0500 )edit

Wow! yes!i get that! Thank you so much! Your explain is really useful for me.

Zero gravatar image Zero  ( 2016-06-15 00:49:29 -0500 )edit

Question Tools

1 follower


Asked: 2016-06-13 03:04:16 -0500

Seen: 313 times

Last updated: Jun 14 '16