Pololu¶
- class Pololu(*args, **kwargs)¶
Bases:
pybind11_object
Interface for the Pololu Maestro USB Servo Controllers.
See https://www.pololu.com/category/102/maestro-usb-servo-controllers for more details.
This class give a position and velocity control for the servo motors plugged into the board on a given channel. If you want to control two or more servo motors, you need to instanciate a new object for each additional servo motor. An example is given in the vpRobotPololuPtu class that allows to control a pan-tilt unit with two servo motors.
It implements a velocity controller that runs in a separate thread.
A servomotor can be position-controlled by giving it position commands in pwm units using setPwmPosition() or in angles expressed in radians using setAngularPosition() .
It can be also velocity-controller by giving it velocity commands in pwm units using setPwmVelocity() or in ras/s using setAngularVelocity() .
The conversion between pwm units and radians positions is done using radToPwm() or pwmToRad() . For velocity control conversion from pwm units and rad/s is done using speedToRadS() and radSToSpeed() .
Each servo has a pwm position range that could be retrieved using calibrate() and set using set using setPwmRange() .
It is the user responsability to set the corresponding angular range using setAngularRange() .
Overloaded function.
__init__(self: visp._visp.robot.Pololu, verbose: bool = false) -> None
Default constructor.
You need to call connect() to setup the serial link with the Pololu board.
- Parameters:
- verbose
When true enable verbose mode.
__init__(self: visp._visp.robot.Pololu, device: str, baudrate: int = 38400, channel: int = 0, verbose: bool = false) -> None
Constructor that enables the serial link with the Pololu board calling internally connect() . The velocity controller thread is created in the constructor and will run independently of the rest of the class. You can set velocity commands using setPwmVelocity() or setAngularVelocity() .
- Parameters:
- device
Serial device name to dial with Pololu board.
- baudrate
Baudrate used to dial with Pololu board. Note that this parameter is only used on Windows.
- channel
Channel to which the servo is connected to the Pololu board.
- verbose
When true enable verbose mode.
Methods
Overloaded function.
Move servo motor to minimal pwm position and then to maximal pwm position to retrieve min and max pwm values.
Open a connection with the Pololu board.
Check if the serial connection is still up.
Return angular position in rad.
Return PWM position.
Get min, max and range for angle cmd.
Get min, max range for PWM cmd.
Convert a PWM value to an angle in radians.
Convert deg/s speed into Pololu's speed.
Convert angles in radians to PWM for servo commands.
Set the position to reach in angle.
Set min and max axis angles range in rad.
Set the angular velocity of the motor movements in rad/s.
Set the position to reach in PWM.
Set min, max PWM cmd.
Set the pwm velocity of the motor movements.
Enable/disable verbose mode.
Convert Pololu's pwm velocity to rad/s velocity.
Stop the velocity command thread.
Inherited Methods
Operators
__doc__
Overloaded function.
__module__
Attributes
__annotations__
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: visp._visp.robot.Pololu, verbose: bool = false) -> None
Default constructor.
You need to call connect() to setup the serial link with the Pololu board.
- Parameters:
- verbose
When true enable verbose mode.
__init__(self: visp._visp.robot.Pololu, device: str, baudrate: int = 38400, channel: int = 0, verbose: bool = false) -> None
Constructor that enables the serial link with the Pololu board calling internally connect() . The velocity controller thread is created in the constructor and will run independently of the rest of the class. You can set velocity commands using setPwmVelocity() or setAngularVelocity() .
- Parameters:
- device
Serial device name to dial with Pololu board.
- baudrate
Baudrate used to dial with Pololu board. Note that this parameter is only used on Windows.
- channel
Channel to which the servo is connected to the Pololu board.
- verbose
When true enable verbose mode.
- calibrate(self, pwm_min: int, pwm_max: int) None ¶
Move servo motor to minimal pwm position and then to maximal pwm position to retrieve min and max pwm values.
- connect(self, device: str, baudrate: int, channel: int) None ¶
Open a connection with the Pololu board.
- connected(self) bool ¶
Check if the serial connection is still up.
- Returns:
true is the connection is enabled, false if the board is not connected.
- getRangeAngles(self, minAngle: float, maxAngle: float) tuple[float, float] ¶
Get min, max and range for angle cmd.
Note
See setAngularRange()
- radSToSpeed(self, speed_rad_s: float) int ¶
Convert deg/s speed into Pololu’s speed.
Note
See speedToRadS()
- radToPwm(self, angle: float) int ¶
Convert angles in radians to PWM for servo commands.
Note
See pwmToRad()
- setAngularPosition(self: visp._visp.robot.Pololu, pos_rad: float, vel_rad_s: float = 0.f) None ¶
Set the position to reach in angle.
- Parameters:
- pos_rad
Position to reach in radians.
- vel_rad_s
Velocity to use for the positioning in rad/s. Default is ‘0’ and will use maximum speed.
- setAngularRange(self, min_angle: float, max_angle: float) None ¶
Set min and max axis angles range in rad.
Note
See getRangeAngles()
- setAngularVelocity(self, vel_rad_s: float) None ¶
Set the angular velocity of the motor movements in rad/s.
- setPwmVelocity(self, pwm_vel: int) None ¶
Set the pwm velocity of the motor movements. The motor will move to the edge of the range at the given speed.