Dr. Davis and Dr. Dyer special studies robotics project
Dependencies: BSP_DISCO_F469NI LCD_DISCO_F469NI TS_DISCO_F469NI mbed Motordriver
Fork of Configurable_Robots by
Classes/RobotMVC/RobotModel.h@19:c44dc6716201, 2017-05-10 (annotated)
- Committer:
- chris1996
- Date:
- Wed May 10 19:14:25 2017 +0000
- Revision:
- 19:c44dc6716201
- Parent:
- 18:f2a516ad24eb
Updated. Quality of LIfe. More Motors Capabailties
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
blu12758 | 4:4989e85d16b6 | 1 | //OU Configurable Robot Project |
blu12758 | 4:4989e85d16b6 | 2 | //Spring 2017 |
blu12758 | 5:be5e1177bb43 | 3 | //William Bonner |
blu12758 | 5:be5e1177bb43 | 4 | |
blu12758 | 5:be5e1177bb43 | 5 | #include "mbed.h" |
blu12758 | 18:f2a516ad24eb | 6 | #include "motordriver.h" |
blu12758 | 5:be5e1177bb43 | 7 | |
blu12758 | 10:4dd8b18e07d0 | 8 | |
blu12758 | 5:be5e1177bb43 | 9 | class RobotModel |
blu12758 | 5:be5e1177bb43 | 10 | { |
blu12758 | 5:be5e1177bb43 | 11 | //Current mode of operation |
blu12758 | 8:1173b502b316 | 12 | //0 = await command |
blu12758 | 5:be5e1177bb43 | 13 | int _mode; |
blu12758 | 5:be5e1177bb43 | 14 | |
blu12758 | 11:10a7bb4bc714 | 15 | int _larray[8]; |
blu12758 | 11:10a7bb4bc714 | 16 | int _threshold; |
blu12758 | 11:10a7bb4bc714 | 17 | int _cds[2]; |
blu12758 | 11:10a7bb4bc714 | 18 | |
blu12758 | 18:f2a516ad24eb | 19 | Timer sonar_t; |
blu12758 | 18:f2a516ad24eb | 20 | |
blu12758 | 18:f2a516ad24eb | 21 | float speedLeft; |
blu12758 | 18:f2a516ad24eb | 22 | float speedRight; |
blu12758 | 18:f2a516ad24eb | 23 | |
blu12758 | 5:be5e1177bb43 | 24 | public: |
blu12758 | 5:be5e1177bb43 | 25 | |
blu12758 | 6:8232db1ed208 | 26 | //Constructors/Destructors |
blu12758 | 6:8232db1ed208 | 27 | ~RobotModel(); |
blu12758 | 6:8232db1ed208 | 28 | RobotModel(); |
blu12758 | 6:8232db1ed208 | 29 | |
blu12758 | 6:8232db1ed208 | 30 | //Accessors/Mutators |
blu12758 | 5:be5e1177bb43 | 31 | int getMode() const {return _mode;} |
blu12758 | 5:be5e1177bb43 | 32 | void setMode(int m){_mode = m;} |
blu12758 | 5:be5e1177bb43 | 33 | |
blu12758 | 10:4dd8b18e07d0 | 34 | //initialize the robot's hardware |
blu12758 | 10:4dd8b18e07d0 | 35 | void init(); |
blu12758 | 10:4dd8b18e07d0 | 36 | //update the model based on the mode |
blu12758 | 10:4dd8b18e07d0 | 37 | int update(); |
blu12758 | 11:10a7bb4bc714 | 38 | |
blu12758 | 11:10a7bb4bc714 | 39 | //read the indicated light sensor |
blu12758 | 11:10a7bb4bc714 | 40 | int checkLight(int x); |
blu12758 | 11:10a7bb4bc714 | 41 | //read bit b of the line array |
blu12758 | 11:10a7bb4bc714 | 42 | int checkLine(int b); |
blu12758 | 11:10a7bb4bc714 | 43 | //scan the ADC on channel n |
blu12758 | 11:10a7bb4bc714 | 44 | int scan(int n); |
blu12758 | 18:f2a516ad24eb | 45 | |
blu12758 | 18:f2a516ad24eb | 46 | //Motor Methods |
blu12758 | 18:f2a516ad24eb | 47 | void StopMotors(void); |
blu12758 | 18:f2a516ad24eb | 48 | void TurnRight(); |
blu12758 | 18:f2a516ad24eb | 49 | void TurnLeft(); |
blu12758 | 18:f2a516ad24eb | 50 | void DriveStraight(); |
blu12758 | 18:f2a516ad24eb | 51 | void DriveSquare(); |
chris1996 | 19:c44dc6716201 | 52 | void DriveStraightMode(int ModeSetting); |
chris1996 | 19:c44dc6716201 | 53 | void TurnDegrees(int Degrees,int TurnDir); |
blu12758 | 18:f2a516ad24eb | 54 | |
blu12758 | 18:f2a516ad24eb | 55 | float LeftSpeed(); |
blu12758 | 18:f2a516ad24eb | 56 | float RightSpeed(); |
blu12758 | 5:be5e1177bb43 | 57 | }; |