motor_victor#

Initializing the motor_victor Class#

A Motor Victor Controller is created by using one of the following constructors:

The motor_victor constructor creates a motor_victor object in the specified Three Wire Port.

Parameter

Description

port

The 3-Wire Port that the Motor Victor Controller is connected to, whether it’s a port on the Brain, or a 3-Wire Expander.

// Create the Brain.
brain Brain;
// Construct a Motor Victor Controller "victor" with the
// MotorVictor class.
motor_victor victor = motor_victor(Brain.ThreeWirePort.A);

The motor_victor(port, reverse) constructor creates a motor_victor object in the specified Three Wire Port with the reverse flag set to the specified value.

Parameter

Description

port

The 3-Wire Port that the Motor Victor Controller is connected to, whether it’s a port on the Brain, or a 3-Wire Expander.

reverse

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

// Create the Brain.
brain Brain;
// Construct a Motor Victor Controller "victor" with the
// motor_victor class.
motor_victor victor = motor_victor(Brain.ThreeWirePort.A, true);

A Brain or 3-Wire Expander must be created first before they can be used to create an object with the motor_victor Class constructor.

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

Class Methods#

spin()#

This is a non-blocking method and allows the next method to run without delay.

This method is called in the following ways:

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

Parameters

Description

direction

A valid DirectionType.

Returns: None.

// Spin the Motor forward.
victor.spin(forward);

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.

Parameters

Description

direction

A valid DirectionType.

velocity

The velocity to spin the Motor.

units

A valid VelocityUnit.

Returns: None.

// Spin the Motor forward at 100 rpm.
victor.spin(forward, 100, rpm);

stop()#

The stop() method stops the Motor.

Returns: None.

setVelocity()#

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

Parameters

Description

value

The velocity value to set.

units

The only valid unit for velocity in this usecase is percent.

Returns: None.

setReversed()#

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

Parameters

Description

value

A boolean or binary value to set the reverse flag of the motor to true or false.

Returns: None.