Bot'n Roll ONE A+ - Raspberry Pi 5 library
 
Loading...
Searching...
No Matches
onepi.utils.drive_pid.DrivePid Class Reference

Public Member Functions

 __init__ (self, pid_params=PidParams(), robot_params=RobotParams(), update_period_ms=100)
 
 move (self, left_speed_mmps, right_speed_mmps)
 
 stop (self)
 

Protected Member Functions

 _initialise (self)
 
 _compute_left_speed (self)
 
 _compute_right_speed (self)
 
 _update_speeds (self)
 

Protected Attributes

 _cut = ControlUtils(robot_params)
 
 _left_pid
 
 _right_pid
 
 _update_period_ms = update_period_ms
 
 _pid_timer
 

Static Protected Attributes

int _left_speed = 0
 
int _right_speed = 0
 
int _previous_left_speed = 0
 
int _previous_right_speed = 0
 
int _counter = 0
 
int _left_encoder = 0
 
int _right_encoder = 0
 
 _one = BnrOneAPlus(0, 0)
 
bool _initialised = False
 

Detailed Description

This class provides PID control for a differential drive robot.

Constructor & Destructor Documentation

◆ __init__()

onepi.utils.drive_pid.DrivePid.__init__ ( self,
pid_params = PidParams(),
robot_params = RobotParams(),
update_period_ms = 100 )
initialises the class with kp, ki, kd,
max speed (mm/s) and update period (ms)

Member Function Documentation

◆ _compute_left_speed()

onepi.utils.drive_pid.DrivePid._compute_left_speed ( self)
protected
computes left speed

◆ _compute_right_speed()

onepi.utils.drive_pid.DrivePid._compute_right_speed ( self)
protected
computes right speed

◆ _initialise()

onepi.utils.drive_pid.DrivePid._initialise ( self)
protected
resets the system to be ready to start (again)

◆ _update_speeds()

onepi.utils.drive_pid.DrivePid._update_speeds ( self)
protected
update wheel speeds by running the pid controller and sets the wheel
speeds of the robot

◆ move()

onepi.utils.drive_pid.DrivePid.move ( self,
left_speed_mmps,
right_speed_mmps )
Makes the robot move at the desired wheel speeds in mm/s

◆ stop()

onepi.utils.drive_pid.DrivePid.stop ( self)
Stops the robot and stops the corresponding timer
used by the controller

Member Data Documentation

◆ _left_pid

onepi.utils.drive_pid.DrivePid._left_pid
protected
Initial value:
= PidController(
pid_params, -robot_params.max_speed_mmps, robot_params.max_speed_mmps
)

◆ _pid_timer

onepi.utils.drive_pid.DrivePid._pid_timer
protected
Initial value:
= SimpleTimer(
increment=self._update_period_ms / 1000.0, function=self._update_speeds
)

◆ _right_pid

onepi.utils.drive_pid.DrivePid._right_pid
protected
Initial value:
= PidController(
pid_params, -robot_params.max_speed_mmps, robot_params.max_speed_mmps
)

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