2016/07/23
Dependents: Cansat2016_v1 Cansat2016_v1
Cansat2016.h@2:6fa291470764, 2016-08-27 (annotated)
- Committer:
- s1210160
- Date:
- Sat Aug 27 01:53:43 2016 +0000
- Revision:
- 2:6fa291470764
- Parent:
- 1:dad5c9475937
2016/08/27
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
s1210160 | 0:b42b5cb8b646 | 1 | #include "mbed.h" |
s1210160 | 0:b42b5cb8b646 | 2 | #include "VNH5019.h" |
s1210160 | 0:b42b5cb8b646 | 3 | |
s1210160 | 0:b42b5cb8b646 | 4 | #define M_PI 3.1415926535897932384626433832795 |
s1210160 | 0:b42b5cb8b646 | 5 | class Cansat2016 |
s1210160 | 0:b42b5cb8b646 | 6 | { |
s1210160 | 0:b42b5cb8b646 | 7 | |
s1210160 | 0:b42b5cb8b646 | 8 | private: |
s1210160 | 0:b42b5cb8b646 | 9 | typedef struct { |
s1210160 | 0:b42b5cb8b646 | 10 | double x; // latitude |
s1210160 | 0:b42b5cb8b646 | 11 | double y; // longitude |
s1210160 | 0:b42b5cb8b646 | 12 | int direction; // compass |
s1210160 | 0:b42b5cb8b646 | 13 | } BasicData; |
s1210160 | 0:b42b5cb8b646 | 14 | |
s1210160 | 0:b42b5cb8b646 | 15 | // robot data, target data |
s1210160 | 0:b42b5cb8b646 | 16 | BasicData robot, target; |
s1210160 | 0:b42b5cb8b646 | 17 | // distance of robot and target |
s1210160 | 0:b42b5cb8b646 | 18 | double sub_x, sub_y; |
s1210160 | 0:b42b5cb8b646 | 19 | double distance; |
s1210160 | 0:b42b5cb8b646 | 20 | // motor |
s1210160 | 0:b42b5cb8b646 | 21 | VNH5019 _motor; |
s1210160 | 0:b42b5cb8b646 | 22 | // speed of robot |
s1210160 | 0:b42b5cb8b646 | 23 | int speed; |
s1210160 | 0:b42b5cb8b646 | 24 | // action of robot |
s1210160 | 0:b42b5cb8b646 | 25 | char action; |
s1210160 | 0:b42b5cb8b646 | 26 | |
s1210160 | 0:b42b5cb8b646 | 27 | public: |
s1210160 | 0:b42b5cb8b646 | 28 | // constructor |
s1210160 | 0:b42b5cb8b646 | 29 | Cansat2016(VNH5019 motor); |
s1210160 | 0:b42b5cb8b646 | 30 | |
s1210160 | 0:b42b5cb8b646 | 31 | void calc_distance(void); |
s1210160 | 0:b42b5cb8b646 | 32 | void robot_compass(DigitalIn *sensor); |
s1210160 | 0:b42b5cb8b646 | 33 | void target_compass(); |
s1210160 | 0:b42b5cb8b646 | 34 | void robot_action(void); |
s1210160 | 0:b42b5cb8b646 | 35 | void motor_control(void); |
s1210160 | 0:b42b5cb8b646 | 36 | |
s1210160 | 0:b42b5cb8b646 | 37 | // set |
s1210160 | 0:b42b5cb8b646 | 38 | void set_robotGPS(double x, double y); |
s1210160 | 0:b42b5cb8b646 | 39 | void set_targetGPS(double x, double y); |
s1210160 | 0:b42b5cb8b646 | 40 | void set_action(char a); |
s1210160 | 1:dad5c9475937 | 41 | void set_speed(int value); |
s1210160 | 0:b42b5cb8b646 | 42 | |
s1210160 | 0:b42b5cb8b646 | 43 | // get |
s1210160 | 0:b42b5cb8b646 | 44 | double get_x(void); |
s1210160 | 0:b42b5cb8b646 | 45 | double get_y(void); |
s1210160 | 0:b42b5cb8b646 | 46 | int get_compass(char c); |
s1210160 | 0:b42b5cb8b646 | 47 | double get_distance(void); |
s1210160 | 0:b42b5cb8b646 | 48 | char get_action(void); |
s1210160 | 0:b42b5cb8b646 | 49 | }; |