Hi,
Thanks for posting your code. The architecture is very pleasing to a controls engineer. I like control loops and filters as classes.
Can you expand a little on your use of negitive inertia. I assume this is equivalent to adding derivatives of the control input to improve performance, but I would like to hear more about your use. Any papers to refererence?
Also, I think you can use much simpler functions to fit your Victors. One linearizer that involves a single parameter to adjust is:
vic_cmd = min_cmd/(1 - (1-min_cmd)*input_cmd)
where min_cmd = the minimum command to keep the motor moving, i.e. equivalent to the torque required to overcome dynamic friction.
All commands are normalized [-1,1]. One can play with min_cmd to get a very good fit. The equation is valid for input_cmd>0. You have to change a few signs for input_cmd<0 and the min_cmd can be different for each sign.
This equation follows directly from the steady state current model of the h_bridge with a low frequency pwm. The current model is summarized in this
older post. I will write a blog post on this later.
Attached is a curve fit of some old data I had on a victor. Maybe Joe Ross sent it to me and it could be an 883 or 884. The inverse is obtained by taking the victor speed and running it through the inverse function above.