Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Motion Chaining and Quicker Exiting #109

Closed
ssejrog opened this issue Jun 2, 2024 · 0 comments
Closed

Motion Chaining and Quicker Exiting #109

ssejrog opened this issue Jun 2, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@ssejrog
Copy link
Member

ssejrog commented Jun 2, 2024

Is your feature request related to a problem? Please describe.

EZ's exit conditions are inherently slow. There are multiple timers that have to tick a certain amount for it to allow the code to continue. Users can solve this by:

  1. making the timer values extremely low
    This isn't ideal because it makes it clunky to switch between exiting quickly and exiting slower for more consistency. You'd need to switch between two sets of constants whenever you exit.
  2. using pid_wait_until() everywhere
    This can work. At worlds, some teams were using the code below which tells the PID to go a little farther than you input, but use a pid_wait_until() exit when you're where you wanted to be. Not every user will figure out how to implement this.
double last_set_angle = 0.0;
double added_angle = 3.0;
double added_distance = 3.0;
void swing(ez::e_swing swing_type, double angle, int speed, int curve = 0, bool slew = false) {
  last_set_angle = angle;
  double temp_added_angle = ez::util::sgn(angle - chassis.drive_imu_get()) * added_angle;
  chassis.pid_swing_set(swing_type, angle + temp_added_angle, speed, curve, slew);
  chassis.pid_wait_until(angle);
}

void turn(double angle, int speed, bool slew = false) {
  last_set_angle = angle;
  double temp_added_angle = ez::util::sgn(angle - chassis.drive_imu_get()) * added_angle;
  chassis.pid_turn_set(angle + temp_added_angle, speed, slew);
  chassis.pid_wait_until(angle);
}

void drive(double distance, int speed, bool slew = false) {
  if (chassis.turnPID.target != last_set_angle) {
    chassis.pid_drive_toggle(false);
    chassis.pid_turn_set(last_set_angle, 0, false);
  }
  chassis.pid_drive_set(distance + added_distance, speed, slew);
  chassis.pid_drive_toggle(true);
  chassis.pid_wait_until(distance);
}

Describe the solution you'd like

Two new functions, pid_wait_quick() and pid_wait_chain().

pid_wait_quick() will be a wrapper for pid_wait_until(target), where target is the target from the previously run pid_x_set(...)
pid_wait_chain() will have the robot try to go farther than you input, but will exit with pid_wait_quick()

This allows users to use pid_wait() and pid_wait_until() like they have been, and use the exit that best fits what they're doing.

@ssejrog ssejrog added the enhancement New feature or request label Jun 2, 2024
@ssejrog ssejrog self-assigned this Jun 2, 2024
ssejrog added a commit that referenced this issue Jun 2, 2024
* Motion chaining and quick exits are functional #109

* Added reverse constants, okapi units, finalized function names and comments
ssejrog added a commit that referenced this issue Jun 10, 2024
* New action for deploying website

