# Motors for cushioning

In this comment @Torrance mentions using motors as a spring but as he is not a software person did not explain how this was done.

Also if using a motor, you can do fancy software to make the motor act like a spring and not be in an ultra-hold-position mode. I’m no software person, so perhaps others can share their implementation. You’ll

Limelight, an integrated vision coprocessor
see it when we release our 2023 code this Fall for our Laterator and Floor intake linear degrees of freedom.

I find the idea interesting. I am

AndyMark
assuming it only works if held in position by a motor and not a motor in move it to limit then coast.

So how could this be done, just a low amp limit and break mode? Detecting feedback current somehow and responding with ramping output to resist? If so how would you detect feedback current? Maybe they only uncommanded reverses in position using motor encoder?

I realize I am

AndyMark
only speculating and too impatient to wait for 254s code release to find out.

Does anyone do this or know how it is done?

1 Like

Underdamped PID. That’s all this is.

18 Likes

Not sure how they actually did it, but here’s another way to think about it:

Spring force is proportional to displacement from “nominal”.

Motor force is proportional to current.

Current is proportional to motor speed and voltage.

If you know motor speed & mechanism displacement (probably measured off the same sensor), you can pick a voltage command which causes the current to make the force act like a spring would.

At slow speeds, this collapses into a P controller on position (as marshall indicated).

6 Likes

given that it’s 254, I immediately jump to PID wizardry, but as an alternate theory:

It’s possible they make use of ctre’s new torque control modes, eg engage `TorqueCurrentFOC` control mode when the mechanism get pushed away from its setpoint, and increase the torque proportionally to how far it gets pushed.

3 Likes

So really any PID holding position acts like a spring but some are just stiffer.

7 Likes

Otherwise known as proportional only? Or something else?

The same equations that govern why a guitar string makes a note.

This world is a beautiful place.

4 Likes

Yeah, a PID graph:

Compared to a damped oscillator graph (From here):

Yeah… that might actually work but it depends on the desired effect?

6 Likes

From a slightly different perspective the combination of pid tuning and also springs can help get “tendon-like” behavior for compliant grippers. Also specifically force controlled by limiting amperage as it relates directly to your output torque. Sometimes just PID isn’t enough.

Proportional feedback is a software spring. Hooke’s law is the same as the control law for proportional feedback.

8 Likes

Instead of underdamping my pid constants, setting a lower maximum torque limit (on phoenix) when squish mode is needed would work just the same right? Idk if that requires torque pid or if torque limits can apply to all requests.

I believe 148 did this in 2022. By applying a low current limit to the motor (2 amps if I recall correctly) it makes it so external force that at strong enough to break the mechanism will instead cause it to “fold in” on itself as it overpower the motor.
The downside I see to using a pid for damping force is that if you have to tune it specially for damping, then you can’t tune it for some other factor.

1 Like

A few things to note for folks walking through:

• In the simple model of a brushed DC motor, torque limits and current limits have the exact same effect on the system.
• A limit on torque or current will be non-linear - this is not “spring” behavior as Hooke’s law describes it.
2 Likes

This one did get me thinking.

My first thought was “that doesn’t make sense - tuning goals are for system behavior - having a cascaded PID + limit system won’t give you an extra degree of freedom for some system behavior”

However, two possible architectures:

1. Switch-gain controller - a “soft spring” mode, and a “GET TO THE CHOPPER” aggressive mode.
2. Path plan a spring-like gentle trajectory from wherever you’re at to where you want to be, but keep the PID gains hot to aggressively follow it.

Again these are deviations from Hooke’s law, but I can construct different situations where I might want them.

4 Likes

The “switching” concept you’re thinking of is called “gain scheduling,” where you use one linear controller for one operating “mode” and a different controller for a different mode. It’s a normal thing to do.

You could also think of the control problem as needing to respond to force rather than position – i.e. you want to hold an intake in the right place, without flopping around, but you want to retract it if some external force is imposed (e.g. hitting something). So you might want to add some sort of sensor to measure that force directly. This is what high-dexterity grips do, the things that can grab grapes without squishing them but they can also lift heavy things: they use fingertip-force sensors of various kinds, rather than relying on the coarse controls in the arm/wrist motor/control chain.

1 Like

Torque is directly related to current. If you want a motor spring you would control current in some way. So your current would be your control variable (CV)