diff --git a/include/pros/motor_group.hpp b/include/pros/motor_group.hpp index 8701bf08..9feb444b 100644 --- a/include/pros/motor_group.hpp +++ b/include/pros/motor_group.hpp @@ -758,7 +758,7 @@ class MotorGroup : public virtual AbstractMotor { * * EDOM - THe motor group is empty * - * \return A vecotr containing each motor's efficiency in percent or PROS_ERR_F if the operation + * \return A vector containing each motor's efficiency in percent or PROS_ERR_F if the operation * failed, setting errno. * * \b Example @@ -1107,7 +1107,7 @@ class MotorGroup : public virtual AbstractMotor { * ENODEV - The port cannot be configured as a motor * EDOM - The motor group is empty * - * \return A vecotr of each motor's temperature in degrees Celsius or PROS_ERR_F if the + * \return A vector of each motor's temperature in degrees Celsius or PROS_ERR_F if the * operation failed, setting errno. * * \b Example @@ -1320,7 +1320,7 @@ class MotorGroup : public virtual AbstractMotor { */ std::int32_t is_over_temp(const std::uint8_t index = 0) const; /** - * Gets a vecotr with the temperature limit flag for each motor in the motor group. + * Gets a vector with the temperature limit flag for each motor in the motor group. * * This function uses the following values of errno when an error state is * reached: @@ -1377,7 +1377,7 @@ class MotorGroup : public virtual AbstractMotor { */ MotorBrake get_brake_mode(const std::uint8_t index = 0) const; /** - * Gets a vecotr with the brake mode that was set for each motor in the motor group. + * Gets a vector with the brake mode that was set for each motor in the motor group. * * This function uses the following values of errno when an error state is * reached: diff --git a/include/pros/motors.hpp b/include/pros/motors.hpp index 5381568c..7b959e8f 100644 --- a/include/pros/motors.hpp +++ b/include/pros/motors.hpp @@ -372,29 +372,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. * @@ -430,32 +407,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 @@ -495,33 +446,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. * @@ -558,18 +482,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 @@ -578,17 +510,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 @@ -603,9 +540,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 @@ -614,26 +551,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 @@ -642,22 +589,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 @@ -673,8 +616,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 @@ -683,29 +625,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 @@ -714,18 +661,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 @@ -741,9 +686,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 @@ -752,45 +697,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 @@ -806,7 +768,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 @@ -815,26 +778,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 @@ -843,16 +814,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 @@ -868,9 +839,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 @@ -879,25 +850,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 @@ -906,16 +887,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 @@ -932,8 +913,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 @@ -942,42 +923,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 MotorBrake, 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 @@ -990,72 +983,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 MotorUnits 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 @@ -1071,51 +1052,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 MotorGears according to what is set for the motor, + * or pros::MotorGears::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 @@ -1123,61 +1105,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 MotorBrake 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 MotorBrake 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 @@ -1189,56 +1173,29 @@ class Motor : public AbstractMotor, public Device { * * EOVERFLOW - The index is non 0 * + * + * \param mode + * The MotorBrake 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 @@ -1251,57 +1208,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 MotorUnits 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 MotorUnits 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 @@ -1318,57 +1278,25 @@ 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 @@ -1384,45 +1312,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 MotorBrake, 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 MotorBrake, 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 @@ -1431,57 +1378,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 @@ -1494,25 +1448,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 MotorUnits 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. + * 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 @@ -1528,408 +1491,616 @@ 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 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. * - * \return A vector containing One of MotorUnits according to what is set for the - * motor or E_MOTOR_ENCODER_INVALID if the operation failed. + * \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; + + /** + * Gets the number of motors. + * + * \return Always returns 1 + * + */ + std::int8_t size(void) const; + + /** + * gets the port number of the motor + * + * \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 + * + * + * \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() { - * pros::Motor motor (1, E_MOTOR_GEARSET_06, E_MOTOR_ENCODER_COUNTS); - * std::cout << "Motor Encoder Units: " << motor.get_encoder_units_all()[0]; + * 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_encoder_units_all(void) const; + std::vector get_target_position_all(void) const; /** - * Gets the gearset that was set for the motor. + * Gets a vector containing the velocity commanded to the motor by the user * - * \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 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; + + /** + * 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 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 * - * 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 current in mA or PROS_ERR if the operation failed, + * setting errno. * - * \return One of MotorGears according to what is set for the motor, - * or pros::MotorGears::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 Current Draw: " << motor.get_current_draw_all()[0]; + * pros::delay(2); + * } + * } + * \endcode + */ + std::vector get_current_draw_all(void) const; + + /** + * 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 + * + * + * \return A vector 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() { - * pros::Motor motor (1, E_MOTOR_GEARSET_06, E_MOTOR_ENCODER_COUNTS); - * std::cout << "Motor Gearing: " << motor.get_gearing(); + * 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 Direction: " << motor.get_direction_all()[0]; + * pros::delay(2); + * } * } * \endcode */ - MotorGears get_gearing(const std::uint8_t index = 0) const; + std::vector get_direction_all(void) const; + + /** + * 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 + * + * + * \return A vector containing The motor's efficiency in percent 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 Efficiency: " << motor.get_efficiency(); + * pros::delay(2); + * } + * } + * \endcode + */ + std::vector get_efficiency_all(void) const; /** - * Gets a vector containing the gearset that was set for 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 * - * \return A vector containing one of MotorGears according to what is set for the motor, - * or pros::MotorGears::invalid if the operation failed. + * \return A bitfield containing the motor's faults. * * \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]; + * 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 Faults: " << motor.get_faults_all()[0]; + * pros::delay(2); + * } * } * \endcode */ - std::vector get_gearing_all(void) const; + std::vector get_faults_all(void) const; /** - * Gets returns a vector with all the port numbers in the motor group. + * 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 + * + * + * \return A bitfield containing the motor's flags. * - * \return A vector containing the signed port of the motor. (negaitve if the motor is reversed) + * \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 Faults: " << motor.get_faults_all()[0]; + * pros::delay(2); + * } + * } + * \endcode */ - std::vector get_port_all(void) const; + std::vector get_flags_all(void) const; + + /** + * 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 the voltage limit set by the user. + * Gets a vector containing the power drawn by the motor in Watts. + * + * 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. * - * Default value is 0V, which means that there is no software limitation - * imposed on the voltage. + * \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 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. * - * \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 vector containing the raw encoder count at the given timestamp or PROS_ERR if the + * operation failed. * * \b Example * \code - * void initialize() { + * void opcontrol() { + * std::uint32_t now = pros::millis(); * pros::Motor motor (1); - * std::cout << "Motor Voltage Limit: " << motor.get_voltage_limit(); + * 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 get_voltage_limit(const std::uint8_t index = 0) const; + std::vector get_raw_position_all(std::uint32_t* const timestamp) 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 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 * - * \return A vector containing the motor's voltage limit in V or PROS_ERR if the operation failed, - * setting errno. + * \return A vector contaioning the motor's temperature in degrees Celsius + * or PROS_ERR_F 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 = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); + * std::cout << "Motor Temperature: " << motor.get_temperature_all()[0]; + * pros::delay(2); + * } * } * \endcode */ - std::vector get_voltage_limit_all(void) const; + std::vector get_temperature_all(void) const; /** - * Gets whether the motor is reversed or not + * 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. * - * \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 + * 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 motor has been reversed and 0 if the motor was not - * reversed, or PROS_ERR if the operation failed, setting errno. + * \return A vector of the motor's voltage in mV 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 = master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y); + * std::cout << "Motor Voltage: " << motor.get_voltage_all()[0]; + * pros::delay(2); + * } * } * \endcode */ - std::int32_t is_reversed(const std::uint8_t index = 0) const; + std::vector get_voltage_all(void) const; /** - * Gets a vector containg whether the motor is reversed or not + * Checks if the motor is drawing over its current limit. * - * \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. + * 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. * * \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 << "Is the motor over its current limit?: " << motor.is_over_current_all()[0]; + * pros::delay(2); + * } * } * \endcode */ - std::vector is_reversed_all(void) const; - + std::vector is_over_current_all(void) const; + /** - * Sets one of MotorBrake 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 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 * - * ENODEV - The port cannot be configured as a motor - * - * EOVERFLOW - The index is non 0 - * - * - * \param mode - * The MotorBrake 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 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 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 << "Is the motor over its temperature limit?: " << motor.is_over_temp_all(); + * pros::delay(2); + * } * } * \endcode */ - std::int32_t set_brake_mode(const MotorBrake mode, const std::uint8_t index = 0) const; + std::vector is_over_temp_all(void) const; + /** - * Sets one of MotorBrake 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 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 - * - * EOVERFLOW - The index is non 0 - * - * - * \param mode - * The MotorBrake 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 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_brake_mode_all(pros::E_MOTOR_BRAKE_HOLD); + * motor.set_brake_mode(pros::E_MOTOR_BRAKE_HOLD); * std::cout << "Brake Mode: " << motor.get_brake_mode(); * } * \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_brake_mode_all(void) const; /** - * Sets one of MotorBrake to the motor. + * Gets a vector containing the current limit for the motor in mA. + * + * 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 * - * \param mode - * The MotorBrake to set for the motor - * - * \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 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(); + * while (true) { + * std::cout << "Motor Current Limit: " << motor.get_current_limit_all()[0]; + * pros::delay(2); + * } * } * \endcode */ - std::int32_t set_brake_mode_all(const MotorBrake mode) const; + std::vector get_current_limit_all(void) const; + /** - * Sets one of MotorBrake to the motor. + * 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 * - * \param mode - * The MotorBrake to set for the motor - * - * \return 1 if the operation was successful or PROS_ERR if the operation - * failed, setting errno. + * \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); - * motor.set_brake_mode_all(pros::E_MOTOR_BRAKE_HOLD); - * std::cout << "Brake Mode: " << motor.get_brake_mode(); + * 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::int32_t set_brake_mode_all(const pros::motor_brake_mode_e_t mode) const; + std::vector get_encoder_units_all(void) const; + /** - * Sets the current limit for the motor in mA. + * Gets a vector containing 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 - * * 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 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 operation was successful or PROS_ERR if the operation - * failed, setting errno. + * \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 opcontrol() { - * pros::Motor motor (1); - * pros::Controller master (E_CONTROLLER_MASTER); - * - * 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); - * } + * 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::int32_t set_current_limit(const std::int32_t limit, const std::uint8_t index = 0) const; + std::vector get_gearing_all(void) const; + /** - * Sets the current limit for the motor in mA. + * 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 * - * \param limit - * The new current limit in mA - * - * \return 1 if the operation was successful or PROS_ERR if the operation - * failed, setting errno. + * \return A vector containing the motor's voltage limit in V 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); - * - * 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); - * } + * std::cout << "Motor Voltage Limit: " << motor.get_voltage_limit_all()[0]; * } * \endcode */ - std::int32_t set_current_limit_all(const std::int32_t limit) const; + std::vector get_voltage_limit_all(void) const; + /** - * Sets one of MotorUnits 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 units - * The new motor encoder units + * Gets a vector containg whether the motor is reversed or not * - * \return 1 if the operation was successful or PROS_ERR if the operation - * failed, setting errno. + * \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); - * motor.set_encoder_units(E_MOTOR_ENCODER_DEGREES); - * std::cout << "Encoder Units: " << motor.get_encoder_units(); + * std::cout << "Is the motor reversed? " << motor.is_reversed_all()[0]; + * // Prints "0" * } * \endcode */ - std::int32_t set_encoder_units(const MotorUnits units, const std::uint8_t index = 0) const; + std::vector is_reversed_all(void) const; + /** - * Sets one of MotorUnits for the motor encoder. Works with the C - * enum and the C++ enum class. + * 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 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 + * + * \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. @@ -1938,33 +2109,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(const pros::motor_encoder_units_e_t units, const std::uint8_t index = 0) const; + std::int32_t set_brake_mode_all(const MotorBrake mode) const; + /** - * Sets one of MotorUnits for the motor encoder. Works with the C - * enum and the C++ enum class. + * 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. @@ -1973,41 +2133,46 @@ 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 pros::motor_brake_mode_e_t mode) const; + /** - * Sets one of MotorUnits for the motor encoder. Works with the C - * enum and the C++ enum class. + * Sets the current limit for 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 * - * \param units - * The new motor encoder units + * \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_encoder_units(E_MOTOR_ENCODER_DEGREES); - * std::cout << "Encoder Units: " << motor.get_encoder_units(); + * 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_encoder_units_all(const pros::motor_encoder_units_e_t units) 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 @@ -2020,11 +2185,12 @@ class Motor : public AbstractMotor, public Device { * * 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 gearset - * The new motor gearset * * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. @@ -2033,35 +2199,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 MotorGears 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. - - * \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 - * + * 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 - * - * 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 * + * \param units + * The new motor encoder units * * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. @@ -2070,13 +2224,14 @@ 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 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. @@ -2126,42 +2281,7 @@ class Motor : public AbstractMotor, public Device { * \endcode */ std::int32_t set_gearing_all(const pros::motor_gearset_e_t gearset) const; - - - /** - * 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 - * 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 - * - * \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_reversed(true); - * std::cout << "Is this motor reversed? " << motor.is_reversed(); - * } - * \endcode - */ - std::int32_t set_reversed(const bool reverse, const std::uint8_t index = 0); + /** * Sets the reverse flag for the motor. * @@ -2183,36 +2303,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. @@ -2254,49 +2344,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. @@ -2329,41 +2376,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. * @@ -2388,21 +2400,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. (negative if the motor is reversed) - * - */ - std::int8_t get_port(const std::uint8_t index = 0) const; + ///@} private: std::int8_t _port; diff --git a/include/pros/rotation.hpp b/include/pros/rotation.hpp index b58ad912..25806c3f 100644 --- a/include/pros/rotation.hpp +++ b/include/pros/rotation.hpp @@ -53,27 +53,7 @@ class Rotation : public Device { * } * \endcode */ - explicit Rotation(const std::uint8_t port) : Device(port, DeviceType::rotation) {}; - - /** - * Constructs a new Rotation Sensor object - * - * ENXIO - The given value is not within the range of V5 ports |1-21|. - * ENODEV - The port cannot be configured as a Rotation Sensor - * - * \param port - * The V5 port number from 1 to 21, or from -21 to -1 for reversed Rotation Sensors. - * \param reverse_flag - * Determines if the Rotation Sensor is reversed or not. - * - * \b Example - * \code - * void opcontrol() { - * pros::Rotation rotation_sensor(1, true); //Creates a reversed Rotation Sensor on port 1 - * } - * \endcode - */ - explicit Rotation(const std::uint8_t port, const bool reverse_flag); + explicit Rotation(const std::int8_t port); /** * Reset the Rotation Sensor diff --git a/src/devices/vdml_motorgroup.cpp b/src/devices/vdml_motorgroup.cpp index 2b1438de..ca9b37cf 100644 --- a/src/devices/vdml_motorgroup.cpp +++ b/src/devices/vdml_motorgroup.cpp @@ -31,7 +31,7 @@ using namespace pros::c; #define empty_MotorGroup_check_vector(error, vector) \ if (_ports.size() <= 0) { \ errno = EDOM; \ - vector.emplace_back(error); \ + vector.push_back(error); \ return vector; \ } @@ -137,7 +137,7 @@ std::vector MotorGroup::get_actual_velocity_all(void) const { empty_MotorGroup_check_vector(PROS_ERR_F, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(motor_get_actual_velocity(*it)); + return_vector.push_back(motor_get_actual_velocity(*it)); } return return_vector; } @@ -154,7 +154,7 @@ std::vector MotorGroup::get_brake_mode_all(void) const { empty_MotorGroup_check_vector(pros::v5::MotorBrake::invalid, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(static_cast(motor_get_brake_mode(*it))); + return_vector.push_back(static_cast(motor_get_brake_mode(*it))); } return return_vector; } @@ -170,7 +170,7 @@ std::vector MotorGroup::get_current_draw_all(void) const { empty_MotorGroup_check_vector(PROS_ERR, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(motor_get_current_draw(*it)); + return_vector.push_back(motor_get_current_draw(*it)); } return return_vector; } @@ -187,7 +187,7 @@ std::vector MotorGroup::get_current_limit_all(void) const { empty_MotorGroup_check_vector(PROS_ERR, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(motor_get_current_limit(*it)); + return_vector.push_back(motor_get_current_limit(*it)); } return return_vector; } @@ -202,7 +202,7 @@ std::vector MotorGroup::is_over_current_all(void) const { std::vector return_vector; empty_MotorGroup_check_vector(PROS_ERR, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(motor_is_over_current(*it)); + return_vector.push_back(motor_is_over_current(*it)); } return return_vector; } @@ -210,14 +210,18 @@ std::vector MotorGroup::is_over_current_all(void) const { std::int32_t MotorGroup::get_direction(const std::uint8_t index) const { empty_MotorGroup_check(PROS_ERR); MotorGroup_index_check(PROS_ERR, index); - return motor_get_direction(_ports[index]); + int ret = motor_get_direction(_ports[index]); + ret = _ports[index] >= 0 ? ret : ret * -1; + return ret; } std::vector MotorGroup::get_direction_all(void) const { std::vector return_vector; empty_MotorGroup_check_vector(PROS_ERR, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(motor_get_direction(*it)); + int ret = motor_get_direction(*it); + ret = *it >= 0 ? ret : ret * -1; + return_vector.push_back(ret); } return return_vector; } @@ -232,7 +236,7 @@ std::vector MotorGroup::get_efficiency_all(void) const { std::vector return_vector; empty_MotorGroup_check_vector(PROS_ERR_F, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(motor_get_efficiency(*it)); + return_vector.push_back(motor_get_efficiency(*it)); } return return_vector; } @@ -247,7 +251,7 @@ std::vector MotorGroup::get_encoder_units_all(void) const std::vector return_vector; empty_MotorGroup_check_vector(pros::v5::MotorUnits::invalid, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(static_cast(motor_get_encoder_units(*it))); + return_vector.push_back(static_cast(motor_get_encoder_units(*it))); } return return_vector; } @@ -262,7 +266,7 @@ std::vector MotorGroup::get_faults_all(void) const { std::vector return_vector; empty_MotorGroup_check_vector(PROS_ERR, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(motor_get_faults(*it)); + return_vector.push_back(motor_get_faults(*it)); } return return_vector; } @@ -277,7 +281,7 @@ std::vector MotorGroup::get_flags_all(void) const { std::vector return_vector; empty_MotorGroup_check_vector(PROS_ERR, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(motor_get_flags(*it)); + return_vector.push_back(motor_get_flags(*it)); } return return_vector; } @@ -292,7 +296,7 @@ std::vector MotorGroup::get_gearing_all(void) const { std::vector return_vector; empty_MotorGroup_check_vector(pros::v5::MotorGears::invalid, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(static_cast(motor_get_gearing(*it))); + return_vector.push_back(static_cast(motor_get_gearing(*it))); } return return_vector; } @@ -307,7 +311,7 @@ std::vector MotorGroup::get_raw_position_all(std::uint32_t* const std::vector return_vector; empty_MotorGroup_check_vector(PROS_ERR, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(motor_get_raw_position(*it, timestamp)); + return_vector.push_back(motor_get_raw_position(*it, timestamp)); } return return_vector; } @@ -322,7 +326,7 @@ std::vector MotorGroup::is_over_temp_all(void) const { std::vector return_vector; empty_MotorGroup_check_vector(PROS_ERR, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(motor_is_over_temp(*it)); + return_vector.push_back(motor_is_over_temp(*it)); } return return_vector; } @@ -337,7 +341,7 @@ std::vector MotorGroup::get_position_all(void) const { std::vector return_vector; empty_MotorGroup_check_vector(PROS_ERR_F, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(motor_get_position(*it)); + return_vector.push_back(motor_get_position(*it)); } return return_vector; } @@ -352,7 +356,7 @@ std::vector MotorGroup::get_power_all(void) const { std::vector return_vector; empty_MotorGroup_check_vector(PROS_ERR_F, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(motor_get_power(*it)); + return_vector.push_back(motor_get_power(*it)); } return return_vector; } @@ -367,7 +371,7 @@ std::vector MotorGroup::is_reversed_all(void) const { std::vector return_vector; empty_MotorGroup_check_vector(PROS_ERR, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(motor_is_reversed(*it)); + return_vector.push_back(motor_is_reversed(*it)); } return return_vector; } @@ -382,7 +386,7 @@ std::vector MotorGroup::get_temperature_all(void) const { std::vector return_vector; empty_MotorGroup_check_vector(PROS_ERR_F, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(motor_get_temperature(*it)); + return_vector.push_back(motor_get_temperature(*it)); } return return_vector; } @@ -397,7 +401,7 @@ std::vector MotorGroup::get_target_position_all(void) const { std::vector return_vector; empty_MotorGroup_check_vector(PROS_ERR_F, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(motor_get_target_position(*it)); + return_vector.push_back(motor_get_target_position(*it)); } return return_vector; } @@ -412,7 +416,7 @@ std::vector MotorGroup::get_torque_all(void) const { std::vector return_vector; empty_MotorGroup_check_vector(PROS_ERR_F, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(motor_get_torque(*it)); + return_vector.push_back(motor_get_torque(*it)); } return return_vector; } @@ -427,7 +431,7 @@ std::vector MotorGroup::get_target_velocity_all(void) const { std::vector return_vector; empty_MotorGroup_check_vector(PROS_ERR, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(motor_get_target_velocity(*it)); + return_vector.push_back(motor_get_target_velocity(*it)); } return return_vector; } @@ -441,7 +445,7 @@ std::vector MotorGroup::get_voltage_all(void) const { std::vector return_vector; empty_MotorGroup_check_vector(PROS_ERR, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(motor_get_voltage(*it)); + return_vector.push_back(motor_get_voltage(*it)); } return return_vector; } @@ -456,7 +460,7 @@ std::vector MotorGroup::get_voltage_limit_all(void) const { std::vector return_vector; empty_MotorGroup_check_vector(PROS_ERR, return_vector); for (auto it = _ports.begin(); it < _ports.end(); it++) { - return_vector.emplace_back(motor_get_voltage_limit(*it)); + return_vector.push_back(motor_get_voltage_limit(*it)); } return return_vector; } @@ -488,9 +492,6 @@ std::int32_t MotorGroup::tare_position_all(void) const { std::int32_t MotorGroup::set_brake_mode(const pros::motor_brake_mode_e_t mode, const std::uint8_t index) const { empty_MotorGroup_check(PROS_ERR); MotorGroup_index_check(PROS_ERR, index); - for (auto it = _ports.begin() + 1; it < _ports.end(); it++) { - motor_set_brake_mode(*it, mode); - } return motor_set_brake_mode(_ports[index], mode); } @@ -552,10 +553,7 @@ std::int32_t MotorGroup::set_encoder_units(const pros::motor_encoder_units_e_t u std::int32_t MotorGroup::set_encoder_units(const pros::v5::MotorUnits units, const std::uint8_t index) const { empty_MotorGroup_check(PROS_ERR); MotorGroup_index_check(PROS_ERR, index); - for (auto it = _ports.begin() + 1; it < _ports.end(); it++) { - motor_set_encoder_units(*it, static_cast(units)); - } - return motor_set_encoder_units(_ports[0], static_cast(units)); + return motor_set_encoder_units(_ports[index], static_cast(units)); } std::int32_t MotorGroup::set_gearing(const motor_gearset_e_t gearset, const std::uint8_t index) const { @@ -640,7 +638,7 @@ std::int8_t MotorGroup::size() const { void MotorGroup::operator+=(MotorGroup& other) { for (auto it = other._ports.begin(); it < other._ports.end(); it++) { - _ports.emplace_back(*it); + _ports.push_back(*it); } } diff --git a/src/devices/vdml_motors.cpp b/src/devices/vdml_motors.cpp index 8b720c98..fae02581 100644 --- a/src/devices/vdml_motors.cpp +++ b/src/devices/vdml_motors.cpp @@ -70,7 +70,7 @@ double Motor::get_actual_velocity(const std::uint8_t index) const { } std::vector Motor::get_actual_velocity_all(void) const { std::vector return_vector; - return_vector.emplace_back(motor_get_actual_velocity(_port)); + return_vector.push_back(motor_get_actual_velocity(_port)); return return_vector; } @@ -84,7 +84,7 @@ pros::v5::MotorBrake Motor::get_brake_mode(const std::uint8_t index) const { std::vector Motor::get_brake_mode_all() const { std::vector return_vector; - return_vector.emplace_back(static_cast(motor_get_brake_mode(_port))); + return_vector.push_back(static_cast(motor_get_brake_mode(_port))); return return_vector; } @@ -97,7 +97,7 @@ std::int32_t Motor::get_current_draw(const std::uint8_t index) const { } std::vector Motor::get_current_draw_all(void) const { std::vector return_vector; - return_vector.emplace_back(motor_get_current_draw(_port)); + return_vector.push_back(motor_get_current_draw(_port)); return return_vector; } std::int32_t Motor::get_current_limit(const std::uint8_t index) const { @@ -109,7 +109,7 @@ std::int32_t Motor::get_current_limit(const std::uint8_t index) const { } std::vector Motor::get_current_limit_all(void) const { std::vector return_vector; - return_vector.emplace_back(motor_get_current_limit(_port)); + return_vector.push_back(motor_get_current_limit(_port)); return return_vector; } @@ -123,7 +123,7 @@ std::int32_t Motor::is_over_current(const std::uint8_t index) const { std::vector Motor::is_over_current_all(void) const { std::vector return_vector; - return_vector.emplace_back(motor_is_over_current(_port)); + return_vector.push_back(motor_is_over_current(_port)); return return_vector; } @@ -133,11 +133,15 @@ std::int32_t Motor::get_direction(const std::uint8_t index) const { errno = EOVERFLOW; return PROS_ERR; } - return motor_get_direction(_port); + int ret = motor_get_direction(_port); + ret = _port >= 0 ? ret : ret * -1; + return ret; } std::vector Motor::get_direction_all(void) const { std::vector return_vector; - return_vector.emplace_back(motor_get_direction(_port)); + int ret = motor_get_direction(_port); + ret = _port >= 0 ? ret : ret * -1; + return_vector.push_back(ret); return return_vector; } @@ -150,7 +154,7 @@ double Motor::get_efficiency(const std::uint8_t index) const { } std::vector Motor::get_efficiency_all(void) const { std::vector return_vector; - return_vector.emplace_back(motor_get_efficiency(_port)); + return_vector.push_back(motor_get_efficiency(_port)); return return_vector; } @@ -164,7 +168,7 @@ pros::v5::MotorUnits Motor::get_encoder_units(const std::uint8_t index) const { std::vector Motor::get_encoder_units_all(void) const { std::vector return_vector; - return_vector.emplace_back(static_cast(motor_get_encoder_units(_port))); + return_vector.push_back(static_cast(motor_get_encoder_units(_port))); return return_vector; } @@ -178,7 +182,7 @@ std::uint32_t Motor::get_faults(const std::uint8_t index) const { std::vector Motor::get_faults_all(void) const { std::vector return_vector; - return_vector.emplace_back(motor_get_faults(_port)); + return_vector.push_back(motor_get_faults(_port)); return return_vector; } @@ -192,7 +196,7 @@ std::uint32_t Motor::get_flags(const std::uint8_t index) const { std::vector Motor::get_flags_all(void) const { std::vector return_vector; - return_vector.emplace_back(motor_get_flags(_port)); + return_vector.push_back(motor_get_flags(_port)); return return_vector; } @@ -205,7 +209,7 @@ pros::v5::MotorGears Motor::get_gearing(const std::uint8_t index) const { } std::vector Motor::get_gearing_all(void) const { std::vector return_vector; - return_vector.emplace_back(static_cast(motor_get_gearing(_port))); + return_vector.push_back(static_cast(motor_get_gearing(_port))); return return_vector; } @@ -219,7 +223,7 @@ std::int32_t Motor::get_raw_position(std::uint32_t* const timestamp, std::uint8_ std::vector Motor::get_raw_position_all(std::uint32_t* const timestamp) const { std::vector return_vector; - return_vector.emplace_back(motor_get_raw_position(_port, timestamp)); + return_vector.push_back(motor_get_raw_position(_port, timestamp)); return return_vector; } @@ -233,7 +237,7 @@ std::int32_t Motor::is_over_temp(const std::uint8_t index) const { std::vector Motor::is_over_temp_all(void) const { std::vector return_vector; - return_vector.emplace_back(motor_is_over_temp(_port)); + return_vector.push_back(motor_is_over_temp(_port)); return return_vector; } @@ -246,7 +250,7 @@ double Motor::get_position(const std::uint8_t index) const { } std::vector Motor::get_position_all(void) const { std::vector return_vector; - return_vector.emplace_back(motor_get_position(_port)); + return_vector.push_back(motor_get_position(_port)); return return_vector; } @@ -260,7 +264,7 @@ double Motor::get_power(const std::uint8_t index) const { std::vector Motor::get_power_all(void) const { std::vector return_vector; - return_vector.emplace_back(motor_get_power(_port)); + return_vector.push_back(motor_get_power(_port)); return return_vector; } @@ -273,7 +277,7 @@ std::int32_t Motor::is_reversed(const std::uint8_t index) const { } std::vector Motor::is_reversed_all(void) const { std::vector return_vector; - return_vector.emplace_back(_port < 0); + return_vector.push_back(_port < 0); return return_vector; } @@ -287,7 +291,7 @@ double Motor::get_temperature(const std::uint8_t index) const { std::vector Motor::get_temperature_all(void) const { std::vector return_vector; - return_vector.emplace_back(motor_get_temperature(_port)); + return_vector.push_back(motor_get_temperature(_port)); return return_vector; } @@ -301,7 +305,7 @@ double Motor::get_target_position(const std::uint8_t index) const { std::vector Motor::get_target_position_all(void) const { std::vector return_vector; - return_vector.emplace_back(motor_get_target_position(_port)); + return_vector.push_back(motor_get_target_position(_port)); return return_vector; } @@ -314,7 +318,7 @@ double Motor::get_torque(const std::uint8_t index) const { } std::vector Motor::get_torque_all(void) const { std::vector return_vector; - return_vector.emplace_back(motor_get_torque(_port)); + return_vector.push_back(motor_get_torque(_port)); return return_vector; } std::int32_t Motor::get_target_velocity(const std::uint8_t index) const { @@ -326,7 +330,7 @@ std::int32_t Motor::get_target_velocity(const std::uint8_t index) const { } std::vector Motor::get_target_velocity_all(void) const { std::vector return_vector; - return_vector.emplace_back(motor_get_target_velocity(_port)); + return_vector.push_back(motor_get_target_velocity(_port)); return return_vector; } @@ -339,7 +343,7 @@ std::int32_t Motor::get_voltage(const std::uint8_t index) const { } std::vector Motor::get_voltage_all(void) const { std::vector return_vector; - return_vector.emplace_back(motor_get_voltage(_port)); + return_vector.push_back(motor_get_voltage(_port)); return return_vector; } @@ -352,7 +356,7 @@ std::int32_t Motor::get_voltage_limit(const std::uint8_t index) const { } std::vector Motor::get_voltage_limit_all(void) const { std::vector return_vector; - return_vector.emplace_back(motor_get_voltage_limit(_port)); + return_vector.push_back(motor_get_voltage_limit(_port)); return return_vector; } std::int8_t Motor::get_port(const std::uint8_t index) const { @@ -365,7 +369,7 @@ std::int8_t Motor::get_port(const std::uint8_t index) const { std::vector Motor::get_port_all(void) const { std::vector return_vector; - return_vector.emplace_back(_port); + return_vector.push_back(_port); return return_vector; } diff --git a/src/devices/vdml_rotation.cpp b/src/devices/vdml_rotation.cpp index 7a0a84a8..c937dc03 100644 --- a/src/devices/vdml_rotation.cpp +++ b/src/devices/vdml_rotation.cpp @@ -16,8 +16,12 @@ namespace pros { inline namespace v5 { -Rotation::Rotation(const std::uint8_t port, const bool reverse_flag) : Device(port, DeviceType::rotation) { - pros::c::rotation_set_reversed(port, reverse_flag); +Rotation::Rotation(const std::int8_t port) : Device(port, DeviceType::rotation) { + if (port < 0) { + pros::c::rotation_set_reversed(abs(port), true); + } else { + pros::c::rotation_set_reversed(port, false); + } } std::int32_t Rotation::reset() { diff --git a/src/main.cpp b/src/main.cpp index 13d12a0f..f384cc4f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -75,19 +75,19 @@ void autonomous() {} */ void opcontrol() { pros::Controller master(pros::E_CONTROLLER_MASTER); - pros::Motor left_mtr(1); - pros::Motor right_mtr(2); + pros::MotorGroup left_mg({1,-2,3}); // Creates a motor group with forwards ports 1 & 3 and reversed port 2 + pros::MotorGroup right_mg({-4,5,-6}); // Creates a motor group with forwards port 4 and reversed ports 4 & 6 while (true) { pros::lcd::print(0, "%d %d %d", (pros::lcd::read_buttons() & LCD_BTN_LEFT) >> 2, (pros::lcd::read_buttons() & LCD_BTN_CENTER) >> 1, - (pros::lcd::read_buttons() & LCD_BTN_RIGHT) >> 0); - int left = master.get_analog(ANALOG_LEFT_Y); - int right = master.get_analog(ANALOG_RIGHT_Y); - - left_mtr = left; - right_mtr = right; - - pros::delay(20); + (pros::lcd::read_buttons() & LCD_BTN_RIGHT) >> 0); // Prints status of the emulated screen LCDs + + // Arcade control scheme + int dir = master.get_analog(ANALOG_LEFT_Y); // Gets amount forward/backward from left joystick + int turn = master.get_analog(ANALOG_RIGHT_X); // Gets the turn left/right from right joystick + left_mg = dir - turn; // Sets left motor voltage + right_mg = dir + turn; // Sets right motor voltage + pros::delay(20); // Run for 20 ms then update } } \ No newline at end of file