* ⬆️ PROS 4 Porting work (#100)

* New action for deploying website (#98)

* PROS 4 Porting work

* Revert gitignore

* Added imu loading animation

---------

Co-authored-by: Jess Zarchi <[email protected]>

* 🐛Fixed unit conversion for exit conditions

* 🐛Fixed derivative kick #99 (#105)

* ✨Added imu scaling #104 (#106)

* ✨Imu velocity exiting #102 

* PID class has secondary sensor velocity support, implemented that with imu accel into exit conditions

* Made names more clear, added missing functions

* 🐛Max text width is wider #112 (#113)

* 🐛Exit condition print error #111 (#114)

* ✨Motion chaining #109 (#115)

* Motion chaining and quick exits are functional #109

* Added reverse constants, okapi units, finalized function names and comments

* 🐛Fixed scaling in drive pid #110 (#116)

* Upgraded example project, cleaned formatting everywhere

Main project builds fine, the example project is giving me strange errors about the LCD.  Not sure how to fix this

* Timers now correctly reset between motions #117

* Added liblvgl to example project, updated template

* Changing max speed works, new (old) default constants, new constructor #118 #119 #120

* Fixed typo in example project

* Cleaned up example project

* Main project updated to example, fixed #122 and #123

* Final 3.1.0 push.  Template and example project finalized

---------

Co-authored-by: Will Xu <[email protected]>
@ssejrog ssejrog closed this as completed Jun 10, 2024
ssejrog added a commit that referenced this issue Jun 10, 2024
* New action for deploying website (#98)

* ⬆️3.1.0 (#124)

* New action for deploying website

* ⬆️ PROS 4 Porting work (#100)

* New action for deploying website (#98)

* PROS 4 Porting work

* Revert gitignore

* Added imu loading animation

---------

Co-authored-by: Jess Zarchi <[email protected]>

* 🐛Fixed unit conversion for exit conditions

* 🐛Fixed derivative kick #99 (#105)

* ✨Added imu scaling #104 (#106)

* ✨Imu velocity exiting #102 

* PID class has secondary sensor velocity support, implemented that with imu accel into exit conditions

* Made names more clear, added missing functions

* 🐛Max text width is wider #112 (#113)

* 🐛Exit condition print error #111 (#114)

* ✨Motion chaining #109 (#115)

* Motion chaining and quick exits are functional #109

* Added reverse constants, okapi units, finalized function names and comments

* 🐛Fixed scaling in drive pid #110 (#116)

* Upgraded example project, cleaned formatting everywhere

Main project builds fine, the example project is giving me strange errors about the LCD.  Not sure how to fix this

* Timers now correctly reset between motions #117

* Added liblvgl to example project, updated template

* Changing max speed works, new (old) default constants, new constructor #118 #119 #120

* Fixed typo in example project

* Cleaned up example project

* Main project updated to example, fixed #122 and #123

* Final 3.1.0 push.  Template and example project finalized

---------

Co-authored-by: Will Xu <[email protected]>

* Hotfix broken link

---------

Co-authored-by: Will Xu <[email protected]>
ssejrog added a commit that referenced this issue Jun 10, 2024
* Upgraded example project, cleaned formatting everywhere

Main project builds fine, the example project is giving me strange errors about the LCD.  Not sure how to fix this

* Timers now correctly reset between motions #117

* Added liblvgl to example project, updated template

* Changing max speed works, new (old) default constants, new constructor #118 #119 #120

* Fixed typo in example project

* Cleaned up example project

* Main project updated to example, fixed #122 and #123

* Final 3.1.0 push.  Template and example project finalized

* Bring final 3.1.0 over to dev (#125)

* New action for deploying website (#98)

* ⬆️3.1.0 (#124)

* New action for deploying website

* ⬆️ PROS 4 Porting work (#100)

* New action for deploying website (#98)

* PROS 4 Porting work

* Revert gitignore

* Added imu loading animation

---------

Co-authored-by: Jess Zarchi <[email protected]>

* 🐛Fixed unit conversion for exit conditions

* 🐛Fixed derivative kick #99 (#105)

* ✨Added imu scaling #104 (#106)

* ✨Imu velocity exiting #102 

* PID class has secondary sensor velocity support, implemented that with imu accel into exit conditions

* Made names more clear, added missing functions

* 🐛Max text width is wider #112 (#113)

* 🐛Exit condition print error #111 (#114)

* ✨Motion chaining #109 (#115)

* Motion chaining and quick exits are functional #109

* Added reverse constants, okapi units, finalized function names and comments

* 🐛Fixed scaling in drive pid #110 (#116)

* Upgraded example project, cleaned formatting everywhere

Main project builds fine, the example project is giving me strange errors about the LCD.  Not sure how to fix this

* Timers now correctly reset between motions #117

* Added liblvgl to example project, updated template

* Changing max speed works, new (old) default constants, new constructor #118 #119 #120

* Fixed typo in example project

* Cleaned up example project

* Main project updated to example, fixed #122 and #123

* Final 3.1.0 push.  Template and example project finalized

---------

Co-authored-by: Will Xu <[email protected]>

* Hotfix broken link

---------

Co-authored-by: Will Xu <[email protected]>

---------

Co-authored-by: Will Xu <[email protected]>
ssejrog added a commit that referenced this issue Jun 10, 2024
* New action for deploying website (#98)

* Upgraded example project, cleaned formatting everywhere

Main project builds fine, the example project is giving me strange errors about the LCD.  Not sure how to fix this

* Timers now correctly reset between motions #117

* Added liblvgl to example project, updated template

* Changing max speed works, new (old) default constants, new constructor #118 #119 #120

* Fixed typo in example project

* Cleaned up example project

* Main project updated to example, fixed #122 and #123

* Final 3.1.0 push.  Template and example project finalized

* ⬆️3.1.0 (#124)

* New action for deploying website

* ⬆️ PROS 4 Porting work (#100)

* New action for deploying website (#98)

* PROS 4 Porting work

* Revert gitignore

* Added imu loading animation

---------

Co-authored-by: Jess Zarchi <[email protected]>

* 🐛Fixed unit conversion for exit conditions

* 🐛Fixed derivative kick #99 (#105)

* ✨Added imu scaling #104 (#106)

* ✨Imu velocity exiting #102 

* PID class has secondary sensor velocity support, implemented that with imu accel into exit conditions

* Made names more clear, added missing functions

* 🐛Max text width is wider #112 (#113)

* 🐛Exit condition print error #111 (#114)

* ✨Motion chaining #109 (#115)

* Motion chaining and quick exits are functional #109

* Added reverse constants, okapi units, finalized function names and comments

* 🐛Fixed scaling in drive pid #110 (#116)

* Upgraded example project, cleaned formatting everywhere

Main project builds fine, the example project is giving me strange errors about the LCD.  Not sure how to fix this

* Timers now correctly reset between motions #117

* Added liblvgl to example project, updated template

* Changing max speed works, new (old) default constants, new constructor #118 #119 #120

* Fixed typo in example project

* Cleaned up example project

* Main project updated to example, fixed #122 and #123

* Final 3.1.0 push.  Template and example project finalized

---------

Co-authored-by: Will Xu <[email protected]>

* Hotfix broken link

---------

Co-authored-by: Will Xu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant