Adapt to varying external forces

I was wondering if it would be possible to adapt the closed loop positioning to varying loads and external forces. For example if you go up or down with a heavy load you’re going to require different accelerations since gravity is acting with or against the movement. How would one go about setting up an odrive system for this if it’s even possible?

My guess is that you could change the gains in the controller config for every time you change directions. Is there any better way of doing this, or is it even possible? I have never seen any implementation where the load is unbalanced like this.

What you want to do is send the ODrive a “feasible trajectory”. You can use the same gains, as long as you know what is feasible. For instance, you could have a Python script that knows how much torque your motor can apply, pulley radius, the mass of the object you want to accelerate, and it can calculate the maximum acceleration. So you send a sequence of pos_setpoint values that accelerates slower than that.

You can do the latter half of this by requesting trapezoidal moves via <odrv>.<axis>.controller.plan_trapezoidal() and configuring appropriate values in <odrv>.<axis>.trap_traj.config

When I was at university they taught us to calculate the forces you are aware of (such as gravity), convert them to torque at your motor, and feed these into your motor controller. The controller has no other way of knowing which loads to expect. This happens in parallel to the position control.

In theory you request a trapezoidal trajectory from the ODrive, and then simultaneously calculate the expected load torque at each moment in time and feed this into the current controller. I have no idea if that works with the current firmware.

Its hard to find a good explanation online. Can somebody help me out? This is the best I could find online - https://studywolf.wordpress.com/2013/09/07/robot-control-3-accounting-for-mass-and-gravity/

It’s really easy if you only have one motor, but if your system consists of multiple joints, then you need to use spacial math and Jacobians which have steep learning curves.