Drivetrain¶
- drivetrain.go_straight(distance: float, speed: float = 0.5, timeout: float = None) None ¶
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:
bool
- drivetrain.go_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:
turn_degrees – 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:
bool
- drivetrain.set_effort(left_effort: float, right_effort: float) None: ¶
Set the raw effort of both motors individually
- Parameters:
left_effort – The power (Bounded from -1 to 1) to set the left motor to.
right_effort – The power (Bounded from -1 to 1) to set the right motor to.
- drivetrain.stop() None: ¶
Stops both drivetrain motors
- drivetrain.get_left_encoder_position() float: ¶
Return the current position of the left motor’s encoder in revolutions.
- drivetrain.get_right_encoder_position() float: ¶
Return the current position of the right motor’s encoder in revolutions.
- drivetrain.set_encoder_position(left_position: float, right_position: float) None: ¶
Set the position of the motors’ encoders in revolutions. 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.
- Parameters:
left_position – The distance to recalibrate the left encoder to.
right_position – The distance to recalibrate the left encoder to.