forked from robotology/yarp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
46 lines (36 loc) · 1.21 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
/*
* Copyright: (C) 2010 RobotCub Consortium
* Author: Paul Fitzpatrick
* CopyPolicy: Released under the terms of the LGPLv2.1 or later, see LGPL.TXT
*/
#include <stdio.h>
#include <stdlib.h>
#include <yarp/os/Property.h>
using namespace yarp::os;
int main(int argc, char *argv[]) {
Property cmdLine;
cmdLine.fromCommand(argc,argv);
if (!cmdLine.check("file")) {
printf("Please call with: --file config.txt\n");
exit(1);
}
ConstString fname = cmdLine.find("file").asString();
printf("Working with config file %s\n", fname.c_str());
Property robot;
robot.fromConfigFile(fname.c_str());
if (!robot.check("GENERAL")) {
printf("Cannot understand config file\n");
exit(1);
}
int joints = robot.findGroup("GENERAL").find("Joints").asInt();
printf("Robot has %d joints\n", joints);
Bottle& maxes = robot.findGroup("LIMITS").findGroup("Max");
printf("Robot has limits: ");
for (int i=1; i<maxes.size(); i++) {
printf("%d ", maxes.get(i).asInt());
}
printf("\n");
//printf("If you wanted to transmit this configuration, here it is in Bottle format:\n");
//printf("%s\n", robot.toString().c_str());
return 0;
}