VEX IQ Python API
Public Member Functions | List of all members
drivetrain.Drivetrain Class Reference

Config Drivetrain: motors and wheels that move a robot. More...

Public Member Functions

def __init__ (self, left_motor, right_motor, wheel_travel_mm=200, track_mm=176)
 
def wheel_travel (self, wheel_travel_mm)
 Wheel travel (circumference) in mm. More...
 
def wheel_track (self, distance_mm)
 Distance between left and right wheels in mm. More...
 
def drive (self, power, distance_mm=None)
 Begin driving in a straight line. More...
 
def drive_until (self, power, distance_mm)
 Drive in a straight line until the distance is reached. More...
 
def turn (self, power, angle_deg=None)
 Begin turning by a given angle, positive to turn left, negative to turn right. More...
 
def turn_until (self, power, angle_deg)
 Turn by a given angle, positive to turn left, negative to turn right. More...
 
def arcade (self, drive_power, turn_power)
 Arcade drive given two axes of a controller. More...
 
def off (self)
 Turn off both motors. More...
 
def brake (self)
 Brake both motors. More...
 
def hold (self)
 Hold both motors. More...
 
def reached_target (self)
 True if both motors reached their target (turn or drive finished). More...
 
def stall_timeout (self, duration_sec=None)
 Get or set the stall detection timeout (in seconds) More...
 
def stalled (self)
 True if one motor has stalled, and the other either reached target or stalled (as specified by stall_timeout()) More...
 
def reached_target_or_stalled (self)
 True if both motors reached their target or stalled (as specified by stall_timeout()) More...
 

Detailed Description

Config Drivetrain: motors and wheels that move a robot.

Parameters
left_motorMotor driving the left wheel
right_motorMotor driving the right wheel
travel_mmWheel travel (circumference) in mm, default 200mm
track_mmDistance between left and right wheels in mm, default 176mm

Constructor & Destructor Documentation

◆ __init__()

def drivetrain.Drivetrain.__init__ (   self,
  left_motor,
  right_motor,
  wheel_travel_mm = 200,
  track_mm = 176 
)

Member Function Documentation

◆ wheel_travel()

def drivetrain.Drivetrain.wheel_travel (   self,
  wheel_travel_mm 
)

Wheel travel (circumference) in mm.

◆ wheel_track()

def drivetrain.Drivetrain.wheel_track (   self,
  distance_mm 
)

Distance between left and right wheels in mm.

◆ drive()

def drivetrain.Drivetrain.drive (   self,
  power,
  distance_mm = None 
)

Begin driving in a straight line.

Parameters
power-100.0...100.0 (percent power).
distance_mmdistance in mm, negative to go backwards.

◆ drive_until()

def drivetrain.Drivetrain.drive_until (   self,
  power,
  distance_mm 
)

Drive in a straight line until the distance is reached.

Parameters
power-100.0...100.0 (percent power).
distance_mmdistance in mm, negative to go backwards.
Returns
True if the drivetrain reached the target, False if stalled

◆ turn()

def drivetrain.Drivetrain.turn (   self,
  power,
  angle_deg = None 
)

Begin turning by a given angle, positive to turn left, negative to turn right.

Parameters
power-100.0...100.0 (percent power).
angle_degangle in degrees, positive to turn left, negative to turn right.

◆ turn_until()

def drivetrain.Drivetrain.turn_until (   self,
  power,
  angle_deg 
)

Turn by a given angle, positive to turn left, negative to turn right.

Parameters
power-100.0...100.0 (percent power).
angle_degangle in degrees, positive to turn left, negative to turn right.
Returns
True if the drivetrain reached the target, False if stalled

◆ arcade()

def drivetrain.Drivetrain.arcade (   self,
  drive_power,
  turn_power 
)

Arcade drive given two axes of a controller.

◆ off()

def drivetrain.Drivetrain.off (   self)

Turn off both motors.

◆ brake()

def drivetrain.Drivetrain.brake (   self)

Brake both motors.

◆ hold()

def drivetrain.Drivetrain.hold (   self)

Hold both motors.

◆ reached_target()

def drivetrain.Drivetrain.reached_target (   self)

True if both motors reached their target (turn or drive finished).

◆ stall_timeout()

def drivetrain.Drivetrain.stall_timeout (   self,
  duration_sec = None 
)

Get or set the stall detection timeout (in seconds)

◆ stalled()

def drivetrain.Drivetrain.stalled (   self)

True if one motor has stalled, and the other either reached target or stalled (as specified by stall_timeout())

◆ reached_target_or_stalled()

def drivetrain.Drivetrain.reached_target_or_stalled (   self)

True if both motors reached their target or stalled (as specified by stall_timeout())