-
Notifications
You must be signed in to change notification settings - Fork 57
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
Armdevel: Create PID Library #231
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should write a test for threadsafety.
also what are the accumulated errors and average error compared to the matlab?
Co-authored-by: Melvin Wang <[email protected]>
…er2020-firmware into younes/pidforarmdevel
Co-authored-by: Melvin Wang <[email protected]>
I'll rerun the app sometime this weekend and let you know |
maybe have the expected value saved in the test and have an assert that checks against it. almost like a unit test haha. |
…er2020-firmware into younes/pidforarmdevel
I didnt add a test for threadability. the work needed to create any sort of meaningful test is too much to be worth it. i think we're safe skipping threadability test since it we lock a mutex with lock guard at the top of every function basically |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
couple comments from the old review weren't addressed and got auto dismissed because of changes
lib/pid/src/PID.cpp
Outdated
|
||
realOutput_ = 0.0; | ||
void PID::Pid::updateProportionalGain(uint32_t p) { | ||
std::lock_guard<Mutex> lock(m_mutex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump
lib/pid/src/PID.cpp
Outdated
float paths = computePPath(error); | ||
paths += computeIPath(error, dt); | ||
paths += m_antiKickback ? computeDPathOnPV(error, dt) : computeDPathOnError(processVariable, dt); | ||
paths = std::clamp(paths, static_cast<float>(m_lowerBound), static_cast<float>(m_upperBound)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump
lib/pid/src/PID.cpp
Outdated
void PID::setDeadZoneError(float error) { | ||
deadZoneError_ = error; | ||
void PID::PID::reset() { | ||
std::lock_guard<Mutex> lock(m_mutex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump on the scoped lock comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wdym bump?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look at my previous comment about lockguard vs scoped lock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont see any comment abt scoped lock (edit: nvm i found it)
Do we need feed-forward support or ability to accept tuning params on the fly? Or will those be future issues |
this is just a pid lib feed fwd is part of the control loop which is at a higher level. this includes on the fly tuning. see comment at the top of the header |
something i just thought about re: feedforward is that by adding the feedforward outside of PID, we may run into issues with:
|
This PR is currently on hold. The average error is very large atm, there must be a bug in the code |
This PR is no longer on hold |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. pls update the other branch and tag it or smth
* Move Encoder class and create new sensor class * Move files to better folders * Modify Moisture sensor to use new Sensor Base * Edit cmake file for sensor folder * Update Moisture Sensor files and test app * Modify make files to build moved files * Changes to 'READ()' after PR * modify sensor read functions * Add actuator base class and derived classes (#171) * Add actuator base class and derived classes * Actuators lib: tweak actuator classes, delete old actuator libraries * Actuators lib: add copy constructor * Actuators lib: apply feedback comments * Actuators lib: apply feedback comments again * Actuators lib: Wrap classes in namespaces * Actuators lib: fix compile errors * Actuators lib: fix comments, rename variables, and other small tweaks * Actuators lib: fix comments and variable names again * Actuators lib: add std::abs guards * Armdevel: Create PID Library (#231) * created pid lib and fixed easily fixable errors * Update apps/test-pid/CMakeLists.txt Co-authored-by: Melvin Wang <[email protected]> * implemented melvin comments * Update apps/test-pid/CMakeLists.txt Co-authored-by: Melvin Wang <[email protected]> * implemented melvin comments * formatting * added mention of matlab code * use scoped lock. use better anti windup. * use new values * avg error is now 37 * fix formatting * debug commit (not final commit) * ready for review Co-authored-by: yreda1999 <[email protected]> Co-authored-by: Melvin Wang <[email protected]> * Younes: simplified interface, added namespaces, add config structs * Further updates after PR * Fixed and updated Moisture sensor and app * update relative encoder files * Update absolute encoder files * fix error with pwm in * initial commit * arm main compiles! * gimbtonomy also compiles * ready for reviews * fix silly mistake * change protected fields of final classes to private * forgot one file * added comments with instructions for felix and orson * implemented feedback and fixed failing test apps * changed pointers to refs where appropriate * fixed melvin anc cindy comments * remove current sensors from arm config headers since we wont have em ready for SAR * fix formatting * fix formatting angain * fixed test can app * Fw/younes actuator (#280) * Update science pins * Update pin names, update science apps * Updated for clang format * Revert "Updated for clang format" This reverts commit f3831a1. * Proper clang formatting * PR comments * Updating PR for changes on base * update servo range of motion * Missed a file for clang * Fixed code which was mistakenly changed Co-authored-by: Felix Wong <[email protected]> * fix formatting * fixed check not running * fixed comments * updated version of bridge Co-authored-by: Felix Wong <[email protected]> Co-authored-by: Cindy Li <[email protected]> Co-authored-by: yreda1999 <[email protected]> Co-authored-by: Melvin Wang <[email protected]> Co-authored-by: younes <[email protected]> Co-authored-by: FK3wong <[email protected]> Co-authored-by: Felix Wong <[email protected]>
* Move Encoder class and create new sensor class * Move files to better folders * Modify Moisture sensor to use new Sensor Base * Edit cmake file for sensor folder * Update Moisture Sensor files and test app * Modify make files to build moved files * Changes to 'READ()' after PR * modify sensor read functions * Add actuator base class and derived classes (#171) * Add actuator base class and derived classes * Actuators lib: tweak actuator classes, delete old actuator libraries * Actuators lib: add copy constructor * Actuators lib: apply feedback comments * Actuators lib: apply feedback comments again * Actuators lib: Wrap classes in namespaces * Actuators lib: fix compile errors * Actuators lib: fix comments, rename variables, and other small tweaks * Actuators lib: fix comments and variable names again * Actuators lib: add std::abs guards * Armdevel: Create PID Library (#231) * created pid lib and fixed easily fixable errors * Update apps/test-pid/CMakeLists.txt Co-authored-by: Melvin Wang <[email protected]> * implemented melvin comments * Update apps/test-pid/CMakeLists.txt Co-authored-by: Melvin Wang <[email protected]> * implemented melvin comments * formatting * added mention of matlab code * use scoped lock. use better anti windup. * use new values * avg error is now 37 * fix formatting * debug commit (not final commit) * ready for review Co-authored-by: yreda1999 <[email protected]> Co-authored-by: Melvin Wang <[email protected]> * Younes: simplified interface, added namespaces, add config structs * Further updates after PR * Fixed and updated Moisture sensor and app * update relative encoder files * Update absolute encoder files * fix error with pwm in * initial commit * arm main compiles! * gimbtonomy also compiles * ready for reviews * fix silly mistake * change protected fields of final classes to private * forgot one file * added comments with instructions for felix and orson * implemented feedback and fixed failing test apps * changed pointers to refs where appropriate * fixed melvin anc cindy comments * remove current sensors from arm config headers since we wont have em ready for SAR * fix formatting * fix formatting angain * fixed test can app * Fw/younes actuator (#280) * Update science pins * Update pin names, update science apps * Updated for clang format * Revert "Updated for clang format" This reverts commit f3831a1. * Proper clang formatting * PR comments * Updating PR for changes on base * update servo range of motion * Missed a file for clang * Fixed code which was mistakenly changed Co-authored-by: Felix Wong <[email protected]> * fix formatting * fixed check not running * fixed comments * updated version of bridge Co-authored-by: Felix Wong <[email protected]> Co-authored-by: Cindy Li <[email protected]> Co-authored-by: yreda1999 <[email protected]> Co-authored-by: Melvin Wang <[email protected]> Co-authored-by: younes <[email protected]> Co-authored-by: FK3wong <[email protected]> Co-authored-by: Felix Wong <[email protected]>
This lib was tested with test-pid. I apologise to anyone following the git workflow of this feature it has been rough. This feature is finally ready for review