VEX V5 Python API
Public Member Functions | List of all members
smartdrive.Smartdrive Class Reference

Creates a new smartdrive object. More...

Inherits drivetrain.Drivetrain.

Public Member Functions

def __init__ (self, left_motor, right_motor, gyro, wheel_travel=319.1764, track_width=292.1, distanceUnits=DistanceUnits.MM, gear_ratio=1.0)
 
def set_turn_threshold (self, t)
 
def turn_to_heading (self, angle, angleUnits=RotationUnits.DEG, velocity=None, velocityUnits=VelocityUnits.PCT, waitForCompletion=True)
 Turn on the motors and rotate to a heading at the default velocity. More...
 
def turn_to_rotation (self, angle, angleUnits=RotationUnits.DEG, velocity=None, velocityUnits=VelocityUnits.PCT, waitForCompletion=True)
 
def turn_for (self, turnType, angle, angleUnits=RotationUnits.DEG, velocity=None, velocityUnits=VelocityUnits.PCT, waitForCompletion=True)
 Turn the drivetrain left or right until the specified angle is reached. More...
 
def start_turn_to_heading (self, angle, angleUnits=RotationUnits.DEG, velocity=None, velocityUnits=VelocityUnits.PCT)
 
def start_turn_to_rotation (self, angle, angleUnits=RotationUnits.DEG, velocity=None, velocityUnits=VelocityUnits.PCT)
 
def start_turn_for (self, turnType, angle, angleUnits=RotationUnits.DEG, velocity=None, velocityUnits=VelocityUnits.PCT)
 Start turning the drivetrain left or right unitl the specified angle is reached. More...
 
def set_heading (self, angle, rotationUnits=RotationUnits.DEG)
 Set the gyro/inertial sensor heading to angle. More...
 
def heading (self, rotationUnits=RotationUnits.DEG)
 Gets the heading (angle) of the gyro/inertial sensor. More...
 
def set_rotation (self, angle, rotationUnits=RotationUnits.DEG)
 Set the gyro/inertial sensor rotation to angle. More...
 
def rotation (self, rotationUnits=RotationUnits.DEG)
 Gets the heading (angle) of the gyro/inertial sensor. More...
 
def is_turning (self)
 Checks to see if the turnToHeading, turnToRotation or turnFor function is still running. More...
 
def is_moving (self)
 True if drivetrain is moving to a target, False otherwise. More...
 
def is_done (self)
 True if drivetrain is done driving/turning to a specified target, False otherwise. More...
 
def set_gear_ratio (self, gear_ratio)
 Sets the external gear ratio of the drivetrain. More...
 
def set_drive_velocity (self, velocity, velocityUnits=VelocityUnits.PCT)
 Sets the velocity of the drive. More...
 
def set_turn_velocity (self, velocity, velocityUnits=VelocityUnits.PCT)
 Sets the velocity of the turn. More...
 
def set_timeout (self, time, timeUnits=TimeUnits.SEC)
 Sets the timeout for the drivetrain. More...
 
def timeout (self, timeUnits=TimeUnits.SEC)
 Returns a timeout in given time units. More...
 
def did_timeout (self)
 True if the last drivetrain operation timed out, False otherwise. More...
 
def set_stopping (self, brakeType)
 Sets the stopping mode of the motor group by passing a brake mode as a parameter. More...
 
def drive (self, directionType, velocity=None, velocityUnits=VelocityUnits.PCT)
 Turns the motors on and drives in the specified direction. More...
 
def drive_for (self, directionType, distance, distanceUnits=DistanceUnits.MM, velocity=None, velocityUnits=VelocityUnits.PCT, waitForCompletion=True)
 Drives for a specified distance. More...
 
def turn (self, turnType, velocity=None, velocityUnits=VelocityUnits.PCT)
 Turn the drivetrain left or right. More...
 
def start_drive_for (self, directionType, distance, distanceUnits=DistanceUnits.MM, velocity=None, velocityUnits=VelocityUnits.PCT)
 Start driving for a specified distance. More...
 
def arcade (self, drivePower, turnPower, percentUnit=PercentUnits.PCT)
 Drive in arcade mode, normally corresponding to two controller joystick axis values. More...
 
def stop (self, brakeType=None)
 Stops the drive using a specified brake mode. More...
 
