Skip to content

Commit

Permalink
⬆️v3.2.0
Browse files Browse the repository at this point in the history
Merge pull request #229 from EZ-Robotics/dev
  • Loading branch information
ssejrog authored Dec 17, 2024
2 parents ab91aa7 + 1277dcc commit bf917d3
Show file tree
Hide file tree
Showing 67 changed files with 9,584 additions and 1,801 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ EZ-Template-Example-Project/temp.log
EZ-Template-Example-Project/temp.errors
EZ-Template-Example-Project/*.ini
EZ-Template-Example-Project/.d/
.d/
.d/
Binary file not shown.
Binary file removed EZ-Template-Example-Project/[email protected]
Binary file not shown.
Binary file added EZ-Template-Example-Project/[email protected]
Binary file not shown.
Binary file modified EZ-Template-Example-Project/firmware/EZ-Template.a
Binary file not shown.
Binary file modified EZ-Template-Example-Project/firmware/libpros.a
Binary file not shown.
78 changes: 49 additions & 29 deletions EZ-Template-Example-Project/include/EZ-Template/PID.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,42 +73,43 @@ class PID {
* Set's constants for exit conditions.
*
* \param p_small_exit_time
* Sets small_exit_time. Timer for to exit within smalL_error.
* sets small_exit_time, timer for to exit within smalL_error
* \param p_small_error
* Sets smalL_error. Timer will start when error is within this.
* sets smalL_error, timer will start when error is within this
* \param p_big_exit_time
* Sets big_exit_time. Timer for to exit within big_error.
* sets big_exit_time, timer for to exit within big_error
* \param p_big_error
* Sets big_error. Timer will start when error is within this.
* sets big_error, timer will start when error is within this
* \param p_velocity_exit_time
* Sets velocity_exit_time. Timer will start when velocity is 0.
* sets velocity_exit_time, timer will start when velocity is 0
*/
void exit_condition_set(int p_small_exit_time, double p_small_error, int p_big_exit_time = 0, double p_big_error = 0, int p_velocity_exit_time = 0, int p_mA_timeout = 0);

/**
* Sets target.
* Sets PID target.
*
* \param target
* Target for PID.
* new target for PID
*/
void target_set(double input);

/**
* Computes PID.
*
* \param current
* Current sensor value.
* current sensor value
*/
double compute(double current);

/**
* Computes PID, but you set the error yourself. This function ignores target.
* Current is only used here for calculative derivative.
* Computes PID, but you compute the error yourself.
*
* Current is only used here for calculative derivative to solve derivative kick.
*
* \param err
* Error in PID, you need to calculate this yourself.
* error for the PID, you need to calculate this yourself
* \param current
* Current sensor value.
* current sensor value
*/
double compute_error(double err, double current);

Expand All @@ -122,26 +123,31 @@ class PID {
*/
Constants constants_get();

/**
* Returns true if PID constants are set, returns false if they're all 0.
*/
bool constants_set_check();

/**
* Resets all variables to 0. This does not reset constants.
*/
void variables_reset();

/**
* Constants
* Constants.
*/
Constants constants;

/**
* Exit
* Exit.
*/
exit_condition_ exit;

/**
* Updates a secondary sensor for velocity exiting. Ideal use is IMU during normal drive motions.
*
* \param secondary_sensor
* double for a secondary sensor.
* secondary sensor value
*/
void velocity_sensor_secondary_set(double secondary_sensor);

Expand All @@ -154,7 +160,7 @@ class PID {
* Boolean for if the secondary sensor will be updated or not. True uses this sensor, false does not.
*
* \param toggle
* True uses this sensor, false does not.
* true uses this sensor, false does not
*/
void velocity_sensor_secondary_toggle_set(bool toggle);

Expand All @@ -164,64 +170,74 @@ class PID {
bool velocity_sensor_secondary_toggle_get();

/**
* Sets the threshold that the main sensor will return 0 velocity within
* Sets the threshold that the main sensor will return 0 velocity within.
*
* \param zero
* a small double
*/
void velocity_sensor_main_exit_set(double zero);

/**
* Returns the threshold that the main sensor will return 0 velocity within
* Returns the threshold that the main sensor will return 0 velocity within.
*/
double velocity_sensor_main_exit_get();

/**
* Sets the threshold that the secondary sensor will return 0 velocity within
* Sets the threshold that the secondary sensor will return 0 velocity within.
*
* \param zero
* a small double
*/
void velocity_sensor_secondary_exit_set(double zero);

/**
* Returns the threshold that the secondary sensor will return 0 velocity within
* Returns the threshold that the secondary sensor will return 0 velocity within.
*/
double velocity_sensor_secondary_exit_get();

/**
* Iterative exit condition for PID.
*
* \param print = false
* if true, prints when complete.
* if true, prints when complete
*/
ez::exit_output exit_condition(bool print = false);

/**
* Iterative exit condition for PID.
*
* \param sensor
* A pros motor on your mechanism.
* a pros motor on your mechanism
* \param print = false
* if true, prints when complete.
* if true, prints when complete
*/
ez::exit_output exit_condition(pros::Motor sensor, bool print = false);

/**
* Iterative exit condition for PID.
*
* \param sensor
* Pros motors on your mechanism.
* pros motors on your mechanism
* \param print = false
* if true, prints when complete.
* if true, prints when complete
*/
ez::exit_output exit_condition(std::vector<pros::Motor> sensor, bool print = false);

/**
* Iterative exit condition for PID.
*
* \param sensor
* pros motor group on your mechanism
* \param print = false
* if true, prints when complete
*/
ez::exit_output exit_condition(pros::MotorGroup sensor, bool print = false);

/**
* Sets the name of the PID that prints during exit conditions.
*
* \param name
* a string that is the name you want to print
* the name of the mechanism for printing
*/
void name_set(std::string name);

Expand All @@ -231,15 +247,19 @@ class PID {
std::string name_get();

/**
* Enables / disables i resetting when sgn of error changes. True resets, false doesn't.
* Enables / disables i resetting when sgn of error changes.
*
* True resets, false doesn't.
*
* \param toggle
* true resets, false doesn't
*/
void i_reset_toggle(bool toggle);

/**
* Returns if i will reset when sgn of error changes. True resets, false doesn't.
* Returns if i will reset when sgn of error changes.
*
* True resets, false doesn't.
*/
bool i_reset_get();

Expand All @@ -264,7 +284,7 @@ class PID {

private:
double velocity_zero_main = 0.05;
double velocity_zero_secondary = 0.1;
double velocity_zero_secondary = 0.075;
int i = 0, j = 0, k = 0, l = 0, m = 0;
bool is_mA = false;
double second_sensor = 0.0;
Expand Down
1 change: 1 addition & 0 deletions EZ-Template-Example-Project/include/EZ-Template/api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include "EZ-Template/piston.hpp"
#include "EZ-Template/sdcard.hpp"
#include "EZ-Template/slew.hpp"
#include "EZ-Template/tracking_wheel.hpp"
#include "EZ-Template/util.hpp"
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class AutonSelector {
std::vector<Auton> Autons;
int auton_page_current;
int auton_count;
int last_auton_page_current;
AutonSelector();
AutonSelector(std::vector<Auton> autons);
void selected_auton_call();
Expand Down
Loading

0 comments on commit bf917d3

Please sign in to comment.