Cheetah Software
1.0
Main Page
Namespaces
Classes
Files
File List
File Members
main_helper.cpp
Go to the documentation of this file.
1
9
#include <
HardwareBridge.h
>
10
#include "
SimulationBridge.h
"
11
12
#include <
main_helper.h
>
13
#include <cassert>
14
#include <iostream>
15
16
#include <
RobotController.h
>
17
#include "
Utilities/SegfaultHandler.h
"
18
19
MasterConfig
gMasterConfig
;
20
24
void
printUsage
() {
25
printf(
26
"Usage: robot [robot-id] [sim-or-robot]\n\twhere robot-id: 3 for "
27
"cheetah 3, m for mini-cheetah\n\t sim-or-robot: s for sim, r for "
28
"robot\n"
);
29
}
30
31
int
main_helper
(
int
argc,
char
** argv,
RobotController
* ctrl) {
32
install_segfault_handler
();
33
if
(argc != 3) {
34
printUsage
();
35
return
EXIT_FAILURE;
36
}
37
38
if
(argv[1][0] ==
'3'
) {
39
gMasterConfig.
_robot
=
RobotType::CHEETAH_3
;
40
}
else
if
(argv[1][0] ==
'm'
) {
41
gMasterConfig.
_robot
=
RobotType::MINI_CHEETAH
;
42
}
else
{
43
printUsage
();
44
return
EXIT_FAILURE;
45
}
46
47
if
(argv[2][0] ==
's'
) {
48
gMasterConfig.
simulated
=
true
;
49
}
else
if
(argv[2][0] ==
'r'
) {
50
gMasterConfig.
simulated
=
false
;
51
}
else
{
52
printUsage
();
53
return
EXIT_FAILURE;
54
}
55
56
printf(
"[Quadruped] Cheetah Software\n"
);
57
printf(
" Quadruped: %s\n"
,
58
gMasterConfig.
_robot
==
RobotType::MINI_CHEETAH
?
"Mini Cheetah"
59
:
"Cheetah 3"
);
60
printf(
" Driver: %s\n"
, gMasterConfig.
simulated
61
?
"Development Simulation Driver"
62
:
"Quadruped Driver"
);
63
64
// dispatch the appropriate driver
65
if
(gMasterConfig.
simulated
) {
66
if
(gMasterConfig.
_robot
==
RobotType::MINI_CHEETAH
) {
67
SimulationBridge
simulationBridge(gMasterConfig.
_robot
, ctrl);
68
simulationBridge.
run
();
69
printf(
"[Quadruped] SimDriver run() has finished!\n"
);
70
}
else
if
(gMasterConfig.
_robot
==
RobotType::CHEETAH_3
) {
71
SimulationBridge
simulationBridge(gMasterConfig.
_robot
, ctrl);
72
simulationBridge.
run
();
73
}
else
{
74
printf(
"[ERROR] unknown robot\n"
);
75
assert(
false
);
76
}
77
}
else
{
78
if
(gMasterConfig.
_robot
==
RobotType::MINI_CHEETAH
) {
79
MiniCheetahHardwareBridge
hw(ctrl);
80
hw.
run
();
81
printf(
"[Quadruped] SimDriver run() has finished!\n"
);
82
}
else
if
(gMasterConfig.
_robot
==
RobotType::CHEETAH_3
) {
83
printf(
"[ERROR] can't do cheetah 3 hardware\n"
);
84
assert(
false
);
85
}
else
{
86
printf(
"[ERROR] unknown robot\n"
);
87
assert(
false
);
88
}
89
}
90
91
return
0;
92
}
RobotType::MINI_CHEETAH
MasterConfig::simulated
bool simulated
Definition:
Types.h:8
HardwareBridge.h
Interface between robot code and robot hardware.
RobotController
Definition:
RobotController.h:10
MiniCheetahHardwareBridge
Definition:
HardwareBridge.h:72
SimulationBridge
Definition:
SimulationBridge.h:18
printUsage
void printUsage()
Definition:
main_helper.cpp:24
MiniCheetahHardwareBridge::run
void run()
Definition:
HardwareBridge.cpp:204
RobotController.h
gMasterConfig
MasterConfig gMasterConfig
Definition:
main_helper.cpp:19
SegfaultHandler.h
MasterConfig::_robot
RobotType _robot
Definition:
Types.h:7
MasterConfig
Definition:
Types.h:6
RobotType::CHEETAH_3
install_segfault_handler
void install_segfault_handler()
Definition:
SegfaultHandler.cpp:25
SimulationBridge::run
void run()
Definition:
SimulationBridge.cpp:13
SimulationBridge.h
main_helper
int main_helper(int argc, char **argv, RobotController *ctrl)
Definition:
main_helper.cpp:31
main_helper.h
home
dhkim
Public_Repository
Cheetah-Software
robot
src
main_helper.cpp
Generated by
1.8.11