MotorVictor#

Inicializando la clase MotorVictor#

Un controlador Motor Victor se crea utilizando el siguiente constructor:

MotorVictor(port, reverse)

Este constructor utiliza dos parámetros:

Parámetro

Descripción

port

El puerto de 3 cables al que está conectado el controlador Motor Victor, ya sea un puerto en el Cerebro o un Expandedor de 3 cables.

reverse

Optional. Set this Motor to be reversed or not. If set to True, the Motor will spin in the opposite rotation. The default is False.

Primero se debe crear un Brain o un 3-Wire Expander antes de poder usarlos para crear un objeto con el constructor de clase MotorVictor.

# Create the Brain.
brain = Brain()
# Construct a Motor Victor Controller "victor" with the
# MotorVictor class.
victor = MotorVictor(brain.three_wire_port.a)

This victor object will be used in all subsequent examples throughout this API documentation when referring to MotorVictor class methods.

Métodos de clase#

spin()#

The spin(direction, velocty, units) method spins the Motor in a specified direction. The Motor is assumed to have a maximum velocity of 100 rpm.

Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.

Parámetros

Descripción

dirección

Un DirectionType válido.

velocidad

Optional. The velocity to spin the Motor. The default is the value set by the set_velocity() method.

unidades

Optional. A valid VelocityUnits type. The default is RPM.

Devoluciones: Ninguna.

# Spin the Motor forward at velocity set with set_velocity.
victor.spin(FORWARD)

stop()#

The stop() method stops the Motor.

Devoluciones: Ninguna.

set_velocity()#

The set_velocity() method sets the velocity of the Motor. This will be the velocity used for subsequent uses of spin() if a velocity is not provided.

Parámetros

Descripción

valor

El valor de velocidad a establecer.

unidades

Optional. A valid VelocityUnits type. The default is RPM.

Devoluciones: Ninguna.

set_reversed()#

The set_reversed() method sets the Motor direction to be reversed or not.

Parámetros

Descripción

valor

True to reverse the motor direction. False to maintain the normal direction.

Devoluciones: Ninguna.

# set Motor reversed flag True
victor.set_reversed(True)