62 this->hasEndEffectorVisualizer = endEffector ? true :
false;
65 this->material =
new SoMaterial();
66 this->material->transparency = 0.5;
67 this->material->setOverride(
true);
68 this->addChild(material);
71 if (this->hasEndEffectorVisualizer)
74 VirtualRobot::CoinVisualizationPtr endEffectorVisualization =
75 endEffectorRobot->getVisualization();
76 this->addChild(endEffectorVisualization->getCoinVisualization());
80 SoCube* cube =
new SoCube();
88 this->manip.reset(
new SoTransformerManip());
94 SoSeparator* nullSep =
new SoSeparator;
97 manip->getDragger()->setPart(
"scale1", nullSep);
98 manip->getDragger()->setPart(
"scale2", nullSep);
99 manip->getDragger()->setPart(
"scale3", nullSep);
100 manip->getDragger()->setPart(
"scale4", nullSep);
101 manip->getDragger()->setPart(
"scale5", nullSep);
102 manip->getDragger()->setPart(
"scale6", nullSep);
103 manip->getDragger()->setPart(
"scale7", nullSep);
104 manip->getDragger()->setPart(
"scale8", nullSep);
107 manip->getDragger()->setPart(
"translator1", nullSep);
108 manip->getDragger()->setPart(
"translator2", nullSep);
109 manip->getDragger()->setPart(
"translator3", nullSep);
110 manip->getDragger()->setPart(
"translator4", nullSep);
111 manip->getDragger()->setPart(
"translator5", nullSep);
112 manip->getDragger()->setPart(
"translator6", nullSep);
115 manip->getDragger()->setPart(
"rotator1", nullSep);
116 manip->getDragger()->setPart(
"rotator2", nullSep);
117 manip->getDragger()->setPart(
"rotator3", nullSep);
118 manip->getDragger()->setPart(
"rotator4", nullSep);
119 manip->getDragger()->setPart(
"rotator5", nullSep);
120 manip->getDragger()->setPart(
"rotator6", nullSep);
123 Eigen::Matrix4f globalMat = endEffector->getTcp()->getGlobalPose();
124 if (this->hasEndEffectorVisualizer)
127 this->localTransformation =
128 endEffector->getBase()->getTransformationTo(endEffector->getTcp());
130 globalMat = endEffector->getBase()->getGlobalPose();
135 globalMat(0, 3) /= 1000;
136 globalMat(1, 3) /= 1000;
137 globalMat(2, 3) /= 1000;
138 manip->setMatrix(VirtualRobot::CoinVisualizationFactory::getSbMatrix(globalMat));
139 this->insertChild(manip.get(), 0);
141 this->isVisualizing =
true;
171 SoGetMatrixAction* action =
new SoGetMatrixAction(SbViewportRegion());
173 sa.setNode(manip.get());
174 sa.setSearchingAll(TRUE);
175 SoBaseKit::setSearchingChildren(TRUE);
178 action->apply(sa.getPath());
180 SbMatrix matrix = action->getMatrix();
182 Eigen::Matrix4f mat = Eigen::Matrix4f::Identity();
183 mat(0, 0) = matrix[0][0];
184 mat(0, 1) = matrix[1][0];
185 mat(0, 2) = matrix[2][0];
186 mat(0, 3) = matrix[3][0] * 1000;
188 mat(1, 0) = matrix[0][1];
189 mat(1, 1) = matrix[1][1];
190 mat(1, 2) = matrix[2][1];
191 mat(1, 3) = matrix[3][1] * 1000;
193 mat(2, 0) = matrix[0][2];
194 mat(2, 1) = matrix[1][2];
195 mat(2, 2) = matrix[2][2];
196 mat(2, 3) = matrix[3][2] * 1000;
198 mat(3, 0) = matrix[0][3];
199 mat(3, 1) = matrix[1][3];
200 mat(3, 2) = matrix[2][3];
201 mat(3, 3) = matrix[3][3];
206 if (this->hasEndEffectorVisualizer)
208 mat = mat * this->localTransformation;
214 return Eigen::Matrix4f::Identity();
233 if (this->hasEndEffectorVisualizer)
235 globalPose = globalPose * this->localTransformation.inverse();
237 globalPose(0, 3) /= 1000;
238 globalPose(1, 3) /= 1000;
239 globalPose(2, 3) /= 1000;
240 manip->setMatrix(VirtualRobot::CoinVisualizationFactory::getSbMatrix(globalPose));