diff --git a/include/pros/motors.hpp b/include/pros/motors.hpp index 850779a1..a9c195e1 100644 --- a/include/pros/motors.hpp +++ b/include/pros/motors.hpp @@ -399,29 +399,6 @@ class Motor : public AbstractMotor, public Device { */ double get_target_position(const std::uint8_t index = 0) const; - /** - * Gets a vector containing the target position set for the motor by the user - * - * This function uses the following values of errno when an error state is - * reached: - * ENODEV - The port cannot be configured as a motor - * - * - * \return A vector containing the target position in its encoder units or PROS_ERR_F if the - * operation failed, setting errno. - * - * \b Example - * \code - * void autonomous() { - * pros::Motor motor (1); - * motor.move_absolute(100, 100); - * std::cout << "Motor Target: " << motor.get_target_position_all()[0]; - * // Prints 100 - * } - * \endcode - */ - std::vector get_target_position_all(void) const; - /** * Gets the velocity commanded to the motor by the user at the index specified. * @@ -457,32 +434,6 @@ class Motor : public AbstractMotor, public Device { */ std::int32_t get_target_velocity(const std::uint8_t index = 0) const; - /** - * Gets a vector containing the velocity commanded to the motor by the user - * - * This function uses the following values of errno when an error state is - * reached: - * ENODEV - The port cannot be configured as a motor - * - * \return A vector containing the commanded motor velocity from +-100, - * +-200, or +-600, or PROS_ERR if the operation failed, setting errno. - * - * \b Example - * \code - * void opcontrol() { - * pros::Motor motor (1); - * pros::Controller master (E_CONTROLLER_MASTER); - * while (true) { - * motor.move_velocity(master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y)); - * std::cout << "Motor Velocity: " << motor.get_target_velocity_all()[0]; - * // Prints the value of E_CONTROLLER_ANALOG_LEFT_Y - * pros::delay(2); - * } - * } - * \endcode - */ - std::vector get_target_velocity_all(void) const; - ///@} /// \name Motor telemetry functions @@ -522,33 +473,6 @@ class Motor : public AbstractMotor, public Device { */ double get_actual_velocity(const std::uint8_t index = 0) const; - - /** - * Gets a vector containing the actual velocity commanded of the motor - * - * This function uses the following values of errno when an error state is - * reached: - * ENODEV - The port cannot be configured as a motor - * - * \return A vector containing the motor's actual velocity in RPM or PROS_ERR_F - * if the operation failed, setting errno. - * - * \b Example - * \code - * void opcontrol() { - * pros::Motor motor (1); - * pros::Controller master (E_CONTROLLER_MASTER); - * while (true) { - * motor.move_velocity(master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y)); - * std::cout << "Motor Velocity: " << motor.get_actual_velocity_all()[0]; - * // Prints the value of E_CONTROLLER_ANALOG_LEFT_Y - * pros::delay(2); - * } - * } - * \endcode - */ - std::vector get_actual_velocity_all(void) const; - /** * Gets the current drawn by the motor in mA. * @@ -585,18 +509,26 @@ class Motor : public AbstractMotor, public Device { */ std::int32_t get_current_draw(const std::uint8_t index = 0) const; - /** - * Gets a vector containing the current drawn by the motor in mA. + * Gets the direction of movement for the motor. + * + * \note This is one of many Motor functions that takes in an optional index parameter. + * This parameter can be ignored by most users but exists to give a shared base class + * for motors and motor groups * * 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 non 0 * - * \return A vector conatining the motor's current in mA or PROS_ERR if the operation failed, - * setting errno. + * \param index Optional parameter. + * The zero-indexed index of the motor to get the target position of. + * By default index is 0, and will return an error for a non-zero index + * + * \return 1 for moving in the positive direction, -1 for moving in the + * negative direction, and PROS_ERR if the operation failed, setting errno. * * \b Example * \code @@ -605,17 +537,22 @@ class Motor : public AbstractMotor, public Device { * pros::Controller master (E_CONTROLLER_MASTER); * while (true) { * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Current Draw: " << motor.get_current_draw_all()[0]; + * std::cout << "Motor Direction: " << motor.get_direction(); * pros::delay(2); * } * } * \endcode */ - std::vector get_current_draw_all(void) const; + std::int32_t get_direction(const std::uint8_t index = 0) const; /** - * Gets the direction of movement for the motor. + * Gets the efficiency of the motor in percent. + * + * 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. * + * * \note This is one of many Motor functions that takes in an optional index parameter. * This parameter can be ignored by most users but exists to give a shared base class * for motors and motor groups @@ -630,9 +567,9 @@ class Motor : public AbstractMotor, public Device { * \param index Optional parameter. * The zero-indexed index of the motor to get the target position of. * By default index is 0, and will return an error for a non-zero index - * - * \return 1 for moving in the positive direction, -1 for moving in the - * negative direction, and PROS_ERR if the operation failed, setting errno. + * + * \return The motor's efficiency in percent or PROS_ERR_F if the operation + * failed, setting errno. * * \b Example * \code @@ -641,26 +578,36 @@ class Motor : public AbstractMotor, public Device { * pros::Controller master (E_CONTROLLER_MASTER); * while (true) { * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Direction: " << motor.get_direction(); + * std::cout << "Motor Efficiency: " << motor.get_efficiency(); * pros::delay(2); * } * } * \endcode */ - std::int32_t get_direction(const std::uint8_t index = 0) const; + double get_efficiency(const std::uint8_t index = 0) const; /** - * Gets a vector containing the direction of movement for the motor. + * Gets the faults experienced by the motor. + * + * Compare this bitfield to the bitmasks in pros::motor_fault_e_t. * + * \note This is one of many Motor functions that takes in an optional index parameter. + * This parameter can be ignored by most users but exists to give a shared base class + * for motors and motor groups * * 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 non 0 * - * \return A vecotr containing 1 for moving in the positive direction, -1 for moving in the - * negative direction, and PROS_ERR if the operation failed, setting errno. + * \param index Optional parameter. + * The zero-indexed index of the motor to get the target position of. + * By default index is 0, and will return an error for a non-zero index + * + * + * \return A bitfield containing the motor's faults. * * \b Example * \code @@ -669,22 +616,18 @@ class Motor : public AbstractMotor, public Device { * pros::Controller master (E_CONTROLLER_MASTER); * while (true) { * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Direction: " << motor.get_direction_all()[0]; - * pros::delay(2); + * std::cout << "Motor Faults: " << motor.get_faults();pros::delay(2); * } * } * \endcode */ - std::vector get_direction_all(void) const; - + std::uint32_t get_faults(const std::uint8_t index = 0) const; + /** - * Gets the efficiency of the motor in percent. + * Gets the flags set by the motor's operation. * - * 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. + * Compare this bitfield to the bitmasks in pros::motor_flag_e_t. * - * * \note This is one of many Motor functions that takes in an optional index parameter. * This parameter can be ignored by most users but exists to give a shared base class * for motors and motor groups @@ -700,8 +643,7 @@ class Motor : public AbstractMotor, public Device { * The zero-indexed index of the motor to get the target position of. * By default index is 0, and will return an error for a non-zero index * - * \return The motor's efficiency in percent or PROS_ERR_F if the operation - * failed, setting errno. + * \return A bitfield containing the motor's flags. * * \b Example * \code @@ -710,29 +652,34 @@ class Motor : public AbstractMotor, public Device { * pros::Controller master (E_CONTROLLER_MASTER); * while (true) { * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Efficiency: " << motor.get_efficiency(); + * std::cout << "Motor Faults: " << motor.get_faults(); * pros::delay(2); * } * } * \endcode */ - double get_efficiency(const std::uint8_t index = 0) const; + std::uint32_t get_flags(const std::uint8_t index = 0) const; /** - * Gets a vector containing the efficiency of the motor in percent. + * Gets the absolute position of the motor in its encoder units. * - * 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. + * \note This is one of many Motor functions that takes in an optional index parameter. + * This parameter can be ignored by most users but exists to give a shared base class + * for motors and motor groups * * 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 non 0 + * + * \param index Optional parameter. + * The zero-indexed index of the motor to get the target position of. + * By default index is 0, and will return an error for a non-zero index * - * \return A vector containing The motor's efficiency in percent or PROS_ERR_F if the operation - * failed, setting errno. + * \return The motor's absolute position in its encoder units or PROS_ERR_F + * if the operation failed, setting errno. * * \b Example * \code @@ -741,18 +688,16 @@ class Motor : public AbstractMotor, public Device { * pros::Controller master (E_CONTROLLER_MASTER); * while (true) { * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Efficiency: " << motor.get_efficiency(); + * std::cout << "Motor Position: " << motor.get_position(); * pros::delay(2); * } * } * \endcode */ - std::vector get_efficiency_all(void) const; + double get_position(const std::uint8_t index = 0) const; /** - * Gets the faults experienced by the motor. - * - * Compare this bitfield to the bitmasks in pros::motor_fault_e_t. + * Gets the power drawn by the motor in Watts. * * \note This is one of many Motor functions that takes in an optional index parameter. * This parameter can be ignored by most users but exists to give a shared base class @@ -768,9 +713,9 @@ class Motor : public AbstractMotor, public Device { * \param index Optional parameter. * The zero-indexed index of the motor to get the target position of. * By default index is 0, and will return an error for a non-zero index - * - * - * \return A bitfield containing the motor's faults. + * + * \return The motor's power draw in Watts or PROS_ERR_F if the operation + * failed, setting errno. * * \b Example * \code @@ -779,45 +724,62 @@ class Motor : public AbstractMotor, public Device { * pros::Controller master (E_CONTROLLER_MASTER); * while (true) { * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Faults: " << motor.get_faults();pros::delay(2); + * std::cout << "Motor Power: " << motor.get_power(); + * pros::delay(2); * } * } * \endcode */ - std::uint32_t get_faults(const std::uint8_t index = 0) const; + double get_power(const std::uint8_t index = 0) const; /** - * Gets a vector of the faults experienced by the motor. + * Gets the raw encoder count of the motor at a given timestamp. * - * Compare this bitfield to the bitmasks in pros::motor_fault_e_t. + * \note This is one of many Motor functions that takes in an optional index parameter. + * This parameter can be ignored by most users but exists to give a shared base class + * for motors and motor groups * * 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 non 0 + * + * + * \param 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 + * + * \param index Optional parameter. + * The zero-indexed index of the motor to get the target position of. + * By default index is 0, and will return an error for a non-zero index * - * \return A bitfield containing the motor's faults. + * + * + * \return The raw encoder count at the given timestamp or PROS_ERR if the + * operation failed. * * \b Example * \code * void opcontrol() { + * std::uint32_t now = pros::millis(); * pros::Motor motor (1); * pros::Controller master (E_CONTROLLER_MASTER); * while (true) { * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Faults: " << motor.get_faults_all()[0]; - * pros::delay(2); + * std::cout << "Motor Position: " << motor.get_raw_position(&now); + * pros::delay(2); * } * } * \endcode */ - std::vector get_faults_all(void) const; - + std::int32_t get_raw_position(std::uint32_t* const timestamp, const std::uint8_t index = 0) const; + /** - * Gets the flags set by the motor's operation. - * - * Compare this bitfield to the bitmasks in pros::motor_flag_e_t. - * + * Gets the temperature of the motor in degrees Celsius. + * \note This is one of many Motor functions that takes in an optional index parameter. * This parameter can be ignored by most users but exists to give a shared base class * for motors and motor groups @@ -833,7 +795,8 @@ class Motor : public AbstractMotor, public Device { * The zero-indexed index of the motor to get the target position of. * By default index is 0, and will return an error for a non-zero index * - * \return A bitfield containing the motor's flags. + * \return The motor's temperature in degrees Celsius or PROS_ERR_F if the + * operation failed, setting errno. * * \b Example * \code @@ -842,26 +805,34 @@ class Motor : public AbstractMotor, public Device { * pros::Controller master (E_CONTROLLER_MASTER); * while (true) { * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Faults: " << motor.get_faults(); + * std::cout << "Motor Temperature: " << motor.get_temperature(); * pros::delay(2); * } * } * \endcode */ - std::uint32_t get_flags(const std::uint8_t index = 0) const; + double get_temperature(const std::uint8_t index = 0) const; /** - * Gets a vector of the flags set by the motor's operation. + * Gets the torque generated by the motor in Newton Meters (Nm). * - * Compare this bitfield to the bitmasks in pros::motor_flag_e_t. + * \note This is one of many Motor functions that takes in an optional index parameter. + * This parameter can be ignored by most users but exists to give a shared base class + * for motors and motor groups * * 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 non 0 + * + * \param index Optional parameter. + * The zero-indexed index of the motor to get the target position of. + * By default index is 0, and will return an error for a non-zero index * - * - * \return A bitfield containing the motor's flags. + * \return The motor's torque in Nm or PROS_ERR_F if the operation failed, + * setting errno. * * \b Example * \code @@ -870,16 +841,16 @@ class Motor : public AbstractMotor, public Device { * pros::Controller master (E_CONTROLLER_MASTER); * while (true) { * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Faults: " << motor.get_faults_all()[0]; + * std::cout << "Motor Torque: " << motor.get_torque(); * pros::delay(2); * } * } * \endcode */ - std::vector get_flags_all(void) const; + double get_torque(const std::uint8_t index = 0) const; /** - * Gets the absolute position of the motor in its encoder units. + * Gets the voltage delivered to the motor in millivolts. * * \note This is one of many Motor functions that takes in an optional index parameter. * This parameter can be ignored by most users but exists to give a shared base class @@ -895,9 +866,9 @@ class Motor : public AbstractMotor, public Device { * \param index Optional parameter. * The zero-indexed index of the motor to get the target position of. * By default index is 0, and will return an error for a non-zero index - * - * \return The motor's absolute position in its encoder units or PROS_ERR_F - * if the operation failed, setting errno. + * + * \return The motor's voltage in mV or PROS_ERR_F if the operation failed, + * setting errno. * * \b Example * \code @@ -906,25 +877,35 @@ class Motor : public AbstractMotor, public Device { * pros::Controller master (E_CONTROLLER_MASTER); * while (true) { * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Position: " << motor.get_position(); + * std::cout << "Motor Voltage: " << motor.get_voltage(); * pros::delay(2); * } * } * \endcode */ - double get_position(const std::uint8_t index = 0) const; + std::int32_t get_voltage(const std::uint8_t index = 0) const; /** - * Gets a vector containing the absolute position of the motor in its encoder units. + * Checks if the motor is drawing over its current limit. + * + * \note This is one of many Motor functions that takes in an optional index parameter. + * This parameter can be ignored by most users but exists to give a shared base class + * for motors and motor groups * * 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 non 0 + * + * \param index Optional parameter. + * The zero-indexed index of the motor to get the target position of. + * By default index is 0, and will return an error for a non-zero index * - * \return A vector containing the motor's absolute position in its encoder units or PROS_ERR_F - * if the operation failed, setting errno. + * \return 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. * * \b Example * \code @@ -933,16 +914,16 @@ class Motor : public AbstractMotor, public Device { * pros::Controller master (E_CONTROLLER_MASTER); * while (true) { * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Position: " << motor.get_position_all()[0]; + * std::cout << "Is the motor over its current limit?: " << motor.is_over_current(); * pros::delay(2); * } * } * \endcode */ - std::vector get_position_all(void) const; + std::int32_t is_over_current(const std::uint8_t index = 0) const; /** - * Gets the power drawn by the motor in Watts. + * Gets the temperature limit flag for the motor. * * \note This is one of many Motor functions that takes in an optional index parameter. * This parameter can be ignored by most users but exists to give a shared base class @@ -959,8 +940,8 @@ class Motor : public AbstractMotor, public Device { * The zero-indexed index of the motor to get the target position of. * By default index is 0, and will return an error for a non-zero index * - * \return The motor's power draw in Watts or PROS_ERR_F if the operation - * failed, setting errno. + * \return 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. * * \b Example * \code @@ -969,42 +950,54 @@ class Motor : public AbstractMotor, public Device { * pros::Controller master (E_CONTROLLER_MASTER); * while (true) { * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Power: " << motor.get_power(); + * std::cout << "Is the motor over its temperature limit?: " << motor.is_over_temp(); * pros::delay(2); * } * } * \endcode */ - double get_power(const std::uint8_t index = 0) const; + std::int32_t is_over_temp(const std::uint8_t index = 0) const; + + ///@} + + /// \name Motor configuration functions + /// These functions allow programmers to configure the behavior of motors + ///@{ /** - * Gets a vector containing the power drawn by the motor in Watts. + * Gets the brake mode that was set for the motor. + * + * \note This is one of many Motor functions that takes in an optional index parameter. + * This parameter can be ignored by most users but exists to give a shared base class + * for motors and motor groups * * This function uses the following values of errno when an error state is * reached: * * ENODEV - The port cannot be configured as a motor * - * \return A vector containing the motor's power draw in Watts or PROS_ERR_F if the operation - * failed, setting errno. + * EOVERFLOW - The index is non 0 + * + * \param index Optional parameter. + * The zero-indexed index of the motor to get the target position of. + * By default index is 0, and will return an error for a non-zero index + * + * \return One of Motor_Brake, according to what was set for the + * motor, or E_MOTOR_BRAKE_INVALID if the operation failed, setting errno. * * \b Example * \code - * void opcontrol() { + * void initialize() { * pros::Motor motor (1); - * pros::Controller master (E_CONTROLLER_MASTER); - * while (true) { - * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Power: " << motor.get_power_all()[0]; - * pros::delay(2); - * } + * motor.set_brake_mode(pros::E_MOTOR_BRAKE_HOLD); + * std::cout << "Brake Mode: " << motor.get_brake_mode(); * } * \endcode */ - std::vector get_power_all(void) const; + MotorBrake get_brake_mode(const std::uint8_t index = 0) const; /** - * Gets the raw encoder count of the motor at a given timestamp. + * Gets the current limit for the motor in mA. * * \note This is one of many Motor functions that takes in an optional index parameter. * This parameter can be ignored by most users but exists to give a shared base class @@ -1017,72 +1010,60 @@ class Motor : public AbstractMotor, public Device { * * EOVERFLOW - The index is non 0 * - * - * \param 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 - * * \param index Optional parameter. * The zero-indexed index of the motor to get the target position of. * By default index is 0, and will return an error for a non-zero index - * - * - * - * \return The raw encoder count at the given timestamp or PROS_ERR if the - * operation failed. + * + * \return The motor's current limit in mA or PROS_ERR if the operation failed, + * setting errno. * * \b Example * \code * void opcontrol() { - * std::uint32_t now = pros::millis(); * pros::Motor motor (1); - * pros::Controller master (E_CONTROLLER_MASTER); * while (true) { - * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Position: " << motor.get_raw_position(&now); + * std::cout << "Motor Current Limit: " << motor.get_current_limit(); * pros::delay(2); * } * } * \endcode */ - std::int32_t get_raw_position(std::uint32_t* const timestamp, const std::uint8_t index = 0) const; + std::int32_t get_current_limit(const std::uint8_t index = 0) const; + /** - * Gets a vector of the raw encoder count of the motor at a given timestamp. + * Gets the encoder units that were set for the motor. * + * \note This is one of many Motor functions that takes in an optional index parameter. + * This parameter can be ignored by most users but exists to give a shared base class + * for motors and motor groups * * This function uses the following values of errno when an error state is * reached: * * ENODEV - The port cannot be configured as a motor * - * \param 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 + * EOVERFLOW - The index is non 0 * - * \return A vector containing the raw encoder count at the given timestamp or PROS_ERR if the - * operation failed. + * \param index Optional parameter. + * The zero-indexed index of the motor to get the target position of. + * By default index is 0, and will return an error for a non-zero index + * + * \return One of Motor_Units according to what is set for the + * motor or E_MOTOR_ENCODER_INVALID if the operation failed. * * \b Example * \code - * void opcontrol() { - * std::uint32_t now = pros::millis(); - * pros::Motor motor (1); - * pros::Controller master (E_CONTROLLER_MASTER); - * while (true) { - * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Position: " << motor.get_raw_position(&now); - * pros::delay(2); - * } + * void initialize() { + * pros::Motor motor (1, E_MOTOR_GEARSET_06, E_MOTOR_ENCODER_COUNTS); + * std::cout << "Motor Encoder Units: " << motor.get_encoder_units(); * } * \endcode */ - std::vector get_raw_position_all(std::uint32_t* const timestamp) const; + MotorUnits get_encoder_units(const std::uint8_t index = 0) const; /** - * Gets the temperature of the motor in degrees Celsius. - + * Gets the gearset that was set for the motor. + * * \note This is one of many Motor functions that takes in an optional index parameter. * This parameter can be ignored by most users but exists to give a shared base class * for motors and motor groups @@ -1098,51 +1079,52 @@ class Motor : public AbstractMotor, public Device { * The zero-indexed index of the motor to get the target position of. * By default index is 0, and will return an error for a non-zero index * - * \return The motor's temperature in degrees Celsius or PROS_ERR_F if the - * operation failed, setting errno. + * \return One of Motor_Gears according to what is set for the motor, + * or pros::Motor_Gears::invalid if the operation failed. * * \b Example * \code - * void opcontrol() { - * pros::Motor motor (1); - * pros::Controller master (E_CONTROLLER_MASTER); - * while (true) { - * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Temperature: " << motor.get_temperature(); - * pros::delay(2); - * } + * void initialize() { + * pros::Motor motor (1, E_MOTOR_GEARSET_06, E_MOTOR_ENCODER_COUNTS); + * std::cout << "Motor Gearing: " << motor.get_gearing(); * } * \endcode */ - double get_temperature(const std::uint8_t index = 0) const; - + MotorGears get_gearing(const std::uint8_t index = 0) const; + /** - * Gets a vector of the temperature of the motor in degrees Celsius. + * Gets the voltage limit set by the user. + * + * Default value is 0V, which means that there is no software limitation + * imposed on the voltage. * + * \note This is one of many Motor functions that takes in an optional index parameter. + * This parameter can be ignored by most users but exists to give a shared base class + * for motors and motor groups + * * This function uses the following values of errno when an error state is * reached: + * * ENODEV - The port cannot be configured as a motor - * - * \return A vector contaioning the motor's temperature in degrees Celsius - * or PROS_ERR_F if the operation failed, setting errno. + * + * EOVERFLOW - The index is non 0 + * + * \param index Optional parameter. + * The zero-indexed index of the motor to get the target position of. + * By default index is 0, and will return an error for a non-zero index * * \b Example * \code - * void opcontrol() { + * void initialize() { * pros::Motor motor (1); - * pros::Controller master (E_CONTROLLER_MASTER); - * while (true) { - * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Temperature: " << motor.get_temperature_all()[0]; - * pros::delay(2); - * } + * std::cout << "Motor Voltage Limit: " << motor.get_voltage_limit(); * } * \endcode */ - std::vector get_temperature_all(void) const; + std::int32_t get_voltage_limit(const std::uint8_t index = 0) const; /** - * Gets the torque generated by the motor in Newton Meters (Nm). + * Gets whether the motor is reversed or not * * \note This is one of many Motor functions that takes in an optional index parameter. * This parameter can be ignored by most users but exists to give a shared base class @@ -1150,61 +1132,63 @@ class Motor : public AbstractMotor, public Device { * * 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 non 0 * * \param index Optional parameter. * The zero-indexed index of the motor to get the target position of. * By default index is 0, and will return an error for a non-zero index * - * \return The motor's torque in Nm or PROS_ERR_F if the operation failed, - * setting errno. + * \return 1 if the motor has been reversed and 0 if the motor was not + * reversed, or PROS_ERR if the operation failed, setting errno. * * \b Example * \code - * void opcontrol() { + * void initialize() { * pros::Motor motor (1); - * pros::Controller master (E_CONTROLLER_MASTER); - * while (true) { - * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Torque: " << motor.get_torque(); - * pros::delay(2); - * } + * std::cout << "Is the motor reversed? " << motor.is_reversed(); + * // Prints "0" * } * \endcode */ - double get_torque(const std::uint8_t index = 0) const; + std::int32_t is_reversed(const std::uint8_t index = 0) const; /** - * Gets a vector of the torque generated by the motor in Newton Meters (Nm). - * + * Sets one of Motor_Brake to the motor. + * \note This is one of many Motor functions that takes in an optional index parameter. + * This parameter can be ignored by most users but exists to give a shared base class + * for motors and motor groups + * * This function uses the following values of errno when an error state is * reached: + * * ENODEV - The port cannot be configured as a motor * - * \return A vector containing the motor's torque in Nm or PROS_ERR_F if the operation failed, - * setting errno. + * EOVERFLOW - The index is non 0 + * + * + * \param mode + * The Motor_Brake to set for the motor + * + * \param index Optional parameter. + * The zero-indexed index of the motor to get the target position of. + * By default index is 0, and will return an error for a non-zero index + * + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. * * \b Example * \code - * void opcontrol() { + * void initialize() { * pros::Motor motor (1); - * pros::Controller master (E_CONTROLLER_MASTER); - * while (true) { - * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Torque: " << motor.get_torque(); - * pros::delay(2); - * } + * motor.set_brake_mode(pros::E_MOTOR_BRAKE_HOLD); + * std::cout << "Brake Mode: " << motor.get_brake_mode(); * } * \endcode */ - std::vector get_torque_all(void) const; - + std::int32_t set_brake_mode(const MotorBrake mode, const std::uint8_t index = 0) const; /** - * Gets the voltage delivered to the motor in millivolts. - * + * Sets one of Motor_Brake to the motor. * \note This is one of many Motor functions that takes in an optional index parameter. * This parameter can be ignored by most users but exists to give a shared base class * for motors and motor groups @@ -1216,56 +1200,30 @@ class Motor : public AbstractMotor, public Device { * * EOVERFLOW - The index is non 0 * + * + * \param mode + * The Motor_Brake to set for the motor + * * \param index Optional parameter. * The zero-indexed index of the motor to get the target position of. * By default index is 0, and will return an error for a non-zero index - * - * \return The motor's voltage in mV or PROS_ERR_F if the operation failed, - * setting errno. + * + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. * * \b Example * \code - * void opcontrol() { + * void initialize() { * pros::Motor motor (1); - * pros::Controller master (E_CONTROLLER_MASTER); - * while (true) { - * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Voltage: " << motor.get_voltage(); - * pros::delay(2); - * } - * } - * \endcode - */ - std::int32_t get_voltage(const std::uint8_t index = 0) const; - - /** - * Gets a vector of the voltage delivered to the motor in millivolts. - * - * This function uses the following values of errno when an error state is - * reached: - * ENODEV - The port cannot be configured as a motor - * - * - * \return A vector of the motor's voltage in mV or PROS_ERR_F if the operation failed, - * setting errno. - * - * \b Example - * \code - * void opcontrol() { - * pros::Motor motor (1); - * pros::Controller master (E_CONTROLLER_MASTER); - * while (true) { - * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Motor Voltage: " << motor.get_voltage_all()[0]; - * pros::delay(2); - * } + * motor.set_brake_mode(pros::E_MOTOR_BRAKE_HOLD); + * std::cout << "Brake Mode: " << motor.get_brake_mode(); * } * \endcode */ - std::vector get_voltage_all(void) const; + std::int32_t set_brake_mode(const pros::motor_brake_mode_e_t mode, const std::uint8_t index = 0) const; /** - * Checks if the motor is drawing over its current limit. + * Sets the current limit for the motor in mA. * * \note This is one of many Motor functions that takes in an optional index parameter. * This parameter can be ignored by most users but exists to give a shared base class @@ -1278,57 +1236,60 @@ class Motor : public AbstractMotor, public Device { * * EOVERFLOW - The index is non 0 * + * * \param limit + * The new current limit in mA + * * \param index Optional parameter. * The zero-indexed index of the motor to get the target position of. * By default index is 0, and will return an error for a non-zero index * - * \return 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. + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. * * \b Example * \code * void opcontrol() { * pros::Motor motor (1); * pros::Controller master (E_CONTROLLER_MASTER); - * while (true) { - * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Is the motor over its current limit?: " << motor.is_over_current(); - * pros::delay(2); + * + * motor.set_current_limit(1000); + * while (true) { + * motor = 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); * } * } * \endcode */ - std::int32_t is_over_current(const std::uint8_t index = 0) const; + std::int32_t set_current_limit(const std::int32_t limit, const std::uint8_t index = 0) const; /** - * Checks if the motor is drawing over its current limit. + * Sets one of Motor_Units for the motor encoder. 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 * - * \return A vector containing 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. + * \param units + * The new motor encoder units + * + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. * * \b Example * \code - * void opcontrol() { + * void initialize() { * pros::Motor motor (1); - * pros::Controller master (E_CONTROLLER_MASTER); - * while (true) { - * motor = 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); - * } + * motor.set_encoder_units(E_MOTOR_ENCODER_DEGREES); + * std::cout << "Encoder Units: " << motor.get_encoder_units(); * } * \endcode */ - std::vector is_over_current_all(void) const; - + std::int32_t set_encoder_units(const MotorUnits units, const std::uint8_t index = 0) const; /** - * Gets the temperature limit flag for the motor. + * Sets one of Motor_Units for the motor encoder. Works with the C + * enum and the C++ enum class. * * \note This is one of many Motor functions that takes in an optional index parameter. * This parameter can be ignored by most users but exists to give a shared base class @@ -1345,57 +1306,26 @@ class Motor : public AbstractMotor, public Device { * The zero-indexed index of the motor to get the target position of. * By default index is 0, and will return an error for a non-zero index * - * \return 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. - * - * \b Example - * \code - * void opcontrol() { - * pros::Motor motor (1); - * pros::Controller master (E_CONTROLLER_MASTER); - * while (true) { - * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Is the motor over its temperature limit?: " << motor.is_over_temp(); - * pros::delay(2); - * } - * } - * \endcode - */ - std::int32_t is_over_temp(const std::uint8_t index = 0) const; - - /** - * Gets the temperature limit flag for the motor. + * * \param units + * The new motor encoder units * - * This function uses the following values of errno when an error state is - * reached: - * ENODEV - The port cannot be configured as a motor - * - * \return A vector containing 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. + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. * * \b Example * \code - * void opcontrol() { + * void initialize() { * pros::Motor motor (1); - * pros::Controller master (E_CONTROLLER_MASTER); - * while (true) { - * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * std::cout << "Is the motor over its temperature limit?: " << motor.is_over_temp_all(); - * pros::delay(2); - * } + * motor.set_encoder_units(E_MOTOR_ENCODER_DEGREES); + * std::cout << "Encoder Units: " << motor.get_encoder_units(); * } * \endcode */ - std::vector is_over_temp_all(void) const; - - ///@} - - /// \name Motor configuration functions - /// These functions allow programmers to configure the behavior of motors - ///@{ + std::int32_t set_encoder_units(const pros::motor_encoder_units_e_t units, const std::uint8_t index = 0) const; /** - * Gets the brake mode that was set for the motor. + * Sets one of the gear cartridge (red, green, blue) for the motor. Usable with + * the C++ enum class and the C enum. * * \note This is one of many Motor functions that takes in an optional index parameter. * This parameter can be ignored by most users but exists to give a shared base class @@ -1411,44 +1341,64 @@ class Motor : public AbstractMotor, public Device { * \param index Optional parameter. * The zero-indexed index of the motor to get the target position of. * By default index is 0, and will return an error for a non-zero index + * \param gearset + * The new motor gearset * - * \return One of Motor_Brake, according to what was set for the - * motor, or E_MOTOR_BRAKE_INVALID if the operation failed, setting errno. + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. * * \b Example * \code * void initialize() { * pros::Motor motor (1); - * motor.set_brake_mode(pros::E_MOTOR_BRAKE_HOLD); - * std::cout << "Brake Mode: " << motor.get_brake_mode(); + * motor.set_gearing(E_MOTOR_GEARSET_06); + * std::cout << "Gearset: " << motor.get_gearing(); * } * \endcode */ - MotorBrake get_brake_mode(const std::uint8_t index = 0) const; + std::int32_t set_gearing(const MotorGears gearset, const std::uint8_t index = 0) const; /** - * Gets a vector containing the brake mode that was set for the motor. - * + * Sets one of the gear cartridge (red, green, blue) for the motor. Usable with + * the C++ enum class and the C enum. + + * \note This is one of many Motor functions that takes in an optional index parameter. + * This parameter can be ignored by most users but exists to give a shared base class + * for motors and motor groups + * * 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 non 0 + * + * \param gearset + * The new motor gearset + * + * \param index Optional parameter. + * The zero-indexed index of the motor to get the target position of. + * By default index is 0, and will return an error for a non-zero index * - * \return One of Motor_Brake, according to what was set for the - * motor, or E_MOTOR_BRAKE_INVALID if the operation failed, setting errno. + * + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. * * \b Example * \code * void initialize() { * pros::Motor motor (1); - * motor.set_brake_mode(pros::E_MOTOR_BRAKE_HOLD); - * std::cout << "Brake Mode: " << motor.get_brake_mode(); + * motor.set_gearing(E_MOTOR_GEARSET_06); + * std::cout << "Gearset: " << motor.get_gearing(); * } * \endcode */ - std::vector get_brake_mode_all(void) const; + std::int32_t set_gearing(const pros::motor_gearset_e_t gearset, const std::uint8_t index = 0) const; /** - * Gets the current limit for the motor in mA. + * Sets the reverse flag for the motor. + * + * This will invert its movements and the values returned for its position. * * \note This is one of many Motor functions that takes in an optional index parameter. * This parameter can be ignored by most users but exists to give a shared base class @@ -1457,57 +1407,64 @@ class Motor : public AbstractMotor, public Device { * 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 non 0 * + * \param reverse + * True reverses the motor, false is default direction + * * \param index Optional parameter. * The zero-indexed index of the motor to get the target position of. * By default index is 0, and will return an error for a non-zero index - * - * \return The motor's current limit in mA or PROS_ERR if the operation failed, - * setting errno. + * + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. * * \b Example * \code - * void opcontrol() { + * void initialize() { * pros::Motor motor (1); - * while (true) { - * std::cout << "Motor Current Limit: " << motor.get_current_limit(); - * pros::delay(2); - * } + * motor.set_reversed(true); + * std::cout << "Is this motor reversed? " << motor.is_reversed(); * } * \endcode */ - std::int32_t get_current_limit(const std::uint8_t index = 0) const; - + std::int32_t set_reversed(const bool reverse, const std::uint8_t index = 0); + /** - * Gets a vector containing the current limit for the motor in mA. - * - * The default value is 2500 mA. + * Sets the voltage limit for the motor in Volts. * * This function uses the following values of errno when an error state is * reached: * ENODEV - The port cannot be configured as a motor * - * \return A vector containing the motor's current limit in mA or PROS_ERR if the operation failed, - * setting errno. + * \param limit + * The new voltage limit in Volts + * + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. * * \b Example * \code - * void opcontrol() { + * void autonomous() { * pros::Motor motor (1); + * pros::Controller master (E_CONTROLLER_MASTER); + * + * motor.set_voltage_limit(10000); * while (true) { - * std::cout << "Motor Current Limit: " << motor.get_current_limit_all()[0]; + * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); + * // The motor will not output more than 10 V * pros::delay(2); * } * } * \endcode */ - std::vector get_current_limit_all(void) const; + std::int32_t set_voltage_limit(const std::int32_t limit, const std::uint8_t index = 0) const; /** - * Gets the encoder units that were set for the motor. + * Sets the position for the motor in its encoder units. + * + * This will be the future reference point for the motor's "absolute" + * position. * * \note This is one of many Motor functions that takes in an optional index parameter. * This parameter can be ignored by most users but exists to give a shared base class @@ -1520,45 +1477,34 @@ class Motor : public AbstractMotor, public Device { * * EOVERFLOW - The index is non 0 * + * \param position + * The new reference position in its encoder units + * * \param index Optional parameter. * The zero-indexed index of the motor to get the target position of. * By default index is 0, and will return an error for a non-zero index - * - * \return One of Motor_Units according to what is set for the - * motor or E_MOTOR_ENCODER_INVALID if the operation failed. + * + * + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. * * \b Example * \code - * void initialize() { - * pros::Motor motor (1, E_MOTOR_GEARSET_06, E_MOTOR_ENCODER_COUNTS); - * std::cout << "Motor Encoder Units: " << motor.get_encoder_units(); + * void autonomous() { + * pros::Motor motor (1); + * motor.move_absolute(100, 100); // Moves 100 units forward + * motor.move_absolute(100, 100); // This does not cause a movement + * + * motor.set_zero_position(80); + * motor.move_absolute(100, 100); // Moves 80 units forward * } * \endcode + * */ - MotorUnits get_encoder_units(const std::uint8_t index = 0) const; + std::int32_t set_zero_position(const double position, const std::uint8_t index = 0) const; /** - * Gets a vector containing the encoder units that were set for the motor. - * - * This function uses the following values of errno when an error state is - * reached: - * ENODEV - The port cannot be configured as a motor - * - * \return A vector containing One of Motor_Units according to what is set for the - * motor or E_MOTOR_ENCODER_INVALID if the operation failed. - * - * \b Example - * \code - * void initialize() { - * pros::Motor motor (1, E_MOTOR_GEARSET_06, E_MOTOR_ENCODER_COUNTS); - * std::cout << "Motor Encoder Units: " << motor.get_encoder_units_all()[0]; - * } - * \endcode - */ - std::vector get_encoder_units_all(void) const; - - /** - * Gets the gearset that was set for the motor. + * Sets the "absolute" zero position of the motor to its current position. * * \note This is one of many Motor functions that takes in an optional index parameter. * This parameter can be ignored by most users but exists to give a shared base class @@ -1574,285 +1520,297 @@ class Motor : public AbstractMotor, public Device { * \param index Optional parameter. * The zero-indexed index of the motor to get the target position of. * By default index is 0, and will return an error for a non-zero index - * - * \return One of Motor_Gears according to what is set for the motor, - * or pros::Motor_Gears::invalid if the operation failed. + * + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. * * \b Example * \code - * void initialize() { - * pros::Motor motor (1, E_MOTOR_GEARSET_06, E_MOTOR_ENCODER_COUNTS); - * std::cout << "Motor Gearing: " << motor.get_gearing(); - * } - * \endcode - */ - MotorGears get_gearing(const std::uint8_t index = 0) const; - - /** - * Gets a vector containing the gearset that was set for the motor. - * - * This function uses the following values of errno when an error state is - * reached: - * ENODEV - The port cannot be configured as a motor - * - * \return A vector containing one of Motor_Gears according to what is set for the motor, - * or pros::Motor_Gears::invalid if the operation failed. + * void autonomous() { + * pros::Motor motor (1); + * motor.move_absolute(100, 100); // Moves 100 units forward + * motor.move_absolute(100, 100); // This does not cause a movement * - * \b Example - * \code - * void initialize() { - * pros::Motor motor (1, E_MOTOR_GEARSET_06, E_MOTOR_ENCODER_COUNTS); - * std::cout << "Motor Gearing: " << motor.get_gearing_all()[0]; + * motor.tare_position(); + * motor.move_absolute(100, 100); // Moves 100 units forward * } * \endcode */ - std::vector get_gearing_all(void) const; + std::int32_t tare_position(const std::uint8_t index = 0) const; /** - * Gets returns a vector with all the port numbers in the motor group. - * - * \return A vector containing the signed port of the motor. (negaitve if the motor is reversed) + * Gets the number of motors. + * + * \return Always returns 1 + * */ - std::vector get_port_all(void) const; + std::int8_t size(void) const; /** - * Gets the voltage limit set by the user. - * - * Default value is 0V, which means that there is no software limitation - * imposed on the voltage. + * gets the port number of the motor * - * \note This is one of many Motor functions that takes in an optional index parameter. - * This parameter can be ignored by most users but exists to give a shared base class - * for motors and motor groups + * \return The signed port of the motor. (negative if the motor is reversed) * + */ + std::int8_t get_port(const std::uint8_t index = 0) const; + + ///@} + + /// \name Additional motor functions + /// These functions allow for motors and motor groups to be used interchangeably + ///@{ + /** + * Gets a vector containing the target position set for the motor by the user + * * 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 non 0 - * - * \param index Optional parameter. - * The zero-indexed index of the motor to get the target position of. - * By default index is 0, and will return an error for a non-zero index + * + * + * \return A vector containing the target position in its encoder units or PROS_ERR_F if the + * operation failed, setting errno. * * \b Example * \code - * void initialize() { + * void autonomous() { * pros::Motor motor (1); - * std::cout << "Motor Voltage Limit: " << motor.get_voltage_limit(); + * motor.move_absolute(100, 100); + * std::cout << "Motor Target: " << motor.get_target_position_all()[0]; + * // Prints 100 * } * \endcode */ - std::int32_t get_voltage_limit(const std::uint8_t index = 0) const; - + std::vector get_target_position_all(void) const; + /** - * Gets a vector of the voltage limit set by the user. - * - * Default value is 0V, which means that there is no software limitation - * imposed on the voltage. + * Gets a vector containing the velocity commanded to the motor by the user * * This function uses the following values of errno when an error state is * reached: * ENODEV - The port cannot be configured as a motor * - * \return A vector containing the motor's voltage limit in V or PROS_ERR if the operation failed, - * setting errno. + * \return A vector containing the commanded motor velocity from +-100, + * +-200, or +-600, or PROS_ERR if the operation failed, setting errno. * * \b Example * \code - * void initialize() { + * void opcontrol() { * pros::Motor motor (1); - * std::cout << "Motor Voltage Limit: " << motor.get_voltage_limit_all()[0]; + * pros::Controller master (E_CONTROLLER_MASTER); + * while (true) { + * motor.move_velocity(master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y)); + * std::cout << "Motor Velocity: " << motor.get_target_velocity_all()[0]; + * // Prints the value of E_CONTROLLER_ANALOG_LEFT_Y + * pros::delay(2); + * } * } * \endcode */ - std::vector get_voltage_limit_all(void) const; + std::vector get_target_velocity_all(void) const; /** - * Gets whether the motor is reversed or not + * Gets a vector containing the actual velocity commanded of the motor * - * \note This is one of many Motor functions that takes in an optional index parameter. - * This parameter can be ignored by most users but exists to give a shared base class - * for motors and motor groups - * * This function uses the following values of errno when an error state is * reached: - * - * EOVERFLOW - The index is non 0 - * - * \param index Optional parameter. - * The zero-indexed index of the motor to get the target position of. - * By default index is 0, and will return an error for a non-zero index + * ENODEV - The port cannot be configured as a motor * - * \return 1 if the motor has been reversed and 0 if the motor was not - * reversed, or PROS_ERR if the operation failed, setting errno. + * \return A vector containing the motor's actual velocity in RPM or PROS_ERR_F + * if the operation failed, setting errno. * * \b Example * \code - * void initialize() { + * void opcontrol() { * pros::Motor motor (1); - * std::cout << "Is the motor reversed? " << motor.is_reversed(); - * // Prints "0" + * pros::Controller master (E_CONTROLLER_MASTER); + * while (true) { + * motor.move_velocity(master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y)); + * std::cout << "Motor Velocity: " << motor.get_actual_velocity_all()[0]; + * // Prints the value of E_CONTROLLER_ANALOG_LEFT_Y + * pros::delay(2); + * } * } * \endcode - */ - std::int32_t is_reversed(const std::uint8_t index = 0) const; + */ + std::vector get_actual_velocity_all(void) const; /** - * Gets a vector containg whether the motor is reversed or not - * - * \return A vector containing 1 if the motor has been reversed and 0 if the motor was not - * reversed, or PROS_ERR if the operation failed, setting errno. + * Gets a vector containing the current drawn by the motor in mA. + * + * This function uses the following values of errno when an error state is + * reached: + * + * ENODEV - The port cannot be configured as a motor + * + * + * \return A vector containing the motor's current in mA or PROS_ERR if the operation failed, + * setting errno. * * \b Example * \code - * void initialize() { + * void opcontrol() { * pros::Motor motor (1); - * std::cout << "Is the motor reversed? " << motor.is_reversed_all()[0]; - * // Prints "0" + * pros::Controller master (E_CONTROLLER_MASTER); + * while (true) { + * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); + * std::cout << "Motor Current Draw: " << motor.get_current_draw_all()[0]; + * pros::delay(2); + * } * } * \endcode */ - std::vector is_reversed_all(void) const; + std::vector get_current_draw_all(void) const; /** - * Sets one of Motor_Brake to the motor. - * \note This is one of many Motor functions that takes in an optional index parameter. - * This parameter can be ignored by most users but exists to give a shared base class - * for motors and motor groups + * Gets a vector containing the direction of movement for the motor. + * * * 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 non 0 - * - * - * \param mode - * The Motor_Brake to set for the motor * - * \param index Optional parameter. - * The zero-indexed index of the motor to get the target position of. - * By default index is 0, and will return an error for a non-zero index - * - * \return 1 if the operation was successful or PROS_ERR if the operation - * failed, setting errno. + * \return A vecotr containing 1 for moving in the positive direction, -1 for moving in the + * negative direction, and PROS_ERR if the operation failed, setting errno. * * \b Example * \code - * void initialize() { + * void opcontrol() { * pros::Motor motor (1); - * motor.set_brake_mode_all(pros::E_MOTOR_BRAKE_HOLD); - * std::cout << "Brake Mode: " << motor.get_brake_mode(); + * pros::Controller master (E_CONTROLLER_MASTER); + * while (true) { + * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); + * std::cout << "Motor Direction: " << motor.get_direction_all()[0]; + * pros::delay(2); + * } * } * \endcode */ - std::int32_t set_brake_mode(const MotorBrake mode, const std::uint8_t index = 0) const; + std::vector get_direction_all(void) const; + /** - * Sets one of Motor_Brake to the motor. - * \note This is one of many Motor functions that takes in an optional index parameter. - * This parameter can be ignored by most users but exists to give a shared base class - * for motors and motor groups + * Gets a vector containing the efficiency of the motor in percent. + * + * 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 * - * EOVERFLOW - The index is non 0 - * - * - * \param mode - * The Motor_Brake to set for the motor - * - * \param index Optional parameter. - * The zero-indexed index of the motor to get the target position of. - * By default index is 0, and will return an error for a non-zero index * - * \return 1 if the operation was successful or PROS_ERR if the operation + * \return A vector containing The motor's efficiency in percent or PROS_ERR_F if the operation * failed, setting errno. * * \b Example * \code - * void initialize() { + * void opcontrol() { * pros::Motor motor (1); - * motor.set_brake_mode_all(pros::E_MOTOR_BRAKE_HOLD); - * std::cout << "Brake Mode: " << motor.get_brake_mode(); + * pros::Controller master (E_CONTROLLER_MASTER); + * while (true) { + * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); + * std::cout << "Motor Efficiency: " << motor.get_efficiency(); + * pros::delay(2); + * } * } * \endcode */ - std::int32_t set_brake_mode(const pros::motor_brake_mode_e_t mode, const std::uint8_t index = 0) const; + std::vector get_efficiency_all(void) const; /** - * Sets one of Motor_Brake to the motor. + * Gets a vector of the faults experienced by the motor. * + * 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 * - * \param mode - * The Motor_Brake to set for the motor - * - * \return 1 if the operation was successful or PROS_ERR if the operation - * failed, setting errno. + * \return A bitfield containing the motor's faults. * * \b Example * \code - * void initialize() { + * void opcontrol() { * pros::Motor motor (1); - * motor.set_brake_mode_all(pros::E_MOTOR_BRAKE_HOLD); - * std::cout << "Brake Mode: " << motor.get_brake_mode(); + * pros::Controller master (E_CONTROLLER_MASTER); + * while (true) { + * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); + * std::cout << "Motor Faults: " << motor.get_faults_all()[0]; + * pros::delay(2); + * } * } * \endcode */ - std::int32_t set_brake_mode_all(const MotorBrake mode) const; + std::vector get_faults_all(void) const; + /** - * Sets one of Motor_Brake to the motor. + * Gets a vector of the flags set by the motor's operation. * + * 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 * - * \param mode - * The Motor_Brake to set for the motor * - * \return 1 if the operation was successful or PROS_ERR if the operation - * failed, setting errno. + * \return A bitfield containing the motor's flags. * * \b Example * \code - * void initialize() { + * void opcontrol() { * pros::Motor motor (1); - * motor.set_brake_mode_all(pros::E_MOTOR_BRAKE_HOLD); - * std::cout << "Brake Mode: " << motor.get_brake_mode(); + * pros::Controller master (E_CONTROLLER_MASTER); + * while (true) { + * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); + * std::cout << "Motor Faults: " << motor.get_faults_all()[0]; + * pros::delay(2); + * } * } * \endcode */ - std::int32_t set_brake_mode_all(const pros::motor_brake_mode_e_t mode) const; + std::vector get_flags_all(void) const; + /** - * Sets the current limit for the motor in mA. - * - * \note This is one of many Motor functions that takes in an optional index parameter. - * This parameter can be ignored by most users but exists to give a shared base class - * for motors and motor groups + * Gets a vector containing the absolute position of the motor in its encoder units. * * This function uses the following values of errno when an error state is * reached: * * ENODEV - The port cannot be configured as a motor + + * + * \return A vector containing the motor's absolute position in its encoder units or PROS_ERR_F + * if the operation failed, setting errno. + * + * \b Example + * \code + * void opcontrol() { + * pros::Motor motor (1); + * pros::Controller master (E_CONTROLLER_MASTER); + * while (true) { + * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); + * std::cout << "Motor Position: " << motor.get_position_all()[0]; + * pros::delay(2); + * } + * } + * \endcode + */ + std::vector get_position_all(void) const; + + /** + * Gets a vector containing the power drawn by the motor in Watts. * - * EOVERFLOW - The index is non 0 + * This function uses the following values of errno when an error state is + * reached: * - * * \param limit - * The new current limit in mA + * ENODEV - The port cannot be configured as a motor * - * \param index Optional parameter. - * The zero-indexed index of the motor to get the target position of. - * By default index is 0, and will return an error for a non-zero index - * - * \return 1 if the operation was successful or PROS_ERR if the operation + * \return A vector containing the motor's power draw in Watts or PROS_ERR_F if the operation * failed, setting errno. * * \b Example @@ -1860,126 +1818,318 @@ class Motor : public AbstractMotor, public Device { * void opcontrol() { * pros::Motor motor (1); * pros::Controller master (E_CONTROLLER_MASTER); + * while (true) { + * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); + * std::cout << "Motor Power: " << motor.get_power_all()[0]; + * pros::delay(2); + * } + * } + * \endcode + */ + std::vector get_power_all(void) const; + + /** + * Gets a vector of the raw encoder count of the motor at a given timestamp. * - * motor.set_current_limit(1000); - * while (true) { - * motor = 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); + * + * This function uses the following values of errno when an error state is + * reached: + * + * ENODEV - The port cannot be configured as a motor + * + * \param 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 + * + * \return A vector containing the raw encoder count at the given timestamp or PROS_ERR if the + * operation failed. + * + * \b Example + * \code + * void opcontrol() { + * std::uint32_t now = pros::millis(); + * pros::Motor motor (1); + * pros::Controller master (E_CONTROLLER_MASTER); + * while (true) { + * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); + * std::cout << "Motor Position: " << motor.get_raw_position(&now); + * pros::delay(2); * } * } * \endcode */ - std::int32_t set_current_limit(const std::int32_t limit, const std::uint8_t index = 0) const; + std::vector get_raw_position_all(std::uint32_t* const timestamp) const; + /** - * Sets the current limit for the motor in mA. + * Gets a vector of the temperature of the motor in degrees Celsius. * * This function uses the following values of errno when an error state is * reached: * ENODEV - The port cannot be configured as a motor * - * \param limit - * The new current limit in mA + * \return A vector contaioning the motor's temperature in degrees Celsius + * or PROS_ERR_F if the operation failed, setting errno. * - * \return 1 if the operation was successful or PROS_ERR if the operation - * failed, setting errno. + * \b Example + * \code + * void opcontrol() { + * pros::Motor motor (1); + * pros::Controller master (E_CONTROLLER_MASTER); + * while (true) { + * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); + * std::cout << "Motor Temperature: " << motor.get_temperature_all()[0]; + * pros::delay(2); + * } + * } + * \endcode + */ + std::vector get_temperature_all(void) const; + + /** + * Gets a vector of the torque generated by the motor in Newton Meters (Nm). + * + * This function uses the following values of errno when an error state is + * reached: + * ENODEV - The port cannot be configured as a motor + * + * \return A vector containing the motor's torque in Nm or PROS_ERR_F if the operation failed, + * setting errno. * * \b Example * \code * void opcontrol() { * pros::Motor motor (1); * pros::Controller master (E_CONTROLLER_MASTER); + * while (true) { + * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); + * std::cout << "Motor Torque: " << motor.get_torque(); + * pros::delay(2); + * } + * } + * \endcode + */ + std::vector get_torque_all(void) const; + + /** + * Gets a vector of the voltage delivered to the motor in millivolts. * - * motor.set_current_limit(1000); - * while (true) { - * motor = 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); + * This function uses the following values of errno when an error state is + * reached: + * ENODEV - The port cannot be configured as a motor + * + * + * \return A vector of the motor's voltage in mV or PROS_ERR_F if the operation failed, + * setting errno. + * + * \b Example + * \code + * void opcontrol() { + * pros::Motor motor (1); + * pros::Controller master (E_CONTROLLER_MASTER); + * while (true) { + * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); + * std::cout << "Motor Voltage: " << motor.get_voltage_all()[0]; + * pros::delay(2); * } * } * \endcode */ - std::int32_t set_current_limit_all(const std::int32_t limit) const; + std::vector get_voltage_all(void) const; + /** - * Sets one of Motor_Units for the motor encoder. Works with the C - * enum and the C++ enum class. + * Checks if the motor is drawing over its current limit. * * This function uses the following values of errno when an error state is * reached: * ENODEV - The port cannot be configured as a motor * - * \param units - * The new motor encoder units + * \return A vector containing 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. * - * \return 1 if the operation was successful or PROS_ERR if the operation - * failed, setting errno. + * \b Example + * \code + * void opcontrol() { + * pros::Motor motor (1); + * pros::Controller master (E_CONTROLLER_MASTER); + * while (true) { + * motor = 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); + * } + * } + * \endcode + */ + std::vector is_over_current_all(void) const; + + /** + * Gets the temperature limit flag for the motor. + * + * This function uses the following values of errno when an error state is + * reached: + * ENODEV - The port cannot be configured as a motor + * + * \return A vector containing 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. + * + * \b Example + * \code + * void opcontrol() { + * pros::Motor motor (1); + * pros::Controller master (E_CONTROLLER_MASTER); + * while (true) { + * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); + * std::cout << "Is the motor over its temperature limit?: " << motor.is_over_temp_all(); + * pros::delay(2); + * } + * } + * \endcode + */ + std::vector is_over_temp_all(void) const; + + /** + * Gets a vector containing the brake mode that was set for the motor. + * + * This function uses the following values of errno when an error state is + * reached: + * ENODEV - The port cannot be configured as a motor + * + * \return One of Motor_Brake, according to what was set for the + * motor, or E_MOTOR_BRAKE_INVALID if the operation failed, setting errno. * * \b Example * \code * void initialize() { * pros::Motor motor (1); - * motor.set_encoder_units(E_MOTOR_ENCODER_DEGREES); - * std::cout << "Encoder Units: " << motor.get_encoder_units(); + * motor.set_brake_mode(pros::E_MOTOR_BRAKE_HOLD); + * std::cout << "Brake Mode: " << motor.get_brake_mode(); * } * \endcode */ - std::int32_t set_encoder_units(const MotorUnits units, const std::uint8_t index = 0) const; + std::vector get_brake_mode_all(void) const; + /** - * Sets one of Motor_Units for the motor encoder. Works with the C - * enum and the C++ enum class. + * Gets a vector containing the current limit for the motor in mA. + * + * The default value is 2500 mA. * - * \note This is one of many Motor functions that takes in an optional index parameter. - * This parameter can be ignored by most users but exists to give a shared base class - * for motors and motor groups - * * 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 non 0 - * - * \param index Optional parameter. - * The zero-indexed index of the motor to get the target position of. - * By default index is 0, and will return an error for a non-zero index - * - * * \param units - * The new motor encoder units * - * \return 1 if the operation was successful or PROS_ERR if the operation - * failed, setting errno. + * \return A vector containing the motor's current limit in mA or PROS_ERR if the operation failed, + * setting errno. + * + * \b Example + * \code + * void opcontrol() { + * pros::Motor motor (1); + * while (true) { + * std::cout << "Motor Current Limit: " << motor.get_current_limit_all()[0]; + * pros::delay(2); + * } + * } + * \endcode + */ + std::vector get_current_limit_all(void) const; + + /** + * Gets a vector containing the encoder units that were set for the motor. + * + * This function uses the following values of errno when an error state is + * reached: + * ENODEV - The port cannot be configured as a motor + * + * \return A vector containing One of Motor_Units according to what is set for the + * motor or E_MOTOR_ENCODER_INVALID if the operation failed. + * + * \b Example + * \code + * void initialize() { + * pros::Motor motor (1, E_MOTOR_GEARSET_06, E_MOTOR_ENCODER_COUNTS); + * std::cout << "Motor Encoder Units: " << motor.get_encoder_units_all()[0]; + * } + * \endcode + */ + std::vector get_encoder_units_all(void) const; + + /** + * Gets a vector containing the gearset that was set for the motor. + * + * This function uses the following values of errno when an error state is + * reached: + * ENODEV - The port cannot be configured as a motor + * + * \return A vector containing one of Motor_Gears according to what is set for the motor, + * or pros::Motor_Gears::invalid if the operation failed. + * + * \b Example + * \code + * void initialize() { + * pros::Motor motor (1, E_MOTOR_GEARSET_06, E_MOTOR_ENCODER_COUNTS); + * std::cout << "Motor Gearing: " << motor.get_gearing_all()[0]; + * } + * \endcode + */ + std::vector get_gearing_all(void) const; + + /** + * Gets returns a vector with all the port numbers in the motor group. + * + * \return A vector containing the signed port of the motor. (negative if the motor is reversed) + */ + std::vector get_port_all(void) const; + + /** + * Gets a vector of the voltage limit set by the user. + * + * 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 + * + * \return A vector containing the motor's voltage limit in V or PROS_ERR if the operation failed, + * setting errno. * * \b Example * \code * void initialize() { * pros::Motor motor (1); - * motor.set_encoder_units(E_MOTOR_ENCODER_DEGREES); - * std::cout << "Encoder Units: " << motor.get_encoder_units(); + * std::cout << "Motor Voltage Limit: " << motor.get_voltage_limit_all()[0]; * } * \endcode */ - std::int32_t set_encoder_units(const pros::motor_encoder_units_e_t units, const std::uint8_t index = 0) const; + std::vector get_voltage_limit_all(void) const; + /** - * Sets one of Motor_Units for the motor encoder. Works with the C - * enum and the C++ enum class. + * Gets a vector containg whether the motor is reversed or not + * + * \return A vector containing 1 if the motor has been reversed and 0 if the motor was not + * reversed, or PROS_ERR if the operation failed, setting errno. + * + * \b Example + * \code + * void initialize() { + * pros::Motor motor (1); + * std::cout << "Is the motor reversed? " << motor.is_reversed_all()[0]; + * // Prints "0" + * } + * \endcode + */ + std::vector is_reversed_all(void) const; + + /** + * Sets one of Motor_Brake to the motor. * - * \note This is one of many Motor functions that takes in an optional index parameter. - * This parameter can be ignored by most users but exists to give a shared base class - * for motors and motor groups - * * 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 non 0 - * - * * \param units - * The new motor encoder units - * - * \param index Optional parameter. - * The zero-indexed index of the motor to get the target position of. - * By default index is 0, and will return an error for a non-zero index + * + * \param mode + * The Motor_Brake to set for the motor * * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. @@ -1988,23 +2138,22 @@ class Motor : public AbstractMotor, public Device { * \code * void initialize() { * pros::Motor motor (1); - * motor.set_encoder_units(E_MOTOR_ENCODER_DEGREES); - * std::cout << "Encoder Units: " << motor.get_encoder_units(); + * motor.set_brake_mode_all(pros::E_MOTOR_BRAKE_HOLD); + * std::cout << "Brake Mode: " << motor.get_brake_mode(); * } * \endcode */ - std::int32_t set_encoder_units_all(const MotorUnits units) const; + std::int32_t set_brake_mode_all(const MotorBrake mode) const; /** - * Sets one of Motor_Units for the motor encoder. Works with the C - * enum and the C++ enum class. + * Sets one of Motor_Brake to the motor. * * This function uses the following values of errno when an error state is * reached: * ENODEV - The port cannot be configured as a motor * - * \param units - * The new motor encoder units + * \param mode + * The Motor_Brake to set for the motor * * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. @@ -2013,52 +2162,47 @@ class Motor : public AbstractMotor, public Device { * \code * void initialize() { * pros::Motor motor (1); - * motor.set_encoder_units(E_MOTOR_ENCODER_DEGREES); - * std::cout << "Encoder Units: " << motor.get_encoder_units(); + * motor.set_brake_mode_all(pros::E_MOTOR_BRAKE_HOLD); + * std::cout << "Brake Mode: " << motor.get_brake_mode(); * } * \endcode */ - std::int32_t set_encoder_units_all(const pros::motor_encoder_units_e_t units) const; - + std::int32_t set_brake_mode_all(const pros::motor_brake_mode_e_t mode) const; + /** - * Sets one of the gear cartridge (red, green, blue) for the motor. Usable with - * the C++ enum class and the C enum. + * Sets the current limit for the motor in mA. * - * \note This is one of many Motor functions that takes in an optional index parameter. - * This parameter can be ignored by most users but exists to give a shared base class - * for motors and motor groups - * * 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 non 0 - * - * \param index Optional parameter. - * The zero-indexed index of the motor to get the target position of. - * By default index is 0, and will return an error for a non-zero index - * \param gearset - * The new motor gearset + * + * \param limit + * The new current limit in mA * * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. * * \b Example * \code - * void initialize() { + * void opcontrol() { * pros::Motor motor (1); - * motor.set_gearing(E_MOTOR_GEARSET_06); - * std::cout << "Gearset: " << motor.get_gearing(); + * pros::Controller master (E_CONTROLLER_MASTER); + * + * motor.set_current_limit_all(1000); + * while (true) { + * motor = 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); + * } * } * \endcode */ - std::int32_t set_gearing(const MotorGears gearset, const std::uint8_t index = 0) const; - + std::int32_t set_current_limit_all(const std::int32_t limit) const; + /** - * Sets one of the gear cartridge (red, green, blue) for the motor. Usable with - * the C++ enum class and the C enum. - + * Sets one of Motor_Units for the motor encoder. Works with the C + * enum and the C++ enum class. + * * \note This is one of many Motor functions that takes in an optional index parameter. * This parameter can be ignored by most users but exists to give a shared base class * for motors and motor groups @@ -2070,14 +2214,13 @@ class Motor : public AbstractMotor, public Device { * * EOVERFLOW - The index is non 0 * - * \param gearset - * The new motor gearset + * * \param units + * The new motor encoder units * * \param index Optional parameter. * The zero-indexed index of the motor to get the target position of. * By default index is 0, and will return an error for a non-zero index * - * * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. * @@ -2085,23 +2228,23 @@ class Motor : public AbstractMotor, public Device { * \code * void initialize() { * pros::Motor motor (1); - * motor.set_gearing(E_MOTOR_GEARSET_06); - * std::cout << "Gearset: " << motor.get_gearing(); + * motor.set_encoder_units_all(E_MOTOR_ENCODER_DEGREES); + * std::cout << "Encoder Units: " << motor.get_encoder_units(); * } * \endcode */ - std::int32_t set_gearing(const pros::motor_gearset_e_t gearset, const std::uint8_t index = 0) const; + std::int32_t set_encoder_units_all(const MotorUnits units) const; /** - * Sets one of the gear cartridge (red, green, blue) for the motor. Usable with - * the C++ enum class and the C enum. + * Sets one of Motor_Units for the motor encoder. 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 * - * \param gearset - * The new motor gearset + * \param units + * The new motor encoder units * * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. @@ -2110,13 +2253,14 @@ class Motor : public AbstractMotor, public Device { * \code * void initialize() { * pros::Motor motor (1); - * motor.set_gearing_all(E_MOTOR_GEARSET_06); - * std::cout << "Gearset: " << motor.get_gearing(); + * motor.set_encoder_units_all(E_MOTOR_ENCODER_DEGREES); + * std::cout << "Encoder Units: " << motor.get_encoder_units(); * } * \endcode */ - std::int32_t set_gearing_all(const MotorGears gearset) const; + std::int32_t set_encoder_units_all(const pros::motor_encoder_units_e_t units) const; + /** * Sets one of the gear cartridge (red, green, blue) for the motor. Usable with * the C++ enum class and the C enum. @@ -2140,29 +2284,18 @@ class Motor : public AbstractMotor, public Device { * } * \endcode */ - std::int32_t set_gearing_all(const pros::motor_gearset_e_t gearset) const; - - + std::int32_t set_gearing_all(const MotorGears gearset) const; + /** - * Sets the reverse flag for the motor. - * - * This will invert its movements and the values returned for its position. + * Sets one of the gear cartridge (red, green, blue) for the motor. Usable with + * the C++ enum class and the C enum. * - * \note This is one of many Motor functions that takes in an optional index parameter. - * This parameter can be ignored by most users but exists to give a shared base class - * for motors and motor groups - * * This function uses the following values of errno when an error state is * reached: - * - * EOVERFLOW - The index is non 0 - * - * \param reverse - * True reverses the motor, false is default direction - * - * \param index Optional parameter. - * The zero-indexed index of the motor to get the target position of. - * By default index is 0, and will return an error for a non-zero index + * ENODEV - The port cannot be configured as a motor + * + * \param gearset + * The new motor gearset * * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. @@ -2171,12 +2304,13 @@ class Motor : public AbstractMotor, public Device { * \code * void initialize() { * pros::Motor motor (1); - * motor.set_reversed(true); - * std::cout << "Is this motor reversed? " << motor.is_reversed(); + * motor.set_gearing_all(E_MOTOR_GEARSET_06); + * std::cout << "Gearset: " << motor.get_gearing(); * } * \endcode */ - std::int32_t set_reversed(const bool reverse, const std::uint8_t index = 0); + std::int32_t set_gearing_all(const pros::motor_gearset_e_t gearset) const; + /** * Sets the reverse flag for the motor. * @@ -2198,36 +2332,6 @@ class Motor : public AbstractMotor, public Device { * \endcode */ std::int32_t set_reversed_all(const bool reverse); - - /** - * Sets the voltage limit for the motor in Volts. - * - * This function uses the following values of errno when an error state is - * reached: - * ENODEV - The port cannot be configured as a motor - * - * \param limit - * The new voltage limit in Volts - * - * \return 1 if the operation was successful or PROS_ERR if the operation - * failed, setting errno. - * - * \b Example - * \code - * void autonomous() { - * pros::Motor motor (1); - * pros::Controller master (E_CONTROLLER_MASTER); - * - * motor.set_voltage_limit(10000); - * while (true) { - * motor = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); - * // The motor will not output more than 10 V - * pros::delay(2); - * } - * } - * \endcode - */ - std::int32_t set_voltage_limit(const std::int32_t limit, const std::uint8_t index = 0) const; /** * Sets the voltage limit for the motor in Volts. @@ -2269,49 +2373,6 @@ class Motor : public AbstractMotor, public Device { * \endcode */ std::int32_t set_voltage_limit_all(const std::int32_t limit) const; - - /** - * Sets the position for the motor in its encoder units. - * - * This will be the future reference point for the motor's "absolute" - * position. - * - * \note This is one of many Motor functions that takes in an optional index parameter. - * This parameter can be ignored by most users but exists to give a shared base class - * for motors and motor groups - * - * 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 non 0 - * - * \param position - * The new reference position in its encoder units - * - * \param index Optional parameter. - * The zero-indexed index of the motor to get the target position of. - * By default index is 0, and will return an error for a non-zero index - * - * - * \return 1 if the operation was successful or PROS_ERR if the operation - * failed, setting errno. - * - * \b Example - * \code - * void autonomous() { - * pros::Motor motor (1); - * motor.move_absolute(100, 100); // Moves 100 units forward - * motor.move_absolute(100, 100); // This does not cause a movement - * - * motor.set_zero_position(80); - * motor.move_absolute(100, 100); // Moves 80 units forward - * } - * \endcode - * - */ - std::int32_t set_zero_position(const double position, const std::uint8_t index = 0) const; /** * Sets the position for the motor in its encoder units. @@ -2344,41 +2405,6 @@ class Motor : public AbstractMotor, public Device { */ std::int32_t set_zero_position_all(const double position) const; - /** - * Sets the "absolute" zero position of the motor to its current position. - * - * \note This is one of many Motor functions that takes in an optional index parameter. - * This parameter can be ignored by most users but exists to give a shared base class - * for motors and motor groups - * - * 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 non 0 - * - * \param index Optional parameter. - * The zero-indexed index of the motor to get the target position of. - * By default index is 0, and will return an error for a non-zero index - * - * \return 1 if the operation was successful or PROS_ERR if the operation - * failed, setting errno. - * - * \b Example - * \code - * void autonomous() { - * pros::Motor motor (1); - * motor.move_absolute(100, 100); // Moves 100 units forward - * motor.move_absolute(100, 100); // This does not cause a movement - * - * motor.tare_position(); - * motor.move_absolute(100, 100); // Moves 100 units forward - * } - * \endcode - */ - std::int32_t tare_position(const std::uint8_t index = 0) const; - /** * Sets the "absolute" zero position of the motor to its current position. * @@ -2403,21 +2429,7 @@ class Motor : public AbstractMotor, public Device { */ std::int32_t tare_position_all(void) const; - /** - * Gets the number of motors. - * - * \return Always returns 1 - * - */ - std::int8_t size(void) const; - - /** - * gets the port number of the motor - * - * \return A vector containing the signed port of the motor. (negaitve if the motor is reversed) - * - */ - std::int8_t get_port(const std::uint8_t index = 0) const; + ///@} private: std::int8_t _port;