Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: BilateralTeleoperation
PID.h@1:f39ce45861fb, 2022-09-26 (annotated)
- Committer:
- sangbae
- Date:
- Mon Sep 26 19:38:40 2022 +0000
- Revision:
- 1:f39ce45861fb
Bilateral Teleoperation between two motors using impedance control
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| sangbae | 1:f39ce45861fb | 1 | //Ben Katz, 2013 |
| sangbae | 1:f39ce45861fb | 2 | //PID Controller class |
| sangbae | 1:f39ce45861fb | 3 | |
| sangbae | 1:f39ce45861fb | 4 | #include "mbed.h" |
| sangbae | 1:f39ce45861fb | 5 | #ifndef PID_H |
| sangbae | 1:f39ce45861fb | 6 | #define PID_H |
| sangbae | 1:f39ce45861fb | 7 | |
| sangbae | 1:f39ce45861fb | 8 | class PIDController{ |
| sangbae | 1:f39ce45861fb | 9 | public: |
| sangbae | 1:f39ce45861fb | 10 | |
| sangbae | 1:f39ce45861fb | 11 | PIDController(float desired_position, float desired_torque, float p_gainp, float d_gainp, float i_gain_p, float p_gain_c, float i_gain_c); |
| sangbae | 1:f39ce45861fb | 12 | ~PIDController(); |
| sangbae | 1:f39ce45861fb | 13 | |
| sangbae | 1:f39ce45861fb | 14 | float goal_position; |
| sangbae | 1:f39ce45861fb | 15 | float current_position; |
| sangbae | 1:f39ce45861fb | 16 | |
| sangbae | 1:f39ce45861fb | 17 | float kp_p; |
| sangbae | 1:f39ce45861fb | 18 | float kd_p; |
| sangbae | 1:f39ce45861fb | 19 | float ki_p; |
| sangbae | 1:f39ce45861fb | 20 | |
| sangbae | 1:f39ce45861fb | 21 | float kp_c; |
| sangbae | 1:f39ce45861fb | 22 | float ki_c; |
| sangbae | 1:f39ce45861fb | 23 | float c_error; |
| sangbae | 1:f39ce45861fb | 24 | float error_sum; |
| sangbae | 1:f39ce45861fb | 25 | float command; |
| sangbae | 1:f39ce45861fb | 26 | float torque_command; |
| sangbae | 1:f39ce45861fb | 27 | float c_torque; |
| sangbae | 1:f39ce45861fb | 28 | |
| sangbae | 1:f39ce45861fb | 29 | float error; |
| sangbae | 1:f39ce45861fb | 30 | float old_error; |
| sangbae | 1:f39ce45861fb | 31 | float integral_error; |
| sangbae | 1:f39ce45861fb | 32 | |
| sangbae | 1:f39ce45861fb | 33 | |
| sangbae | 1:f39ce45861fb | 34 | int counter; |
| sangbae | 1:f39ce45861fb | 35 | |
| sangbae | 1:f39ce45861fb | 36 | Timer timer; |
| sangbae | 1:f39ce45861fb | 37 | |
| sangbae | 1:f39ce45861fb | 38 | float torque; |
| sangbae | 1:f39ce45861fb | 39 | float direction; |
| sangbae | 1:f39ce45861fb | 40 | |
| sangbae | 1:f39ce45861fb | 41 | float past_currents [5]; |
| sangbae | 1:f39ce45861fb | 42 | |
| sangbae | 1:f39ce45861fb | 43 | float command_position(void); |
| sangbae | 1:f39ce45861fb | 44 | float command_torque(void); |
| sangbae | 1:f39ce45861fb | 45 | float command_position_tm(void); |
| sangbae | 1:f39ce45861fb | 46 | private: |
| sangbae | 1:f39ce45861fb | 47 | |
| sangbae | 1:f39ce45861fb | 48 | |
| sangbae | 1:f39ce45861fb | 49 | |
| sangbae | 1:f39ce45861fb | 50 | |
| sangbae | 1:f39ce45861fb | 51 | |
| sangbae | 1:f39ce45861fb | 52 | |
| sangbae | 1:f39ce45861fb | 53 | }; |
| sangbae | 1:f39ce45861fb | 54 | #endif |