yotaro morizumi
/
zoomy_customLibrary
my new gear...
actuator/IMC_motorDrive.hpp@2:e7b09385d197, 2022-03-27 (annotated)
- Committer:
- yootee
- Date:
- Sun Mar 27 04:39:16 2022 +0000
- Revision:
- 2:e7b09385d197
- Parent:
- IMC_motorDrive.hpp@0:1456b6f84c75
- Child:
- 8:1ca5a2052b0c
arrc?
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yootee | 0:1456b6f84c75 | 1 | #pragma once |
yootee | 0:1456b6f84c75 | 2 | #include<mbed.h> |
yootee | 0:1456b6f84c75 | 3 | #include <portSet.hpp> |
yootee | 0:1456b6f84c75 | 4 | #include <rotary_inc_sp.hpp> |
yootee | 0:1456b6f84c75 | 5 | |
yootee | 2:e7b09385d197 | 6 | #ifdef constrain |
yootee | 0:1456b6f84c75 | 7 | inline double constrain(double x,double minimum,double maximum){ |
yootee | 0:1456b6f84c75 | 8 | return (x < minimum ? minimum : x > maximum ? maximum : x); |
yootee | 0:1456b6f84c75 | 9 | } |
yootee | 2:e7b09385d197 | 10 | #endif |
yootee | 0:1456b6f84c75 | 11 | |
yootee | 0:1456b6f84c75 | 12 | class IMC_motor |
yootee | 0:1456b6f84c75 | 13 | { |
yootee | 0:1456b6f84c75 | 14 | public: |
yootee | 0:1456b6f84c75 | 15 | IMC_motor(Port encoder,int resolution,double wheel_ensyu,Port motor_,double K_,double Tau_,double dt_); |
yootee | 0:1456b6f84c75 | 16 | void IMCdrive(double target); |
yootee | 0:1456b6f84c75 | 17 | void IMCreset(); |
yootee | 0:1456b6f84c75 | 18 | void drive(int pwm); |
yootee | 0:1456b6f84c75 | 19 | RotaryInc motor_enc; |
yootee | 0:1456b6f84c75 | 20 | private: |
yootee | 0:1456b6f84c75 | 21 | double imc_out(double target); |
yootee | 0:1456b6f84c75 | 22 | double imc_controler(double y); |
yootee | 0:1456b6f84c75 | 23 | double process_model(double x,double mv); |
yootee | 0:1456b6f84c75 | 24 | double process_model_val; |
yootee | 0:1456b6f84c75 | 25 | double out_pwm; |
yootee | 0:1456b6f84c75 | 26 | double K; |
yootee | 0:1456b6f84c75 | 27 | double Tau; |
yootee | 0:1456b6f84c75 | 28 | double dt; |
yootee | 0:1456b6f84c75 | 29 | Port motor; |
yootee | 0:1456b6f84c75 | 30 | }; |