23 #include <boost/program_options.hpp> 38 namespace po = boost::program_options;
41 int main(
int argc,
char *argv[])
43 std::string filename, initial, cfg;
44 unsigned int iterations;
49 unsigned int examplesMax;
50 unsigned int counterMod;
51 double ivLineWidth, ivSphereRadius, ivCoordScale;
54 po::options_description desc(
"Usage : kinematic_chain_optimizer [options]");
56 (
"help,h",
"show help screen")
57 (
"exit",
"show only initial error")
58 (
"filename",po::value<std::string>(&filename)->default_value(
"data/calib_dump"),
"load data from filename")
59 (
"initial",po::value<std::string>(&initial)->default_value(
""),
"Initial value for optimization, e.g. 0.6 0.4 0.3 (n = 3)")
60 (
"cfg",po::value<std::string>(&cfg)->default_value(
"data/frames.xml"),
"load cfg from filename")
62 (
"trim",po::value<double>(&trim)->default_value(0.2),
"trimming percentage")
63 (
"epsilon",po::value<double>(&epsilon)->default_value(1.0e-8),
"convergence limit, 0.00000001")
64 (
"random",po::value<bool>(&useRandom)->default_value(
false),
"use random start value" )
65 (
"always",po::value<bool>(&useShowResult)->default_value(
false),
"always show result" )
66 (
"max",po::value<unsigned int>(&examplesMax)->default_value(10000000),
"use max number of data" )
67 (
"iterations",po::value<unsigned int>(&iterations)->default_value(500),
"use max number of iterations" )
68 (
"debugiterations",po::value<unsigned int>(&counterMod)->default_value(100),
"show result each x iterations" )
69 (
"ivlinewidth",po::value<double>(&ivLineWidth)->default_value(0.5),
"width of Inventor line")
70 (
"ivsphereradius",po::value<double>(&ivSphereRadius)->default_value(1.0),
"radius of Inventor sphere")
71 (
"ivcoordscale",po::value<double>(&ivCoordScale)->default_value(0.2),
"scaleFactor of Inventor coordinate system")
75 po::store(po::parse_command_line(argc, argv, desc), vm);
78 if (vm.count(
"help")) {
79 std::cout << desc <<std::endl;
83 bool doQuit = vm.count(
"exit");
86 std::vector<double> initialValues;
91 LOG_MSG(2,
"Random Generator Seed is %d\n", seed);
111 optimizer.
load(cfg, filename);
113 optimizer.
run(initialValues);
118 LOG_MSG(1,
"Error: Optimization failed\n.");
122 printf(
"Showing final result:\n");
123 printf(
"Value: %f\n", result.
result);
129 CVec position, quater;
133 printf(
"Name: %s Position (xyz): %f %f %f Quaternion (wxyz): %f %f %f %f\n", result.
optimizedPoses[i].first.c_str(),
134 position.
x, position.
y, position.
z,
135 quater.
w, quater.
x, quater.
y, quater.
z);
void setShowModulo(unsigned int counterMod)
std::vector< std::pair< std::string, CMatrix > > optimizedPoses
void run(const std::vector< double > &initialValues)
bool getResult(COptimizerResult &out)
void setIterations(unsigned int iterations)
void setIvLineWidth(double ivLineWidth)
bool generateInventor(std::vector< double > values, std::string filename, std::string ivCoordFilename="data/coord.iv")
std::vector< double > values
std::string arrayToString(std::vector< T > &array)
static void quaternionFromMatrix(const CMatrix &mat, CVec &quaternion)
Transforms a homogenous matrix into quaternion representation.
void setRandomStart(bool useRandom)
void setIvSphereRadius(double ivSphereRadius)
void setUniformSeed(unsigned int seed)
void setQuit(bool doQuit)
#define LOG_MSG(index, format,...)
void setEpsilon(double eps)
void setDataMax(unsigned int examplesMax)
void setTrimming(double trim)
void setShowResult(bool useShowResult)
void strToArray(std::string text, std::vector< double > &result, std::string delimiter=" ")
void load(std::string cfg, std::string data, unsigned int start=0)
void setIvCoordScale(double ivCoordScale)
int main(int argc, char *argv[])
unsigned long getTickCount()