def velocity (self, velocityUnits=VelocityUnits.PCT)
 Gets the average current velocity of all motors. More...
 
def current (self, currentUnits=CurrentUnits.AMP)
 Gets the electrical current of all motors. More...
 
def power (self, powerUnits=PowerUnits.WATT)
 Gets the total power of all motors in the drivetrain. More...
 
def torque (self, torqueUnits=TorqueUnits.NM)
 Gets the total torque of all motors in the drivetrain. More...
 
def efficiency (self, percentUnits=PercentUnits.PCT)
 Gets the average efficiency of the drivetrain. More...
 
def temperature (self, percentUnits=PercentUnits.PCT)
 Gets the average temperature of the drivetrain. More...
 

Detailed Description

Creates a new smartdrive object.

Parameters
left_motorthe motor, motor group or a list/tuple of motors driving the left side of the drivetrain
right_motorthe motor, motor group or a list/tuple of motors driving the right side of the drivetrain
gyrothe gyro or initial sensor used to determine orientation
wheel_travelcircumference of the wheel type used
track_widthdistance between the wheels on opposite sides
distanceUnitsunit for wheel_travel and track_with, a DistanceUnits enum value
gear_ratioexternal gear ratio, usually 1.0

Constructor & Destructor Documentation

◆ __init__()

def smartdrive.Smartdrive.__init__ (   self,
  left_motor,
  right_motor,
  gyro,
  wheel_travel = 319.1764,
  track_width = 292.1,
  distanceUnits = DistanceUnits.MM,
  gear_ratio = 1.0 
)

Member Function Documentation

◆ set_turn_threshold()

def smartdrive.Smartdrive.set_turn_threshold (   self,
  t 
)

◆ turn_to_heading()

def smartdrive.Smartdrive.turn_to_heading (   self,
  angle,
  angleUnits = RotationUnits.DEG,
  velocity = None,
  velocityUnits = VelocityUnits.PCT,
  waitForCompletion = True 
)

Turn on the motors and rotate to a heading at the default velocity.

Returns
True if the motor has reached the target rotation value.
Parameters
angleSets the angle to turn.
angleUnitsThe measurement unit for the angle value.
velocitySets the amount of velocity.
velocityUnitsThe measurement unit for the velocity value.
waitForCompletion(Optional) If true, your program will wait until the motor reaches the target rotational value. If false, the program will continue after calling this function. By default, this parameter is true.

◆ turn_to_rotation()

def smartdrive.Smartdrive.turn_to_rotation (   self,
  angle,
  angleUnits = RotationUnits.DEG,
  velocity = None,
  velocityUnits = VelocityUnits.PCT,
  waitForCompletion = True 
)

◆ turn_for()

def smartdrive.Smartdrive.turn_for (   self,
  turnType,
  angle,
  angleUnits = RotationUnits.DEG,
  velocity = None,
  velocityUnits = VelocityUnits.PCT,
  waitForCompletion = True 
)

Turn the drivetrain left or right until the specified angle is reached.

Parameters
turnTypedirection to turn in, left or right, a TurnType enum value
anglesets the angle to turn
angleUnitsunits for the angle parameter, a RotationUnits enum value
velocityset velocity of the motors
velocityUnitsunit for the velocity parameter, a VelocityUnits enum value
waitForCompletionif True, your program will wait until the motor reaches the target rotational value, otherwise it will continue immediately.
Returns
True if the drivetrain has reached the target angle, False otherwise

Reimplemented from drivetrain.Drivetrain.

◆ start_turn_to_heading()

def smartdrive.Smartdrive.start_turn_to_heading (   self,
  angle,
  angleUnits = RotationUnits.DEG,
  velocity = None,
  velocityUnits = VelocityUnits.PCT 
)

◆ start_turn_to_rotation()

def smartdrive.Smartdrive.start_turn_to_rotation (   self,
  angle,
  angleUnits = RotationUnits.DEG,
  velocity = None,
  velocityUnits = VelocityUnits.PCT 
)

◆ start_turn_for()

def smartdrive.Smartdrive.start_turn_for (   self,
  turnType,
  angle,
  angleUnits = RotationUnits.DEG,
  velocity = None,
  velocityUnits = VelocityUnits.PCT 
)

Start turning the drivetrain left or right unitl the specified angle is reached.

