VEX IQ Python API
Public Member Functions | Public Attributes | List of all members
vexiq.Motor Class Reference

Config Motor with power setting and distance encoder More...

Public Member Functions

def __init__ (self, port=None, switch_polarity=False)
 
def off (self)
 Turn off motor. More...
 
def brake (self)
 Brake motor. More...
 
def hold (self)
 Hold motor. More...
 
def run (self, power, distance=None, hold=False)
 Begin running at the given power. More...
 
def run_until (self, power, distance, hold=False)
 Run at a given power until the given distance is reached. More...
 
def run_raw (self, power_raw, distance_ticks=None, hold=False)
 Begin running at given raw power, with distance in ticks. More...
 
def run_raw_until (self, power, distance_ticks, hold=False)
 Run at a given raw power until the given distance is reached. More...
 
def run_to_position (self, power, position, hold=False)
 Begin running the motor until it reaches an absolute position. More...
 
def run_until_position (self, power, position, hold=False)
 Run the motor until it reaches an absolute position. More...
 
def run_time (self, power, time, hold=False)
 Begin running at given power for given time. More...
 
def run_until_time (self, power, time, hold=False)
 Run at given power until given time is reached. 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 set in the motor.stall_timeout field. More...
 
def position (self)
 Get the current motor position in degrees. More...
 
def position_ticks (self)
 Get the current motor position in ticks, 960 per full rotation. More...
 
def reset_position (self)
 Reset the motor position to zero. More...
 
def velocity (self)
 Get the current motor velocity. More...
 
def current (self)
 Get the electrical current. More...
 
def set_max_current (self, current)
 Set the maximum current setting. More...
 

Public Attributes

 stall_timeout
 

Detailed Description

Config Motor with power setting and distance encoder

Parameters
port1-12, None to autodetect. Default None.
switch_polarityTrue to reverse polarity (direction). Default False.

Constructor & Destructor Documentation

◆ __init__()

def vexiq.Motor.__init__ (   self,
  port = None,
  switch_polarity = False 
)

Member Function Documentation

◆ off()

def vexiq.Motor.off (   self)

Turn off motor.

◆ brake()

def vexiq.Motor.brake (   self)

Brake motor.

◆ hold()

def vexiq.Motor.hold (   self)

Hold motor.

◆ run()

def vexiq.Motor.run (   self,
  power,
  distance = None,
  hold = False 
)

Begin running at the given power.

Parameters
power-100.0...100.0 (percent power).
distancedistance in degrees
holdif True, hold motor when destination is reached

◆ run_until()

def vexiq.Motor.run_until (   self,
  power,
  distance,
  hold = False 
)

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

Parameters
power-100.0...100.0 (percent power).
distancedistance in degrees
holdif True, hold motor when destination is reached
Returns
True if the motor reached the target, False if stalled

◆ run_raw()

def vexiq.Motor.run_raw (   self,
  power_raw,
  distance_ticks = None,
  hold = False 
)

Begin running at given raw power, with distance in ticks.

Parameters
power_raw-127...127
distance_ticksdistance in ticks, 960 per full rotation
holdif True, hold motor when destination is reached

◆ run_raw_until()

def vexiq.Motor.run_raw_until (   self,
  power,
  distance_ticks,
  hold = False 
)

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

Parameters
power-100.0...100.0 (percent power).
distance_ticksdistance in ticks, 960 per full rotation
holdif True, hold motor when destination is reached
Returns
True if the motor reached the target, False if stalled

◆ run_to_position()

def vexiq.Motor.run_to_position (   self,
  power,
  position,
  hold = False 
)

Begin running the motor until it reaches an absolute position.

Parameters
power0...100.0 (percent power).
positionabsolute target position in degrees
holdif True, hold motor when destination is reached

◆ run_until_position()

def vexiq.Motor.run_until_position (   self,
  power,
  position,
  hold = False 
)

Run the motor until it reaches an absolute position.

Parameters
power0...100.0 (percent power).
positionabsolute target position in degrees
holdif True, hold motor when destination is reached
Returns
True if the motor reached the target, False if stalled

◆ run_time()

def vexiq.Motor.run_time (   self,
  power,
  time,
  hold = False 
)

Begin running at given power for given time.

Parameters
power-100.0...100.0 (percent power).
timetime to run in seconds
holdif True, hold motor when destination is reached

◆ run_until_time()

def vexiq.Motor.run_until_time (   self,
  power,
  time,
  hold = False 
)

Run at given power until given time is reached.

Parameters
power-100.0...100.0 (percent power).
timetime to run in seconds
holdif True, hold motor when destination is reached
Returns
True if the motor reached the target, False if stalled

◆ reached_target()

def vexiq.Motor.reached_target (   self)

True if the motor reached the target, False otherwise.

Returns
bool

◆ stalled()

def vexiq.Motor.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 vexiq.Motor.reached_target_or_stalled (   self)

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

Returns
bool

◆ position()

def vexiq.Motor.position (   self)

Get the current motor position in degrees.

Returns
number

◆ position_ticks()

def vexiq.Motor.position_ticks (   self)

Get the current motor position in ticks, 960 per full rotation.

Returns
number

◆ reset_position()

def vexiq.Motor.reset_position (   self)

Reset the motor position to zero.

◆ velocity()

def vexiq.Motor.velocity (   self)

Get the current motor velocity.

Returns
number

◆ current()

def vexiq.Motor.current (   self)

Get the electrical current.

Returns
number

◆ set_max_current()

def vexiq.Motor.set_max_current (   self,
  current 
)

Set the maximum current setting.

Parameters
currentmaximum current

Member Data Documentation

◆ stall_timeout

vexiq.Motor.stall_timeout