WPILib
Library for programming XRP roobts
Author(s): Open STEM Authors
Implementation Notes
Hardware:
TODO Add links to any specific hardware product page(s), or category page(s).
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
- class WPILib.XRPBot(is_prototype: bool = False, ticks_per_rev: int = 288)
If you need to change the encoder counts, alter the ticksPerRev values in the following two constructors. Most robots have either 144 or 288 ticks per revolution, depending on which motors are used.
High Level
- class WPILib.Drivetrain(left_encoded_motor: <module 'WPILib._encoded_motor' from '/home/docs/checkouts/readthedocs.org/user_builds/circuitpython-xrp-library/checkouts/latest/WPILib/_encoded_motor.py'>, right_encoded_motor: <module 'WPILib._encoded_motor' from '/home/docs/checkouts/readthedocs.org/user_builds/circuitpython-xrp-library/checkouts/latest/WPILib/_encoded_motor.py'>)
The drivetrain class … todo
- get_left_encoder_position() float
Return the current position of the left motor’s encoder in degrees.
- get_right_encoder_position() float
Return the current position of the right motor’s encoder in degrees.
- set_effort(left_effort: float, right_effort: float) None
Set the raw effort of both motors individually
- set_encoder_position(left_degrees: float, right_degrees: float) None
Set the position of the motors’ encoders in degrees. Note that this does not actually move the motor but just recalibrates the stored encoder value. If only one encoder position is specified, the encoders for each motor will be set to that position.
- straight(distance: float, speed: float = 0.5, timeout: float = None) bool
Go forward the specified distance in centimeters, and exit function when distance has been reached. Speed is bounded from -1 (reverse at full speed) to 1 (forward at full speed)
- Parameters:
distance (float) – The distance for the robot to travel (In Centimeters)
speed (float) – The speed for which the robot to travel (Bounded from -1 to 1). Default is half speed forward
timeout (float) – The amount of time before the robot stops trying to move forward and continues to the next step (In Seconds)
- Returns:
if the distance was reached before the timeout
- Return type:
- turn(turn_degrees: float, speed: float = 0.5, timeout: float = None) bool
Turn the robot some relative heading given in turnDegrees, and exit function when the robot has reached that heading. Speed is bounded from -1 (turn counterclockwise the relative heading at full speed) to 1 (turn clockwise the relative heading at full speed)
- Parameters:
turnDegrees (float) – The number of angle for the robot to turn (In Degrees)
speed (float) – The speed for which the robot to travel (Bounded from -1 to 1). Default is half speed forward.
timeout (float) – The amount of time before the robot stops trying to turn and continues to the next step (In Seconds)
- Returns:
if the distance was reached before the timeout
- Return type:
Outputs
Inputs
- class WPILib.Buttons
- class WPILib.ReflectanceWrapper
A wrapper for an object that stores either the legacy or new implementation of the reflectance sensor User can set one of two modes, and get the value of either reflectance sensor
- get_left() float
Gets the the reflectance of the left reflectance sensor :return: The reflectance ranging from 0 (white) to 1 (black) :rtype: float
- class WPILib.UltrasonicWrapper
A wrapper for an object that stores either the legacy or new implementation of the ultrasonic sensor User can set one of two modes, and get the value of either ultrasonic sensor