Updated references from MPU6050 to BNO080
Dependencies: QEI2 PID Watchdog VL53L1X_Filter BNOWrapper ros_lib_kinetic
wheelchair.h@15:ddd61f6dc5ab, 2018-08-13 (annotated)
- Committer:
- ryanlin97
- Date:
- Mon Aug 13 21:33:09 2018 +0000
- Revision:
- 15:ddd61f6dc5ab
- Parent:
- 14:9caca9fde9b0
- Child:
- 17:7f3b69300bb6
changed for ros;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ryanlin97 | 0:fc0c4a184482 | 1 | #ifndef wheelchair |
ryanlin97 | 0:fc0c4a184482 | 2 | #define wheelchair |
ryanlin97 | 0:fc0c4a184482 | 3 | |
ryanlin97 | 11:d14a1f7f1297 | 4 | #include "chair_BNO055.h" |
ryanlin97 | 12:921488918749 | 5 | #include "PID_v1.h" |
ryanlin97 | 12:921488918749 | 6 | #include "QEI.h" |
ryanlin97 | 15:ddd61f6dc5ab | 7 | #include <ros.h> |
ryanlin97 | 15:ddd61f6dc5ab | 8 | #include <geometry_msgs/Twist.h> |
ryanlin97 | 12:921488918749 | 9 | |
ryanlin97 | 11:d14a1f7f1297 | 10 | //#include "chair_MPU9250.h" |
ryanlin97 | 0:fc0c4a184482 | 11 | |
ryanlin97 | 11:d14a1f7f1297 | 12 | #define turn_precision 10 |
ryanlin97 | 0:fc0c4a184482 | 13 | #define def (2.5f/3.3f) |
ryanlin97 | 12:921488918749 | 14 | #define high 3.3f/3.3f |
ryanlin97 | 3:a5e71bfdb492 | 15 | #define offset .02f |
ryanlin97 | 3:a5e71bfdb492 | 16 | #define low (1.7f/3.3f) |
ryanlin97 | 10:e5463c11e0a0 | 17 | #define process .1 |
ryanlin97 | 14:9caca9fde9b0 | 18 | |
ryanlin97 | 14:9caca9fde9b0 | 19 | /* for big mbed board |
ryanlin97 | 3:a5e71bfdb492 | 20 | #define xDir D12 //top right two pins |
ryanlin97 | 0:fc0c4a184482 | 21 | #define yDir D13 //top left two pins |
ryanlin97 | 12:921488918749 | 22 | #define Encoder1 D0 |
ryanlin97 | 12:921488918749 | 23 | #define Encoder2 D1 |
ryanlin97 | 14:9caca9fde9b0 | 24 | */ |
ryanlin97 | 14:9caca9fde9b0 | 25 | |
ryanlin97 | 14:9caca9fde9b0 | 26 | //for small mbed board |
ryanlin97 | 14:9caca9fde9b0 | 27 | #define xDir D9 |
ryanlin97 | 14:9caca9fde9b0 | 28 | #define yDir D10 |
ryanlin97 | 14:9caca9fde9b0 | 29 | #define Encoder1 D7 |
ryanlin97 | 14:9caca9fde9b0 | 30 | #define Encoder2 D8 |
ryanlin97 | 14:9caca9fde9b0 | 31 | |
ryanlin97 | 12:921488918749 | 32 | #define EncoderReadRate 1200 |
ryanlin97 | 12:921488918749 | 33 | #define Diameter 31.75 |
ryanlin97 | 12:921488918749 | 34 | /** Wheelchair class |
ryanlin97 | 12:921488918749 | 35 | * Used for controlling the smart wheelchair |
ryanlin97 | 12:921488918749 | 36 | */ |
ryanlin97 | 0:fc0c4a184482 | 37 | class Wheelchair |
ryanlin97 | 0:fc0c4a184482 | 38 | { |
ryanlin97 | 0:fc0c4a184482 | 39 | public: |
ryanlin97 | 12:921488918749 | 40 | /** Create Wheelchair Object with x,y pin for analog dc output |
ryanlin97 | 12:921488918749 | 41 | * serial for printout, and timer |
ryanlin97 | 12:921488918749 | 42 | */ |
ryanlin97 | 7:5e38d43fbce3 | 43 | Wheelchair(PinName xPin, PinName yPin, Serial* pc, Timer* time); |
ryanlin97 | 12:921488918749 | 44 | |
ryanlin97 | 12:921488918749 | 45 | /** move using the joystick */ |
ryanlin97 | 3:a5e71bfdb492 | 46 | void move(float x_coor, float y_coor); |
ryanlin97 | 12:921488918749 | 47 | |
ryanlin97 | 12:921488918749 | 48 | /* turn right a certain amount of degrees (overshoots)*/ |
ryanlin97 | 11:d14a1f7f1297 | 49 | double turn_right(int deg); |
ryanlin97 | 12:921488918749 | 50 | |
ryanlin97 | 12:921488918749 | 51 | /* turn left a certain amount of degrees (overshoots)*/ |
ryanlin97 | 11:d14a1f7f1297 | 52 | double turn_left(int deg); |
ryanlin97 | 12:921488918749 | 53 | |
ryanlin97 | 12:921488918749 | 54 | /* turn right a certain amount of degrees using PID*/ |
ryanlin97 | 12:921488918749 | 55 | void pid_right(int deg); |
ryanlin97 | 12:921488918749 | 56 | |
ryanlin97 | 12:921488918749 | 57 | /* turn left a certain amount of degrees using PID*/ |
ryanlin97 | 12:921488918749 | 58 | void pid_left(int deg); |
ryanlin97 | 12:921488918749 | 59 | |
ryanlin97 | 12:921488918749 | 60 | /* turning function that turns any direction */ |
ryanlin97 | 11:d14a1f7f1297 | 61 | void turn(int deg); |
ryanlin97 | 12:921488918749 | 62 | |
ryanlin97 | 12:921488918749 | 63 | /* drive the wheelchair forward */ |
ryanlin97 | 1:c0beadca1617 | 64 | void forward(); |
ryanlin97 | 12:921488918749 | 65 | |
ryanlin97 | 12:921488918749 | 66 | /* drive the wheelchair backward*/ |
ryanlin97 | 1:c0beadca1617 | 67 | void backward(); |
ryanlin97 | 12:921488918749 | 68 | |
ryanlin97 | 12:921488918749 | 69 | /* turn the wheelchair right*/ |
ryanlin97 | 1:c0beadca1617 | 70 | void right(); |
ryanlin97 | 12:921488918749 | 71 | |
ryanlin97 | 12:921488918749 | 72 | /* turn the wheelchair left*/ |
ryanlin97 | 1:c0beadca1617 | 73 | void left(); |
ryanlin97 | 12:921488918749 | 74 | |
ryanlin97 | 12:921488918749 | 75 | /* stop the wheelchair*/ |
ryanlin97 | 1:c0beadca1617 | 76 | void stop(); |
ryanlin97 | 12:921488918749 | 77 | |
ryanlin97 | 12:921488918749 | 78 | /* function to get imu data*/ |
ryanlin97 | 11:d14a1f7f1297 | 79 | void compass_thread(); |
ryanlin97 | 12:921488918749 | 80 | float getDistance(); |
ryanlin97 | 12:921488918749 | 81 | void resetDistance(); |
ryanlin97 | 12:921488918749 | 82 | void pid_turn(int deg); |
ryanlin97 | 12:921488918749 | 83 | |
ryanlin97 | 1:c0beadca1617 | 84 | private: |
ryanlin97 | 3:a5e71bfdb492 | 85 | PwmOut* x; |
ryanlin97 | 3:a5e71bfdb492 | 86 | PwmOut* y; |
ryanlin97 | 12:921488918749 | 87 | chair_BNO055* imu; |
ryanlin97 | 7:5e38d43fbce3 | 88 | Serial* out; |
ryanlin97 | 11:d14a1f7f1297 | 89 | Timer* ti; |
ryanlin97 | 12:921488918749 | 90 | QEI* wheel; |
ryanlin97 | 1:c0beadca1617 | 91 | |
ryanlin97 | 0:fc0c4a184482 | 92 | }; |
ryanlin97 | 0:fc0c4a184482 | 93 | #endif |