Motors C++ API module
Contents
Files
- file motor_group.hpp
Functions
-
MotorGroup(const std::initializer_list<std::int8_t>,
const pros::
v5:: MotorGears gearset = pros:: v5:: MotorGears:: invalid, const pros:: v5:: MotorUnits encoder_units = pros::v5::MotorUnits::invalid) - Constructs a new MotorGroup object.
-
MotorGroup(const std::vector<std::int8_t>& ports,
const pros::
v5:: MotorGears gearset = pros:: v5:: MotorGears:: invalid, const pros:: v5:: MotorUnits encoder_units = pros::v5::MotorUnits::invalid) - Constructs a new MotorGroup object.
- MotorGroup(AbstractMotor& motor_group)
- Constructs a new MotorGroup object from an abstract motor.
Motor movement functions
These functions allow programmers to make motors move
- std::int32_t move(std::int32_t voltage) const virtual
- Sets the voltage for the motor group from -127 to 127.
- std::int32_t move_absolute(const double position, const std::int32_t velocity) const virtual
- Sets the target absolute position for the motor group to move to.
- std::int32_t move_relative(const double position, const std::int32_t velocity) const virtual
- Sets the relative target position for the motor group to move to.
- std::int32_t move_velocity(const std::int32_t velocity) const virtual
- Sets the velocity for the motor group.
- std::int32_t move_voltage(const std::int32_t voltage) const virtual
- Sets the output voltage for the motor group from -12000 to 12000 in millivolts.
- std::int32_t brake(void) const virtual
- Stops the motor group using the currently configured brake mode.
- std::int32_t modify_profiled_velocity(const std::int32_t velocity) const virtual
- Changes the output velocity for a profiled movement (move_absolute or move_relative).
- double get_target_position(const std::uint8_t index) const virtual
- Gets the target position set for a motor in the motor group, with a parameter for the motor index.
- std::vector<double> get_target_position_all(void) const virtual
- Gets a vector of the the target positions set for the motor group.
- std::int32_t get_target_velocity(const std::uint8_t index = 0) const virtual
- Gets the velocity commanded to the motor by the user at the index specified.
- std::vector<std::int32_t> get_target_velocity_all(void) const virtual
- Gets a vector of the velocity commanded to the motor by the user.
Motor telemetry functions
These functions allow programmers to collect telemetry from motors
- double get_actual_velocity(const std::uint8_t index = 0) const virtual
- Gets the actual velocity of a motor in the motor group.
- std::vector<double> get_actual_velocity_all(void) const virtual
- Gets a vector of the the actual velocity of each motor the motor group.
- std::int32_t get_current_draw(const std::uint8_t index = 0) const virtual
- Gets the current drawn by a motor in the motor group in mA.
- std::vector<std::int32_t> get_current_draw_all(void) const virtual
- Gets a vector of the current drawn each motor in the motor group in mA.
- std::int32_t get_direction(const std::uint8_t index = 0) const virtual
- Gets the direction of movement for a motor in the motor group.
- std::vector<std::int32_t> get_direction_all(void) const virtual
- Gets a vector of the directions of movement for each motor in the motor group.
- double get_efficiency(const std::uint8_t index = 0) const virtual
- Gets the efficiency of a motor in the motor group in percent.
- std::vector<double> get_efficiency_all(void) const virtual
- Gets a vector of the efficiency of each motor in percent.
- std::uint32_t get_faults(const std::uint8_t index = 0) const virtual
- Gets the faults experienced by a motor in the motor group.
- std::vector<std::uint32_t> get_faults_all(void) const virtual
- Gets a vector of the faults experienced by each motor in the motor group.
- std::uint32_t get_flags(const std::uint8_t index = 0) const virtual
- Gets the flags set by a motor in the motor group's operation.
- std::vector<std::uint32_t> get_flags_all(void) const virtual
- Gets a vector of the flags set by each motor in the motor groups's operation.
- double get_position(const std::uint8_t index = 0) const virtual
- Gets the absolute position of a motor in the motor group in its encoder units.
- std::vector<double> get_position_all(void) const virtual
- Gets a vector of the absolute position of each motor in its encoder units.
- double get_power(const std::uint8_t index = 0) const virtual
- Gets the power drawn by a motor in the motor group in Watts.
- std::vector<double> get_power_all(void) const virtual
- Gets a vector of the power drawn by each motor in the motor group in Watts.
- std::int32_t get_raw_position(std::uint32_t*const timestamp, const std::uint8_t index = 0) const virtual
- Gets the raw encoder count of a motor in the motor group at a given timestamp.
- std::vector<std::int32_t> get_raw_position_all(std::uint32_t*const timestamp) const virtual
- Gets the raw encoder count of each motor at a given timestamp.
- double get_temperature(const std::uint8_t index = 0) const virtual
- Gets the temperature of a motor in the motor group in degrees Celsius.
- std::vector<double> get_temperature_all(void) const virtual
- Gets the temperature of each motor in the motor group in degrees Celsius.
- double get_torque(const std::uint8_t index = 0) const virtual
- Gets the torque generated by a motor in the motor groupin Newton Meters (Nm).
- std::vector<double> get_torque_all(void) const virtual
- Gets a vector of the torque generated by each motor in Newton Meters (Nm).
- std::int32_t get_voltage(const std::uint8_t index = 0) const virtual
- Gets the voltage delivered to a motor in the motor group in millivolts.
- std::vector<std::int32_t> get_voltage_all(void) const virtual
- Gets a vector of the voltage delivered to each motor in millivolts.
- std::int32_t is_over_current(const std::uint8_t index = 0) const virtual
- Checks if a motor in the motor group is drawing over its current limit.
- std::vector<std::int32_t> is_over_current_all(void) const virtual
- Checks if each motor in the motor group is drawing over its current limit.
- std::int32_t is_over_temp(const std::uint8_t index = 0) const virtual
- Gets the temperature limit flag for a motor in the motor group.
- std::vector<std::int32_t> is_over_temp_all(void) const virtual
- Gets a vector with the temperature limit flag for each motor in the motor group.
Motor configuration functions
These functions allow programmers to configure the behavior of motors
- MotorBrake get_brake_mode(const std::uint8_t index = 0) const virtual
- Gets the brake mode that was set for a motor in the motor group.
- std::vector<MotorBrake> get_brake_mode_all(void) const virtual
- Gets a vector with the brake mode that was set for each motor in the motor group.
- std::int32_t get_current_limit(const std::uint8_t index = 0) const virtual
- Gets the current limit for a motor in the motor group in mA.
- std::vector<std::int32_t> get_current_limit_all(void) const virtual
- Gets a vector of the current limit for each motor in the motor group in mA.
- MotorUnits get_encoder_units(const std::uint8_t index = 0) const virtual
- Gets the encoder units that were set for a motor in the motor group.
- std::vector<MotorUnits> get_encoder_units_all(void) const virtual
- Gets a vector of the encoder units that were set for each motor in the motor group.
- MotorGears get_gearing(const std::uint8_t index = 0) const virtual
- Gets the gearset that was set for a motor in the motor group.
- std::vector<MotorGears> get_gearing_all(void) const virtual
- Gets a vector of the gearset that was set for each motor.
- std::vector<std::int8_t> get_port_all(void) const virtual
- Gets a vector with all the port numbers in the motor group.
- std::int32_t get_voltage_limit(const std::uint8_t index = 0) const virtual
- Gets the voltage limit of a motor in the motor group set by the user.
- std::vector<std::int32_t> get_voltage_limit_all(void) const virtual
- Gets a vector of the voltage limit of each motor in the motor group.
- std::int32_t is_reversed(const std::uint8_t index = 0) const virtual
- Gets the operation direction of a motor in the motor group as set by the user.
- std::vector<std::int32_t> is_reversed_all(void) const virtual
- Gets a vector of the operation direction of each motor in the motor group as set by the user.
- std::int32_t set_brake_mode(const MotorBrake mode, const std::uint8_t index = 0) const virtual
- Sets one of MotorBrake to a motor in the motor group.
- std::int32_t set_brake_mode(const pros::motor_brake_mode_e_t mode, const std::uint8_t index = 0) const virtual
- Sets one of MotorBrake to a motor in the motor group.
- std::int32_t set_brake_mode_all(const MotorBrake mode) const virtual
- Sets one of MotorBrake all the motors in the motor group.
- std::int32_t set_brake_mode_all(const pros::motor_brake_mode_e_t mode) const virtual
- Sets one of MotorBrake to a motor in the motor group.
- std::int32_t set_current_limit(const std::int32_t limit, const std::uint8_t index = 0) const virtual
- Sets the current limit for one motor in the motor group in mA.
- std::int32_t set_current_limit_all(const std::int32_t limit) const virtual
- Sets the current limit for every motor in the motor group in mA.
- std::int32_t set_encoder_units(const MotorUnits units, const std::uint8_t index = 0) const virtual
- Sets one of MotorUnits for one motor in the motor group's motor encoder.
- std::int32_t set_encoder_units(const pros::motor_encoder_units_e_t units, const std::uint8_t index = 0) const virtual
- Sets one of MotorUnits for one motor in the motor group's motor encoder.
- std::int32_t set_encoder_units_all(const MotorUnits units) const virtual
- Sets one of MotorUnits for every motor in the motor group's motor encoder.
- std::int32_t set_encoder_units_all(const pros::motor_encoder_units_e_t units) const virtual
- Sets one of MotorUnits for every motor in the motor group's motor encoder.
- std::int32_t set_gearing(std::vector<pros::motor_gearset_e_t> gearsets) const
- Sets one of the gear cartridge (red, green, blue) for one motor in the motor group.
- std::int32_t set_gearing(const pros::motor_gearset_e_t gearset, const std::uint8_t index = 0) const virtual
- Sets one of the gear cartridge (red, green, blue) for one motor in the motor group.
- std::int32_t set_gearing(std::vector<MotorGears> gearsets) const
- Sets the gear cartridge (red, green, blue) for each motor in the motor group by taking in a vector of the cartridges.
- std::int32_t set_gearing(const MotorGears gearset, const std::uint8_t index = 0) const virtual
- Sets one of the gear cartridge (red, green, blue) for one motor in the motor group.
- std::int32_t set_gearing_all(const MotorGears gearset) const virtual
- Sets one of the gear cartridge (red, green, blue) for one motor in the motor group.
- std::int32_t set_gearing_all(const pros::motor_gearset_e_t gearset) const virtual
- Sets one of the gear cartridge (red, green, blue) for every motor in the motor group.
- std::int32_t set_reversed(const bool reverse, const std::uint8_t index = 0) virtual
- sets the reversal for a motor in the motor group.
- std::int32_t set_reversed_all(const bool reverse) virtual
- Sets the reversal for all the motors in the motor group.
- std::int32_t set_voltage_limit(const std::int32_t limit, const std::uint8_t index = 0) const virtual
- Sets the voltage limit for a motor in the motor group in millivolts.
- std::int32_t set_voltage_limit_all(const std::int32_t limit) const virtual
- Sets the voltage limit for every motor in the motor group in millivolts.
- std::int32_t set_zero_position(const double position, const std::uint8_t index = 0) const virtual
- Sets the position for a motor in the motor group in its encoder units.
- std::int32_t set_zero_position_all(const double position) const virtual
- Sets the position for every motor in the motor group in its encoder units.
- std::int32_t tare_position(const std::uint8_t index = 0) const virtual
- Sets the "absolute" zero position of a motor in the motor group to its current position.
- std::int32_t tare_position_all(void) const virtual
- Sets the "absolute" zero position of every motor in the motor group to its current position.
- std::int8_t size(void) const virtual
- Returns the number of motors in the motor group.
- std::int8_t get_port(const std::uint8_t index = 0) const virtual
- Gets the port of a motor in the motor group via index.
- void operator+=(AbstractMotor&)
- Appends all the motors in the other motor group reference to this motor group.
- void append(AbstractMotor&)
- Appends all the motors in the other motor group reference to this motor group.
- void erase_port(std::int8_t port)
- Removes the all motors on the port (regardless of reversal) from the motor group.
Variables
- std::vector<std::int8_t> _ports
- The ordered vector of ports used by the motor group.
-
pros::
Mutex _MotorGroup_mutex
Function documentation
MotorGroup(const std::initializer_list<std::int8_t>,
const pros:: v5:: MotorGears gearset = pros:: v5:: MotorGears:: invalid,
const pros:: v5:: MotorUnits encoder_units = pros::v5::MotorUnits::invalid)
#include <pros/motor_group.hpp>
Constructs a new MotorGroup object.
Parameters | |
---|---|
gearset | = pros:: |
encoder_units | = pros::v5::MotorUnits::invalid Optional parameter for the encoder units of the motor Does not explicitly set the motor units if it is invalid or not specified |
This function uses the following values of errno when an error state is reached: ENXIO - The given value is not within the range of V5 ports |1-21|. ENODEV - The port cannot be configured as a motor
Example
void opcontrol() { MotorGroup first_mg({1, -2}); //Creates a motor on port 1 and a reversed motor on port 2 MotorGroup rotations_mg({4, 5}, pros::v5::MotorGears::blue, pros::v5::MotorUnits::rotations); //Creates a motor group on ports 4 and 5 with blue motors using rotaions as the encoder units }
MotorGroup(const std::vector<std::int8_t>& ports,
const pros:: v5:: MotorGears gearset = pros:: v5:: MotorGears:: invalid,
const pros:: v5:: MotorUnits encoder_units = pros::v5::MotorUnits::invalid)
#include <pros/motor_group.hpp>
Constructs a new MotorGroup object.
Parameters | |
---|---|
ports | |
gearset | = pros:: |
encoder_units | = pros::v5::MotorUnits::invalid Optional parameter for the encoder units of the motor Does not explicitly set the motor units if it is invalid or not specified |
This function uses the following values of errno when an error state is reached:
ENXIO - The given value is not within the range of V5 ports |1-21|.
ENODEV - The port cannot be configured as a motor
EDOM - The motor group is empty
Example
void opcontrol() { MotorGroup first_mg({1, -2}); //Creates a motor on port 1 and a reversed motor on port 2 with with both motors using the green gearset and degrees as the encoder units MotorGroup rotations_mg({4, 5}, pros::v5::MotorGears::blue, pros::v5::MotorUnits::rotations); //Creates a motor group on ports 4 and 5 with blue motors using rotaions as the encoder units }
MotorGroup(AbstractMotor& motor_group)
#include <pros/motor_group.hpp>
Constructs a new MotorGroup object from an abstract motor.
This function uses the following values of errno when an error state is reached:
ENXIO - The given value is not within the range of V5 ports |1-21|.
ENODEV - The port cannot be configured as a motor
EDOM - The motor group is empty
Example
void opcontrol() { MotorGroup first_mg({1, -2}); //Creates a motor on port 1 and a reversed motor on port 2 with with both motors using the green gearset and degrees as the encoder units AbstractMotor abs_mtr_group = first_mg; MotorGroup new_mg = (MotorGroup) abs_mtr_group; }
std::int32_t move(std::int32_t voltage) const virtual
#include <pros/motor_group.hpp>
Sets the voltage for the motor group from -127 to 127.
Parameters | |
---|---|
voltage | The new voltage from -127 to 127 |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
This is designed to map easily to the input from the controller's analog stick for simple opcontrol use. The actual behavior of the motor is analogous to use of motor_
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void opcontrol() { pros::MotorGroup MotorGroup ({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg.move(master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y)); pros::delay(2); } }
std::int32_t move_absolute(const double position,
const std::int32_t velocity) const virtual
#include <pros/motor_group.hpp>
Sets the target absolute position for the motor group to move to.
Parameters | |
---|---|
position | The absolute position to move to in the motor's encoder units |
velocity | The maximum allowable velocity for the movement in RPM |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
This movement is relative to the position of the motor when initialized or the position when it was most recently reset with pros::
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - the motor group has size 0
Example
void autonomous() { pros::MotorGroup mg ({1,3}); mg.move_absolute(100, 100); // Moves 100 units forward while (!((mg.get_position() < 105) && (mg.get_position() > 95))) { // Continue running this loop as long as the mg is not within +-5 units of its goal pros::delay(2); } mg.move_absolute(100, 100); // This does not cause a movement while (!((mg.get_position() < 105) && (mg.get_position() > 95))) { pros::delay(2); } mg.tare_position(); mg.move_absolute(100, 100); // Moves 100 units forward while (!((mg.get_position() < 105) && (mg.get_position() > 95))) { pros::delay(2); } }
std::int32_t move_relative(const double position,
const std::int32_t velocity) const virtual
#include <pros/motor_group.hpp>
Sets the relative target position for the motor group to move to.
Parameters | |
---|---|
position | The relative position to move to in the motor's encoder units |
velocity | The maximum allowable velocity for the movement in RPM |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
This movement is relative to the current position of each motor as given in pros::
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void autonomous() { pros::MotorGroup mg({1,3}); mg.move_relative(100, 100); // Moves 100 units forward while (!((mg.get_position() < 105) && (mg.get_position() > 95))) { // Continue running this loop as long as the motor is not within +-5 units of its goal pros::delay(2); } mg.move_relative(100, 100); // Also moves 100 units forward while (!((mg.get_position() < 205) && (mg.get_position() > 195))) { pros::delay(2); } }
std::int32_t move_velocity(const std::int32_t velocity) const virtual
#include <pros/motor_group.hpp>
Sets the velocity for the motor group.
Parameters | |
---|---|
velocity | The new velocity from +-100, +-200, or +-600 depending on the motor's gearset |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
This velocity corresponds to different actual speeds depending on the gearset used for the motor. This results in a range of +-100 for E_MOTOR_GEARSET_36, +-200 for E_MOTOR_GEARSET_18, and +-600 for E_MOTOR_GEARSET_6. The velocity is held with PID to ensure consistent speed, as opposed to setting the motor's voltage.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void autonomous() { pros::MotorGroup mg({1,3}); mg.move_velocity(100); pros::delay(1000); // Move at 100 RPM for 1 second mg.move_velocity(0); }
std::int32_t move_voltage(const std::int32_t voltage) const virtual
#include <pros/motor_group.hpp>
Sets the output voltage for the motor group from -12000 to 12000 in millivolts.
Parameters | |
---|---|
voltage | The new voltage value from -12000 to 12000 |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor
Example
void autonomous() { mg.move_voltage(12000); pros::delay(1000); // Move at max voltage for 1 second mg.move_voltage(0); }
std::int32_t brake(void) const virtual
#include <pros/motor_group.hpp>
Stops the motor group using the currently configured brake mode.
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
---|
This function sets motor velocity to zero, which will cause it to act according to the set brake mode. If brake mode is set to MOTOR_BRAKE_HOLD, this function may behave differently than calling move_absolute(0) or motor_move_relative(0).
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor
EDOM - The motor group is empty
Example
void autonomous() { Motor motor(1); mg.move_voltage(12000); pros::delay(1000); // Move at max voltage for 1 second motor.brake(); }
std::int32_t modify_profiled_velocity(const std::int32_t velocity) const virtual
#include <pros/motor_group.hpp>
Changes the output velocity for a profiled movement (move_absolute or move_relative).
Parameters | |
---|---|
velocity | The new motor velocity from +-100, +-200, or +-600 depending on the motor's gearset |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
This will have no effect if the motor group is not following a profiled movement.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void autonomous() { pros::MotorGroup mg ({1,3}); mg.move_absolute(100, 100); pros::delay(100); mg.modify_profiled_velocity(0); // Stop the motor group early }
double get_target_position(const std::uint8_t index) const virtual
#include <pros/motor_group.hpp>
Gets the target position set for a motor in the motor group, with a parameter for the motor index.
Parameters | |
---|---|
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | The target position in its encoder units or PROS_ERR_F if the operation failed, setting errno. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void autonomous() { pros::MotorGroup mg({1,3}); mg.move_absolute(100, 100); // get the target position from motor at index 1. (port 3) std::cout << "Motor Target: " << mg.get_target_position(1); // Prints 100 }
std::vector<double> get_target_position_all(void) const virtual
#include <pros/motor_group.hpp>
Gets a vector of the the target positions set for the motor group.
Returns | The a vector of the target positions in its encoder units or PROS_ERR_F if the operation failed, setting errno. |
---|
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The Motor group is empty
Example
void autonomous() { pros::MotorGroup mg({1,3}); mg.move_absolute(100, 100); std::cout << "Motor Target: " << mg.get_target_position_all()[0]; // Prints 100 }
std::int32_t get_target_velocity(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the velocity commanded to the motor by the user at the index specified.
Parameters | |
---|---|
index | Optional parameter. The zero indexed index of the motor in the motor group |
Returns | The commanded motor velocity from +-100, +-200, or +-600, or PROS_ERR if the operation failed, setting errno. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void opcontrol() { pros::MotorGroup mg ({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg.move_velocity(master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y)); // get the target velocity from motor at index 1. (port 3) std::cout << "Motor Velocity: " << mg.get_target_velocity(1); pros::delay(2); } }
std::vector<std::int32_t> get_target_velocity_all(void) const virtual
#include <pros/motor_group.hpp>
Gets a vector of the velocity commanded to the motor by the user.
Returns | A vector of the commanded motor velocity from +-100, +-200, or +-600, or PROS_ERR if the operation failed, setting errno. |
---|
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - THe motor group is empty
Example
void opcontrol() { pros::MotorGroup mg ({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg.move_velocity(master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y)); std::cout << "Motor Velocity: " << mg.get_target_velocity_all(); pros::delay(2); } }
double get_actual_velocity(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the actual velocity of a motor in the motor group.
Parameters | |
---|---|
index | Optional parameter. The zero indexed index of the motor in the motor group |
Returns | The motor's actual velocity in RPM or PROS_ERR_F if the operation failed, setting errno. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor
EDOM - THe motor group is empty
EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void opcontrol() { pros::MotorGroup mg({1,3}); while (true) { mg = controller_get_analog(E_CONTROLLER_MASTER, E_CONTROLLER_ANALOG_LEFT_Y); // get the actual velocity from motor at index 1. (port 3) printf("Actual velocity: %lf\n", mg.get_actual_velocity(1)); pros::delay(2); } }
std::vector<double> get_actual_velocity_all(void) const virtual
#include <pros/motor_group.hpp>
Gets a vector of the the actual velocity of each motor the motor group.
Returns | A vector of the each motor's actual velocity in RPM or PROS_ERR_F if the operation failed, setting errno. |
---|
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor
EDOM - THe motor group is empty
Example
void opcontrol() { pros::MotorGroup mg({1,3}); while (true) { mg = controller_get_analog(E_CONTROLLER_MASTER, E_CONTROLLER_ANALOG_LEFT_Y); // get the target velocity from motor at index 1. (port 3) printf("Actual velocity: %lf\n", mg.get_actual_velocity(1)); pros::delay(2); } }
std::int32_t get_current_draw(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the current drawn by a motor in the motor group in mA.
Parameters | |
---|---|
index | Optional parameter. The zero indexed index of the motor in the motor group |
Returns | The motor's current in mA or PROS_ERR if the operation failed, setting errno. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor
EDOM - The motor group is empty
EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); //Print the current draw for the motor at index 1. (port 3) std::cout << "Motor Current Draw: " << mg.get_current_draw(1); pros::delay(2); } }
std::vector<std::int32_t> get_current_draw_all(void) const virtual
#include <pros/motor_group.hpp>
Gets a vector of the current drawn each motor in the motor group in mA.
Returns | A vector with each motor's current in mA or PROS_ERR if the operation failed, setting errno. |
---|
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor
EDOM - The motor group is empty
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Motor Current Draw: " << mg.get_current_draw_all(); pros::delay(2); } }
std::int32_t get_direction(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the direction of movement for a motor in the motor group.
Parameters | |
---|---|
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | 1 for moving in the positive direction, -1 for moving in the negative direction, and PROS_ERR if the operation failed, setting errno. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor
EDOM - The motor group is empty
EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); //Print the motor direction for the motor at index 1. (port 3) std::cout << "Motor Direction: " << mg.get_direction(); pros::delay(2); } }
std::vector<std::int32_t> get_direction_all(void) const virtual
#include <pros/motor_group.hpp>
Gets a vector of the directions of movement for each motor in the motor group.
Returns | 1 for moving in the positive direction, -1 for moving in the negative direction, and PROS_ERR if the operation failed, setting errno. |
---|
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor
EDOM - The motor group is empty
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Motor Direction: " << mg.get_direction_all()[0]; pros::delay(2); } }
double get_efficiency(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the efficiency of a motor in the motor group in percent.
Parameters | |
---|---|
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | The motor's efficiency in percent or PROS_ERR_F if the operation failed, setting errno. |
An efficiency of 100% means that the motor is moving electrically while drawing no electrical power, and an efficiency of 0% means that the motor is drawing power but not moving.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor
EDOM - The motor group is empty
EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); //Prints the efficiency of the motor at index 1 (port 3) std::cout << "Motor Efficiency: " << mg.get_efficiency(1); pros::delay(2); } }
std::vector<double> get_efficiency_all(void) const virtual
#include <pros/motor_group.hpp>
Gets a vector of the efficiency of each motor in percent.
Returns | A vector containing each motor's efficiency in percent or PROS_ERR_F if the operation failed, setting errno. |
---|
An efficiency of 100% means that the motor is moving electrically while drawing no electrical power, and an efficiency of 0% means that the motor is drawing power but not moving.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor
EDOM - THe motor group is empty
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Motor Efficiency: " << mg.get_efficiency_all()[0]; pros::delay(2); } }
std::uint32_t get_faults(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the faults experienced by a motor in the motor group.
Parameters | |
---|---|
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | A bitfield containing the motor's faults. |
Compare this bitfield to the bitmasks in pros::motor_fault_e_t.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor
EDOM - The motor group is empty
EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Motor Faults: " << mg.get_faults(); pros::delay(2); } }
std::vector<std::uint32_t> get_faults_all(void) const virtual
#include <pros/motor_group.hpp>
Gets a vector of the faults experienced by each motor in the motor group.
Returns | A vector containing the bitfields containing each motor's faults. |
---|
Compare these bitfields to the bitmasks in pros::motor_fault_e_t.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor
EDOM - The motor group is empty
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Motor Faults: " << mg.get_faults_all(); pros::delay(2); } }
std::uint32_t get_flags(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the flags set by a motor in the motor group's operation.
Parameters | |
---|---|
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | A bitfield containing the motor's flags. |
Compare this bitfield to the bitmasks in pros::motor_flag_e_t.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Motor Faults: " << mg.get_faults(1); pros::delay(2); } }
std::vector<std::uint32_t> get_flags_all(void) const virtual
#include <pros/motor_group.hpp>
Gets a vector of the flags set by each motor in the motor groups's operation.
Returns | A bitfield containing the motor's flags. |
---|
Compare this bitfield to the bitmasks in pros::motor_flag_e_t.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Motor Faults: " << mg.get_faults_all()[0]; pros::delay(2); } }
double get_position(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the absolute position of a motor in the motor group in its encoder units.
Parameters | |
---|---|
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | The motor's absolute position in its encoder units or PROS_ERR_F if the operation failed, setting errno. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Motor Position: " << mg.get_position(1); pros::delay(2); } }
std::vector<double> get_position_all(void) const virtual
#include <pros/motor_group.hpp>
Gets a vector of the absolute position of each motor in its encoder units.
Returns | A vector of the motor's absolute position in its encoder units or PROS_ERR_F if the operation failed, setting errno. |
---|
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Motor Position: " << mg.get_position_all(); pros::delay(2); } }
double get_power(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the power drawn by a motor in the motor group in Watts.
Parameters | |
---|---|
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | The motor's power draw in Watts or PROS_ERR_F if the operation failed, setting errno. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Motor Power: " << mg.get_power(); pros::delay(2); } }
std::vector<double> get_power_all(void) const virtual
#include <pros/motor_group.hpp>
Gets a vector of the power drawn by each motor in the motor group in Watts.
Returns | A vector of each motor's power draw in Watts or PROS_ERR_F if the operation failed, setting errno. |
---|
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Motor Power: " << mg.get_power_all()[0]; pros::delay(2); } }
std::int32_t get_raw_position(std::uint32_t*const timestamp,
const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the raw encoder count of a motor in the motor group at a given timestamp.
Parameters | |
---|---|
timestamp | A pointer to a time in milliseconds for which the encoder count will be returned. If NULL, the timestamp at which the encoder count was read will not be supplied |
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | The raw encoder count at the given timestamp or PROS_ERR if the operation failed. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void opcontrol() { std::uint32_t now = pros::millis(); pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Motor Position: " << mg.get_raw_position(&now); pros::delay(2); } }
std::vector<std::int32_t> get_raw_position_all(std::uint32_t*const timestamp) const virtual
#include <pros/motor_group.hpp>
Gets the raw encoder count of each motor at a given timestamp.
Parameters | |
---|---|
timestamp | A pointer to a time in milliseconds for which the encoder count will be returned. If NULL, the timestamp at which the encoder count was read will not be supplied |
Returns | A vector of each raw encoder count at the given timestamp or PROS_ERR if the operation failed. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor
Example
void opcontrol() { std::uint32_t now = pros::millis(); pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Motor Position: " << mg.get_raw_position_all(&now)[0]; pros::delay(2); } }
double get_temperature(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the temperature of a motor in the motor group in degrees Celsius.
Parameters | |
---|---|
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | The motor's temperature in degrees Celsius or PROS_ERR_F if the operation failed, setting errno. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Motor Temperature: " << mg.get_temperature(); pros::delay(2); } }
std::vector<double> get_temperature_all(void) const virtual
#include <pros/motor_group.hpp>
Gets the temperature of each motor in the motor group in degrees Celsius.
Returns | A vector of each motor's temperature in degrees Celsius or PROS_ERR_F if the operation failed, setting errno. |
---|
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Motor Temperature: " << mg.get_temperature_all()[1]; pros::delay(2); } }
double get_torque(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the torque generated by a motor in the motor groupin Newton Meters (Nm).
Parameters | |
---|---|
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | The motor's torque in Nm or PROS_ERR_F if the operation failed, setting errno. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Motor Torque: " << mg.get_torque(); pros::delay(2); } }
std::vector<double> get_torque_all(void) const virtual
#include <pros/motor_group.hpp>
Gets a vector of the torque generated by each motor in Newton Meters (Nm).
Returns | A vector containing each motor's torque in Nm or PROS_ERR_F if the operation failed, setting errno. |
---|
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Motor Torque: " << mg.get_torque(); pros::delay(2); } }
std::int32_t get_voltage(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the voltage delivered to a motor in the motor group in millivolts.
Parameters | |
---|---|
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | The motor's voltage in mV or PROS_ERR_F if the operation failed, setting errno. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Motor Voltage: " << mg.get_voltage(); pros::delay(2); } }
std::vector<std::int32_t> get_voltage_all(void) const virtual
#include <pros/motor_group.hpp>
Gets a vector of the voltage delivered to each motor in millivolts.
Returns | A vector of each motor's voltage in mV or PROS_ERR_F if the operation failed, setting errno. |
---|
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Motor Voltage: " << mg.get_voltage_all()[0]; pros::delay(2); } }
std::int32_t is_over_current(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Checks if a motor in the motor group is drawing over its current limit.
Parameters | |
---|---|
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | 1 if the motor's current limit is being exceeded and 0 if the current limit is not exceeded, or PROS_ERR if the operation failed, setting errno. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Is the motor over its current limit?: " << mg.is_over_current(); pros::delay(2); } }
std::vector<std::int32_t> is_over_current_all(void) const virtual
#include <pros/motor_group.hpp>
Checks if each motor in the motor group is drawing over its current limit.
Returns | A vector containing the following for each motor: 1 if the motor's current limit is being exceeded and 0 if the current limit is not exceeded, or PROS_ERR if the operation failed, setting errno. |
---|
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Is the motor over its current limit?: " << motor.is_over_current_all()[0]; pros::delay(2); } }
std::int32_t is_over_temp(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the temperature limit flag for a motor in the motor group.
Parameters | |
---|---|
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | 1 if the temperature limit is exceeded and 0 if the temperature is below the limit, or PROS_ERR if the operation failed, setting errno. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Is the motor over its temperature limit?: " << motor.is_over_temp(); pros::delay(2); } }
std::vector<std::int32_t> is_over_temp_all(void) const virtual
#include <pros/motor_group.hpp>
Gets a vector with the temperature limit flag for each motor in the motor group.
Returns | 1 if the temperature limit is exceeded and 0 if the temperature is below the limit, or PROS_ERR if the operation failed, setting errno. |
---|
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); std::cout << "Is the motor over its temperature limit?: " << motor.is_over_temp(); pros::delay(2); } }
MotorBrake get_brake_mode(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the brake mode that was set for a motor in the motor group.
Parameters | |
---|---|
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | One of MotorBrake, according to what was set for the motor, or E_MOTOR_BRAKE_INVALID if the operation failed, setting errno. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void initialize() { pros::MotorGroup mg({1,3}); mg.set_brake_mode(pros::E_MOTOR_BRAKE_HOLD); std::cout << "Brake Mode: " << mg.get_brake_mode(); }
std::vector<MotorBrake> get_brake_mode_all(void) const virtual
#include <pros/motor_group.hpp>
Gets a vector with the brake mode that was set for each motor in the motor group.
Returns | A vector with one of MotorBrake for each motor in the motor group, according to what was set for the motor, or E_MOTOR_BRAKE_INVALID if the operation failed, setting errno. |
---|
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void initialize() { pros::MotorGroup mg({1,3}); mg.set_brake_mode(pros::E_MOTOR_BRAKE_HOLD); std::cout << "Brake Mode: " << mg.get_brake_mode_all()[0]; }
std::int32_t get_current_limit(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the current limit for a motor in the motor group in mA.
Parameters | |
---|---|
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | The motor's current limit in mA or PROS_ERR if the operation failed, setting errno. |
The default value is 2500 mA.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void opcontrol() { pros::MotorGroup mg({1,3}); while (true) { std::cout << "Motor Current Limit: " << mg.get_current_limit(); pros::delay(2); } }
std::vector<std::int32_t> get_current_limit_all(void) const virtual
#include <pros/motor_group.hpp>
Gets a vector of the current limit for each motor in the motor group in mA.
Returns | A vector of each motor's current limit in mA or PROS_ERR if the operation failed, setting errno. |
---|
The default value is 2500 mA.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void opcontrol() { pros::MotorGroup mg({1,3}); while (true) { std::cout << "Motor Current Limit: " << mg.get_current_limit_all()[0]; pros::delay(2); } }
MotorUnits get_encoder_units(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the encoder units that were set for a motor in the motor group.
Parameters | |
---|---|
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | One of MotorUnits according to what is set for the motor or E_MOTOR_ENCODER_INVALID if the operation failed. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void initialize() { pros::MotorGroup mg ({1,3}, E_MOTOR_GEARSET_06, false, E_MOTOR_ENCODER_COUNTS); std::cout << "Motor Encoder Units: " << mg.get_encoder_units(); }
std::vector<MotorUnits> get_encoder_units_all(void) const virtual
#include <pros/motor_group.hpp>
Gets a vector of the encoder units that were set for each motor in the motor group.
Returns | A vector with the following for each motor, One of MotorUnits according to what is set for the motor or E_MOTOR_ENCODER_INVALID if the operation failed. |
---|
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void initialize() { pros::MotorGroup mg ({1,3}, E_MOTOR_GEARSET_06, false, E_MOTOR_ENCODER_COUNTS); std::cout << "Motor Encoder Units: " << mg.get_encoder_units_all()[0]; }
MotorGears get_gearing(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the gearset that was set for a motor in the motor group.
Parameters | |
---|---|
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | One of MotorGears according to what is set for the motor, or pros::MotorGears::invalid if the operation failed. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void initialize() { pros::MotorGroup mg ({1,3}, E_MOTOR_GEARSET_06, false, E_MOTOR_ENCODER_COUNTS); std::cout << "Motor Gearing: " << mg.get_gearing(); }
std::vector<MotorGears> get_gearing_all(void) const virtual
#include <pros/motor_group.hpp>
Gets a vector of the gearset that was set for each motor.
Returns | A vector with one of MotorGears according to what is set for the motor, or pros::MotorGears::invalid if the operation failed for each motor. |
---|
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void initialize() { pros::MotorGroup mg ({1,3}, E_MOTOR_GEARSET_06, false, E_MOTOR_ENCODER_COUNTS); std::cout << "Motor Gearing: " << mg.get_gearing_all()[0]; }
std::vector<std::int8_t> get_port_all(void) const virtual
#include <pros/motor_group.hpp>
Gets a vector with all the port numbers in the motor group.
Returns | a vector with all the port numbers for the motor group |
---|
A port will be negative if the motor in the motor group is reversed
std::int32_t get_voltage_limit(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the voltage limit of a motor in the motor group set by the user.
Parameters | |
---|---|
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | The motor's voltage limit in V or PROS_ERR if the operation failed, setting errno. |
Default value is 0V, which means that there is no software limitation imposed on the voltage.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void initialize() { pros::MotorGroup mg({1,3}); std::cout << "Motor Voltage Limit: " << mg.get_voltage_limit(1); }
std::vector<std::int32_t> get_voltage_limit_all(void) const virtual
#include <pros/motor_group.hpp>
Gets a vector of the voltage limit of each motor in the motor group.
Returns | The motor's voltage limit in V or PROS_ERR if the operation failed, setting errno. |
---|
Default value is 0V, which means that there is no software limitation imposed on the voltage.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The Motor group is empty
Example
void initialize() { pros::MotorGroup mg({1,3}); std::cout << "Motor Voltage Limit: " << mg.get_voltage_limit_all()[0]; }
std::int32_t is_reversed(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the operation direction of a motor in the motor group as set by the user.
Parameters | |
---|---|
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | 1 if the motor has been reversed and 0 if the motor was not reversed, or PROS_ERR if the operation failed, setting errno. |
This function uses the following values of errno when an error state is reached:
EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void initialize() { pros::MotorGroup mg({1,3}); std::cout << "Is the motor reversed? " << motor.is_reversed(); // Prints "0" }
std::vector<std::int32_t> is_reversed_all(void) const virtual
#include <pros/motor_group.hpp>
Gets a vector of the operation direction of each motor in the motor group as set by the user.
Returns | A vector conatining the following for each motor: 1 if the motor has been reversed and 0 if the motor was not reversed, or PROS_ERR if the operation failed, setting errno. |
---|
This function uses the following values of errno when an error state is reached: EDOM - The motor group is empty
Example
void initialize() { pros::MotorGroup mg({1,3}); std::cout << "Is the motor reversed? " << motor.is_reversed_all()[0]; // Prints "0" }
std::int32_t set_brake_mode(const MotorBrake mode,
const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Sets one of MotorBrake to a motor in the motor group.
Parameters | |
---|---|
mode | The MotorBrake to set for the motor |
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
Works with the C enum and the C++ enum class.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void initialize() { pros::MotorGroup mg({1,3}); mg.set_brake_mode(pros::MotorBrake::brake, 1); std::cout << "Brake Mode: " << mg.get_brake_mode(); }
std::int32_t set_brake_mode(const pros::motor_brake_mode_e_t mode,
const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Sets one of MotorBrake to a motor in the motor group.
Parameters | |
---|---|
mode | The MotorBrake to set for the motor |
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
Works with the C enum and the C++ enum class.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void initialize() { pros::MotorGroup mg({1,3}); mg.set_brake_mode(pros::E_MOTOR_BRAKE_HOLD, 1); std::cout << "Brake Mode: " << mg.get_brake_mode(); }
std::int32_t set_brake_mode_all(const MotorBrake mode) const virtual
#include <pros/motor_group.hpp>
Sets one of MotorBrake all the motors in the motor group.
Parameters | |
---|---|
mode | The MotorBrake to set for the motor |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
Works with the C enum and the C++ enum class.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void initialize() { pros::MotorGroup mg({1,3}); mg.set_brake_mode_all(pros::MotorBrake:brake); std::cout << "Brake Mode: " << mg.get_brake_mode(); }
std::int32_t set_brake_mode_all(const pros::motor_brake_mode_e_t mode) const virtual
#include <pros/motor_group.hpp>
Sets one of MotorBrake to a motor in the motor group.
Parameters | |
---|---|
mode | The MotorBrake to set for the motor |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
Works with the C enum and the C++ enum class.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void initialize() { pros::MotorGroup mg({1,3}); mg.set_brake_mode_all(pros::E_MOTOR_BRAKE_HOLD); std::cout << "Brake Mode: " << mg.get_brake_mode(); }
std::int32_t set_current_limit(const std::int32_t limit,
const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Sets the current limit for one motor in the motor group in mA.
Parameters | |
---|---|
limit | The new current limit in mA |
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); mg.set_current_limit(1000); while (true) { mg = controller_get_analog(E_CONTROLLER_ANALOG_LEFT_Y); // The motor will reduce its output at 1000 mA instead of the default 2500 mA pros::delay(2); } }
std::int32_t set_current_limit_all(const std::int32_t limit) const virtual
#include <pros/motor_group.hpp>
Sets the current limit for every motor in the motor group in mA.
Parameters | |
---|---|
limit | The new current limit in mA |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group was empty
Example
void opcontrol() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); mg.set_current_limit_all(1000); while (true) { mg = controller_get_analog(E_CONTROLLER_ANALOG_LEFT_Y); // The motor will reduce its output at 1000 mA instead of the default 2500 mA pros::delay(2); } }
std::int32_t set_encoder_units(const MotorUnits units,
const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Sets one of MotorUnits for one motor in the motor group's motor encoder.
Parameters | |
---|---|
units | The new motor encoder units |
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
Works with the C enum and the C++ enum class.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void initialize() { pros::MotorGroup mg({1,3}); mg.set_encoder_units(E_MOTOR_ENCODER_DEGREES, 1); std::cout << "Encoder Units: " << mg.get_encoder_units(); }
std::int32_t set_encoder_units(const pros::motor_encoder_units_e_t units,
const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Sets one of MotorUnits for one motor in the motor group's motor encoder.
Parameters | |
---|---|
units | The new motor encoder units |
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
Works with the C enum and the C++ enum class.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void initialize() { pros::MotorGroup mg({1,3}); mg.set_encoder_units(E_MOTOR_ENCODER_DEGREES, 1); std::cout << "Encoder Units: " << mg.get_encoder_units(); }
std::int32_t set_encoder_units_all(const MotorUnits units) const virtual
#include <pros/motor_group.hpp>
Sets one of MotorUnits for every motor in the motor group's motor encoder.
Parameters | |
---|---|
units | The new motor encoder units |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
Works with the C enum and the C++ enum class.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void initialize() { pros::MotorGroup mg({1,3}); mg.set_encoder_units_all(E_MOTOR_ENCODER_DEGREES); std::cout << "Encoder Units: " << mg.get_encoder_units(); }
std::int32_t set_encoder_units_all(const pros::motor_encoder_units_e_t units) const virtual
#include <pros/motor_group.hpp>
Sets one of MotorUnits for every motor in the motor group's motor encoder.
Parameters | |
---|---|
units | The new motor encoder units |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
Works with the C enum and the C++ enum class.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void initialize() { pros::MotorGroup mg({1,3}); mg.set_encoder_units_all(E_MOTOR_ENCODER_DEGREES); std::cout << "Encoder Units: " << mg.get_encoder_units(); }
std::int32_t set_gearing(std::vector<pros::motor_gearset_e_t> gearsets) const
#include <pros/motor_group.hpp>
Sets one of the gear cartridge (red, green, blue) for one motor in the motor group.
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
---|
Usable with the C++ enum class and the C enum.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty E2BIG - The size of the vector mismatches the number of motors in the motor group
Example
void initialize() { pros::MotorGroup mg({1,3}); mg.set_gearing(pros::MotorGears::blue, 1); std::cout << "Gearset: " << mg.get_gearing(); }
std::int32_t set_gearing(const pros::motor_gearset_e_t gearset,
const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Sets one of the gear cartridge (red, green, blue) for one motor in the motor group.
Parameters | |
---|---|
gearset | The new geatset of the motor |
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
Usable with the C++ enum class and the C enum.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void initialize() { pros::MotorGroup mg({1,3}); mg.set_gearing(E_MOTOR_GEARSET_06, 1); std::cout << "Gearset: " << mg.get_gearing(); }
std::int32_t set_gearing(std::vector<MotorGears> gearsets) const
#include <pros/motor_group.hpp>
Sets the gear cartridge (red, green, blue) for each motor in the motor group by taking in a vector of the cartridges.
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
---|
Usable with the C++ enum class and the C enum.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty E2BIG - The size of the vector mismatches the number of motors in the motor group
Example
void initialize() { pros::MotorGroup mg({1,3}); mg.set_gearing(pros::MotorGears::blue, 1); std::cout << "Gearset: " << mg.get_gearing(); }
std::int32_t set_gearing(const MotorGears gearset,
const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Sets one of the gear cartridge (red, green, blue) for one motor in the motor group.
Parameters | |
---|---|
gearset | The new geatset of the motor |
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
Usable with the C++ enum class and the C enum.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void initialize() { pros::MotorGroup mg({1,3}); mg.set_gearing(E_MOTOR_GEARSET_06, 1); std::cout << "Gearset: " << mg.get_gearing(); }
std::int32_t set_gearing_all(const MotorGears gearset) const virtual
#include <pros/motor_group.hpp>
Sets one of the gear cartridge (red, green, blue) for one motor in the motor group.
Parameters | |
---|---|
gearset | The new geatset of the motor |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
Usable with the C++ enum class and the C enum.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void initialize() { pros::MotorGroup mg({1,3}); mg.set_gearing_all(E_MOTOR_GEARSET_06); std::cout << "Gearset: " << mg.get_gearing(); }
std::int32_t set_gearing_all(const pros::motor_gearset_e_t gearset) const virtual
#include <pros/motor_group.hpp>
Sets one of the gear cartridge (red, green, blue) for every motor in the motor group.
Parameters | |
---|---|
gearset | The new geatset of the motor |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
Usable with the C++ enum class and the C enum.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void initialize() { pros::MotorGroup mg({1,3}); mg.set_gearing_all(E_MOTOR_GEARSET_06); std::cout << "Gearset: " << mg.get_gearing(); }
std::int32_t set_reversed(const bool reverse,
const std::uint8_t index = 0) virtual
#include <pros/motor_group.hpp>
sets the reversal for a motor in the motor group.
Parameters | |
---|---|
reverse | True reverses the motor, false is default |
index | |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
This will invert its movements and the values returned for its position.
This function uses the following values of errno when an error state is reached: EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void initialize() { pros::MotorGroup mg({1,3}); //reverse the motor at index 1 (port 3) mg.set_reversed(true, 1); std::cout << "Is this motor reversed? " << motor.is_reversed(1); pros::delay(100); // unreverse the motor at index 1 (port 3) mg.set_reversed(false, 1); std::cout << "Is this motor reversed? " << motor.is_reversed(1); }
std::int32_t set_reversed_all(const bool reverse) virtual
#include <pros/motor_group.hpp>
Sets the reversal for all the motors in the motor group.
Parameters | |
---|---|
reverse | True reverses the motor, false is default |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
This will invert its movements and the values returned for its position.
This function uses the following values of errno when an error state is reached: EDOM - The motor group is empty
Example
void initialize() { pros::MotorGroup mg({1,3}); mg.set_reversed_all(true); std::cout << "Is this motor reversed? " << motor.is_reversed(); }
std::int32_t set_voltage_limit(const std::int32_t limit,
const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Sets the voltage limit for a motor in the motor group in millivolts.
Parameters | |
---|---|
limit | The new voltage limit in Volts |
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void autonomous() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); mg.set_voltage_limit(10000, 1); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); // The motor on at index 1 (port 3) will not output more than 10 V pros::delay(2); } }
std::int32_t set_voltage_limit_all(const std::int32_t limit) const virtual
#include <pros/motor_group.hpp>
Sets the voltage limit for every motor in the motor group in millivolts.
Parameters | |
---|---|
limit | The new voltage limit in Volts |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void autonomous() { pros::MotorGroup mg({1,3}); pros::Controller master (E_CONTROLLER_MASTER); mg.set_voltage_limit_all(10000); while (true) { mg = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); // The motor will not output more than 10 V pros::delay(2); } }
std::int32_t set_zero_position(const double position,
const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Sets the position for a motor in the motor group in its encoder units.
Parameters | |
---|---|
position | The new reference position in its encoder units |
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
This will be the future reference point for the motor's "absolute" position.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void autonomous() { pros::MotorGroup mg({1,3}); mg.move_absolute(100, 100); // Moves 100 units forward mg.move_absolute(100, 100); // This does not cause a movement mg.set_zero_position(80); mg.set_zero_position(80, 1); mg.move_absolute(100, 100); // Moves 80 units forward }
std::int32_t set_zero_position_all(const double position) const virtual
#include <pros/motor_group.hpp>
Sets the position for every motor in the motor group in its encoder units.
Parameters | |
---|---|
position | The new reference position in its encoder units |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
This will be the future reference point for the motor's "absolute" position.
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty
Example
void autonomous() { pros::MotorGroup mg({1,3}); mg.move_absolute(100, 100); // Moves 100 units forward mg.move_absolute(100, 100); // This does not cause a movement mg.set_zero_position_all(80); mg.move_absolute(100, 100); // Moves 80 units forward }
std::int32_t tare_position(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Sets the "absolute" zero position of a motor in the motor group to its current position.
Parameters | |
---|---|
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor EDOM - The motor group is empty EOVERFLOW - The index is greater than or equal to MotorGroup::
Example
void autonomous() { pros::MotorGroup mg({1,3}); mg.move_absolute(100, 100); // Moves 100 units forward mg.move_absolute(100, 100); // This does not cause a movement mg.tare_position(); mg.tare_position(1); mg.move_absolute(100, 100); // Moves 100 units forward }
std::int32_t tare_position_all(void) const virtual
#include <pros/motor_group.hpp>
Sets the "absolute" zero position of every motor in the motor group to its current position.
Returns | 1 if the operation was successful or PROS_ERR if the operation failed, setting errno. |
---|
This function uses the following values of errno when an error state is reached: ENODEV - The port cannot be configured as a motor
Example
void autonomous() { pros::MotorGroup mg({1,3}); mg.move_absolute(100, 100); // Moves 100 units forward mg.move_absolute(100, 100); // This does not cause a movement mg.tare_position_all(); mg.move_absolute(100, 100); // Moves 100 units forward }
std::int8_t size(void) const virtual
#include <pros/motor_group.hpp>
Returns the number of motors in the motor group.
Returns | the number of motors in the motor group |
---|
std::int8_t get_port(const std::uint8_t index = 0) const virtual
#include <pros/motor_group.hpp>
Gets the port of a motor in the motor group via index.
Parameters | |
---|---|
index | Optional parameter, 0 by default. The zero indexed index of the motor in the motor group |
Returns | The port of the motor at the specified index. The return value is negative if the corresponding motor is reversed |
void operator+=(AbstractMotor&)
#include <pros/motor_group.hpp>
Appends all the motors in the other motor group reference to this motor group.
Maintains the order of the other motor group
void append(AbstractMotor&)
#include <pros/motor_group.hpp>
Appends all the motors in the other motor group reference to this motor group.
Maintains the order of the other motor group
void erase_port(std::int8_t port)
#include <pros/motor_group.hpp>
Removes the all motors on the port (regardless of reversal) from the motor group.
Parameters | |
---|---|
port | The port to remove from the motor group |
Variable documentation
std::vector<std::int8_t> _ports
#include <pros/motor_group.hpp>
The ordered vector of ports used by the motor group.