How to read a configuration file. This example is designed to read a file like the following (property/config.txt):
#include <stdio.h>
#include <stdlib.h>
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);
}
std::string 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").asInt32();
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).asInt32());
}
printf("\n");
return 0;
}
An interface to the operating system, including Port based communication.
int main(int argc, char *argv[])