29 std::vector<double> end, start;
30 start.push_back(first.
x);
31 start.push_back(first.
y);
32 start.push_back(first.
z);
33 end.push_back(second.
x);
34 end.push_back(second.
y);
35 end.push_back(second.
z);
37 CVec diff(end.at(0) - start.at(0), end.at(1)-start.at(1), end.at(2) - start.at(2));
53 linIndep.x = (-linIndep.y*diff.y - linIndep.z*diff.z) / diff.x;
55 else if (diff.y != 0.0)
59 linIndep.y = (-linIndep.x*diff.x - linIndep.z*diff.z) / diff.y;
61 else if (diff.z != 0.0)
65 linIndep.z = (-linIndep.x*diff.x - linIndep.y*diff.y) / diff.z;
73 CVec orth(diff.y * linIndep.z - diff.z * linIndep.y, diff.z * linIndep.x - diff.x - linIndep.z, diff.x * linIndep.y - diff.y * linIndep.w);
75 orth = linIndep ^ diff;
82 pose.
set(linIndep.x, diff.x, orth.
x, 0, linIndep.y, diff.y, orth.
y, 0, linIndep.z, diff.z, orth.
z, 0, 0, 0, 0, 1);
94 file +=
"Separator {\n";
96 file +=
printToString(
"Transform { translation %f %f %f\n rotation %f %f %f %f\n }\n",
97 start.at(0) + (end.at(0) - start.at(0)) / 2, start.at(1) + (end.at(1) - start.at(1)) / 2, start.at(2) + (end.at(2) - start.at(2)) / 2,
98 axis.
x, axis.
y, axis.
z, angle);
100 file +=
"Material { ambientColor 0.6 0.6 0.6 diffuseColor 0.6 0.6 0.6 }\n";
102 file +=
printToString(
"Cylinder { radius %f height %f }\n", width, sqrt(pow(end.at(0) - start.at(0),2) + pow(end.at(1) - start.at(1),2) + pow(end.at(2) - start.at(2),2)));
113 file +=
"Separator {\n";
115 file +=
printToString(
"Transform { scaleFactor %f %f %f }\n", scaleFactor, scaleFactor, scaleFactor);
117 file +=
printToString(
"File { name \"%s\" }\n", ivCoordFilename.c_str());
125 double *st = (
double*)calloc(
dofs,
sizeof(
double));
126 for (
unsigned int i=0; i<
dofs && i<values.size(); i++)
143 file +=
"#Inventor V2.1 ascii\n";
144 file +=
"Separator {\n";
147 file +=
"Separator {\n";
150 file +=
"Sphere { radius 10.0 }\n";
155 if (cameraFrame != NULL)
160 file +=
"Separator {\n";
162 file +=
printToString(
"Transform { translation %f %f %f\n rotation %f %f %f %f\n }\n",
163 pose.
a[12], pose.
a[13], pose.
a[14],
164 axis.
x, axis.
y, axis.
z, angle);
168 file +=
"Material { ambientColor 0.5 0.5 0.5 diffuseColor 0.5 0.5 0.5 }\n";
175 for (
unsigned int i=0; i<
examples.size(); i++)
180 if (
false && tcpFrame != NULL)
185 file +=
"Separator {\n";
187 file +=
printToString(
"Transform { translation %f %f %f\n rotation %f %f %f %f\n }\n",
188 pose.
a[12], pose.
a[13], pose.
a[14],
189 axis.
x, axis.
y, axis.
z, angle);
201 file +=
"Separator {\n";
203 file +=
printToString(
"Transform { translation %f %f %f\n rotation %f %f %f %f\n }\n",
204 pose.
a[12], pose.
a[13], pose.
a[14],
205 axis.
x, axis.
y, axis.
z, angle);
209 file +=
"Material { ambientColor 0.0 0.0 1.0 diffuseColor 0.0 0.0 1.0 }\n";
218 for (
unsigned int j=0; j<
functions.size(); j++)
223 file +=
"Separator {\n";
228 file +=
printToString(
"Transform { translation %f %f %f\n rotation %f %f %f %f\n }\n",
229 pose.
a[12], pose.
a[13], pose.
a[14],
230 axis.
x, axis.
y, axis.
z, angle);
234 file +=
"Material { ambientColor 0.0 0.0 1.0 diffuseColor 0.0 0.0 1.0 }\n";
242 pose =
functions[j]->second->getRelativeToBase();
245 file +=
"Separator {\n";
248 file +=
printToString(
"Transform { translation %f %f %f\n rotation %f %f %f %f\n }\n",
249 pose.
a[12], pose.
a[13], pose.
a[14],
250 axis.
x, axis.
y, axis.
z, angle);
254 file +=
"Material { ambientColor 0.0 1.0 0.0 diffuseColor 0.0 1.0 0.0 }\n";
264 for (
unsigned int j=0; j<
functions.size(); j++)
270 fpos = pose *
functions[j]->first->getRelativeToBase()[3];
271 spos = pose *
functions[j]->second->getRelativeToBase()[3];
274 file +=
"Separator {\n";
278 file +=
"Material { ambientColor 0.0 1.0 0.0 diffuseColor 0.0 1.0 0.0 }\n";
282 file +=
printToString(
"Transform { translation %f %f %f\n }\n",
283 spos.
x, spos.
y, spos.
z);
305 file +=
"Separator {\n";
307 file +=
printToString(
"Transform { translation %f %f %f\n rotation %f %f %f %f\n }\n",
308 pose.
a[12], pose.
a[13], pose.
a[14],
309 axis.
x, axis.
y, axis.
z, angle);
313 file +=
"Material { ambientColor 1.0 0.0 0.0 diffuseColor 1.0 0.0 0.0 }\n";
324 std::ofstream textstream(filename.c_str());
325 if (textstream.fail())
std::string addLine(CVec &first, CVec &second, double width)
std::vector< std::vector< double > > examples
std::string printToString(const char *format,...)
bool getFrameByName(const char *name, CFrame *&frame)
bool generateInventor(std::vector< double > values, std::string filename, std::string ivCoordFilename="data/coord.iv")
virtual CMatrix getRelativeToBase()
Returns pose in the base (frame with no predecessor) frame.
static void getRotationFromMatrix(const CMatrix &mat, CVec &axis, double &angle)
Transforms homogenous matrix into axis-angle representation.
void setData(std::vector< double > &values)
void set(PRECISION x, PRECISION y, PRECISION z)
void set(PRECISION a0, PRECISION a4, PRECISION a8, PRECISION a12, PRECISION a1, PRECISION a5, PRECISION a9, PRECISION a13, PRECISION a2, PRECISION a6, PRECISION a10, PRECISION a14, PRECISION a3=0.0f, PRECISION a7=0.0f, PRECISION a11=0.0f, PRECISION a15=1.0f)
Robot types with implemented inverse kinematics.
std::vector< OptimizerGoalGlobal * > globalFunctions
std::string getInventorCoordinateSystem(double scaleFactor, std::string ivCoordFilename="data/coord.iv")
void invert()
Inverts the matrix (only for homogenous matrices)
std::vector< OptimizerGoal * > functions