Obtain current from position PID control

I am trying to add gravity compensation to a 7 DOF robotic arm that has XM-W350 motors. The arm is currently controlled in position control mode. I’d like to add the values from my gravity compensation to the PID controller output; however, gravity compensation is done in terms of current(torque). Is there a way I can get the current/PWM values that are really being sent to the motor even during position control (conversion from position to current/PWM under the hood to drive the motor)?

I’m guessing this corresponds to step 4 in the diagram below from the datasheet.

Screenshot 2024-01-15 at 12.50.37 PM

The Present Current and Present PWM registers contain the values you’re looking for.

Present PWM in specific is the value generated at step four in the diagram you linked, and as such will give you the most accurate information on the final output.

Thanks for the quick response!

One more question, is pwm the output of the PID controller. For example, in position mode, is
kp*(goal_pos - current_pos)? Or is there something else happening internally?

The Present PWM is the final output of the PID controller in all operating modes, as such it’s an accurate report of the actual PWM values being supplied to the motor.

Perfect. Thank you so much Jonathon. Last question, is the present pwm accessible through the interbotix python API? Or is there documentation about the API where I can find this information? I’m easily able to access the joint_positions, velocities, etc… but can’t see where the pwm registers are exposed.

I’m not super familiar with the interbotix API, as that library is developed and maintained by Trossen Robotics. I’d recommend taking a look at their online documentation or reaching out to them directly for that information.