-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_robot2.h
154 lines (132 loc) · 4.08 KB
/
api_robot2.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/****************************************************************
* Description: Uoli Control Application Programming Interface.
*
* Authors: Edson Borin ([email protected])
* Antônio Guimarães ()
*
* Date: 2019
***************************************************************/
#ifndef API_ROBOT_H
#define API_ROBOT_H
/*
* Struct to represent 3-dimensional vectors.
*/
typedef struct
{
int x;
int y;
int z;
} Vector3;
/**************************************************************/
/* List of Friends locations and dangerous locations */
/**************************************************************/
Vector3 friends_locations[5] = {
{.x = 715, .y = 105, .z = -40},
{.x = 613, .y = 105, .z = -24},
{.x = 447, .y = 106, .z = 158},
{.x = 507, .y = 105, .z = 264},
{.x = 596, .y = 105, .z = 402}
};
Vector3 dangerous_locations[5] = {
{.x = 475, .y = 104, .z = 193},
{.x = 526, .y = 105, .z = 225},
{.x = 487, .y = 105, .z = -10},
{.x = 685, .y = 105, .z = -21},
{.x = 421, .y = 105, .z = 116}
};
/**************************************************************/
/* Engines */
/**************************************************************/
/*
* Sets both engines torque. The torque value must be between -100 and 100.
* Parameter:
* engine_1: Engine 1 torque
* engine_2: Engine 2 torque
* Returns:
* -1 in case one or more values are out of range
* 0 in case both values are in range
*/
int set_torque(int engine_1, int engine_2);
/*
* Sets engine torque. Engine ID 0/1 identifies the left/right engine.
* The torque value must be between -100 and 100.
* Parameter:
* engine_id: Engine ID
* torque: Engine torque
* Returns:
* -1 in case the torque value is invalid (out of range)
* -2 in case the engine_id is invalid
* 0 in case both values are valid
*/
int set_engine_torque(int engine_id, int torque);
/*
* Sets the angle of three Servo motors that control the robot head.
* Servo ID 0/1/2 identifies the Base/Mid/Top servos.
* Parameter:
* servo_id: Servo ID
* angle: Servo Angle
* Returns:
* -1 in case the servo id is invalid
* -2 in case the servo angle is invalid
* 0 in case the servo id and the angle is valid
*/
int set_head_servo(int servo_id, int angle);
/**************************************************************/
/* Sensors */
/**************************************************************/
/*
* Reads distance from ultrasonic sensor.
* Parameter:
* none
* Returns:
* distance of nearest object within the detection range, in centimeters.
*/
unsigned short get_us_distance();
/*
* Reads current global position using the GPS device.
* Parameter:
* pos: pointer to structure to be filled with the GPS coordinates.
* Returns:
* void
*/
void get_current_GPS_position(Vector3* pos);
/*
* Reads global rotation from the gyroscope device .
* Parameter:
* pos: pointer to structure to be filled with the Euler angles indicated by the gyroscope.
* Returns:
* void
*/
void get_gyro_angles(Vector3* angles);
/**************************************************************/
/* Timer */
/**************************************************************/
/*
* Reads the system time.
* Parameter:
* * t: pointer to a variable that will receive the system time.
* Returns:
* The system time (in milliseconds)
*/
unsigned int get_time();
/*
* Sets the system time.
* Parameter:
* t: the new system time.
* Returns:
* void
*/
void set_time(unsigned int t);
/**************************************************************/
/* UART */
/**************************************************************/
/*
* Writes a string to the UART. Uses the syscall write with file
* descriptor 1 to instruct the SOUL to write the string to the UART.
* Parameter:
* * s: pointer to the string.
* Returns:
* void
*/
int puts(const char*);
#endif // API_ROBOT_H