How to use pos_vel_controllers/JointTrajectoryController?

asked 2021-10-29 16:05:51 -0600

xman236 gravatar image

updated 2021-10-29 16:06:28 -0600

Hi, I am trying to use pos_vel_controllers/JointTrajectoryController For example one can get the velocity and position command as output by using hardware_interface::PosVelJointHandle pos_vel_handle_jnt0(state_handle_jnt0, &pos_command[0], &vel_command[0])

However, when I apply/write the vel_command to my robot, one can see that the discrepancy between desired and actual velocity values goes to zero.
Comparison between desired and actual velocity of joint 1,2,3 Comparison between desired and actual velocity of joint 1,2,3

At the same time, one can see that the position is actually not tracked (which is reasonable since I just applied the vel_command to the robot). Of course, I can estimate the position difference and apply/write it to the robot, then the velocity tracking will be wrong, right? I have the feeling that I am not using pos_vel_controllers/JointTrajectoryController properly, as it is designed for... Can anyone guide me here?

Comparison between desired and actual position of joint 1,2,3 Comparison between desired and actual position of joint 1,2,3

edit retag flag offensive close merge delete

Comments

Quick comment: afaik, the pos_vel interfaces are expected to allow control over a robot / mechanism which can take a position and a velocity and drive the state of the system-under-control to that combination (ie: at position x, the velocity of the joint should be v).

This in contrast to control systems which only take a position or a velocity.

If your actuators / underlying control system does not take position and velocity, then the pos_vel_controllers/JointTrajectoryController is not what you should be using (and your hw iface should not be exposing the interface).

gvdhoorn gravatar image gvdhoorn  ( 2021-10-30 07:07:15 -0600 )edit

Assuming my robot can take position and velocity, the error in velocity shouldn't be 0, so that the robot can have some „free space“ to minimize the position error. Otherwise, how to minimize the position error? Any attempt here would lead to some motion and the discrepancy in velocity would increase (whereas the positon error might decrease...) How should these outputs of pos_vel_controllers/JointTrajectoryController be used... By any chance, do you have a working code example of this controller?

xman236 gravatar image xman236  ( 2021-10-30 08:25:00 -0600 )edit

Assuming my robot can take position and velocity, the error in velocity shouldn't be 0, so that the robot can have some „free space“ to minimize the position error

I'm not sure, but I don't believe that's necessarily true.

Provided the sampling frequency of the JTC is high enough, and the input trajectory smooth enough (ie: has been generated taking the constraints and requirements of the target electro-mechanical system into account (ie: your dynamics of your robot/actuation)) the JTC should be able to provide references for the underlying actuators / controllers which they should be able to accurately follow.

The output of the JTC is the desired system state at a specific point in time. That's what the underlying actuators/controllers should take in and work towards. If in your case there needs to be "some free space", it might be the input trajectory wasn ...(more)

gvdhoorn gravatar image gvdhoorn  ( 2021-10-31 06:39:29 -0600 )edit