Send a JointTrajectory with a different subset of joints for each JointTrajectoryPoint.

asked 2019-04-11 09:40:47 -0500

Isha Dijcks gravatar image

updated 2019-04-12 07:59:29 -0500

I am currently using the Joint Trajectory Controller and I am quite happy with its performance so far.

The problem arises when I want to actuate 2 joints, but not at exactly the same time. I'll demonstrate with an example:

We have Joint1, which must be at position 0 at time 1, and at position 2 at time 3.

We have Joint2, which must be at position 1 at time 2, and at position 3 at time 4.

Currently I would have to construct the following TrajectoryMsg:

joint_names:
- 'joint1'
- 'joint2'
points:
- positions: [0, *0*]
  time_from_start: {secs: 1, nsecs: 0} 
- positions: [*1*, 1]
  time_from_start: {secs: 2, nsecs: 0} 
- positions: [2, *2*]
  time_from_start: {secs: 3, nsecs: 0} 
- positions: [*2*, 3]
  time_from_start: {secs: 4, nsecs: 0}

Values surrounded by * are values I had rather not have to supply to the Trajectory because I don't care where that joint is at that moment. I only had to add the waypoint because the other joint needed a fixed position.

Is it possible to create a TrajectoryMsg that looks more like the following?

joint_names:
- 'joint1'
- 'joint2'
points:
- joints: ["joint1"]
  positions: [0]
  time_from_start: {secs: 1, nsecs: 0} 
- joints: ["joint2"]
  positions: [1]
  time_from_start: {secs: 2, nsecs: 0} 
- joints: ["joint1"]
  positions: [2]
  time_from_start: {secs: 3, nsecs: 0} 
- joints: ["joint2"]
  positions: [3]
  time_from_start: {secs: 3, nsecs: 0}

I hope I have made my problem clear!

Is there a workaround for this problem or am I missing something that would make creating trajectories easier?

Thanks in advance!

edit retag flag offensive close merge delete

Comments

So joint_trajectory_controller supports goals which target subsets of joints (see here), but I'm not sure that is what you actually want.

gvdhoorn gravatar image gvdhoorn  ( 2019-04-11 11:06:59 -0500 )edit

I don't think that would work with interleaving position instructions as described above. It would require multiple commands to the controller which would mess up the interpolation.

Isha Dijcks gravatar image Isha Dijcks  ( 2019-04-11 11:14:06 -0500 )edit

That's why I wrote that I didn't think it was what you were looking for.

Perhaps a title change would be good, as the JTC can definitely accept goals for "subsets of joints". You are looking for some very specific behaviour.

gvdhoorn gravatar image gvdhoorn  ( 2019-04-11 11:21:39 -0500 )edit

Done. I'd be surprised if I was the first person to want this behavior. I could not find any discussion on it before though.

Isha Dijcks gravatar image Isha Dijcks  ( 2019-04-11 12:08:23 -0500 )edit

thanks for the title fix, this is much clearer.

Send a JointTrajectory with a different subset of joints for each JointTrajectoryPoint.

I don't believe this is supported, at least not with JointTrajectory.

Regardless of whether any component could support it, the JointTrajectory message cannot be used to encode what you are asking for, as the joint_names field is at the level of the trajectory, not individual JointTrajectoryPoints.

I guess an accepted approach would be to use two different trajectory controllers, one for each subset of joints, and pass each an appropriate trajectory (ie: one that includes the joints the controller controls).

gvdhoorn gravatar image gvdhoorn  ( 2019-04-11 15:46:22 -0500 )edit

In this case I would have to use a TrajectoryController for each individual joint. Are there any known disadvantages to this approach I should take into consideration?

Isha Dijcks gravatar image Isha Dijcks  ( 2019-04-12 04:55:45 -0500 )edit

I'm not sure I fully understand what your constraint is: if you "dont't care" where the joints are that you don't want to actuate (which to me means that they won't move during this trajectory), you could just send a goal with a trajectory for a subset of your joints. The JTC will keep the ones not present in the trajectory at their current position.

Perhaps you can describe what it is that you're actually trying to achieve, instead of asking questions about a solution that you've already come up with for a problem we don't know (xy-problem).

gvdhoorn gravatar image gvdhoorn  ( 2019-04-12 07:49:51 -0500 )edit

They do need to move, but their trajectory should not be altered because another joint must be at a position at that point.

The X problem is to create an interface where a user can easily create and visualize trajectories for joints. Initially I figured it would be best to set a position for each joint at a specific setpoint, but that created the problem I've tried to describe above.

I'm considering using individual controllers and don't synchronize the timestamps for positions between joints.

I hope that made it more clear.

Isha Dijcks gravatar image Isha Dijcks  ( 2019-04-12 08:04:29 -0500 )edit