KodlabPenn / kodlab_mjbots_sdk

Repo for kodlab SDK for use with mjbots ecosystem
Other
8 stars 7 forks source link

Add the ability to send pd setpoints and pd scale #71

Closed ShaneRozenLevy closed 2 years ago

ShaneRozenLevy commented 2 years ago

We have wanted the ability to use the moteus's internal pd loop for a long time. This PR should enable us to send PD setpoints and to use the kp and kd scale to control the moteus.

One gotcha with the way moteus does its internal pd loop is that you can't set the gains over CAN, you can only set the scale of the gain (0-1), which means that the configuration of the moteus becomes more important.

Todo

ShaneRozenLevy commented 2 years ago

@ethanmusser @jdcaporale

So currently the robot base contains a vector of JointsBase. I'm wondering how y'all would feel about making the RobotBase templated for the type of joint? The setting of pd gains and target is done is a fairly moteus specific manner which I feel requires access to the JointMoteus

Thoughts?

ShaneRozenLevy commented 2 years ago

I guess the other option would be specify a standard interface for setting pd information where the joint base would have the following functions:

set_kp
set_kd
set_position_target
set_velocity_target

set position target and set velocity target are easy. The set_kp and set_kd will be somewhat problematic to implement since the moteus would still require access to the kp and kd scales rather than the gains. To calculate the scales the user would need to set the internal pd gains for the moteus in their c++ code. Thoughts?

ShaneRozenLevy commented 2 years ago

Got everything working. I don't think we add an example for this since it relies on configuring the moteus in a non standard fashion.