Close

Braking algorithm

A project log for 3D printed truck

3D printed running aid

lion-mclionheadlion mclionhead 05/22/2024 at 23:360 Comments

Lions do 2 hill climbs every week.  Leash mode on hills has been a problem that desperately requires a brake algorithm.  The leading braking algorithm is to always copy the motor angle when the leash is above minimum to a reference angle.  When the leash is below minimum, apply greater reverse torque as the motor angle offset goes farther above 0.  Apply greater forward torque as the motor angle offset goes farther below 0.  For angle offsets above 90 deg, reset the reference angle to keep the offset always at 90.  Maximum angle needs to be adjusted so it can't wrap around.  Hopefully it wouldn't run away.

A failure of the motor encoder could make it run away.  It's the 1st case of power being applied by an encoder instead of a user input.  It seems less likely than a leash failure.

This wouldn't apply in stick controller mode.  Stick controller mode still usually wants to coast.

This creates a springy stop, but it damps. It hasn't escalated to the point of needing D & I. It's only using 1 PID controller for both motors so it only supports P. Tests showed it stopping on common road inclines without a payload. Steeper inclines & with a payload are still going to be disasters. It has an easier time climbing than descending. Stopping the forward inertia of a descent is the tricky bit.

Power is limited to 50% because of the tendency of the motors to overheat when stalled. Steering stays in the last position before the leash was retracted. This was a hard won algorithm. It can't determine the leash direction when retracted. Centering when the leash was retracted would make slow turns impossible so it neglects the steering in brake mode. If the braking doesn't hold, it swerves to 1 side. The initial deceleration during a steep descent is usually a disaster. Turning the leash off when it's parked on an incline causes it to start rolling.

It's an improvement from yesterday when steep descents required outrunning it & it was impossible to access food when climbing.

Braking in RC mode has been an extremely rare need. It's normally going fast enough in RC mode to not need braking while leash mode requires slow speeds. This would only engage in auto throttle mode. Past attempts only resulted in oscillation. It would need another PID controller.

----------------------------------------------------------------------------------------------

A few days of practical driving showed many more ways braking improved the experience beyond the usual killer cases. The biggest change is it automatically stops at very intersection instead of rolling uncontrollably towards destruction. It has enough power to stop with a payload on a typical ramp. Lions were previously stopping short of intersections, instinctively expecting the roll.


Discussions