What does jointVelocity[] return?

Hello everyone,

I have some doubts about using joinVelocity[ ] (Unity - Scripting API: ArticulationBody.jointVelocity) as I’m getting some strange values.

I’m using the position Control as in the documentation (Unity-Robotics-Hub/tutorials/urdf_importer/urdf_appendix.md at main · Unity-Technologies/Unity-Robotics-Hub · GitHub). I calculate a DeltaStep to reach a target in a given time:

distance = targetPos - currentPos;
vel = distance/time_sec;
deltaStep = vel * Time.fixedDeltaTime;

Then, in a FixedUpdate(), I use this deltaStep to update the joint target and so reach the final one. I also get the joint position and velocity:

ArticulationDrive joint_xDrive = joint.xDrive;
joint_xDrive.target += deltaStep;
joint.xDrive = joint_xDrive;

posMsg.data = joint.jointPosition[0];
velMsg.data = joint.jointVelocity[0];

When I use it in a revolute joint I set the deltaStep as degrees, and joint.jointPosition[0] returns the current position in radians. But what is joint.jointVelocity[0] returning? For example when trying to get 1.0 radians from the origin at 2.5 seconds, it means a distance of approximately 57.30 deg, and a velocity of 22.92 deg/sec (0.4 rad/sec). With a fixedDeltaTime of 0.02 sec the value of deltaStep will be 0.4584 deg (0.00799 rad). In this case joint.jointVelocity[0] returns a value similar to 0.0091 (what is also similar to my deltaStep in radians). Is it maybe the applied deltaStep in radians?

But in case of using a Prismatic joint the returned value by joint.jointVelocity[0] is more confusing. I set a deltaStep in meters and joint.jointPosition[0] returns the current position in meters too. But if for example I try to get to 0.015 meters from the origin in 2.5 sec, this means a distance of 0.015m and a velocity of 0.006 m/s. With a fixedDeltaTime of 0.02 I will have a deltaStep of 0.00012 m. In this case when using joint.jointVelocity[0] I get a value of 0.0012, so the order of magnitude is different from my deltaStep. In this case, Is it returning an applied deltaStep in decimeters?

I hope I explained it well. The version of ROS TCP Connector and URDF Importer that I’m using is 0.4.0 as I started the project with these ones.

Thank you.

I might need to repro your scene locally, but all of our reduced coordinate space getters/setters work on the data provided by PhysX directly – that is angles are in rad, distances are in meters, and the velocities are direct time derivatives of those.

Additionally, I wanted to point out that currently we have an asymmetry in the API:

  • ArticulationBody’s angular drive parameters are always in degrees (e.g. target & targetVelocity)
  • When in reduced space, we use the raw values from the physics engine – so angles come out as radians.

Could this be the source of the problem you’re observing?

Thank you for your answers @yant . Yes I realized about that asymmetry you mentioned, that’s why I wanted to confirm what it is returning. So for a revolute joint it should return rad/s and for a prismatic joint it uses m/s right?
Then I’m still having an error somewhere cause as I said in my example when I try to reach 0.4 rad/s (using a deltaStep of 0.4584 deg and a FixedDeltaTime of 0.02), it returns something like 0.0091 .