diff --git a/include/api.h b/include/api.h index d004798b8..290cab565 100644 --- a/include/api.h +++ b/include/api.h @@ -41,8 +41,8 @@ #define PROS_VERSION_MAJOR 3 #define PROS_VERSION_MINOR 7 -#define PROS_VERSION_PATCH 0 -#define PROS_VERSION_STRING "3.7.0" +#define PROS_VERSION_PATCH 1 +#define PROS_VERSION_STRING "3.7.1" #include "pros/adi.h" #include "pros/colors.h" diff --git a/include/pros/motors.hpp b/include/pros/motors.hpp index 91b89b722..56361af65 100644 --- a/include/pros/motors.hpp +++ b/include/pros/motors.hpp @@ -20,11 +20,11 @@ #define _PROS_MOTORS_HPP_ #include -#include #include +#include -#include "pros/rtos.hpp" #include "pros/motors.h" +#include "pros/rtos.hpp" namespace pros { class Motor { @@ -578,8 +578,9 @@ class Motor { * * \return A motor_pid_s_t struct formatted properly in 4.4. */ - [[deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage.")]] - static motor_pid_s_t convert_pid(double kf, double kp, double ki, double kd); + [[deprecated( + "Changing these values is not supported by VEX and may lead to permanent motor damage.")]] static motor_pid_s_t + convert_pid(double kf, double kp, double ki, double kd); /** * Takes in floating point values and returns a properly formatted pid struct. @@ -608,8 +609,10 @@ class Motor { * * \return A motor_pid_s_t struct formatted properly in 4.4. */ - [[deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage.")]] - static motor_pid_full_s_t convert_pid_full(double kf, double kp, double ki, double kd, double filter, double limit, double threshold, + [[deprecated( + "Changing these values is not supported by VEX and may lead to permanent motor " + "damage.")]] static motor_pid_full_s_t + convert_pid_full(double kf, double kp, double ki, double kd, double filter, double limit, double threshold, double loopspeed); /** @@ -629,8 +632,9 @@ class Motor { * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. */ - [[deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage.")]] - virtual std::int32_t set_pos_pid(const motor_pid_s_t pid) const; + [[deprecated( + "Changing these values is not supported by VEX and may lead to permanent motor damage.")]] virtual std::int32_t + set_pos_pid(const motor_pid_s_t pid) const; /** * Sets one of motor_pid_full_s_t for the motor. @@ -648,8 +652,9 @@ class Motor { * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. */ - [[deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage.")]] - virtual std::int32_t set_pos_pid_full(const motor_pid_full_s_t pid) const; + [[deprecated( + "Changing these values is not supported by VEX and may lead to permanent motor damage.")]] virtual std::int32_t + set_pos_pid_full(const motor_pid_full_s_t pid) const; /** * Sets one of motor_pid_s_t for the motor. This intended to just modify the @@ -668,8 +673,9 @@ class Motor { * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. */ - [[deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage.")]] - virtual std::int32_t set_vel_pid(const motor_pid_s_t pid) const; + [[deprecated( + "Changing these values is not supported by VEX and may lead to permanent motor damage.")]] virtual std::int32_t + set_vel_pid(const motor_pid_s_t pid) const; /** * Sets one of motor_pid_full_s_t for the motor. @@ -687,8 +693,9 @@ class Motor { * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. */ - [[deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage.")]] - virtual std::int32_t set_vel_pid_full(const motor_pid_full_s_t pid) const; + [[deprecated( + "Changing these values is not supported by VEX and may lead to permanent motor damage.")]] virtual std::int32_t + set_vel_pid_full(const motor_pid_full_s_t pid) const; /** * Sets the reverse flag for the motor. @@ -787,8 +794,10 @@ class Motor { * \return A motor_pid_full_s_t containing the position PID constants last set * to the given motor */ - [[deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage.")]] - virtual motor_pid_full_s_t get_pos_pid(void) const; + [[deprecated( + "Changing these values is not supported by VEX and may lead to permanent motor " + "damage.")]] virtual motor_pid_full_s_t + get_pos_pid(void) const; /** * Gets the velocity PID that was set for the motor. This function will return @@ -805,8 +814,10 @@ class Motor { * \return A motor_pid_full_s_t containing the velocity PID constants last set * to the given motor */ - [[deprecated("Changing these values is not supported by VEX and may lead to permanent motor damage.")]] - virtual motor_pid_full_s_t get_vel_pid(void) const; + [[deprecated( + "Changing these values is not supported by VEX and may lead to permanent motor " + "damage.")]] virtual motor_pid_full_s_t + get_vel_pid(void) const; /** * Gets the operation direction of the motor as set by the user. @@ -856,38 +867,38 @@ class Motor_Group { /** These functions allow programmers to make motor groups move **/ /****************************************************************************/ /** - * Sets the voltage for all the motors in the motor group from -128 to 127. - * - * This is designed to map easily to the input from the controller's analog - * stick for simple opcontrol use. The actual behavior of the motor is - * analogous to use of pros::Motor::move() on each motor individually - * - * This function uses the following values of errno when an error state is - * reached: - * ENODEV - One of the ports cannot be configured as a motor - * EACCESS - The Motor group mutex can't be taken or given - * - * \param voltage - * The new motor voltage from -127 to 127 - * - * \return 1 if the operation was successful or PROS_ERR if the operation - * failed, setting errno. - */ + * Sets the voltage for all the motors in the motor group from -128 to 127. + * + * This is designed to map easily to the input from the controller's analog + * stick for simple opcontrol use. The actual behavior of the motor is + * analogous to use of pros::Motor::move() on each motor individually + * + * This function uses the following values of errno when an error state is + * reached: + * ENODEV - One of the ports cannot be configured as a motor + * EACCESS - The Motor group mutex can't be taken or given + * + * \param voltage + * The new motor voltage from -127 to 127 + * + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ std::int32_t operator=(std::int32_t); - + /** * Sets the voltage for the motors in the motor group from -127 to 127. * * This is designed to map easily to the input from the controller's analog * stick for simple opcontrol use. The actual behavior of the motor is - * analogous to use of motor_move(), or motorSet() from the + * analogous to use of motor_move(), or motorSet() from the * PROS 2 API on each motor. * * This function uses the following values of errno when an error state is * reached: * ENODEV - The port cannot be configured as a motor * EACCESS - The Motor group mutex can't be taken or given - * + * * \param voltage * The new motor voltage from -127 to 127 * @@ -909,7 +920,7 @@ class Motor_Group { * This function uses the following values of errno when an error state is * reached: * ENODEV - The port cannot be configured as a motor - * EACCESS - The Motor group mutex can't be taken or given + * EACCESS - The Motor group mutex can't be taken or given * * \param position * The absolute position to move to in the motors' encoder units @@ -960,7 +971,7 @@ class Motor_Group { * reached: * ENODEV - The port cannot be configured as a motor * EACCESS - The Motor group mutex can't be taken or given - * + * * \param velocity * The new motor velocity from -+-100, +-200, or +-600 depending on the * motor's gearset @@ -969,7 +980,7 @@ class Motor_Group { * failed, setting errno. */ std::int32_t move_velocity(const std::int32_t velocity); - + /** * Sets the output voltage for the motors from -12000 to 12000 in millivolts. * @@ -977,7 +988,7 @@ class Motor_Group { * reached: * ENODEV - The port cannot be configured as a motor * EACCESS - The Motor group mutex can't be taken or given - * + * * \param voltage * The new voltage value from -12000 to 12000 * @@ -998,12 +1009,12 @@ class Motor_Group { * reached: * ENODEV - The port cannot be configured as a motor * EACCESS - The Motor group mutex can't be taken or given - * + * * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. */ std::int32_t brake(void); - /****************************************************************************/ + /****************************************************************************/ /** Motor configuration functions **/ /** **/ /** These functions let programmers configure the behavior of motor groups **/ @@ -1027,6 +1038,21 @@ class Motor_Group { * failed, setting errno. */ std::int32_t set_zero_position(const double position); + /** + * Sets one of motor_brake_mode_e_t to the motor group. + * + * This function uses the following values of errno when an error state is + * reached: + * ENODEV - The port cannot be configured as a motor + * EACCESS - The Motor group mutex can't be taken or given + * + * \param mode + * The motor_brake_mode_e_t to set for the motor + * + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ + std::int32_t set_brake_modes(motor_brake_mode_e_t mode); /** * Sets the reverse flag for all the motors in the motor group. @@ -1037,7 +1063,7 @@ class Motor_Group { * reached: * ENODEV - The port cannot be configured as a motor * EACCESS - The Motor group mutex can't be taken or given - * + * * \param reverse * True reverses the motor, false is default * @@ -1053,7 +1079,7 @@ class Motor_Group { * reached: * ENODEV - The port cannot be configured as a motor * EACCESS - The Motor group mutex can't be taken or given - * + * * \param limit * The new voltage limit in Volts * @@ -1078,14 +1104,14 @@ class Motor_Group { std::int32_t set_gearing(const motor_gearset_e_t gearset); /** - * Sets one of motor_encoder_units_e_t for the all the motor encoders + * Sets one of motor_encoder_units_e_t for the all the motor encoders * in the motor group. * * This function uses the following values of errno when an error state is * reached: * ENODEV - The port cannot be configured as a motor * EACCESS - The Motor group mutex can't be taken or given - * + * * \param units * The new motor encoder units * @@ -1101,13 +1127,13 @@ class Motor_Group { * reached: * ENODEV - The port cannot be configured as a motor * EACCESS - The Motor group mutex can't be taken or given - * + * * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. */ std::int32_t tare_position(void); - /****************************************************************************/ + /****************************************************************************/ /** Motor telemetry functions **/ /** **/ /** These functions let programmers to collect telemetry from motor groups **/ @@ -1124,7 +1150,7 @@ class Motor_Group { * or a vector filled with PROS_ERR_F if the operation failed, setting errno. */ std::vector get_actual_velocities(void); - + /** * Gets the velocity commanded to the motor by the user. * @@ -1146,13 +1172,12 @@ class Motor_Group { * ENODEV - The port cannot be configured as a motor * EACCESS - The Motor group mutex can't be taken or given * - * \return A vector filled with the target position in its encoder units + * \return A vector filled with the target position in its encoder units * or a vector filled with PROS_ERR_F if the operation failed, setting errno. */ std::vector get_target_positions(void); - - /** + /** * Gets the absolute position of the motor in its encoder units. * * This function uses the following values of errno when an error state is @@ -1163,7 +1188,7 @@ class Motor_Group { * if the operation failed, setting errno. */ std::vector get_positions(void); -/** + /** * Gets the efficiency of the motors in percent. * * An efficiency of 100% means that the motor is moving electrically while @@ -1179,7 +1204,7 @@ class Motor_Group { * or a vector filled with PROS_ERR_F if the operation failed, setting errno. */ std::vector get_efficiencies(void); - + /** * Checks if the motors are drawing over its current limit. * @@ -1187,13 +1212,13 @@ class Motor_Group { * reached: * ENODEV - The port cannot be configured as a motor * EACCESS - The Motor group mutex can't be taken or given - * + * * \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. */ std::vector are_over_current(void); - + /** * Gets the temperature limit flag for the motors. * @@ -1201,8 +1226,8 @@ class Motor_Group { * reached: * ENODEV - The port cannot be configured as a motor * - * \return A vector with for each motor a 1 if the temperature limit is - * exceeded and 0 if the temperature is below the limit, + * \return A vector with for each motor a 1 if the temperature limit is + * exceeded and 0 if the temperature is below the limit, * or a vector filled with PROS_ERR if the operation failed, setting errno. */ std::vector are_over_temp(void); @@ -1214,13 +1239,26 @@ class Motor_Group { * reached: * ENODEV - The port cannot be configured as a motor * EACCESS - The Motor group mutex can't be taken or given - * - * \return A Vector with for each motor one of motor_brake_mode_e_t, + * + * \return A Vector with for each motor one of motor_brake_mode_e_t, * according to what was set for the motor, or a vector filled with * E_MOTOR_BRAKE_INVALID if the operation failed, setting errno. */ std::vector get_brake_modes(void); + /** + * Gets the gearset that was set for the motor. + * + * This function uses the following values of errno when an error state is + * reached: + * ENODEV - The port cannot be configured as a motor + * EACCESS - The Motor group mutex can't be taken or given + * + * \return One of motor_gearset_e_t according to what is set for the motor, + * or E_GEARSET_INVALID if the operation failed. + */ + std::vector get_gearing(void); + /** * Gets the current drawn by each motor in mA. * @@ -1229,7 +1267,7 @@ class Motor_Group { * ENODEV - The port cannot be configured as a motor * EACCESS - The Motor group mutex can't be taken or given * - * \return A vector containing each motor's current in mA + * \return A vector containing each motor's current in mA * or a vector filled with PROS_ERR if the operation failed, setting errno. */ std::vector get_current_draws(void); @@ -1244,10 +1282,10 @@ class Motor_Group { * ENODEV - The port cannot be configured as a motor * EACCESS - The Motor group mutex can't be taken or given * - * \return A vector with each motor's current limit in mA or a vector filled + * \return A vector with each motor's current limit in mA or a vector filled * with PROS_ERR if the operation failed, setting errno. */ - std::vector get_current_limits(void);\ + std::vector get_current_limits(void); /** * Gets the port number of each motor. @@ -1274,9 +1312,9 @@ class Motor_Group { * reached: * ENODEV - The port cannot be configured as a motor * EACCESS - The Motor group mutex can't be taken or given - * - * \return A vector filled with one of motor_encoder_units_e_t for each motor - * according to what is set for the motor or a vector filled with + * + * \return A vector filled with one of motor_encoder_units_e_t for each motor + * according to what is set for the motor or a vector filled with * E_MOTOR_ENCODER_INVALID if the operation failed. */ std::vector get_encoder_units(void); diff --git a/src/devices/vdml_motors.cpp b/src/devices/vdml_motors.cpp index a2e88ecfa..1f4382d3a 100644 --- a/src/devices/vdml_motors.cpp +++ b/src/devices/vdml_motors.cpp @@ -10,75 +10,73 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include + #include "kapi.h" #include "pros/motors.hpp" -#include - /** * Macro to claim the motor group mutex with the error code being PROS_ERR - * + * */ -#define claim_mg_mutex(error) \ +#define claim_mg_mutex(error) \ if (!_motor_group_mutex.take(TIMEOUT_MAX)) { \ - return error; \ - } + return error; \ + } /** * Macro to free the motor group mutex with the error value being PROS_ERR - * + * */ -#define give_mg_mutex(error) \ - if (!_motor_group_mutex.give()) { \ - return error; \ +#define give_mg_mutex(error) \ + if (!_motor_group_mutex.give()) { \ + return error; \ } /** * Macro to loop through a function call for each motor in a motor group * with an error value of PROS_ERR - * + * */ -#define mg_foreach(func_call, motors, out) \ - for(int i = 0; i < _motor_count; i++) { \ - if (motors[i].func_call != PROS_ERR) { \ - out = PROS_SUCCESS; \ - } \ - else { \ - out = PROS_ERR; \ - } \ +#define mg_foreach(func_call, motors, out) \ + for (int i = 0; i < _motor_count; i++) { \ + if (motors[i].func_call != PROS_ERR) { \ + out = PROS_SUCCESS; \ + } else { \ + out = PROS_ERR; \ + } \ } /** * Macro to take the motor group mutex with a vector of error as the error value - * + * */ -#define claim_mg_mutex_vector(error) \ +#define claim_mg_mutex_vector(error) \ if (!_motor_group_mutex.take(TIMEOUT_MAX)) { \ - out.clear(); \ - for (int i = 0; i < _motor_count; i++) { \ - out.push_back(error); \ - } \ - out.resize(_motor_count); \ - out.shrink_to_fit(); \ - return out; \ - } + out.clear(); \ + for (int i = 0; i < _motor_count; i++) { \ + out.push_back(error); \ + } \ + out.resize(_motor_count); \ + out.shrink_to_fit(); \ + return out; \ + } /** * Macro to free the motor group mutex with a vector of error as the error value - * + * */ -#define give_mg_mutex_vector(error) \ - if (!_motor_group_mutex.give()) { \ - out.clear(); \ - for(int i = 0; i < _motor_count; i++) { \ - out.push_back(error); \ - } \ +#define give_mg_mutex_vector(error) \ + if (!_motor_group_mutex.give()) { \ + out.clear(); \ + for (int i = 0; i < _motor_count; i++) { \ + out.push_back(error); \ + } \ } namespace pros { using namespace pros::c; - Motor::Motor(const std::uint8_t port, const motor_gearset_e_t gearset, const bool reverse, const motor_encoder_units_e_t encoder_units) : _port(port) { @@ -179,17 +177,17 @@ motor_gearset_e_t Motor::get_gearing(void) const { } motor_pid_full_s_t Motor::get_pos_pid(void) const { - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" return motor_get_pos_pid(_port); - #pragma GCC diagnostic pop +#pragma GCC diagnostic pop } motor_pid_full_s_t Motor::get_vel_pid(void) const { - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" return motor_get_vel_pid(_port); - #pragma GCC diagnostic pop +#pragma GCC diagnostic pop } std::int32_t Motor::get_raw_position(std::uint32_t* const timestamp) const { @@ -269,46 +267,46 @@ std::int32_t Motor::set_gearing(const motor_gearset_e_t gearset) const { } motor_pid_s_t Motor::convert_pid(double kf, double kp, double ki, double kd) { - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" return motor_convert_pid(kf, kp, ki, kd); - #pragma GCC diagnostic pop +#pragma GCC diagnostic pop } motor_pid_full_s_t Motor::convert_pid_full(double kf, double kp, double ki, double kd, double filter, double limit, double threshold, double loopspeed) { - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" return motor_convert_pid_full(kf, kp, ki, kd, filter, limit, threshold, loopspeed); - #pragma GCC diagnostic pop +#pragma GCC diagnostic pop } std::int32_t Motor::set_pos_pid(const motor_pid_s_t pid) const { - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" return motor_set_pos_pid(_port, pid); - #pragma GCC diagnostic pop +#pragma GCC diagnostic pop } std::int32_t Motor::set_pos_pid_full(const motor_pid_full_s_t pid) const { - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" return motor_set_pos_pid_full(_port, pid); - #pragma GCC diagnostic pop +#pragma GCC diagnostic pop } std::int32_t Motor::set_vel_pid(const motor_pid_s_t pid) const { - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" return motor_set_vel_pid(_port, pid); - #pragma GCC diagnostic pop +#pragma GCC diagnostic pop } std::int32_t Motor::set_vel_pid_full(const motor_pid_full_s_t pid) const { - #pragma GCC diagnostic push - #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" return motor_set_vel_pid_full(_port, pid); - #pragma GCC diagnostic pop +#pragma GCC diagnostic pop } std::int32_t Motor::set_zero_position(const double position) const { @@ -323,13 +321,15 @@ std::int32_t Motor::set_voltage_limit(const std::int32_t limit) const { return motor_set_voltage_limit(_port, limit); } -Motor_Group::Motor_Group(const std::initializer_list motors) : _motors(motors), _motor_group_mutex(pros::Mutex()), _motor_count(motors.size()) {} +Motor_Group::Motor_Group(const std::initializer_list motors) + : _motors(motors), _motor_group_mutex(pros::Mutex()), _motor_count(motors.size()) {} -Motor_Group::Motor_Group(const std::vector motor_ports): _motor_group_mutex(pros::Mutex()), _motor_count(motor_ports.size()) { +Motor_Group::Motor_Group(const std::vector motor_ports) + : _motor_group_mutex(pros::Mutex()), _motor_count(motor_ports.size()) { for (std::uint8_t i = 0; i < _motor_count; ++i) { _motors.push_back(Motor(std::abs(motor_ports[i]), (motor_ports[i] < 0))); - //std::cout << "Motor " << motor_ports[i] << "Reversed: " << (bool)(motor_ports[i] < 0) << std::endl; - } + // std::cout << "Motor " << motor_ports[i] << "Reversed: " << (bool)(motor_ports[i] < 0) << std::endl; + } } std::int32_t Motor_Group::move(std::int32_t voltage) { @@ -388,6 +388,14 @@ std::int32_t Motor_Group::brake(void) { return out; } +std::int32_t Motor_Group::set_brake_modes(motor_brake_mode_e_t mode) { + claim_mg_mutex(PROS_ERR); + std::int32_t out = PROS_SUCCESS; + mg_foreach(set_brake_mode(mode), _motors, out); + give_mg_mutex(PROS_ERR); + return out; +} + std::int32_t Motor_Group::set_zero_position(const double position) { claim_mg_mutex(PROS_ERR); std::int32_t out = PROS_SUCCESS; @@ -438,7 +446,7 @@ std::int32_t Motor_Group::tare_position(void) { std::vector Motor_Group::get_target_positions(void) { std::vector out; claim_mg_mutex_vector(PROS_ERR_F); - for(Motor motor : _motors) { + for (Motor motor : _motors) { out.push_back(motor.get_target_position()); } give_mg_mutex_vector(PROS_ERR_F); @@ -448,7 +456,7 @@ std::vector Motor_Group::get_target_positions(void) { std::vector Motor_Group::get_positions(void) { std::vector out; claim_mg_mutex_vector(PROS_ERR_F); - for(Motor motor : _motors) { + for (Motor motor : _motors) { out.push_back(motor.get_position()); } give_mg_mutex_vector(PROS_ERR_F); @@ -458,7 +466,7 @@ std::vector Motor_Group::get_positions(void) { std::vector Motor_Group::get_efficiencies(void) { std::vector out; claim_mg_mutex_vector(PROS_ERR_F); - for(Motor motor : _motors) { + for (Motor motor : _motors) { out.push_back(motor.get_efficiency()); } give_mg_mutex_vector(PROS_ERR_F); @@ -467,17 +475,17 @@ std::vector Motor_Group::get_efficiencies(void) { std::vector Motor_Group::get_actual_velocities(void) { std::vector out; claim_mg_mutex_vector(PROS_ERR_F); - for(Motor motor : _motors) { + for (Motor motor : _motors) { out.push_back(motor.get_actual_velocity()); } - give_mg_mutex_vector(PROS_ERR_F); + give_mg_mutex_vector(PROS_ERR_F); return out; } std::vector Motor_Group::get_brake_modes(void) { std::vector out; claim_mg_mutex_vector(E_MOTOR_BRAKE_INVALID); - for(Motor motor : _motors) { + for (Motor motor : _motors) { out.push_back(motor.get_brake_mode()); } give_mg_mutex_vector(E_MOTOR_BRAKE_INVALID); @@ -487,16 +495,27 @@ std::vector Motor_Group::get_brake_modes(void) { std::vector Motor_Group::are_over_current(void) { std::vector out; claim_mg_mutex_vector(PROS_ERR); - for(Motor motor : _motors) { + for (Motor motor : _motors) { out.push_back(motor.is_over_current()); } give_mg_mutex_vector(PROS_ERR); return out; } + +std::vector Motor_Group::get_gearing(void) { + std::vector out; + claim_mg_mutex_vector(E_MOTOR_GEARSET_INVALID); + for (Motor motor : _motors) { + out.push_back(motor.get_gearing()); + } + give_mg_mutex_vector(E_MOTOR_GEARSET_INVALID); + return out; +} + std::vector Motor_Group::get_current_draws(void) { std::vector out; claim_mg_mutex_vector(PROS_ERR); - for(Motor motor : _motors) { + for (Motor motor : _motors) { out.push_back(motor.get_current_draw()); } give_mg_mutex_vector(PROS_ERR); @@ -506,7 +525,7 @@ std::vector Motor_Group::get_current_draws(void) { std::vector Motor_Group::get_current_limits(void) { std::vector out; claim_mg_mutex_vector(PROS_ERR); - for(Motor motor : _motors) { + for (Motor motor : _motors) { out.push_back(motor.get_current_limit()); } give_mg_mutex_vector(PROS_ERR); @@ -516,7 +535,7 @@ std::vector Motor_Group::get_current_limits(void) { std::vector Motor_Group::get_ports(void) { std::vector out; claim_mg_mutex_vector(PROS_ERR_BYTE); - for(Motor motor : _motors) { + for (Motor motor : _motors) { out.push_back(motor.get_port()); } give_mg_mutex_vector(PROS_ERR_BYTE); @@ -526,7 +545,7 @@ std::vector Motor_Group::get_ports(void) { std::vector Motor_Group::get_directions(void) { std::vector out; claim_mg_mutex_vector(PROS_ERR); - for(Motor motor : _motors) { + for (Motor motor : _motors) { out.push_back(motor.get_direction()); } give_mg_mutex_vector(PROS_ERR); @@ -536,7 +555,7 @@ std::vector Motor_Group::get_directions(void) { std::vector Motor_Group::get_target_velocities(void) { std::vector out; claim_mg_mutex_vector(PROS_ERR); - for(Motor motor : _motors) { + for (Motor motor : _motors) { out.push_back(motor.get_target_velocity()); } give_mg_mutex_vector(PROS_ERR); @@ -546,7 +565,7 @@ std::vector Motor_Group::get_target_velocities(void) { std::vector Motor_Group::are_over_temp(void) { std::vector out; claim_mg_mutex_vector(PROS_ERR); - for(Motor motor : _motors) { + for (Motor motor : _motors) { out.push_back(motor.is_over_temp()); } give_mg_mutex_vector(PROS_ERR); @@ -556,7 +575,7 @@ std::vector Motor_Group::are_over_temp(void) { std::vector Motor_Group::get_encoder_units(void) { std::vector out; claim_mg_mutex_vector(E_MOTOR_ENCODER_INVALID); - for(Motor motor : _motors) { + for (Motor motor : _motors) { out.push_back(motor.get_encoder_units()); } give_mg_mutex_vector(E_MOTOR_ENCODER_INVALID); diff --git a/template-gitignore b/template-gitignore index d3cf9e0f5..e303e2c03 100644 --- a/template-gitignore +++ b/template-gitignore @@ -9,6 +9,7 @@ # PROS bin/ .vscode/ +.cache/ compile_commands.json temp.log temp.errors diff --git a/version b/version index 7c69a55db..a76ccff2a 100644 --- a/version +++ b/version @@ -1 +1 @@ -3.7.0 +3.7.1