How to retrieve the desired.velocities from JointTrajectoryController
I am trying to connect my robot with actuators. I am using MoveIt and ros_control. My controller is of type position_controllers/JointTrajectoryController. My actuators need velocities. If I check the "/joint_controller/state" topic I can see 3 different types of values: desired, actual and error.
When I issue a trajectory, the desired joint values for position, velocity and acceleration are automatically computed. So from this I assumed that I could simply use these computed desired velocities to command my actuators. So I implemented my own hardware interface with a JointStateInterface, PositionJointInterface and VelocityJointInterface.
In the read/write loop of the hardware interface I see that if I change the position array registered with the JointStateInterface the "actual.positions" value in the "/joint_controller/state" topic changes accordingly, so that works well.
If I read the position_cmd array registered with the PositionJointInterface I see that it corresponds to the "desired.positions" value in the "/joint_controller/state" topic, so that also works as I expected.
But when I read the velocity_cmd array registered with the VelocityJointInterface, all the values are always 0. I thought I could read the "desired.velocities" value from this interface but it seems I was wrong. I guess it has something to do with how I am using position_controllers, but then where are these "desired.velocities" coming from? How are they being calculated and how can I make use of them within my hardware interface? I know I could simply subscribe to the "/joint_controller/state" topic and access the "desired.velocities" value from there but that doesn't feel like the right way of doing this.