Parameters
turnTypedirection to turn in, left or right, a TurnType enum value
anglesets the angle to turn
angleUnitsunits for the angle parameter, a RotationUnits enum value
velocityset velocity of the motors
velocityUnitsunit for the velocity parameter, a VelocityUnits enum value

Reimplemented from drivetrain.Drivetrain.

◆ set_heading()

def smartdrive.Smartdrive.set_heading (   self,
  angle,
  rotationUnits = RotationUnits.DEG 
)

Set the gyro/inertial sensor heading to angle.

Parameters
angleThe new heading for the gyro
rotationUnitsThe rotation unit for the angle

◆ heading()

def smartdrive.Smartdrive.heading (   self,
  rotationUnits = RotationUnits.DEG 
)

Gets the heading (angle) of the gyro/inertial sensor.

Returns
a double that represents the unit value specified by the parameter of the gyro sensor.
Parameters
rotationUnitsThe measurement unit for the gyro device.

◆ set_rotation()

def smartdrive.Smartdrive.set_rotation (   self,
  angle,
  rotationUnits = RotationUnits.DEG 
)

Set the gyro/inertial sensor rotation to angle.

Parameters
angleThe new rotation for the gyro
rotationUnitsThe rotation unit for the angle

◆ rotation()

def smartdrive.Smartdrive.rotation (   self,
  rotationUnits = RotationUnits.DEG 
)

Gets the heading (angle) of the gyro/inertial sensor.

Returns
a double that represents the unit value specified by the parameter of the gyro sensor.
Parameters
rotationUnitsThe measurement unit for the gyro device.

◆ is_turning()

def smartdrive.Smartdrive.is_turning (   self)

Checks to see if the turnToHeading, turnToRotation or turnFor function is still running.

Returns
True if the motor is on and is rotating to a target, False otherwise

◆ is_moving()

def smartdrive.Smartdrive.is_moving (   self)

True if drivetrain is moving to a target, False otherwise.

Reimplemented from drivetrain.Drivetrain.

◆ is_done()

def smartdrive.Smartdrive.is_done (   self)

True if drivetrain is done driving/turning to a specified target, False otherwise.

Reimplemented from drivetrain.Drivetrain.

◆ set_gear_ratio()

def drivetrain.Drivetrain.set_gear_ratio (   self,
  gear_ratio 
)
inherited

Sets the external gear ratio of the drivetrain.

Parameters
gear_ratiogear ratio value, usually 1.0

◆ set_drive_velocity()

def drivetrain.Drivetrain.set_drive_velocity (   self,
  velocity,
  velocityUnits = VelocityUnits.PCT 
)
inherited

Sets the velocity of the drive.

Will not run the motors. Any subsequent call that does not contain a specified velocity will use this value.

Parameters
velocitySets the amount of velocity.
velocityUnitsunit for the velocity parameter, a VelocityUnits enum value

◆ set_turn_velocity()

def drivetrain.Drivetrain.set_turn_velocity (   self,
  velocity,
  velocityUnits = VelocityUnits.PCT 
)
inherited

Sets the velocity of the turn.

Will not run the motors.

Parameters
velocitySets the amount of velocity.
velocityUnitsunit for the velocity parameter, a VelocityUnits enum value

◆ set_timeout()

def drivetrain.Drivetrain.set_timeout (   self,
  time,
  timeUnits = TimeUnits.SEC 
)
inherited

Sets the timeout for the drivetrain.

If the drivetrain does not reach its' commanded position prior to the completion of the timeout, the motors will stop.

Parameters
timethe amount of time.
timeUnitsunit for the time parameter, a TimeUnits enum value

◆ timeout()

def drivetrain.Drivetrain.timeout (   self,
  timeUnits = TimeUnits.SEC 
)
inherited

Returns a timeout in given time units.

◆ did_timeout()

def drivetrain.Drivetrain.did_timeout (   self)
inherited

True if the last drivetrain operation timed out, False otherwise.

◆ set_stopping()

def drivetrain.Drivetrain.set_stopping (   self,
  brakeType 
)
inherited

Sets the stopping mode of the motor group by passing a brake mode as a parameter.

Parameters
brakeTypethe stopping mode, a BrakeType enum value (coast, brake, or hold).

◆ drive()

