-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNavBot.cpp
80 lines (62 loc) · 2.27 KB
/
NavBot.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "ActionExploreVelocity.h"
#include "ActionExploreAvoidFrontNear.h"
#include "ActionExploreNavigateNear.h"
#include "SensorSweepTask.h"
#include "LineExtractionTask.h"
#include <Aria/Aria.h>
#include <Aria/ArMap.h>
#include <iostream>
int main(int argc, char **argv) {
/* initalize robot */
Aria::init();
ArArgumentParser argParser(&argc, argv);
argParser.loadDefaultArguments();
ArRobot robot;
ArRobotConnector robotConnector(&argParser, &robot);
ArLaserConnector laserConnector(&argParser, &robot, &robotConnector);
if (!robotConnector.connectRobot()) {
ArLog::log(ArLog::Terse, "Could not connect to the robot.");
if (argParser.checkHelpAndWarnUnparsed()) {
// -help not given, just exit.
Aria::logOptions();
Aria::exit(1);
return 1;
}
}
// Trigger argument parsing
if (!Aria::parseArgs() || !argParser.checkHelpAndWarnUnparsed()) {
Aria::logOptions();
Aria::exit(1);
return 1;
}
ArKeyHandler keyHandler;
Aria::setKeyHandler(&keyHandler);
robot.attachKeyHandler(&keyHandler);
// Make a map
ArMap map("./", true, "Files", "Map", "Map of the enviroment", true, ArPriority::IMPORTANT, NULL, 100);
// Attach map and robot to instance of class for slam algorithm implementation
std::cout << "Navbot Enabled\n" << std::endl;
ArSonarDevice sonar;
robot.addRangeDevice(&sonar);
robot.runAsync(true);
// made some changes
SensorSweepTask sensorSweepTask(&robot, 1500);
LineExtractionTask lineExtractionTask(&robot, &sensorSweepTask, 0.00, 0.00, 0);
sensorSweepTask.runAsync();
lineExtractionTask.runAsync();
robot.enableMotors();
robot.comInt(ArCommands::SOUNDTOG, 0);
ArActionStallRecover recover;
ArActionBumpers bumpers;
ActionExploreVelocity exploreVelocity(500, 500);
ActionExploreAvoidFrontNear exploreAvoidFrontNear(1500);
ActionExploreNavigateNear exploreNavigateNear(2000);
robot.addAction(&recover, 100);
robot.addAction(&bumpers, 75);
robot.addAction(&exploreAvoidFrontNear, 50);
robot.addAction(&exploreNavigateNear, 50);
robot.addAction(&exploreVelocity, 30);
robot.waitForRunExit();
Aria::exit(0);
return 0;
}