diff --git a/EZ-Template-Example-Project/.gitignore b/EZ-Template-Example-Project/.gitignore new file mode 100644 index 00000000..e303e2c0 --- /dev/null +++ b/EZ-Template-Example-Project/.gitignore @@ -0,0 +1,17 @@ +# Compiled Object files +*.o +*.obj + +# Executables +*.bin +*.elf + +# PROS +bin/ +.vscode/ +.cache/ +compile_commands.json +temp.log +temp.errors +*.ini +.d/ \ No newline at end of file diff --git a/EZ-Template-Example-Project/EZ-Template-Example-Project-v3.0.0.zip b/EZ-Template-Example-Project/EZ-Template-Example-Project-v3.0.1.zip similarity index 79% rename from EZ-Template-Example-Project/EZ-Template-Example-Project-v3.0.0.zip rename to EZ-Template-Example-Project/EZ-Template-Example-Project-v3.0.1.zip index 4b3b258c..327ffed0 100644 Binary files a/EZ-Template-Example-Project/EZ-Template-Example-Project-v3.0.0.zip and b/EZ-Template-Example-Project/EZ-Template-Example-Project-v3.0.1.zip differ diff --git a/EZ-Template-Example-Project/EZ-Template@3.0.0.zip b/EZ-Template-Example-Project/EZ-Template@3.0.1.zip similarity index 54% rename from EZ-Template-Example-Project/EZ-Template@3.0.0.zip rename to EZ-Template-Example-Project/EZ-Template@3.0.1.zip index 18de689c..31e8046b 100644 Binary files a/EZ-Template-Example-Project/EZ-Template@3.0.0.zip and b/EZ-Template-Example-Project/EZ-Template@3.0.1.zip differ diff --git a/EZ-Template-Example-Project/firmware/EZ-Template.a b/EZ-Template-Example-Project/firmware/EZ-Template.a index 3633ac8c..16e2bf4a 100644 Binary files a/EZ-Template-Example-Project/firmware/EZ-Template.a and b/EZ-Template-Example-Project/firmware/EZ-Template.a differ diff --git a/EZ-Template-Example-Project/firmware/libpros.a b/EZ-Template-Example-Project/firmware/libpros.a index 05399901..3dbfc1b7 100644 Binary files a/EZ-Template-Example-Project/firmware/libpros.a and b/EZ-Template-Example-Project/firmware/libpros.a differ diff --git a/EZ-Template-Example-Project/include/EZ-Template/drive/drive.hpp b/EZ-Template-Example-Project/include/EZ-Template/drive/drive.hpp index 6b122d3c..0fddb2eb 100644 --- a/EZ-Template-Example-Project/include/EZ-Template/drive/drive.hpp +++ b/EZ-Template-Example-Project/include/EZ-Template/drive/drive.hpp @@ -722,7 +722,7 @@ class Drive { * \param toggle_heading * toggle for heading correction */ - void pid_drive_set(double target, int speed, bool slew_on, bool toggle_heading = true); + void pid_drive_set(double target, int speed, bool slew_on = false, bool toggle_heading = true); /** * Sets the robot to turn using PID. @@ -782,7 +782,7 @@ class Drive { * \param speed * 0 to 127, max speed during motion * \param opposite_speed - * 0 to 127, max speed of the opposite side of the drive during the swing. This is used for arcs, and is defaulted to 0. + * -127 to 127, max speed of the opposite side of the drive during the swing. This is used for arcs, and is defaulted to 0. */ void pid_swing_set(e_swing type, double target, int speed, int opposite_speed = 0, bool slew_on = false); @@ -796,7 +796,7 @@ class Drive { * \param speed * 0 to 127, max speed during motion * \param opposite_speed - * 0 to 127, max speed of the opposite side of the drive during the swing. This is used for arcs, and is defaulted to 0. + * -127 to 127, max speed of the opposite side of the drive during the swing. This is used for arcs, and is defaulted to 0. */ void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed = 0, bool slew_on = false); @@ -810,7 +810,7 @@ class Drive { * \param speed * 0 to 127, max speed during motion * \param opposite_speed - * 0 to 127, max speed of the opposite side of the drive during the swing. This is used for arcs, and is defaulted to 0. + * -127 to 127, max speed of the opposite side of the drive during the swing. This is used for arcs, and is defaulted to 0. */ void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed = 0, bool slew_on = false); @@ -824,7 +824,7 @@ class Drive { * \param speed * 0 to 127, max speed during motion * \param opposite_speed - * 0 to 127, max speed of the opposite side of the drive during the swing. This is used for arcs, and is defaulted to 0. + * -127 to 127, max speed of the opposite side of the drive during the swing. This is used for arcs, and is defaulted to 0. */ void pid_swing_relative_set(e_swing type, double target, int speed, int opposite_speed = 0, bool slew_on = false); @@ -1305,14 +1305,13 @@ class Drive { bool slew_swing_using_angle = false; bool pid_tuner_terminal_b = false; bool pid_tuner_lcd_b = true; - struct const_and_name { std::string name = ""; PID::Constants *consts; }; std::vector constants; void pid_tuner_print(); - void pid_tuner_value_modify(double p, double i, double d, double start); + void pid_tuner_value_modify(float p, float i, float d, float start); void pid_tuner_value_increase(); void pid_tuner_value_decrease(); void pid_tuner_print_brain(); @@ -1320,16 +1319,12 @@ class Drive { void pid_tuner_brain_init(); int column = 0; int row = 0; - int column_max = 0; - const int row_max = 3; - std::string name, kp, ki, kd, starti; std::string arrow = " <--\n"; - std::string newline = "\n"; - bool last_controller_curve_state; - bool last_auton_selector_state; + bool last_controller_curve_state = false; + bool last_auton_selector_state = false; bool pid_tuner_on = false; - std::string complete_pid_tuner_output; - double p_increment = 0.1, i_increment = 0.001, d_increment = 0.25, start_i_increment = 1.0; + std::string complete_pid_tuner_output = ""; + float p_increment = 0.1, i_increment = 0.001, d_increment = 0.25, start_i_increment = 1.0; /** * Private wait until for drive diff --git a/EZ-Template-Example-Project/include/api.h b/EZ-Template-Example-Project/include/api.h index 7e923199..6b09de1d 100644 --- a/EZ-Template-Example-Project/include/api.h +++ b/EZ-Template-Example-Project/include/api.h @@ -41,8 +41,8 @@ #define PROS_VERSION_MAJOR 3 #define PROS_VERSION_MINOR 8 -#define PROS_VERSION_PATCH 0 -#define PROS_VERSION_STRING "3.8.0" +#define PROS_VERSION_PATCH 3 +#define PROS_VERSION_STRING "3.8.3" #include "pros/adi.h" #include "pros/colors.h" @@ -56,8 +56,8 @@ #include "pros/misc.h" #include "pros/motors.h" #include "pros/optical.h" -#include "pros/rtos.h" #include "pros/rotation.h" +#include "pros/rtos.h" #include "pros/screen.h" #include "pros/vision.h" @@ -66,6 +66,7 @@ #include "pros/distance.hpp" #include "pros/gps.hpp" #include "pros/imu.hpp" +#include "pros/link.hpp" #include "pros/llemu.hpp" #include "pros/misc.hpp" #include "pros/motors.hpp" @@ -74,7 +75,6 @@ #include "pros/rtos.hpp" #include "pros/screen.hpp" #include "pros/vision.hpp" -#include "pros/link.hpp" #endif #endif // _PROS_API_H_ diff --git a/EZ-Template-Example-Project/include/pros/gps.h b/EZ-Template-Example-Project/include/pros/gps.h index 1b2e7e7b..917f6938 100644 --- a/EZ-Template-Example-Project/include/pros/gps.h +++ b/EZ-Template-Example-Project/include/pros/gps.h @@ -188,6 +188,91 @@ double gps_get_error(uint8_t port); */ gps_status_s_t gps_get_status(uint8_t port); +/** + * Gets the X position in meters of the robot relative to the starting position. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * + * \return The X position in meters. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ +double gps_get_x_position(uint8_t port); + +/** + * Gets the Y position in meters of the robot relative to the starting position. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * + * \return The Y position in meters. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ +double gps_get_y_position(uint8_t port); + +/** + * Gets the pitch of the GPS in degrees relative to the starting orientation. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * + * \return The pitch in (-90,90] degree values. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ +double gps_get_pitch(uint8_t port); + +/** + * Gets the roll of the GPS in degrees relative to the starting orientation. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * + * \return The roll in (-180,180] degree values. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ +double gps_get_roll(uint8_t port); + +/** + * Gets the yaw of the GPS in degrees relative to the starting orientation. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * + * \return The yaw in (-180,180] degree values. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ +double gps_get_yaw(uint8_t port); + /** * Get the heading in [0,360) degree values. * diff --git a/EZ-Template-Example-Project/include/pros/gps.hpp b/EZ-Template-Example-Project/include/pros/gps.hpp index fce40c2a..7a321239 100644 --- a/EZ-Template-Example-Project/include/pros/gps.hpp +++ b/EZ-Template-Example-Project/include/pros/gps.hpp @@ -52,8 +52,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \param xOffset * Cartesian 4-Quadrant X offset from center of turning (meters) @@ -77,8 +77,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \param xOffset * Cartesian 4-Quadrant X offset from center of turning (meters) @@ -95,8 +95,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \param xOffset * Pointer to cartesian 4-Quadrant X offset from center of turning (meters) @@ -113,8 +113,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \param xInitial * Initial 4-Quadrant X Position, with (0,0) being at the center of the field (meters) @@ -133,8 +133,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \param rate * Data rate in milliseconds (Minimum: 5 ms) @@ -149,8 +149,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \return Possible RMS (Root Mean Squared) error in meters for GPS position. * If the operation failed, returns PROS_ERR_F and errno is set. @@ -163,8 +163,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * * \return A struct (gps_status_s_t) containing values mentioned above. @@ -173,14 +173,89 @@ class Gps { */ virtual pros::c::gps_status_s_t get_status() const; + /** + * Gets the X position in meters of the robot relative to the starting position. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. + * + * + * \return The X position in meters. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ + virtual double get_x_position() const; + + /** + * Gets the Y position in meters of the robot relative to the starting position. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. + * + * + * \return The Y position in meters. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ + virtual double get_y_position() const; + + /** + * Gets the pitch of the GPS in degrees relative to the starting orientation. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. + * + * + * \return The pitch in [0,360) degree values. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ + virtual double get_pitch() const; + + /** + * Gets the roll of the GPS in degrees relative to the starting orientation. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. + * + * + * \return The roll in [0,360) degree values. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ + virtual double get_roll() const; + + /** + * Gets the yaw of the GPS in degrees relative to the starting orientation. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. + * + * + * \return The yaw in [0,360) degree values. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ + virtual double get_yaw() const; + /** * Get the heading in [0,360) degree values. * * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * * \return The heading in [0,360) degree values. If the operation failed, @@ -194,8 +269,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \return The heading in [DOUBLE_MIN, DOUBLE_MAX] values. If the operation * fails, returns PROS_ERR_F and errno is set. @@ -208,8 +283,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \return The elased heading in degrees. If the operation fails, returns * PROS_ERR_F and errno is set. @@ -222,8 +297,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \param target * Target rotation value to set rotation value to @@ -238,8 +313,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. @@ -252,8 +327,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \return The raw gyroscope values. If the operation failed, all the * structure's members are filled with PROS_ERR_F and errno is set. @@ -266,8 +341,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as an GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS + * EAGAIN - The sensor is still calibrating. * * \param port * The V5 GPS's port number from 1-21 diff --git a/EZ-Template-Example-Project/include/pros/imu.h b/EZ-Template-Example-Project/include/pros/imu.h index f5a1cdc3..d87508c4 100644 --- a/EZ-Template-Example-Project/include/pros/imu.h +++ b/EZ-Template-Example-Project/include/pros/imu.h @@ -29,11 +29,20 @@ namespace c { #endif typedef enum imu_status_e { - E_IMU_STATUS_CALIBRATING = 0x01, - E_IMU_STATUS_ERROR = 0xFF, // NOTE: used for returning an error from the get_status function, not that the IMU is - // necessarily in an error state + E_IMU_STATUS_READY = 0, // IMU is connected but not currently calibrating + E_IMU_STATUS_CALIBRATING = 1, // IMU is calibrating + E_IMU_STATUS_ERROR = 0xFF, // NOTE: used for returning an error from the get_status function, not that the IMU is + // necessarily in an error state } imu_status_e_t; +typedef enum imu_orientation_e { + E_IMU_Z_UP = 0, // IMU has the Z axis UP (VEX Logo facing DOWN) + E_IMU_Z_DOWN = 1, // IMU has the Z axis DOWN (VEX Logo facing UP) + E_IMU_X_UP = 2, // IMU has the X axis UP + E_IMU_X_DOWN = 3, // IMU has the X axis DOWN + E_IMU_Y_UP = 4, // IMU has the Y axis UP + E_IMU_Y_DOWN = 5, // IMU has the Y axis DOWN +} imu_orientation_e_t; typedef struct __attribute__((__packed__)) quaternion_s { double x; double y; @@ -91,10 +100,10 @@ int32_t imu_reset(uint8_t port); /** * Calibrate IMU and Blocks while Calibrating * - * Calibration takes approximately 2 seconds and blocks during this period, + * Calibration takes approximately 2 seconds and blocks during this period, * with a timeout for this operation being set a 3 seconds as a safety margin. - * Like the other reset function, this function also blocks until the IMU - * status flag is set properly to E_IMU_STATUS_CALIBRATING, with a minimum + * Like the other reset function, this function also blocks until the IMU + * status flag is set properly to E_IMU_STATUS_CALIBRATING, with a minimum * blocking time of 5ms and a timeout of 1 second if it's never set. * * This function uses the following values of errno when an error state is @@ -296,7 +305,6 @@ imu_accel_s_t imu_get_accel(uint8_t port); * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). * ENODEV - The port cannot be configured as an Inertial Sensor - * EAGAIN - The sensor is still calibrating * * \param port * The V5 Inertial Sensor port number from 1-21 @@ -309,7 +317,7 @@ imu_status_e_t imu_get_status(uint8_t port); // void imu_set_mode(uint8_t port, uint32_t mode); // uint32_t imu_get_mode(uint8_t port); -//Value reset functions: +// Value reset functions: /** * Resets the current reading of the Inertial Sensor's heading to zero * @@ -422,7 +430,7 @@ int32_t imu_tare_euler(uint8_t port); */ int32_t imu_tare(uint8_t port); -//Value set functions: +// Value set functions: /** * Sets the current reading of the Inertial Sensor's euler values to * target euler values. Will default to +/- 180 if target exceeds +/- 180. @@ -463,7 +471,7 @@ int32_t imu_set_rotation(uint8_t port, double target); /** * Sets the current reading of the Inertial Sensor's heading to target value * Target will default to 360 if above 360 and default to 0 if below 0. - * + * * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). @@ -482,7 +490,7 @@ int32_t imu_set_heading(uint8_t port, double target); /** * Sets the current reading of the Inertial Sensor's pitch to target value * Will default to +/- 180 if target exceeds +/- 180. - * + * * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). @@ -501,7 +509,7 @@ int32_t imu_set_pitch(uint8_t port, double target); /** * Sets the current reading of the Inertial Sensor's roll to target value * Will default to +/- 180 if target exceeds +/- 180. - * + * * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). @@ -520,7 +528,7 @@ int32_t imu_set_roll(uint8_t port, double target); /** * Sets the current reading of the Inertial Sensor's yaw to target value * Will default to +/- 180 if target exceeds +/- 180. - * + * * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). @@ -536,6 +544,21 @@ int32_t imu_set_roll(uint8_t port, double target); */ int32_t imu_set_yaw(uint8_t port, double target); +/** + * Returns the physical orientation of the IMU + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as an Inertial Sensor + * + * \param port + * The V5 Inertial Sensor port number from 1-21 + * \returns The orientation of the Inertial Sensor or PROS_ERR if an error occured. + * + */ +imu_orientation_e_t imu_get_physical_orientation(uint8_t port); + #ifdef __cplusplus } } diff --git a/EZ-Template-Example-Project/include/pros/imu.hpp b/EZ-Template-Example-Project/include/pros/imu.hpp index 99b28c8d..3f6f3933 100644 --- a/EZ-Template-Example-Project/include/pros/imu.hpp +++ b/EZ-Template-Example-Project/include/pros/imu.hpp @@ -19,6 +19,7 @@ #define _PROS_IMU_HPP_ #include + #include "pros/imu.h" namespace pros { @@ -31,47 +32,47 @@ class Imu { /** * Calibrate IMU * - * Calibration takes approximately 2 seconds and blocks during this period if - * the blocking param is true, with a timeout for this operation being set a 3 - * seconds as a safety margin. This function also blocks until the IMU - * status flag is set properly to E_IMU_STATUS_CALIBRATING, with a minimum + * Calibration takes approximately 2 seconds and blocks during this period if + * the blocking param is true, with a timeout for this operation being set a 3 + * seconds as a safety margin. This function also blocks until the IMU + * status flag is set properly to E_IMU_STATUS_CALIBRATING, with a minimum * blocking time of 5ms and a timeout of 1 second if it's never set. - * + * * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). * ENODEV - The port cannot be configured as an Inertial Sensor * EAGAIN - The sensor is already calibrating, or time out setting the status flag. * - * \param blocking + * \param blocking * Whether this function blocks during calibration. * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. */ virtual std::int32_t reset(bool blocking = false) const; /** - * Set the Inertial Sensor's refresh interval in milliseconds. - * - * The rate may be specified in increments of 5ms, and will be rounded down to - * the nearest increment. The minimum allowable refresh rate is 5ms. The default - * rate is 10ms. - * - * As values are copied into the shared memory buffer only at 10ms intervals, - * setting this value to less than 10ms does not mean that you can poll the - * sensor's values any faster. However, it will guarantee that the data is as - * recent as possible. - * - * This function uses the following values of errno when an error state is - * reached: - * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as an Inertial Sensor - * EAGAIN - The sensor is still calibrating - * - * \param rate - * The data refresh interval in milliseconds - * \return 1 if the operation was successful or PROS_ERR if the operation - * failed, setting errno. - */ + * Set the Inertial Sensor's refresh interval in milliseconds. + * + * The rate may be specified in increments of 5ms, and will be rounded down to + * the nearest increment. The minimum allowable refresh rate is 5ms. The default + * rate is 10ms. + * + * As values are copied into the shared memory buffer only at 10ms intervals, + * setting this value to less than 10ms does not mean that you can poll the + * sensor's values any faster. However, it will guarantee that the data is as + * recent as possible. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as an Inertial Sensor + * EAGAIN - The sensor is still calibrating + * + * \param rate + * The data refresh interval in milliseconds + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ virtual std::int32_t set_data_rate(std::uint32_t rate) const; /** * Get the total number of degrees the Inertial Sensor has spun about the z-axis @@ -310,7 +311,7 @@ class Imu { /** * Sets the current reading of the Inertial Sensor's heading to target value * Target will default to 360 if above 360 and default to 0 if below 0. - * + * * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). @@ -345,7 +346,7 @@ class Imu { /** * Sets the current reading of the Inertial Sensor's yaw to target value * Will default to +/- 180 if target exceeds +/- 180. - * + * * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). @@ -380,7 +381,7 @@ class Imu { /** * Sets the current reading of the Inertial Sensor's roll to target value * Will default to +/- 180 if target exceeds +/- 180. - * + * * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). @@ -435,7 +436,6 @@ class Imu { * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). * ENODEV - The port cannot be configured as an Inertial Sensor - * EAGAIN - The sensor is still calibrating * * \param port * The V5 Inertial Sensor port number from 1-21 @@ -450,6 +450,21 @@ class Imu { * false if it is not. */ virtual bool is_calibrating() const; + + /** + * Returns the physical orientation of the IMU + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as an Inertial Sensor + * + * \param port + * The V5 Inertial Sensor port number from 1-21 + * \returns The physical orientation of the Inertial Sensor or PROS_ERR if an error occured. + * + */ + virtual pros::c::imu_orientation_e_t get_physical_orientation() const; }; using IMU = Imu; diff --git a/EZ-Template-Example-Project/include/pros/screen.h b/EZ-Template-Example-Project/include/pros/screen.h index 8076daa9..5c6b538f 100644 --- a/EZ-Template-Example-Project/include/pros/screen.h +++ b/EZ-Template-Example-Project/include/pros/screen.h @@ -67,7 +67,7 @@ typedef struct screen_touch_status_s { #define TEXT_MEDIUM pros::E_TEXT_MEDIUM #define TEXT_LARGE pros::E_TEXT_LARGE #define TEXT_MEDIUM_CENTER pros::E_TEXT_MEDIUM_CENTER -#define TEXT_LARGE_CENTER pros::E_LARGE_CENTER +#define TEXT_LARGE_CENTER pros::E_TEXT_LARGE_CENTER #define TOUCH_RELEASED pros::E_TOUCH_RELEASED #define TOUCH_PRESSED pros::E_TOUCH_PRESSED #define TOUCH_HELD pros::E_TOUCH_HELD diff --git a/EZ-Template-Example-Project/project.pros b/EZ-Template-Example-Project/project.pros index 50d1830a..bf4c88d4 100644 --- a/EZ-Template-Example-Project/project.pros +++ b/EZ-Template-Example-Project/project.pros @@ -5,31 +5,31 @@ "target": "v5", "templates": { "EZ-Template": { - "location": "C:\\Users\\union\\AppData\\Roaming\\PROS\\templates\\EZ-Template@3.0.0", + "location": "C:\\Users\\union\\AppData\\Roaming\\PROS\\templates\\EZ-Template@3.0.1", "metadata": { "origin": "local" }, "name": "EZ-Template", "py/object": "pros.conductor.templates.local_template.LocalTemplate", - "supported_kernels": "^3.8.0", + "supported_kernels": "^3.8.3", "system_files": [ - "include\\EZ-Template\\slew.hpp", - "include\\EZ-Template\\api.hpp", "include\\EZ-Template\\sdcard.hpp", + "include\\EZ-Template\\slew.hpp", "include\\EZ-Template\\drive\\drive.hpp", + "include\\EZ-Template\\auton_selector.hpp", "include\\EZ-Template\\auton.hpp", - "include\\EZ-Template\\piston.hpp", "include\\EZ-Template\\util.hpp", + "include\\EZ-Template\\PID.hpp", + "include\\EZ-Template\\piston.hpp", "firmware\\EZ-Template.a", - "include\\EZ-Template\\auton_selector.hpp", - "include\\EZ-Template\\PID.hpp" + "include\\EZ-Template\\api.hpp" ], "target": "v5", "user_files": [], - "version": "3.0.0" + "version": "3.0.1" }, "kernel": { - "location": "C:\\Users\\union\\AppData\\Roaming\\PROS\\templates\\kernel@3.8.0", + "location": "C:\\Users\\union\\AppData\\Roaming\\PROS\\templates\\kernel@3.8.3", "metadata": { "cold_addr": "58720256", "cold_output": "bin/cold.package.bin", @@ -42,152 +42,152 @@ "py/object": "pros.conductor.templates.local_template.LocalTemplate", "supported_kernels": null, "system_files": [ - "include/display/lv_core/lv_vdb.h", - "include/display/lv_core/lv_core.mk", - "include/display/lv_misc/lv_math.h", - "include/display/lv_objx/lv_tabview.h", - "include/display/lv_misc/lv_color.h", - "include/display/lv_hal/lv_hal_indev.h", - "include/display/lv_fonts/lv_fonts.mk", - "include/display/lv_misc/lv_symbol_def.h", - "include/display/lv_hal/lv_hal.mk", - "include/display/lv_themes/lv_theme_night.h", - "include/display/lv_draw/lv_draw_triangle.h", - "include/pros/optical.hpp", - "include/display/lv_draw/lv_draw_vbasic.h", - "include/display/lv_objx/lv_objx_templ.h", - "include/display/lv_core/lv_refr.h", - "include/pros/link.hpp", - "include/display/lv_objx/lv_btnm.h", - "include/display/lv_objx/lv_cb.h", - "firmware/v5-common.ld", - "include/pros/ext_adi.h", - "include/pros/rotation.h", - "include/display/lv_objx/lv_spinbox.h", - "include/display/lv_misc/lv_circ.h", - "include/display/lv_misc/lv_mem.h", - "include/display/lv_objx/lv_page.h", - "include/display/lv_objx/lv_ddlist.h", - "include/display/lv_core/lv_group.h", - "include/display/lvgl.h", - "include/display/lv_objx/lv_chart.h", - "include/pros/distance.h", - "include/display/lv_objx/lv_list.h", - "include/pros/vision.h", - "include/pros/misc.hpp", - "include/display/lv_draw/lv_draw.h", - "include/display/lv_objx/lv_label.h", - "include/display/lv_misc/lv_font.h", - "include/display/lv_draw/lv_draw_img.h", - "include/display/lv_misc/lv_log.h", - "include/display/lv_misc/lv_templ.h", - "include/pros/llemu.h", - "include/display/lv_objx/lv_btn.h", - "include/display/lv_fonts/lv_font_builtin.h", - "include/display/lv_objx/lv_calendar.h", - "firmware/libm.a", - "include/display/lv_conf.h", - "include/display/lv_objx/lv_sw.h", - "include/display/lv_draw/lv_draw_rect.h", - "include/display/lv_objx/lv_cont.h", - "include/pros/vision.hpp", - "include/display/lv_objx/lv_mbox.h", - "include/pros/adi.hpp", - "include/pros/imu.hpp", - "include/display/lv_objx/lv_table.h", - "include/pros/screen.hpp", - "include/display/lv_draw/lv_draw_label.h", - "include/display/lv_misc/lv_txt.h", - "include/pros/api_legacy.h", - "include/display/lv_objx/lv_lmeter.h", - "include/display/lv_themes/lv_theme_templ.h", - "include/pros/apix.h", - "include/display/lv_draw/lv_draw.mk", - "include/display/lv_themes/lv_theme_alien.h", - "include/pros/colors.hpp", - "include/display/lv_objx/lv_img.h", - "firmware/libc.a", - "include/display/lv_themes/lv_theme_zen.h", - "include/display/lv_themes/lv_theme_material.h", - "include/display/lv_draw/lv_draw_arc.h", - "include/display/lv_themes/lv_theme_mono.h", - "include/display/lv_themes/lv_themes.mk", - "include/display/lv_objx/lv_slider.h", - "include/pros/serial.h", - "include/display/lv_themes/lv_theme.h", - "include/display/README.md", - "include/display/lv_objx/lv_canvas.h", - "include/pros/misc.h", - "include/display/lv_misc/lv_fs.h", - "include/pros/rtos.h", - "include/display/lv_core/lv_indev.h", - "include/pros/motors.hpp", - "include/display/lv_core/lv_style.h", - "include/display/lv_version.h", - "include/display/lv_core/lv_lang.h", - "include/api.h", - "include/display/lv_objx/lv_gauge.h", - "include/pros/rtos.hpp", - "include/display/lv_hal/lv_hal_disp.h", - "include/pros/motors.h", - "include/display/lv_objx/lv_led.h", - "include/display/lv_draw/lv_draw_rbasic.h", - "include/display/lv_objx/lv_kb.h", - "include/display/lv_conf_checker.h", - "include/display/lv_hal/lv_hal.h", - "include/display/lv_draw/lv_draw_line.h", - "include/pros/gps.hpp", - "include/display/lv_objx/lv_objx.mk", - "include/display/lv_objx/lv_win.h", - "include/display/lv_core/lv_obj.h", - "include/display/lv_objx/lv_arc.h", - "include/pros/link.h", - "include/display/lv_objx/lv_preload.h", - "include/display/lv_misc/lv_area.h", - "include/display/lv_misc/lv_ll.h", - "include/pros/optical.h", - "include/pros/serial.hpp", - "include/pros/screen.h", - "include/display/lv_themes/lv_theme_nemo.h", - "include/pros/llemu.hpp", - "firmware/libpros.a", - "include/display/lv_misc/lv_gc.h", - "include/display/lv_misc/lv_anim.h", - "include/display/lv_objx/lv_line.h", - "include/pros/distance.hpp", - "include/pros/rotation.hpp", - "include/pros/error.h", - "include/display/lv_objx/lv_tileview.h", - "include/pros/gps.h", - "include/display/lv_misc/lv_task.h", - "include/pros/imu.h", - "firmware/v5-hot.ld", - "include/display/lv_misc/lv_misc.mk", - "include/pros/colors.h", + "include\\display\\lv_themes\\lv_theme_mono.h", + "include\\display\\lv_themes\\lv_theme_nemo.h", + "include\\display\\lv_objx\\lv_calendar.h", + "include\\display\\lv_themes\\lv_theme_zen.h", + "include\\display\\lv_objx\\lv_spinbox.h", + "include\\pros\\screen.hpp", + "include\\display\\lv_objx\\lv_ddlist.h", + "include\\display\\lv_themes\\lv_theme.h", + "include\\display\\lv_hal\\lv_hal.h", + "include\\display\\lv_draw\\lv_draw_arc.h", + "include\\display\\lv_objx\\lv_list.h", + "include\\display\\lv_themes\\lv_themes.mk", + "include\\pros\\motors.hpp", + "include\\pros\\adi.h", + "include\\display\\lv_draw\\lv_draw.h", + "include\\pros\\colors.hpp", + "include\\display\\licence.txt", + "include\\display\\lv_draw\\lv_draw_img.h", + "include\\display\\lv_fonts\\lv_fonts.mk", + "include\\display\\lv_draw\\lv_draw_rect.h", + "include\\display\\lv_core\\lv_group.h", + "include\\display\\lv_draw\\lv_draw_label.h", + "include\\pros\\llemu.h", + "include\\pros\\error.h", + "include\\display\\lv_misc\\lv_ufs.h", + "firmware\\libm.a", + "include\\display\\lv_objx\\lv_led.h", + "include\\display\\lv_objx\\lv_btn.h", + "include\\display\\lv_misc\\lv_misc.mk", + "include\\display\\lv_objx\\lv_canvas.h", + "include\\display\\lv_objx\\lv_preload.h", + "include\\pros\\misc.hpp", + "include\\display\\lv_misc\\lv_fs.h", + "include\\pros\\rotation.hpp", + "include\\pros\\colors.h", + "include\\pros\\vision.hpp", + "include\\display\\lv_objx\\lv_img.h", + "include\\display\\lv_fonts\\lv_font_builtin.h", + "include\\display\\lv_objx\\lv_lmeter.h", + "include\\display\\lv_misc\\lv_font.h", + "firmware\\v5.ld", + "include\\display\\lv_objx\\lv_tileview.h", + "include\\display\\lv_hal\\lv_hal_tick.h", + "include\\display\\lv_core\\lv_vdb.h", + "include\\display\\lv_core\\lv_indev.h", + "include\\pros\\vision.h", + "firmware\\v5-hot.ld", + "include\\display\\lv_objx\\lv_kb.h", + "include\\display\\lv_misc\\lv_symbol_def.h", + "firmware\\libc.a", + "include\\display\\lv_objx\\lv_label.h", + "include\\display\\lv_objx\\lv_tabview.h", + "firmware\\libpros.a", + "include\\display\\lv_misc\\lv_ll.h", + "include\\display\\lv_misc\\lv_log.h", + "include\\pros\\screen.h", + "include\\display\\lv_hal\\lv_hal.mk", + "include\\pros\\serial.hpp", + "include\\pros\\optical.hpp", + "include\\display\\lv_misc\\lv_txt.h", + "include\\display\\lv_misc\\lv_task.h", + "firmware\\v5-common.ld", + "include\\pros\\optical.h", + "include\\pros\\rtos.hpp", + "include\\display\\lv_conf_checker.h", + "include\\display\\lv_misc\\lv_math.h", + "include\\display\\lv_draw\\lv_draw_rbasic.h", + "include\\display\\lv_themes\\lv_theme_alien.h", + "include\\pros\\motors.h", + "include\\pros\\misc.h", + "include\\display\\lv_themes\\lv_theme_default.h", + "include\\pros\\gps.h", + "include\\display\\lv_misc\\lv_templ.h", + "include\\display\\lv_misc\\lv_circ.h", + "include\\api.h", + "include\\display\\lv_objx\\lv_ta.h", + "include\\display\\lv_draw\\lv_draw_triangle.h", + "include\\display\\lv_misc\\lv_mem.h", + "include\\display\\lv_objx\\lv_imgbtn.h", + "include\\pros\\link.h", + "include\\display\\lv_version.h", + "include\\display\\lv_conf.h", + "include\\display\\lv_objx\\lv_mbox.h", + "include\\display\\lv_misc\\lv_anim.h", + "include\\display\\lv_hal\\lv_hal_indev.h", + "include\\display\\lv_objx\\lv_btnm.h", + "include\\display\\lv_misc\\lv_color.h", + "include\\display\\lv_draw\\lv_draw_vbasic.h", + "include\\pros\\distance.hpp", + "include\\display\\lv_objx\\lv_bar.h", + "include\\display\\lv_objx\\lv_gauge.h", + "include\\display\\lv_draw\\lv_draw.mk", + "include\\display\\lvgl.h", + "include\\display\\lv_objx\\lv_slider.h", + "include\\display\\lv_objx\\lv_objx.mk", + "include\\display\\README.md", + "include\\display\\lv_core\\lv_lang.h", + "include\\display\\lv_objx\\lv_arc.h", + "include\\pros\\serial.h", + "include\\pros\\llemu.hpp", + "include\\pros\\adi.hpp", + "include\\display\\lv_objx\\lv_table.h", + "include\\display\\lv_draw\\lv_draw_line.h", + "include\\display\\lv_misc\\lv_area.h", + "include\\display\\lv_core\\lv_core.mk", + "include\\display\\lv_objx\\lv_line.h", + "include\\display\\lv_hal\\lv_hal_disp.h", + "include\\display\\lv_misc\\lv_gc.h", + "include\\pros\\rotation.h", + "include\\display\\lv_themes\\lv_theme_material.h", + "include\\display\\lv_core\\lv_style.h", + "include\\display\\lv_objx\\lv_cb.h", + "include\\display\\lv_objx\\lv_chart.h", "common.mk", - "include/display/lv_objx/lv_roller.h", - "include/display/lv_objx/lv_bar.h", - "include/display/lv_themes/lv_theme_default.h", - "firmware/v5.ld", - "include/display/lv_misc/lv_ufs.h", - "include/display/lv_hal/lv_hal_tick.h", - "include/display/licence.txt", - "include/display/lv_objx/lv_ta.h", - "include/display/lv_objx/lv_imgbtn.h", - "include/pros/adi.h" + "include\\pros\\ext_adi.h", + "include\\display\\lv_objx\\lv_objx_templ.h", + "include\\display\\lv_core\\lv_refr.h", + "include\\display\\lv_core\\lv_obj.h", + "include\\pros\\api_legacy.h", + "include\\pros\\rtos.h", + "include\\pros\\imu.h", + "include\\display\\lv_objx\\lv_win.h", + "include\\display\\lv_objx\\lv_cont.h", + "include\\display\\lv_themes\\lv_theme_templ.h", + "include\\pros\\link.hpp", + "include\\pros\\distance.h", + "include\\display\\lv_objx\\lv_roller.h", + "include\\display\\lv_objx\\lv_sw.h", + "include\\pros\\imu.hpp", + "include\\pros\\gps.hpp", + "include\\display\\lv_themes\\lv_theme_night.h", + "include\\pros\\apix.h", + "include\\display\\lv_objx\\lv_page.h" ], "target": "v5", "user_files": [ - "src/main.cc", - ".gitignore", + "include\\main.h", + "src\\main.c", + "include\\main.hpp", + "include\\main.hh", + "src\\main.cpp", + "src\\main.cc", "Makefile", - "src/main.cpp", - "src/main.c", - "include/main.hpp", - "include/main.hh", - "include/main.h" + ".gitignore" ], - "version": "3.8.0" + "version": "3.8.3" }, "okapilib": { "location": "C:\\Users\\union\\AppData\\Roaming\\PROS\\templates\\okapilib@4.8.0", diff --git a/EZ-Template-Example-Project/src/main.cpp b/EZ-Template-Example-Project/src/main.cpp index 6386fb1f..c836f129 100644 --- a/EZ-Template-Example-Project/src/main.cpp +++ b/EZ-Template-Example-Project/src/main.cpp @@ -48,7 +48,7 @@ void initialize() { // Configure your chassis controls chassis.opcontrol_curve_buttons_toggle(true); // Enables modifying the controller curve with buttons on the joysticks - chassis.opcontrol_drive_activebrake_set(0); // Sets the active brake kP. We recommend 0.1. + chassis.opcontrol_drive_activebrake_set(0); // Sets the active brake kP. We recommend 2. chassis.opcontrol_curve_default_set(0, 0); // Defaults for curve. If using tank, only the first parameter is used. (Comment this line out if you have an SD card!) default_constants(); // Set the drive to your own constants from autons.cpp! @@ -118,7 +118,14 @@ void autonomous() { chassis.drive_sensor_reset(); // Reset drive sensors to 0 chassis.drive_brake_set(MOTOR_BRAKE_HOLD); // Set motors to hold. This helps autonomous consistency - ez::as::auton_selector.selected_auton_call(); // Calls selected auton from autonomous selector + // ez::as::auton_selector.selected_auton_call(); // Calls selected auton from autonomous selector + int dist = 48; + chassis.pid_drive_set(dist, 127, true); + chassis.pid_wait_until(dist - 5); + + int dist2 = -(dist-6); + chassis.pid_drive_set(dist2, 127, true); + chassis.pid_wait_until(dist2 + 5); } diff --git a/EZ-Template@3.0.0.zip b/EZ-Template@3.0.1.zip similarity index 54% rename from EZ-Template@3.0.0.zip rename to EZ-Template@3.0.1.zip index 18de689c..31e8046b 100644 Binary files a/EZ-Template@3.0.0.zip and b/EZ-Template@3.0.1.zip differ diff --git a/Makefile b/Makefile index 4916542d..78588c4e 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ EXCLUDE_COLD_LIBRARIES:= IS_LIBRARY:=1 # TODO: CHANGE THIS! LIBNAME:=EZ-Template -VERSION:=3.0.0 +VERSION:=3.0.1 # EXCLUDE_SRC_FROM_LIB= $(SRCDIR)/unpublishedfile.c # this line excludes opcontrol.c and similar files EXCLUDE_SRC_FROM_LIB+=$(foreach file, $(SRCDIR)/autons $(SRCDIR)/main,$(foreach cext,$(CEXTS),$(file).$(cext)) $(foreach cxxext,$(CXXEXTS),$(file).$(cxxext))) diff --git a/README.md b/README.md index d23adcea..83b2e89b 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@ ![](https://img.shields.io/github/downloads/EZ-Robotics/EZ-Template/total.svg) ![](https://github.com/EZ-Robotics/EZ-Template/workflows/Build/badge.svg) -[![License: MPL 2.0](https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0) +[![License: MPL 2.0](https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0) -# EZ-Template -EZ-Template is a simple plug-and-play PROS template that handles drive base functions, autonomous selector, input curves, and active brake with PTO support. +**EZ-Template is a simple plug-and-play PROS template that handles drive base functions, autonomous selector, input curves, and active brake with PTO support.** ## Features - Simple to setup @@ -22,24 +21,14 @@ EZ-Template is a simple plug-and-play PROS template that handles drive base func - Add / remove motors from the drive dynamically to allow for PTO use - Exposed PID class for use with your other subsystems +## [Installation and Upgrading](https://ez-robotics.github.io/EZ-Template/tutorials/installation) +Installation and Upgrading tutorials can be foud [here](https://ez-robotics.github.io/EZ-Template/tutorials/installation). -## Installation +## [Tutorials](https://ez-robotics.github.io/EZ-Template/category/tutorials) +Tutorials on how to use and install EZ-Template can be found [here](https://ez-robotics.github.io/EZ-Template/category/tutorials). -1) Download the latest `Example-Project.zip` [here](https://github.com/EZ-Robotics/EZ-Template/releases/latest). Extract the zip, and open it in PROS. -2) In `src/main.cpp`, configure drive and IMU ports to what they are on your robot. Be sure to read the comments! -3) Configure your wheel size and cartridge. Remember that older 4" omni wheels without mounting holes are actually 4.125! -4) In `src/main.cpp`, at the bottom in `void opcontrol()`, decide how you'd like to control your robot! Any flavor of arcade or tank! -5) Turn the robot on and use it in driver control. Make sure the ports are correct and reversed correctly. -6) To test the test autonomous modes, plug into a competition switch and select the autonomous mode on the brain screen by pressing the left and right buttons. The current page will be the autonomous that runs. For making new autonomous routines, [click here](https://ez-robotics.github.io/EZ-Template/tutorials/example_autons) for examples on how to use the drive functions. +## [Docs](https://ez-robotics.github.io/EZ-Template/category/docs) +Documentation on how to use EZ-Template functions can be found [here](https://ez-robotics.github.io/EZ-Template/category/docs). -## Upgrading -*Note: This only works within major versions. 2.1 can upgrade to 2.2, but 2.x cannot upgrade to 3.x.* - -1) Download the most recent `EZ-Template@x.x.x.zip` [here](https://github.com/EZ-Robotics/EZ-Template/releases/latest). -2) Move the file to your project. -3) Open terminal or command prompt, and `cd` into your projects directory. -4) Run this command from terminal `pros c fetch EZ-Template@x.x.x.zip` replacing `x.x.x` with the version number of your file. -5) Apply the library to the project `pros c apply EZ-Template`. - -## License -This project is licensed under the Mozilla Public License, version 2.0 - see the [LICENSE](LICENSE) file for the full license. \ No newline at end of file +## [License](https://opensource.org/licenses/MPL-2.0) +This project is licensed under the Mozilla Public License, version 2.0 - see the [LICENSE](https://opensource.org/licenses/MPL-2.0) file for the full license. \ No newline at end of file diff --git a/firmware/libpros.a b/firmware/libpros.a index 05399901..3dbfc1b7 100644 Binary files a/firmware/libpros.a and b/firmware/libpros.a differ diff --git a/include/EZ-Template/drive/drive.hpp b/include/EZ-Template/drive/drive.hpp index 6b122d3c..0fddb2eb 100644 --- a/include/EZ-Template/drive/drive.hpp +++ b/include/EZ-Template/drive/drive.hpp @@ -722,7 +722,7 @@ class Drive { * \param toggle_heading * toggle for heading correction */ - void pid_drive_set(double target, int speed, bool slew_on, bool toggle_heading = true); + void pid_drive_set(double target, int speed, bool slew_on = false, bool toggle_heading = true); /** * Sets the robot to turn using PID. @@ -782,7 +782,7 @@ class Drive { * \param speed * 0 to 127, max speed during motion * \param opposite_speed - * 0 to 127, max speed of the opposite side of the drive during the swing. This is used for arcs, and is defaulted to 0. + * -127 to 127, max speed of the opposite side of the drive during the swing. This is used for arcs, and is defaulted to 0. */ void pid_swing_set(e_swing type, double target, int speed, int opposite_speed = 0, bool slew_on = false); @@ -796,7 +796,7 @@ class Drive { * \param speed * 0 to 127, max speed during motion * \param opposite_speed - * 0 to 127, max speed of the opposite side of the drive during the swing. This is used for arcs, and is defaulted to 0. + * -127 to 127, max speed of the opposite side of the drive during the swing. This is used for arcs, and is defaulted to 0. */ void pid_swing_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed = 0, bool slew_on = false); @@ -810,7 +810,7 @@ class Drive { * \param speed * 0 to 127, max speed during motion * \param opposite_speed - * 0 to 127, max speed of the opposite side of the drive during the swing. This is used for arcs, and is defaulted to 0. + * -127 to 127, max speed of the opposite side of the drive during the swing. This is used for arcs, and is defaulted to 0. */ void pid_swing_relative_set(e_swing type, okapi::QAngle p_target, int speed, int opposite_speed = 0, bool slew_on = false); @@ -824,7 +824,7 @@ class Drive { * \param speed * 0 to 127, max speed during motion * \param opposite_speed - * 0 to 127, max speed of the opposite side of the drive during the swing. This is used for arcs, and is defaulted to 0. + * -127 to 127, max speed of the opposite side of the drive during the swing. This is used for arcs, and is defaulted to 0. */ void pid_swing_relative_set(e_swing type, double target, int speed, int opposite_speed = 0, bool slew_on = false); @@ -1305,14 +1305,13 @@ class Drive { bool slew_swing_using_angle = false; bool pid_tuner_terminal_b = false; bool pid_tuner_lcd_b = true; - struct const_and_name { std::string name = ""; PID::Constants *consts; }; std::vector constants; void pid_tuner_print(); - void pid_tuner_value_modify(double p, double i, double d, double start); + void pid_tuner_value_modify(float p, float i, float d, float start); void pid_tuner_value_increase(); void pid_tuner_value_decrease(); void pid_tuner_print_brain(); @@ -1320,16 +1319,12 @@ class Drive { void pid_tuner_brain_init(); int column = 0; int row = 0; - int column_max = 0; - const int row_max = 3; - std::string name, kp, ki, kd, starti; std::string arrow = " <--\n"; - std::string newline = "\n"; - bool last_controller_curve_state; - bool last_auton_selector_state; + bool last_controller_curve_state = false; + bool last_auton_selector_state = false; bool pid_tuner_on = false; - std::string complete_pid_tuner_output; - double p_increment = 0.1, i_increment = 0.001, d_increment = 0.25, start_i_increment = 1.0; + std::string complete_pid_tuner_output = ""; + float p_increment = 0.1, i_increment = 0.001, d_increment = 0.25, start_i_increment = 1.0; /** * Private wait until for drive diff --git a/include/api.h b/include/api.h index 7e923199..6b09de1d 100644 --- a/include/api.h +++ b/include/api.h @@ -41,8 +41,8 @@ #define PROS_VERSION_MAJOR 3 #define PROS_VERSION_MINOR 8 -#define PROS_VERSION_PATCH 0 -#define PROS_VERSION_STRING "3.8.0" +#define PROS_VERSION_PATCH 3 +#define PROS_VERSION_STRING "3.8.3" #include "pros/adi.h" #include "pros/colors.h" @@ -56,8 +56,8 @@ #include "pros/misc.h" #include "pros/motors.h" #include "pros/optical.h" -#include "pros/rtos.h" #include "pros/rotation.h" +#include "pros/rtos.h" #include "pros/screen.h" #include "pros/vision.h" @@ -66,6 +66,7 @@ #include "pros/distance.hpp" #include "pros/gps.hpp" #include "pros/imu.hpp" +#include "pros/link.hpp" #include "pros/llemu.hpp" #include "pros/misc.hpp" #include "pros/motors.hpp" @@ -74,7 +75,6 @@ #include "pros/rtos.hpp" #include "pros/screen.hpp" #include "pros/vision.hpp" -#include "pros/link.hpp" #endif #endif // _PROS_API_H_ diff --git a/include/pros/gps.h b/include/pros/gps.h index 1b2e7e7b..917f6938 100644 --- a/include/pros/gps.h +++ b/include/pros/gps.h @@ -188,6 +188,91 @@ double gps_get_error(uint8_t port); */ gps_status_s_t gps_get_status(uint8_t port); +/** + * Gets the X position in meters of the robot relative to the starting position. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * + * \return The X position in meters. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ +double gps_get_x_position(uint8_t port); + +/** + * Gets the Y position in meters of the robot relative to the starting position. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * + * \return The Y position in meters. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ +double gps_get_y_position(uint8_t port); + +/** + * Gets the pitch of the GPS in degrees relative to the starting orientation. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * + * \return The pitch in (-90,90] degree values. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ +double gps_get_pitch(uint8_t port); + +/** + * Gets the roll of the GPS in degrees relative to the starting orientation. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * + * \return The roll in (-180,180] degree values. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ +double gps_get_roll(uint8_t port); + +/** + * Gets the yaw of the GPS in degrees relative to the starting orientation. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a GPS + * EAGAIN - The sensor is still calibrating + * + * \param port + * The V5 GPS port number from 1-21 + * + * \return The yaw in (-180,180] degree values. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ +double gps_get_yaw(uint8_t port); + /** * Get the heading in [0,360) degree values. * diff --git a/include/pros/gps.hpp b/include/pros/gps.hpp index fce40c2a..7a321239 100644 --- a/include/pros/gps.hpp +++ b/include/pros/gps.hpp @@ -52,8 +52,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \param xOffset * Cartesian 4-Quadrant X offset from center of turning (meters) @@ -77,8 +77,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \param xOffset * Cartesian 4-Quadrant X offset from center of turning (meters) @@ -95,8 +95,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \param xOffset * Pointer to cartesian 4-Quadrant X offset from center of turning (meters) @@ -113,8 +113,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \param xInitial * Initial 4-Quadrant X Position, with (0,0) being at the center of the field (meters) @@ -133,8 +133,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \param rate * Data rate in milliseconds (Minimum: 5 ms) @@ -149,8 +149,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \return Possible RMS (Root Mean Squared) error in meters for GPS position. * If the operation failed, returns PROS_ERR_F and errno is set. @@ -163,8 +163,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * * \return A struct (gps_status_s_t) containing values mentioned above. @@ -173,14 +173,89 @@ class Gps { */ virtual pros::c::gps_status_s_t get_status() const; + /** + * Gets the X position in meters of the robot relative to the starting position. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. + * + * + * \return The X position in meters. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ + virtual double get_x_position() const; + + /** + * Gets the Y position in meters of the robot relative to the starting position. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. + * + * + * \return The Y position in meters. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ + virtual double get_y_position() const; + + /** + * Gets the pitch of the GPS in degrees relative to the starting orientation. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. + * + * + * \return The pitch in [0,360) degree values. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ + virtual double get_pitch() const; + + /** + * Gets the roll of the GPS in degrees relative to the starting orientation. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. + * + * + * \return The roll in [0,360) degree values. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ + virtual double get_roll() const; + + /** + * Gets the yaw of the GPS in degrees relative to the starting orientation. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. + * + * + * \return The yaw in [0,360) degree values. If the operation failed, + * returns PROS_ERR_F and errno is set. + */ + virtual double get_yaw() const; + /** * Get the heading in [0,360) degree values. * * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * * \return The heading in [0,360) degree values. If the operation failed, @@ -194,8 +269,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \return The heading in [DOUBLE_MIN, DOUBLE_MAX] values. If the operation * fails, returns PROS_ERR_F and errno is set. @@ -208,8 +283,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \return The elased heading in degrees. If the operation fails, returns * PROS_ERR_F and errno is set. @@ -222,8 +297,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \param target * Target rotation value to set rotation value to @@ -238,8 +313,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. @@ -252,8 +327,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as a GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS. + * EAGAIN - The sensor is still calibrating. * * \return The raw gyroscope values. If the operation failed, all the * structure's members are filled with PROS_ERR_F and errno is set. @@ -266,8 +341,8 @@ class Gps { * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as an GPS - * EAGAIN - The sensor is still calibrating + * ENODEV - The port cannot be configured as a GPS + * EAGAIN - The sensor is still calibrating. * * \param port * The V5 GPS's port number from 1-21 diff --git a/include/pros/imu.h b/include/pros/imu.h index f5a1cdc3..d87508c4 100644 --- a/include/pros/imu.h +++ b/include/pros/imu.h @@ -29,11 +29,20 @@ namespace c { #endif typedef enum imu_status_e { - E_IMU_STATUS_CALIBRATING = 0x01, - E_IMU_STATUS_ERROR = 0xFF, // NOTE: used for returning an error from the get_status function, not that the IMU is - // necessarily in an error state + E_IMU_STATUS_READY = 0, // IMU is connected but not currently calibrating + E_IMU_STATUS_CALIBRATING = 1, // IMU is calibrating + E_IMU_STATUS_ERROR = 0xFF, // NOTE: used for returning an error from the get_status function, not that the IMU is + // necessarily in an error state } imu_status_e_t; +typedef enum imu_orientation_e { + E_IMU_Z_UP = 0, // IMU has the Z axis UP (VEX Logo facing DOWN) + E_IMU_Z_DOWN = 1, // IMU has the Z axis DOWN (VEX Logo facing UP) + E_IMU_X_UP = 2, // IMU has the X axis UP + E_IMU_X_DOWN = 3, // IMU has the X axis DOWN + E_IMU_Y_UP = 4, // IMU has the Y axis UP + E_IMU_Y_DOWN = 5, // IMU has the Y axis DOWN +} imu_orientation_e_t; typedef struct __attribute__((__packed__)) quaternion_s { double x; double y; @@ -91,10 +100,10 @@ int32_t imu_reset(uint8_t port); /** * Calibrate IMU and Blocks while Calibrating * - * Calibration takes approximately 2 seconds and blocks during this period, + * Calibration takes approximately 2 seconds and blocks during this period, * with a timeout for this operation being set a 3 seconds as a safety margin. - * Like the other reset function, this function also blocks until the IMU - * status flag is set properly to E_IMU_STATUS_CALIBRATING, with a minimum + * Like the other reset function, this function also blocks until the IMU + * status flag is set properly to E_IMU_STATUS_CALIBRATING, with a minimum * blocking time of 5ms and a timeout of 1 second if it's never set. * * This function uses the following values of errno when an error state is @@ -296,7 +305,6 @@ imu_accel_s_t imu_get_accel(uint8_t port); * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). * ENODEV - The port cannot be configured as an Inertial Sensor - * EAGAIN - The sensor is still calibrating * * \param port * The V5 Inertial Sensor port number from 1-21 @@ -309,7 +317,7 @@ imu_status_e_t imu_get_status(uint8_t port); // void imu_set_mode(uint8_t port, uint32_t mode); // uint32_t imu_get_mode(uint8_t port); -//Value reset functions: +// Value reset functions: /** * Resets the current reading of the Inertial Sensor's heading to zero * @@ -422,7 +430,7 @@ int32_t imu_tare_euler(uint8_t port); */ int32_t imu_tare(uint8_t port); -//Value set functions: +// Value set functions: /** * Sets the current reading of the Inertial Sensor's euler values to * target euler values. Will default to +/- 180 if target exceeds +/- 180. @@ -463,7 +471,7 @@ int32_t imu_set_rotation(uint8_t port, double target); /** * Sets the current reading of the Inertial Sensor's heading to target value * Target will default to 360 if above 360 and default to 0 if below 0. - * + * * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). @@ -482,7 +490,7 @@ int32_t imu_set_heading(uint8_t port, double target); /** * Sets the current reading of the Inertial Sensor's pitch to target value * Will default to +/- 180 if target exceeds +/- 180. - * + * * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). @@ -501,7 +509,7 @@ int32_t imu_set_pitch(uint8_t port, double target); /** * Sets the current reading of the Inertial Sensor's roll to target value * Will default to +/- 180 if target exceeds +/- 180. - * + * * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). @@ -520,7 +528,7 @@ int32_t imu_set_roll(uint8_t port, double target); /** * Sets the current reading of the Inertial Sensor's yaw to target value * Will default to +/- 180 if target exceeds +/- 180. - * + * * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). @@ -536,6 +544,21 @@ int32_t imu_set_roll(uint8_t port, double target); */ int32_t imu_set_yaw(uint8_t port, double target); +/** + * Returns the physical orientation of the IMU + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as an Inertial Sensor + * + * \param port + * The V5 Inertial Sensor port number from 1-21 + * \returns The orientation of the Inertial Sensor or PROS_ERR if an error occured. + * + */ +imu_orientation_e_t imu_get_physical_orientation(uint8_t port); + #ifdef __cplusplus } } diff --git a/include/pros/imu.hpp b/include/pros/imu.hpp index 99b28c8d..3f6f3933 100644 --- a/include/pros/imu.hpp +++ b/include/pros/imu.hpp @@ -19,6 +19,7 @@ #define _PROS_IMU_HPP_ #include + #include "pros/imu.h" namespace pros { @@ -31,47 +32,47 @@ class Imu { /** * Calibrate IMU * - * Calibration takes approximately 2 seconds and blocks during this period if - * the blocking param is true, with a timeout for this operation being set a 3 - * seconds as a safety margin. This function also blocks until the IMU - * status flag is set properly to E_IMU_STATUS_CALIBRATING, with a minimum + * Calibration takes approximately 2 seconds and blocks during this period if + * the blocking param is true, with a timeout for this operation being set a 3 + * seconds as a safety margin. This function also blocks until the IMU + * status flag is set properly to E_IMU_STATUS_CALIBRATING, with a minimum * blocking time of 5ms and a timeout of 1 second if it's never set. - * + * * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). * ENODEV - The port cannot be configured as an Inertial Sensor * EAGAIN - The sensor is already calibrating, or time out setting the status flag. * - * \param blocking + * \param blocking * Whether this function blocks during calibration. * \return 1 if the operation was successful or PROS_ERR if the operation * failed, setting errno. */ virtual std::int32_t reset(bool blocking = false) const; /** - * Set the Inertial Sensor's refresh interval in milliseconds. - * - * The rate may be specified in increments of 5ms, and will be rounded down to - * the nearest increment. The minimum allowable refresh rate is 5ms. The default - * rate is 10ms. - * - * As values are copied into the shared memory buffer only at 10ms intervals, - * setting this value to less than 10ms does not mean that you can poll the - * sensor's values any faster. However, it will guarantee that the data is as - * recent as possible. - * - * This function uses the following values of errno when an error state is - * reached: - * ENXIO - The given value is not within the range of V5 ports (1-21). - * ENODEV - The port cannot be configured as an Inertial Sensor - * EAGAIN - The sensor is still calibrating - * - * \param rate - * The data refresh interval in milliseconds - * \return 1 if the operation was successful or PROS_ERR if the operation - * failed, setting errno. - */ + * Set the Inertial Sensor's refresh interval in milliseconds. + * + * The rate may be specified in increments of 5ms, and will be rounded down to + * the nearest increment. The minimum allowable refresh rate is 5ms. The default + * rate is 10ms. + * + * As values are copied into the shared memory buffer only at 10ms intervals, + * setting this value to less than 10ms does not mean that you can poll the + * sensor's values any faster. However, it will guarantee that the data is as + * recent as possible. + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as an Inertial Sensor + * EAGAIN - The sensor is still calibrating + * + * \param rate + * The data refresh interval in milliseconds + * \return 1 if the operation was successful or PROS_ERR if the operation + * failed, setting errno. + */ virtual std::int32_t set_data_rate(std::uint32_t rate) const; /** * Get the total number of degrees the Inertial Sensor has spun about the z-axis @@ -310,7 +311,7 @@ class Imu { /** * Sets the current reading of the Inertial Sensor's heading to target value * Target will default to 360 if above 360 and default to 0 if below 0. - * + * * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). @@ -345,7 +346,7 @@ class Imu { /** * Sets the current reading of the Inertial Sensor's yaw to target value * Will default to +/- 180 if target exceeds +/- 180. - * + * * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). @@ -380,7 +381,7 @@ class Imu { /** * Sets the current reading of the Inertial Sensor's roll to target value * Will default to +/- 180 if target exceeds +/- 180. - * + * * This function uses the following values of errno when an error state is * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). @@ -435,7 +436,6 @@ class Imu { * reached: * ENXIO - The given value is not within the range of V5 ports (1-21). * ENODEV - The port cannot be configured as an Inertial Sensor - * EAGAIN - The sensor is still calibrating * * \param port * The V5 Inertial Sensor port number from 1-21 @@ -450,6 +450,21 @@ class Imu { * false if it is not. */ virtual bool is_calibrating() const; + + /** + * Returns the physical orientation of the IMU + * + * This function uses the following values of errno when an error state is + * reached: + * ENXIO - The given value is not within the range of V5 ports (1-21). + * ENODEV - The port cannot be configured as an Inertial Sensor + * + * \param port + * The V5 Inertial Sensor port number from 1-21 + * \returns The physical orientation of the Inertial Sensor or PROS_ERR if an error occured. + * + */ + virtual pros::c::imu_orientation_e_t get_physical_orientation() const; }; using IMU = Imu; diff --git a/include/pros/screen.h b/include/pros/screen.h index 8076daa9..5c6b538f 100644 --- a/include/pros/screen.h +++ b/include/pros/screen.h @@ -67,7 +67,7 @@ typedef struct screen_touch_status_s { #define TEXT_MEDIUM pros::E_TEXT_MEDIUM #define TEXT_LARGE pros::E_TEXT_LARGE #define TEXT_MEDIUM_CENTER pros::E_TEXT_MEDIUM_CENTER -#define TEXT_LARGE_CENTER pros::E_LARGE_CENTER +#define TEXT_LARGE_CENTER pros::E_TEXT_LARGE_CENTER #define TOUCH_RELEASED pros::E_TOUCH_RELEASED #define TOUCH_PRESSED pros::E_TOUCH_PRESSED #define TOUCH_HELD pros::E_TOUCH_HELD diff --git a/project.pros b/project.pros index d827947a..728bdc0f 100644 --- a/project.pros +++ b/project.pros @@ -5,7 +5,7 @@ "target": "v5", "templates": { "kernel": { - "location": "C:\\Users\\union\\AppData\\Roaming\\PROS\\templates\\kernel@3.8.0", + "location": "C:\\Users\\union\\AppData\\Roaming\\PROS\\templates\\kernel@3.8.3", "metadata": { "cold_addr": "58720256", "cold_output": "bin/cold.package.bin", @@ -18,152 +18,152 @@ "py/object": "pros.conductor.templates.local_template.LocalTemplate", "supported_kernels": null, "system_files": [ - "include/display/lv_core/lv_vdb.h", - "include/display/lv_core/lv_core.mk", - "include/display/lv_misc/lv_math.h", - "include/display/lv_objx/lv_tabview.h", - "include/display/lv_misc/lv_color.h", - "include/display/lv_hal/lv_hal_indev.h", - "include/display/lv_fonts/lv_fonts.mk", - "include/display/lv_misc/lv_symbol_def.h", - "include/display/lv_hal/lv_hal.mk", - "include/display/lv_themes/lv_theme_night.h", - "include/display/lv_draw/lv_draw_triangle.h", - "include/pros/optical.hpp", - "include/display/lv_draw/lv_draw_vbasic.h", - "include/display/lv_objx/lv_objx_templ.h", - "include/display/lv_core/lv_refr.h", - "include/pros/link.hpp", - "include/display/lv_objx/lv_btnm.h", - "include/display/lv_objx/lv_cb.h", - "firmware/v5-common.ld", - "include/pros/ext_adi.h", - "include/pros/rotation.h", - "include/display/lv_objx/lv_spinbox.h", - "include/display/lv_misc/lv_circ.h", - "include/display/lv_misc/lv_mem.h", - "include/display/lv_objx/lv_page.h", - "include/display/lv_objx/lv_ddlist.h", - "include/display/lv_core/lv_group.h", - "include/display/lvgl.h", - "include/display/lv_objx/lv_chart.h", - "include/pros/distance.h", - "include/display/lv_objx/lv_list.h", - "include/pros/vision.h", - "include/pros/misc.hpp", - "include/display/lv_draw/lv_draw.h", - "include/display/lv_objx/lv_label.h", - "include/display/lv_misc/lv_font.h", - "include/display/lv_draw/lv_draw_img.h", - "include/display/lv_misc/lv_log.h", - "include/display/lv_misc/lv_templ.h", - "include/pros/llemu.h", - "include/display/lv_objx/lv_btn.h", - "include/display/lv_fonts/lv_font_builtin.h", - "include/display/lv_objx/lv_calendar.h", - "firmware/libm.a", - "include/display/lv_conf.h", - "include/display/lv_objx/lv_sw.h", - "include/display/lv_draw/lv_draw_rect.h", - "include/display/lv_objx/lv_cont.h", - "include/pros/vision.hpp", - "include/display/lv_objx/lv_mbox.h", - "include/pros/adi.hpp", - "include/pros/imu.hpp", - "include/display/lv_objx/lv_table.h", - "include/pros/screen.hpp", - "include/display/lv_draw/lv_draw_label.h", - "include/display/lv_misc/lv_txt.h", - "include/pros/api_legacy.h", - "include/display/lv_objx/lv_lmeter.h", - "include/display/lv_themes/lv_theme_templ.h", - "include/pros/apix.h", - "include/display/lv_draw/lv_draw.mk", - "include/display/lv_themes/lv_theme_alien.h", - "include/pros/colors.hpp", - "include/display/lv_objx/lv_img.h", - "firmware/libc.a", - "include/display/lv_themes/lv_theme_zen.h", - "include/display/lv_themes/lv_theme_material.h", - "include/display/lv_draw/lv_draw_arc.h", - "include/display/lv_themes/lv_theme_mono.h", - "include/display/lv_themes/lv_themes.mk", - "include/display/lv_objx/lv_slider.h", - "include/pros/serial.h", - "include/display/lv_themes/lv_theme.h", - "include/display/README.md", - "include/display/lv_objx/lv_canvas.h", - "include/pros/misc.h", - "include/display/lv_misc/lv_fs.h", - "include/pros/rtos.h", - "include/display/lv_core/lv_indev.h", - "include/pros/motors.hpp", - "include/display/lv_core/lv_style.h", - "include/display/lv_version.h", - "include/display/lv_core/lv_lang.h", - "include/api.h", - "include/display/lv_objx/lv_gauge.h", - "include/pros/rtos.hpp", - "include/display/lv_hal/lv_hal_disp.h", - "include/pros/motors.h", - "include/display/lv_objx/lv_led.h", - "include/display/lv_draw/lv_draw_rbasic.h", - "include/display/lv_objx/lv_kb.h", - "include/display/lv_conf_checker.h", - "include/display/lv_hal/lv_hal.h", - "include/display/lv_draw/lv_draw_line.h", - "include/pros/gps.hpp", - "include/display/lv_objx/lv_objx.mk", - "include/display/lv_objx/lv_win.h", - "include/display/lv_core/lv_obj.h", - "include/display/lv_objx/lv_arc.h", - "include/pros/link.h", - "include/display/lv_objx/lv_preload.h", - "include/display/lv_misc/lv_area.h", - "include/display/lv_misc/lv_ll.h", - "include/pros/optical.h", - "include/pros/serial.hpp", - "include/pros/screen.h", - "include/display/lv_themes/lv_theme_nemo.h", - "include/pros/llemu.hpp", - "firmware/libpros.a", - "include/display/lv_misc/lv_gc.h", - "include/display/lv_misc/lv_anim.h", - "include/display/lv_objx/lv_line.h", - "include/pros/distance.hpp", - "include/pros/rotation.hpp", - "include/pros/error.h", - "include/display/lv_objx/lv_tileview.h", - "include/pros/gps.h", - "include/display/lv_misc/lv_task.h", - "include/pros/imu.h", - "firmware/v5-hot.ld", - "include/display/lv_misc/lv_misc.mk", - "include/pros/colors.h", + "include\\display\\lv_themes\\lv_theme_mono.h", + "include\\display\\lv_themes\\lv_theme_nemo.h", + "include\\display\\lv_objx\\lv_calendar.h", + "include\\display\\lv_themes\\lv_theme_zen.h", + "include\\display\\lv_objx\\lv_spinbox.h", + "include\\pros\\screen.hpp", + "include\\display\\lv_objx\\lv_ddlist.h", + "include\\display\\lv_themes\\lv_theme.h", + "include\\display\\lv_hal\\lv_hal.h", + "include\\display\\lv_draw\\lv_draw_arc.h", + "include\\display\\lv_objx\\lv_list.h", + "include\\display\\lv_themes\\lv_themes.mk", + "include\\pros\\motors.hpp", + "include\\pros\\adi.h", + "include\\display\\lv_draw\\lv_draw.h", + "include\\pros\\colors.hpp", + "include\\display\\licence.txt", + "include\\display\\lv_draw\\lv_draw_img.h", + "include\\display\\lv_fonts\\lv_fonts.mk", + "include\\display\\lv_draw\\lv_draw_rect.h", + "include\\display\\lv_core\\lv_group.h", + "include\\display\\lv_draw\\lv_draw_label.h", + "include\\pros\\llemu.h", + "include\\pros\\error.h", + "include\\display\\lv_misc\\lv_ufs.h", + "firmware\\libm.a", + "include\\display\\lv_objx\\lv_led.h", + "include\\display\\lv_objx\\lv_btn.h", + "include\\display\\lv_misc\\lv_misc.mk", + "include\\display\\lv_objx\\lv_canvas.h", + "include\\display\\lv_objx\\lv_preload.h", + "include\\pros\\misc.hpp", + "include\\display\\lv_misc\\lv_fs.h", + "include\\pros\\rotation.hpp", + "include\\pros\\colors.h", + "include\\pros\\vision.hpp", + "include\\display\\lv_objx\\lv_img.h", + "include\\display\\lv_fonts\\lv_font_builtin.h", + "include\\display\\lv_objx\\lv_lmeter.h", + "include\\display\\lv_misc\\lv_font.h", + "firmware\\v5.ld", + "include\\display\\lv_objx\\lv_tileview.h", + "include\\display\\lv_hal\\lv_hal_tick.h", + "include\\display\\lv_core\\lv_vdb.h", + "include\\display\\lv_core\\lv_indev.h", + "include\\pros\\vision.h", + "firmware\\v5-hot.ld", + "include\\display\\lv_objx\\lv_kb.h", + "include\\display\\lv_misc\\lv_symbol_def.h", + "firmware\\libc.a", + "include\\display\\lv_objx\\lv_label.h", + "include\\display\\lv_objx\\lv_tabview.h", + "firmware\\libpros.a", + "include\\display\\lv_misc\\lv_ll.h", + "include\\display\\lv_misc\\lv_log.h", + "include\\pros\\screen.h", + "include\\display\\lv_hal\\lv_hal.mk", + "include\\pros\\serial.hpp", + "include\\pros\\optical.hpp", + "include\\display\\lv_misc\\lv_txt.h", + "include\\display\\lv_misc\\lv_task.h", + "firmware\\v5-common.ld", + "include\\pros\\optical.h", + "include\\pros\\rtos.hpp", + "include\\display\\lv_conf_checker.h", + "include\\display\\lv_misc\\lv_math.h", + "include\\display\\lv_draw\\lv_draw_rbasic.h", + "include\\display\\lv_themes\\lv_theme_alien.h", + "include\\pros\\motors.h", + "include\\pros\\misc.h", + "include\\display\\lv_themes\\lv_theme_default.h", + "include\\pros\\gps.h", + "include\\display\\lv_misc\\lv_templ.h", + "include\\display\\lv_misc\\lv_circ.h", + "include\\api.h", + "include\\display\\lv_objx\\lv_ta.h", + "include\\display\\lv_draw\\lv_draw_triangle.h", + "include\\display\\lv_misc\\lv_mem.h", + "include\\display\\lv_objx\\lv_imgbtn.h", + "include\\pros\\link.h", + "include\\display\\lv_version.h", + "include\\display\\lv_conf.h", + "include\\display\\lv_objx\\lv_mbox.h", + "include\\display\\lv_misc\\lv_anim.h", + "include\\display\\lv_hal\\lv_hal_indev.h", + "include\\display\\lv_objx\\lv_btnm.h", + "include\\display\\lv_misc\\lv_color.h", + "include\\display\\lv_draw\\lv_draw_vbasic.h", + "include\\pros\\distance.hpp", + "include\\display\\lv_objx\\lv_bar.h", + "include\\display\\lv_objx\\lv_gauge.h", + "include\\display\\lv_draw\\lv_draw.mk", + "include\\display\\lvgl.h", + "include\\display\\lv_objx\\lv_slider.h", + "include\\display\\lv_objx\\lv_objx.mk", + "include\\display\\README.md", + "include\\display\\lv_core\\lv_lang.h", + "include\\display\\lv_objx\\lv_arc.h", + "include\\pros\\serial.h", + "include\\pros\\llemu.hpp", + "include\\pros\\adi.hpp", + "include\\display\\lv_objx\\lv_table.h", + "include\\display\\lv_draw\\lv_draw_line.h", + "include\\display\\lv_misc\\lv_area.h", + "include\\display\\lv_core\\lv_core.mk", + "include\\display\\lv_objx\\lv_line.h", + "include\\display\\lv_hal\\lv_hal_disp.h", + "include\\display\\lv_misc\\lv_gc.h", + "include\\pros\\rotation.h", + "include\\display\\lv_themes\\lv_theme_material.h", + "include\\display\\lv_core\\lv_style.h", + "include\\display\\lv_objx\\lv_cb.h", + "include\\display\\lv_objx\\lv_chart.h", "common.mk", - "include/display/lv_objx/lv_roller.h", - "include/display/lv_objx/lv_bar.h", - "include/display/lv_themes/lv_theme_default.h", - "firmware/v5.ld", - "include/display/lv_misc/lv_ufs.h", - "include/display/lv_hal/lv_hal_tick.h", - "include/display/licence.txt", - "include/display/lv_objx/lv_ta.h", - "include/display/lv_objx/lv_imgbtn.h", - "include/pros/adi.h" + "include\\pros\\ext_adi.h", + "include\\display\\lv_objx\\lv_objx_templ.h", + "include\\display\\lv_core\\lv_refr.h", + "include\\display\\lv_core\\lv_obj.h", + "include\\pros\\api_legacy.h", + "include\\pros\\rtos.h", + "include\\pros\\imu.h", + "include\\display\\lv_objx\\lv_win.h", + "include\\display\\lv_objx\\lv_cont.h", + "include\\display\\lv_themes\\lv_theme_templ.h", + "include\\pros\\link.hpp", + "include\\pros\\distance.h", + "include\\display\\lv_objx\\lv_roller.h", + "include\\display\\lv_objx\\lv_sw.h", + "include\\pros\\imu.hpp", + "include\\pros\\gps.hpp", + "include\\display\\lv_themes\\lv_theme_night.h", + "include\\pros\\apix.h", + "include\\display\\lv_objx\\lv_page.h" ], "target": "v5", "user_files": [ - "src/main.cc", - ".gitignore", + "include\\main.h", + "src\\main.c", + "include\\main.hpp", + "include\\main.hh", + "src\\main.cpp", + "src\\main.cc", "Makefile", - "src/main.cpp", - "src/main.c", - "include/main.hpp", - "include/main.hh", - "include/main.h" + ".gitignore" ], - "version": "3.8.0" + "version": "3.8.3" }, "okapilib": { "location": "C:\\Users\\union\\AppData\\Roaming\\PROS\\templates\\okapilib@4.8.0", diff --git a/src/EZ-Template/PID.cpp b/src/EZ-Template/PID.cpp index dcc9e440..977c85a6 100644 --- a/src/EZ-Template/PID.cpp +++ b/src/EZ-Template/PID.cpp @@ -99,7 +99,7 @@ void PID::exit_condition_print(ez::exit_output exit_type) { exit_output PID::exit_condition(bool print) { // If this function is called while all exit constants are 0, print an error - if (!(exit.small_error && exit.small_exit_time && exit.big_error && exit.big_exit_time && exit.velocity_exit_time && exit.mA_timeout)) { + if (exit.small_error == 0 && exit.small_exit_time == 0 && exit.big_error == 0 && exit.big_exit_time == 0 && exit.velocity_exit_time == 0 && exit.mA_timeout == 0) { exit_condition_print(ERROR_NO_CONSTANTS); return ERROR_NO_CONSTANTS; } diff --git a/src/EZ-Template/drive/exit_conditions.cpp b/src/EZ-Template/drive/exit_conditions.cpp index 6297b7ab..460f8229 100644 --- a/src/EZ-Template/drive/exit_conditions.cpp +++ b/src/EZ-Template/drive/exit_conditions.cpp @@ -118,10 +118,10 @@ void Drive::wait_until_drive(double target) { } // Calculate error between current and target (target needs to be an in between position) - int l_tar = l_start + target; - int r_tar = r_start + target; - int l_error = l_tar - drive_sensor_left(); - int r_error = r_tar - drive_sensor_right(); + double l_tar = l_start + target; + double r_tar = r_start + target; + double l_error = l_tar - drive_sensor_left(); + double r_error = r_tar - drive_sensor_right(); int l_sgn = util::sgn(l_error); int r_sgn = util::sgn(r_error); @@ -166,7 +166,7 @@ void Drive::wait_until_turn_swing(double target) { } // Calculate error between current and target (target needs to be an in between position) - int g_error = target - drive_imu_get(); + double g_error = target - drive_imu_get(); int g_sgn = util::sgn(g_error); exit_output turn_exit = RUNNING; diff --git a/src/EZ-Template/drive/pid_tasks.cpp b/src/EZ-Template/drive/pid_tasks.cpp index 17267a16..a9ecbdee 100644 --- a/src/EZ-Template/drive/pid_tasks.cpp +++ b/src/EZ-Template/drive/pid_tasks.cpp @@ -12,22 +12,24 @@ using namespace ez; void Drive::ez_auto_task() { while (true) { // Autonomous PID - if (drive_mode_get() == DRIVE) - drive_pid_task(); - else if (drive_mode_get() == TURN) - turn_pid_task(); - else if (drive_mode_get() == SWING) - swing_pid_task(); + switch (drive_mode_get()) { + case DRIVE: + drive_pid_task(); + break; + case TURN: + turn_pid_task(); + break; + case SWING: + swing_pid_task(); + break; + case DISABLE: + break; + default: + break; + } util::AUTON_RAN = drive_mode_get() != DISABLE ? true : false; - /* - if (pros::competition::is_autonomous() && !util::AUTON_RAN) - util::AUTON_RAN = true; - else if (!pros::competition::is_autonomous()) - drive_mode_set(DISABLE); - */ - pros::delay(util::DELAY_TIME); } } diff --git a/src/EZ-Template/drive/pid_tuner.cpp b/src/EZ-Template/drive/pid_tuner.cpp index 6da71160..77fa4f44 100644 --- a/src/EZ-Template/drive/pid_tuner.cpp +++ b/src/EZ-Template/drive/pid_tuner.cpp @@ -52,7 +52,6 @@ void Drive::pid_tuner_enable() { {"Turn PID Constants", &turnPID.constants}, {"Swing Forward PID Constants", &forward_swingPID.constants}, {"Swing Backward PID Constants", &backward_swingPID.constants}}; - column_max = constants.size() - 1; pid_tuner_brain_init(); @@ -88,16 +87,16 @@ void Drive::pid_tuner_toggle() { void Drive::pid_tuner_print() { if (!pid_tuner_on) return; - name = constants[column].name + "\n"; - kp = "kp: " + std::to_string(constants[column].consts->kp); - ki = "ki: " + std::to_string(constants[column].consts->ki); - kd = "kd: " + std::to_string(constants[column].consts->kd); - starti = "start i: " + std::to_string(constants[column].consts->start_i); + std::string name = constants[column].name + "\n"; + std::string kp = "kp: " + std::to_string(constants[column].consts->kp); + std::string ki = "ki: " + std::to_string(constants[column].consts->ki); + std::string kd = "kd: " + std::to_string(constants[column].consts->kd); + std::string starti = "start i: " + std::to_string(constants[column].consts->start_i); - kp = row == 0 ? kp + arrow : kp + newline; - ki = row == 1 ? ki + arrow : ki + newline; - kd = row == 2 ? kd + arrow : kd + newline; - starti = row == 3 ? starti + arrow : starti + newline; + kp = row == 0 ? kp + arrow : kp + "\n"; + ki = row == 1 ? ki + arrow : ki + "\n"; + kd = row == 2 ? kd + arrow : kd + "\n"; + starti = row == 3 ? starti + arrow : starti + "\n"; complete_pid_tuner_output = name + "\n" + kp + ki + kd + starti + "\n"; @@ -116,7 +115,7 @@ void Drive::pid_tuner_print_terminal() { } // Modify constants -void Drive::pid_tuner_value_modify(double p, double i, double d, double start) { +void Drive::pid_tuner_value_modify(float p, float i, float d, float start) { if (!pid_tuner_on) return; switch (row) { @@ -163,26 +162,26 @@ void Drive::pid_tuner_iterate() { // Up / Down for Rows if (master.get_digital_new_press(pros::E_CONTROLLER_DIGITAL_RIGHT)) { column++; - if (column > column_max) + if (column > constants.size() - 1) column = 0; pid_tuner_print(); } else if (master.get_digital_new_press(pros::E_CONTROLLER_DIGITAL_LEFT)) { column--; if (column < 0) - column = column_max; + column = constants.size() - 1; pid_tuner_print(); } // Left / Right for Columns if (master.get_digital_new_press(pros::E_CONTROLLER_DIGITAL_DOWN)) { row++; - if (row > row_max) + if (row > 3) row = 0; pid_tuner_print(); } else if (master.get_digital_new_press(pros::E_CONTROLLER_DIGITAL_UP)) { row--; if (row < 0) - row = row_max; + row = 3; pid_tuner_print(); } diff --git a/src/EZ-Template/drive/set_pid.cpp b/src/EZ-Template/drive/set_pid.cpp index 7195d1f9..524df281 100644 --- a/src/EZ-Template/drive/set_pid.cpp +++ b/src/EZ-Template/drive/set_pid.cpp @@ -194,8 +194,6 @@ void Drive::pid_turn_set(double target, int speed, bool slew_on) { // Initialize slew slew_turn.initialize(slew_on, max_speed, target, drive_imu_get()); - printf("%.2f %.2f\n\n", slew_turn.constants.distance_to_travel, slew_turn.constants.min_speed); - // Run task drive_mode_set(TURN); } diff --git a/src/EZ-Template/slew.cpp b/src/EZ-Template/slew.cpp index 079e3052..f75debed 100644 --- a/src/EZ-Template/slew.cpp +++ b/src/EZ-Template/slew.cpp @@ -26,7 +26,7 @@ slew::Constants slew::constants_get() { return constants; } // Get constants // Initialize for the movement void slew::initialize(bool enabled, double maximum_speed, double target, double current) { - is_enabled = enabled; + is_enabled = maximum_speed < constants.min_speed ? false : enabled; max_speed = maximum_speed; sign = util::sgn(target - current); diff --git a/src/main.cpp b/src/main.cpp index 5d60753c..4f5d144c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -10,25 +10,25 @@ ez::Drive chassis ( // Left Chassis Ports (negative port will reverse it!) // the first port is used as the sensor - {-10, -19, 20, 9} + {-7, -6, -8, 20} // Right Chassis Ports (negative port will reverse it!) // the first port is used as the sensor - ,{3, -4, -11, 12} + ,{-12, 2, 5, 11} // IMU Port - ,6 + ,15 // Wheel Diameter (Remember, 4" wheels without screw holes are actually 4.125!) - ,3.25 + ,4.0 // Cartridge RPM - ,600 + ,400 // External Gear Ratio (MUST BE DECIMAL) This is WHEEL GEAR / MOTOR GEAR // eg. if your drive is 84:36 where the 36t is powered, your RATIO would be 84/36 which is 2.333 // eg. if your drive is 36:60 where the 60t is powered, your RATIO would be 36/60 which is 0.6 - ,1.18343195266 + ,1.0 ); @@ -47,7 +47,7 @@ void initialize() { // Configure your chassis controls chassis.opcontrol_curve_buttons_toggle(true); // Enables modifying the controller curve with buttons on the joysticks - chassis.opcontrol_drive_activebrake_set(0); // Sets the active brake kP. We recommend 0.1. + chassis.opcontrol_drive_activebrake_set(0); // Sets the active brake kP. We recommend 2. chassis.opcontrol_curve_default_set(0, 0); // Defaults for curve. If using tank, only the first parameter is used. (Comment this line out if you have an SD card!) default_constants(); // Set the drive to your own constants from autons.cpp! @@ -145,6 +145,9 @@ void opcontrol() { // After you find values that you're happy with, you'll have to set them in auton.cpp if (!pros::competition::is_connected()) { // Enable / Disable PID Tuner + // When enabled: + // * use A and Y to increment / decrement the constants + // * use the arrow keys to navigate the constants if (master.get_digital_new_press(DIGITAL_X)) chassis.pid_tuner_toggle(); diff --git a/version b/version index 56fea8a0..13d683cc 100644 --- a/version +++ b/version @@ -1 +1 @@ -3.0.0 \ No newline at end of file +3.0.1 \ No newline at end of file