-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
executable file
·64 lines (49 loc) · 1.28 KB
/
main.cpp
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
#include <iostream>
#include <robot_delay.h>
#include <robot_instr.h>
#include <robot_link.h>
#include "robot_state.h"
#include "navigation.h"
#include "sensors_actuators.h"
#include "line_following.h"
#include "endpoint_tasks.h" // should not be here
#include <cmath>
#include <stdlib.h>
#ifdef __arm__
#define ROBOT_NUM "127.0.0.1"
#else
#define ROBOT_NUM 50
#endif
int main(int argc, char **argv)
{
robot_state state;
robot_link *link = state.link;
state.current = state.map->vs[VERT_START];
state.target = state.map->vs[VERT_EGG_0];
state.current_path = state.map->find_path(state.current, state.target);
vertex *current = state.current;
for (size_t i = 0; i < state.current_path.size(); ++i)
{
if (!current)
break;
std::cout << "(" << current->posx << ", " << current->posy << "),\n";
current = state.current_path[i]->other(current);
}
std::cout << "(" << current->posx << ", " << current->posy << ")\n";
if (!link->initialise(ROBOT_NUM))
{
std::cout << "Cannot initialise link\n";
link->print_errs(" ");
return -1;
}
std::cout << "Connected\n";
init_sensors_actuators(state);
state.eggs_processed = 0;
while (true)
{
update_sensor_values(state);
follow_line(state);
if (state.current == state.target)
state.current->endpoint_task(state);
}
}