VEX EDR Python API
Public Member Functions | Public Attributes | List of all members
vex.EncoderMotor Class Reference

Config Encoder motor that tracks distance covered. More...

Public Member Functions

def __init__ (self, motornum, switch_polarity=False)
 
def off (self)
 Turn off. More...
 
def run (self, power, distance=None)
 Begin running at given power. More...
 
def run_until (self, power, distance)
 Run at given power until the given distance is reached. More...
 
def run_raw (self, power_raw, distance=None)
 Begin running at given raw power. More...
 
def run_raw_until (self, power_raw, distance)
 Run at given raw power until the given distance is reached. More...
 
def run_sync (self, power, distance, motor_slave=None, motor_slave_rev=None)
 Begin running at given power for given distance, sync with other motors. More...
 
def run_sync_until (self, power, distance, motor_slave=None, motor_slave_rev=None)
 Run at given power until the given distance is reached, sync with other motors. More...
 
def run_sync_raw (self, power_raw, distance, motor_slave=None, motor_slave_rev=None)
 Begin running at given power for given distance, sync with other motors. More...
 
def run_sync_raw_until (self, power_raw, distance, motor_slave=None, motor_slave_rev=None)
 Run at given raw power until the given distance is reached, sync with other motors. More...
 
def reached_target (self)
 True if the motor reached the target, False otherwise. More...
 
def stalled (self)
 True if motor has stalled (did not change position) for the duration set in the motor.stall_timeout field. More...
 
def reached_target_or_stalled (self)
 True if motor reached the target or stalled (did not change position) for the duration in the motor.stall_timeout field. More...
 
def position (self)
 Get the current encoder position (dinstance) in ticks. More...
 
def reset_position (self)
 Reset the motor position to zero. More...
 

Public Attributes

 stall_timeout
 

Detailed Description

Config Encoder motor that tracks distance covered.

Parameters
motornummotor port the motor is connected to (1-10)
switch_polarityif True, switch the polarity (direction) of the motor. Default False.

Constructor & Destructor Documentation

◆ __init__()

def vex.EncoderMotor.__init__ (   self,
  motornum,
  switch_polarity = False 
)

Member Function Documentation

◆ off()

def vex.EncoderMotor.off (   self)

Turn off.

◆ run()

def vex.EncoderMotor.run (   self,
  power,
  distance = None 
)

Begin running at given power.

Parameters
power-100.0...100.0 (percent power).
distancedistance in ticks (encoder motors only)

◆ run_until()

def vex.EncoderMotor.run_until (   self,
  power,
  distance 
)

Run at given power until the given distance is reached.

Parameters
power-100.0...100.0 (percent power).
distancedistance in ticks
Returns
True if the motor reached the target, False if stalled

◆ run_raw()

def vex.EncoderMotor.run_raw (   self,
  power_raw,
  distance = None 
)

Begin running at given raw power.

Parameters
power_raw-127.0...127.0 (raw power).
distancedistance in ticks (encoder motors only)

◆ run_raw_until()

def vex.EncoderMotor.run_raw_until (   self,
  power_raw,
  distance 
)

Run at given raw power until the given distance is reached.

Parameters
power_raw-127.0...127.0 (raw power).
distancedistance in ticks (encoder motors only)
Returns
True if the motor reached the target, False if stalled

◆ run_sync()

def vex.EncoderMotor.run_sync (   self,
  power,
  distance,
  motor_slave = None,
  motor_slave_rev = None 
)

Begin running at given power for given distance, sync with other motors.

Parameters
power-100.0...100.0 (percent power)
distancedistance in ticks
motor_slavemotor to run for the same distance. Pass either None, a single motor, or a list of motors.
motor_slave_revmotor to run for the same distance in reverse. Pass either None, a single motor, or a list of motors.

◆ run_sync_until()

def vex.EncoderMotor.run_sync_until (   self,
  power,
  distance,
  motor_slave = None,
  motor_slave_rev = None 
)

Run at given power until the given distance is reached, sync with other motors.

Parameters
power-100.0...100.0 (percent power)
distancedistance in ticks
motor_slavemotor to run for the same distance. Pass either None, a single motor, or a list of motors.
motor_slave_revmotor to run for the same distance in reverse. Pass either None, a single motor, or a list of motors.
Returns
True if the motor reached the target, False if stalled

◆ run_sync_raw()

def vex.EncoderMotor.run_sync_raw (   self,
  power_raw,
  distance,
  motor_slave = None,
  motor_slave_rev = None 
)

Begin running at given power for given distance, sync with other motors.

Parameters
power_raw-127.0...127.0 (raw power).
distancedistance in ticks
motor_slavemotor to run for the same distance. Pass either None, a single motor, or a list of motors.
motor_slave_revmotor to run for the same distance in reverse. Pass either None, a single motor, or a list of motors.

◆ run_sync_raw_until()

def vex.EncoderMotor.run_sync_raw_until (   self,
  power_raw,
  distance,
  motor_slave = None,
  motor_slave_rev = None 
)

Run at given raw power until the given distance is reached, sync with other motors.

Parameters
power_raw-127.0...127.0 (raw power).
distancedistance in ticks
motor_slavemotor to run for the same distance. Pass either None, a single motor, or a list of motors.
motor_slave_revmotor to run for the same distance in reverse. Pass either None, a single motor, or a list of motors.
Returns
True if the motor reached the target, False if stalled

◆ reached_target()

def vex.EncoderMotor.reached_target (   self)

True if the motor reached the target, False otherwise.

Returns
bool

◆ stalled()

def vex.EncoderMotor.stalled (   self)

True if motor has stalled (did not change position) for the duration set in the motor.stall_timeout field.

Returns
bool

◆ reached_target_or_stalled()

def vex.EncoderMotor.reached_target_or_stalled (   self)

True if motor reached the target or stalled (did not change position) for the duration in the motor.stall_timeout field.

Returns
bool

◆ position()

def vex.EncoderMotor.position (   self)

Get the current encoder position (dinstance) in ticks.

Returns
number

◆ reset_position()

def vex.EncoderMotor.reset_position (   self)

Reset the motor position to zero.

Member Data Documentation

◆ stall_timeout

vex.EncoderMotor.stall_timeout