-
Notifications
You must be signed in to change notification settings - Fork 127
Implement new prim exec logic using motion controllers #3760
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
Merged
Merged
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
5a3fb6d
Remove unused member functions and variables
nycrat 868cf6b
Fix call to setStopPrimitive
nycrat 67b3833
Pass in delta_time dynamically for prim exec
nycrat dd126db
Fix calls to prim exec constructor and stepPrimitive
nycrat c5342f3
Add setters to RobotState class
nycrat d449a95
Replace state variables with one RobotState
nycrat 3e929ba
Create default constructor for robot state
nycrat 03da9c8
Replace use of std::pair with RobotState
nycrat b5b513b
Prim exec update velocity to update state (same logic as only update …
nycrat 5403bbf
Use auto
nycrat 83f5113
Separate time since trajectory creation variables
nycrat 7126c14
Port trajectory path changes from robot localizer branch
nycrat 1d6c8e7
Update robot constants
nycrat b00e31f
Add cmath dependency
nycrat c855e54
Implement getting velocities from motion controllers
nycrat 48eaee3
Fix for inverted yellow team world
nycrat b280095
Remove TODO comment
nycrat cbbc7e0
Merge branch 'master' into avah/prim_exec_motion_controller
nycrat b870c79
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] b08dce1
Tune pid constants
nycrat 6b400ef
Tune more
nycrat bd2ad3a
Merge branch 'master' into avah/prim_exec_motion_controller
nycrat 5925517
Merge branch 'master' of github.com:UBC-Thunderbots/Software into ava…
Andrewyx aa8d9eb
Merge branch 'avah/prim_exec_motion_controller' of github.com:UBC-Thu…
Andrewyx 9155ed6
Fix simulator prmitive executor update order
nycrat b7ddf2a
Reduce linear trajectory target max speed
nycrat def1626
Disable pure pid and tune constants
nycrat 1ad0911
Enable pure pid based on time as well
nycrat c35ab85
Merge branch 'master' into avah/prim_exec_motion_controller
nycrat 1fe5a67
DEBUGGING DONT MERGE
nycrat bc2f713
Revert create trajectory from params changes
nycrat 35f0160
WIP
nycrat 3315560
Revert "DEBUGGING DONT MERGE"
nycrat 241ded8
Get rid of debug stuff
nycrat 5e61060
Tag TODO for robot localizer
nycrat 8808c2b
Reset some stuff
nycrat a37fede
WIP
nycrat 9db8d81
Log motion to plot juggler
Thunderbots 72fa828
Use only feedforward for motion controllers
Thunderbots d65dcda
Formatting
Thunderbots fa2c6b6
Clamp max speed from motion controllers
Thunderbots 81c039b
Formatting
Thunderbots c90a6c8
Implement old velocity dampening
nycrat 45d310d
Increase threshold for test
nycrat e7bb4a3
Rename move tactic test
nycrat 451f856
Comment out linear motion debugging
nycrat 9393179
Revert unused trajectory invalidation code
nycrat 030f74d
Formatting
Thunderbots 6048157
Merge branch 'master' into avah/prim_exec_motion_controller
nycrat c1fc861
Fix dependency issue
nycrat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| #pragma once | ||
|
|
||
| #include "software/time/duration.h" | ||
|
|
||
| /** | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 16 additions & 18 deletions
34
src/software/embedded/motion_control/position_controller.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,32 @@ | ||
| #include "software/embedded/motion_control/position_controller.h" | ||
|
|
||
| #include "software/geom/algorithms/distance.h" | ||
|
|
||
| Vector PositionController::step(const Point& position, | ||
| const TrajectoryPath& target_trajectory, | ||
| Duration elapsed_time, Duration delta_time) | ||
| { | ||
| const Vector distance_from_destination = | ||
| target_trajectory.getDestination() - position; | ||
| // feedforward trajectory velocity with small pid control effort | ||
| const Vector error = | ||
| target_trajectory.getPosition(elapsed_time.toSeconds()) - position; | ||
| const Vector control_effort{x_pid_.step(error.x(), delta_time.toSeconds()), | ||
| y_pid_.step(error.y(), delta_time.toSeconds())}; | ||
| double distance_to_destination = | ||
| distance(position, target_trajectory.getDestination()); | ||
|
|
||
| if (distance_from_destination.length() < LINEAR_PURE_PID_THRESHOLD_METERS) | ||
| { | ||
| // if target destination is close enough, use pure PID for velocity | ||
| return Vector{ | ||
| x_pid_close_.step(distance_from_destination.x(), delta_time.toSeconds()), | ||
| y_pid_close_.step(distance_from_destination.y(), delta_time.toSeconds())}; | ||
| } | ||
| else | ||
| Vector local_velocity = | ||
| target_trajectory.getVelocity(elapsed_time.toSeconds()) + control_effort; | ||
|
|
||
| // Dampen velocity as we get closer to the destination to reduce jittering | ||
| if (distance_to_destination < MAX_DAMPENING_VELOCITY_DISTANCE_M) | ||
| { | ||
| // feedforward trajectory velocity with small pid control effort | ||
| const Vector error = | ||
| target_trajectory.getPosition(elapsed_time.toSeconds()) - position; | ||
| const Vector control_effort{x_pid_.step(error.x(), delta_time.toSeconds()), | ||
| y_pid_.step(error.y(), delta_time.toSeconds())}; | ||
| return target_trajectory.getVelocity(elapsed_time.toSeconds()) + control_effort; | ||
| local_velocity *= distance_to_destination / MAX_DAMPENING_VELOCITY_DISTANCE_M; | ||
| } | ||
| return local_velocity; | ||
| } | ||
|
|
||
| void PositionController::reset() | ||
| { | ||
| x_pid_.reset(); | ||
| y_pid_.reset(); | ||
| x_pid_close_.reset(); | ||
| y_pid_close_.reset(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.