Skip to Content
VectorLib

MotorGroup

vectorlib::MotorGroup — fields, methods, parameters and return types.


pub struct MotorGroup

A group of motors driven together. Port of the pros::MotorGroup subset LemLib uses.




// pros::MotorGroup leftMotors({-5, 4, -3}, pros::MotorGearset::blue);
let left_motors = MotorGroup::new([
    Motor::new(peripherals.port_5, Gearset::Blue, Direction::Reverse),
    Motor::new(peripherals.port_4, Gearset::Blue, Direction::Forward),
    Motor::new(peripherals.port_3, Gearset::Blue, Direction::Reverse),
]);

View source

Methods

Prop

Type

new

pub fn new<M: MotorDevice + 'static>(motors: impl IntoIterator<Item = M>) -> Self

Create a motor group from owned motors.

Parameters

Prop

Type

Returns

Self

View source

from_boxed

pub fn from_boxed(motors: Vec<Box<dyn MotorDevice>>) -> Self

Create a motor group from already-boxed motors (mixed motor types).

Parameters

Returns

Self

View source

move_

pub fn move_(&mut self, voltage: i32)

MotorGroup::move: set every motor to a power in [-127, 127].

Named move_ because move is a Rust keyword.

Parameters

Prop

Type

Returns

()

View source

brake

pub fn brake(&mut self)

MotorGroup::brake: stop every motor using its configured brake mode.

Returns

()

View source

set_brake_mode_all

pub fn set_brake_mode_all(&mut self, mode: BrakeMode)

MotorGroup::set_brake_mode_all.

Parameters

Prop

Type

Returns

()

View source

get_brake_mode_all

pub fn get_brake_mode_all(&self) -> Vec<BrakeMode>

MotorGroup::get_brake_mode_all.

Returns

Vec<BrakeMode>

View source

tare_position_all

pub fn tare_position_all(&mut self)

MotorGroup::tare_position_all.

Returns

()

View source

get_position_all

pub fn get_position_all(&self) -> Vec<f64>

MotorGroup::get_position_all, in rotations.

Returns

Vec<f64>

View source

get_gearing_all

pub fn get_gearing_all(&self) -> Vec<Option<Gearset>>

MotorGroup::get_gearing_all. None is an invalid gearset.

Returns

Vec<Option<Gearset>>

View source

size

pub fn size(&self) -> usize

Number of motors in the group.

Returns

usize

View source