ME 405 Term Project
Loading...
Searching...
No Matches
closed_loop.ClosedLoop Class Reference

Public Member Functions

 __init__ (self, kp, ki, sp_sh, battery, effort_limits=(-100, 100))
 reset (self)
 run (self, fb)

Public Attributes

 kp = kp
 ki = ki
 sp_sh = sp_sh
 effort_min
 effort_max = effort_limits
float integrator = 0.0
 last_time = ticks_ms()
float output = 0.0
float last_output = 0.0
 battery = battery

Static Public Attributes

int GEAR_RATIO = 3952/33
int CPR_MOTOR = 12
int CPR_WHEEL = GEAR_RATIO*CPR_MOTOR
int RAD_PER_COUNT = 2 * math.pi / CPR_WHEEL

Detailed Description

Proportional-Integral (PI) controller for velocity control in rad/s.

Attributes:
    kp: Proportional gain (share object with get() method)
    ki: Integral gain (share object with get() method)
    sp_sh: Setpoint share object with get() method (desired velocity in rad/s)
    battery: Battery object for droop compensation (optional) 
    effort_limits: Tuple defining min and max effort (%)

Constructor & Destructor Documentation

◆ __init__()

closed_loop.ClosedLoop.__init__ ( self,
kp,
ki,
sp_sh,
battery,
effort_limits = (-100, 100) )

Member Function Documentation

◆ reset()

closed_loop.ClosedLoop.reset ( self)
Reset controller integrator and state.

◆ run()

closed_loop.ClosedLoop.run ( self,
fb )
Compute control output (effort %) from velocity feedback and measured battery voltage.

Args:
    fb: Feedback velocity in rad/s.
    
Returns:
    u: Control effort output (%).

Member Data Documentation

◆ battery

closed_loop.ClosedLoop.battery = battery

◆ CPR_MOTOR

int closed_loop.ClosedLoop.CPR_MOTOR = 12
static

◆ CPR_WHEEL

int closed_loop.ClosedLoop.CPR_WHEEL = GEAR_RATIO*CPR_MOTOR
static

◆ effort_max

closed_loop.ClosedLoop.effort_max = effort_limits

◆ effort_min

closed_loop.ClosedLoop.effort_min

◆ GEAR_RATIO

int closed_loop.ClosedLoop.GEAR_RATIO = 3952/33
static

◆ integrator

float closed_loop.ClosedLoop.integrator = 0.0

◆ ki

closed_loop.ClosedLoop.ki = ki

◆ kp

closed_loop.ClosedLoop.kp = kp

◆ last_output

float closed_loop.ClosedLoop.last_output = 0.0

◆ last_time

closed_loop.ClosedLoop.last_time = ticks_ms()

◆ output

float closed_loop.ClosedLoop.output = 0.0

◆ RAD_PER_COUNT

int closed_loop.ClosedLoop.RAD_PER_COUNT = 2 * math.pi / CPR_WHEEL
static

◆ sp_sh

closed_loop.ClosedLoop.sp_sh = sp_sh

The documentation for this class was generated from the following file: