bla
Controller.h@0:7ab090cd6520, 2017-07-13 (annotated)
- Committer:
- skrickl
- Date:
- Thu Jul 13 13:42:50 2017 +0000
- Revision:
- 0:7ab090cd6520
bla
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
skrickl | 0:7ab090cd6520 | 1 | |
skrickl | 0:7ab090cd6520 | 2 | #ifndef CONTROLLER_H |
skrickl | 0:7ab090cd6520 | 3 | #define CONTROLLER_H |
skrickl | 0:7ab090cd6520 | 4 | |
skrickl | 0:7ab090cd6520 | 5 | #include "Pid_control.h" |
skrickl | 0:7ab090cd6520 | 6 | #include "Motor.h" |
skrickl | 0:7ab090cd6520 | 7 | #include "Brake.h" |
skrickl | 0:7ab090cd6520 | 8 | #include "Steering.h" |
skrickl | 0:7ab090cd6520 | 9 | |
skrickl | 0:7ab090cd6520 | 10 | |
skrickl | 0:7ab090cd6520 | 11 | #define max_throttle 50 // 50% maximum throttle |
skrickl | 0:7ab090cd6520 | 12 | #define max_braking 50 |
skrickl | 0:7ab090cd6520 | 13 | #define braking_p1 1.0 |
skrickl | 0:7ab090cd6520 | 14 | #define braking_p2 2.0 |
skrickl | 0:7ab090cd6520 | 15 | #define braking_p3 4.0 |
skrickl | 0:7ab090cd6520 | 16 | #define speed_brake_1 5.0 |
skrickl | 0:7ab090cd6520 | 17 | #define speed_brake_2 10.0 |
skrickl | 0:7ab090cd6520 | 18 | #define speed_brake_3 50.0 |
skrickl | 0:7ab090cd6520 | 19 | #define min_speed 0.5 //at lower speeds vehicle will brake and stop |
skrickl | 0:7ab090cd6520 | 20 | |
skrickl | 0:7ab090cd6520 | 21 | |
skrickl | 0:7ab090cd6520 | 22 | class Controller |
skrickl | 0:7ab090cd6520 | 23 | { |
skrickl | 0:7ab090cd6520 | 24 | public: |
skrickl | 0:7ab090cd6520 | 25 | int update(int Status); |
skrickl | 0:7ab090cd6520 | 26 | |
skrickl | 0:7ab090cd6520 | 27 | Controller(); |
skrickl | 0:7ab090cd6520 | 28 | ~Controller(); |
skrickl | 0:7ab090cd6520 | 29 | |
skrickl | 0:7ab090cd6520 | 30 | |
skrickl | 0:7ab090cd6520 | 31 | private: |
skrickl | 0:7ab090cd6520 | 32 | |
skrickl | 0:7ab090cd6520 | 33 | Pid_control pid_control_speed; |
skrickl | 0:7ab090cd6520 | 34 | Pid_control pid_control_steering; |
skrickl | 0:7ab090cd6520 | 35 | Motor motor; |
skrickl | 0:7ab090cd6520 | 36 | Brake brake; |
skrickl | 0:7ab090cd6520 | 37 | Steering steering; |
skrickl | 0:7ab090cd6520 | 38 | |
skrickl | 0:7ab090cd6520 | 39 | int _drive_direction; |
skrickl | 0:7ab090cd6520 | 40 | int _drive_direction_old; |
skrickl | 0:7ab090cd6520 | 41 | int _drive_direction_change; |
skrickl | 0:7ab090cd6520 | 42 | int _target_speed; |
skrickl | 0:7ab090cd6520 | 43 | int _actual_speed; |
skrickl | 0:7ab090cd6520 | 44 | int _target_steering_angle; |
skrickl | 0:7ab090cd6520 | 45 | int _actual_steering_angle; |
skrickl | 0:7ab090cd6520 | 46 | int _u_steering; |
skrickl | 0:7ab090cd6520 | 47 | int _u_throttle; |
skrickl | 0:7ab090cd6520 | 48 | |
skrickl | 0:7ab090cd6520 | 49 | |
skrickl | 0:7ab090cd6520 | 50 | int Pid_controller(void); |
skrickl | 0:7ab090cd6520 | 51 | void actuate(int u); // value -100 to 100 full braking to full throttle |
skrickl | 0:7ab090cd6520 | 52 | void stop(void); |
skrickl | 0:7ab090cd6520 | 53 | |
skrickl | 0:7ab090cd6520 | 54 | }; |
skrickl | 0:7ab090cd6520 | 55 | |
skrickl | 0:7ab090cd6520 | 56 | #endif |