def drivetrain.Drivetrain.drive (   self,
  directionType,
  velocity = None,
  velocityUnits = VelocityUnits.PCT 
)
inherited

Turns the motors on and drives in the specified direction.

Parameters
directionTypedirection to drive in, forward or reverse, a DirectionType enum value
velocityset velocity of the motors
velocityUnitsunit for the velocity parameter, a VelocityUnits enum value

◆ drive_for()

def drivetrain.Drivetrain.drive_for (   self,
  directionType,
  distance,
  distanceUnits = DistanceUnits.MM,
  velocity = None,
  velocityUnits = VelocityUnits.PCT,
  waitForCompletion = True 
)
inherited

Drives for a specified distance.

Parameters
directionTypedirection to drive in, forward or reverse, a DirectionType enum value
distancedistance to drive in
distanceUnitsunit for the distance parameter, a DistanceUnits enum value
velocityset velocity of the motors
velocityUnitsunit for the velocity parameter, a VelocityUnits enum value
waitForCompletionif True, your program will wait until the motor reaches the target rotational value, otherwise it will continue immediately.
Returns
True if the drivetrain has reached the target distance, False otherwise

◆ turn()

def drivetrain.Drivetrain.turn (   self,
  turnType,
  velocity = None,
  velocityUnits = VelocityUnits.PCT 
)
inherited

Turn the drivetrain left or right.

Parameters
turnTypedirection to turn in, left or right, a TurnType enum value
velocityset velocity of the motors
velocityUnitsunit for the velocity parameter, a VelocityUnits enum value

◆ start_drive_for()

def drivetrain.Drivetrain.start_drive_for (   self,
  directionType,
  distance,
  distanceUnits = DistanceUnits.MM,
  velocity = None,
  velocityUnits = VelocityUnits.PCT 
)
inherited

Start driving for a specified distance.

Parameters
directionTypedirection to drive in, forward or reverse, a DirectionType enum value
distancedistance to drive in
distanceUnitsunit for the distance parameter, a DistanceUnits enum value
velocityset velocity of the motors
velocityUnitsunit for the velocity parameter, a VelocityUnits enum value

◆ arcade()

def drivetrain.Drivetrain.arcade (   self,
  drivePower,
  turnPower,
  percentUnit = PercentUnits.PCT 
)
inherited

Drive in arcade mode, normally corresponding to two controller joystick axis values.

Parameters
drivePowerpercent power to apply to driving, -100..100
turnPowerpercent power to apply to turning, -100..100
percentUnit

◆ stop()

def drivetrain.Drivetrain.stop (   self,
  brakeType = None 
)
inherited

Stops the drive using a specified brake mode.

Parameters
brakeTypebrake mode, an BrakeType enum value. If omitted, the value set in set_stopping is used.

◆ velocity()

def drivetrain.Drivetrain.velocity (   self,
  velocityUnits = VelocityUnits.PCT 
)
inherited

Gets the average current velocity of all motors.

Returns
a float that represents the average current velocity
Parameters
velocityUnitsThe measurement unit for the velocity.

◆ current()

def drivetrain.Drivetrain.current (   self,
  currentUnits = CurrentUnits.AMP 
)
inherited

Gets the electrical current of all motors.

Parameters
currentUnits
Returns
a float that represents the electrical current of the motor in Amps.

◆ power()

def drivetrain.Drivetrain.power (   self,
  powerUnits = PowerUnits.WATT 
)
inherited

Gets the total power of all motors in the drivetrain.

Parameters
powerUnits
Returns
a float that represents the power in given units

◆ torque()

def drivetrain.Drivetrain.torque (   self,
  torqueUnits = TorqueUnits.NM 
)
inherited

Gets the total torque of all motors in the drivetrain.

Parameters
torqueUnits
Returns
a float that represents the torque in given units

◆ efficiency()

def drivetrain.Drivetrain.efficiency (   self,
  percentUnits = PercentUnits.PCT 
)
inherited

Gets the average efficiency of the drivetrain.

Parameters
percentUnits
Returns
efficiency of the motor in percent

◆ temperature()

def drivetrain.Drivetrain.temperature (   self,
  percentUnits = PercentUnits.PCT 
)
inherited

Gets the average temperature of the drivetrain.

Parameters
percentUnits
Returns
temperature of the drivetrain in percent