33 #include <visp3/ustk_needle_modeling/usNeedleModelBaseTip.h>
35 #include <visp3/core/vpException.h>
36 #include <visp3/core/vpExponentialMap.h>
41 : m_basePose(needle.m_basePose), m_worldMbase(needle.m_worldMbase), m_tipPose(needle.m_tipPose),
42 m_worldMtip(needle.m_worldMtip)
94 m_worldMbase.buildFrom(tx, ty, tz, thetax, thetay, thetaz);
117 m_worldMtip.buildFrom(tx, ty, tz, thetax, thetay, thetaz);
140 if (control.size() != 6)
142 vpException::dimensionError,
143 "usNeedleModelBaseTip::moveBase(const vpColVector&, double): invalid control vector dimension, should be 6");
144 if (time <= std::numeric_limits<double>::epsilon())
146 if (control.frobeniusNorm() <= std::numeric_limits<double>::epsilon())
149 vpHomogeneousMatrix Hmotion = vpExponentialMap::direct(control, time);
156 vpHomogeneousMatrix Hmotion(tx, ty, tz, thetax, thetay, thetaz);
163 vpHomogeneousMatrix Hmotion(pose);
171 throw vpException(vpException::dimensionError,
172 "usNeedleModelBaseTip::moveBase(const vpColVector): invalid vector dimension, should be 6");
173 vpHomogeneousMatrix Hmotion(v[0], v[1], v[2], v[3], v[4], v[5]);
188 if (control.size() != 6)
189 throw vpException(vpException::dimensionError,
"usNeedleModelBaseTip::usNeedleModelBaseWorldFrame(const "
190 "vpColVector&, double): invalid control vector dimension, should be "
192 if (time <= std::numeric_limits<double>::epsilon())
194 if (control.frobeniusNorm() <= std::numeric_limits<double>::epsilon())
197 vpHomogeneousMatrix Hmotion = vpExponentialMap::direct(control, time);
205 vpHomogeneousMatrix Hmotion(tx, ty, tz, thetax, thetay, thetaz);
212 vpHomogeneousMatrix Hmotion(pose);
221 vpException::dimensionError,
222 "usNeedleModelBaseTip::moveBaseWorldFrame(const vpColVector&): invalid vector dimension, should be 6");
223 vpHomogeneousMatrix Hmotion(v[0], v[1], v[2], v[3], v[4], v[5]);
236 Hrotation0[0][3] = 0;
237 Hrotation0[1][3] = 0;
238 Hrotation0[2][3] = 0;
240 vpHomogeneousMatrix HmotionBaseFrame = Hrotation0.inverse() * Hmotion * Hrotation0;
247 if (control.size() != 6)
249 vpException::dimensionError,
250 "usNeedleModelBaseTip::moveTip(const vpColVector&, double): invalid control vector dimension, should be 6");
251 if (time <= std::numeric_limits<double>::epsilon())
253 if (control.frobeniusNorm() <= std::numeric_limits<double>::epsilon())
256 vpHomogeneousMatrix Hmotion = vpExponentialMap::direct(control, time);
263 vpHomogeneousMatrix Hmotion(tx, ty, tz, thetax, thetay, thetaz);
270 vpHomogeneousMatrix Hmotion(pose);
278 throw vpException(vpException::dimensionError,
279 "usNeedleModelBaseTip::MoveTip(const vpColVector&): invalid vector dimension, should be 6");
280 vpHomogeneousMatrix Hmotion(v[0], v[1], v[2], v[3], v[4], v[5]);
295 if (control.size() != 6)
296 throw vpException(vpException::dimensionError,
"usNeedleModelBaseTip::moveTipWorldFrame(const vpColVector&, "
297 "double): invalid control vector dimension, should be 6");
298 if (time <= std::numeric_limits<double>::epsilon())
300 if (control.frobeniusNorm() <= std::numeric_limits<double>::epsilon())
303 vpHomogeneousMatrix Hmotion = vpExponentialMap::direct(control, time);
311 vpHomogeneousMatrix Hmotion(tx, ty, tz, thetax, thetay, thetaz);
318 vpHomogeneousMatrix Hmotion(pose);
327 vpException::dimensionError,
328 "usNeedleModelBaseTip::moveTipWorldFrame(const vpColVector&): invalid vector dimension, should be 6");
329 vpHomogeneousMatrix Hmotion(v[0], v[1], v[2], v[3], v[4], v[5]);
342 Hrotation0[0][3] = 0;
343 Hrotation0[1][3] = 0;
344 Hrotation0[2][3] = 0;
346 vpHomogeneousMatrix HmotionBaseFrame = Hrotation0.inverse() * Hmotion * Hrotation0;
348 this->
moveTip(HmotionBaseFrame);
353 s <<
"usNeedleModelBaseTip\n";
354 for (
int i = 0; i < 6; i++)
357 for (
int i = 0; i < 4; i++) {
358 for (
int j = 0; j < 4; j++)
362 for (
int i = 0; i < 6; i++)
365 for (
int i = 0; i < 4; i++) {
366 for (
int j = 0; j < 4; j++)
379 if (c !=
"usNeedleModelBaseTip") {
380 vpException e(vpException::ioError,
"Stream does not contain usNeedleModelBaseTip data");
383 for (
int i = 0; i < 6; i++)
385 for (
int i = 0; i < 4; i++)
386 for (
int j = 0; j < 4; j++)
388 for (
int i = 0; i < 6; i++)
390 for (
int i = 0; i < 4; i++)
391 for (
int j = 0; j < 4; j++)
398 s.write(
"usNeedleModelBaseTip", 21);
399 for (
int i = 0; i < 6; i++)
400 s.write((
char *)&(needle.
m_basePose[i]),
sizeof(
double));
401 for (
int i = 0; i < 4; i++)
402 for (
int j = 0; j < 4; j++)
403 s.write((
char *)&(needle.
m_worldMbase[i][j]),
sizeof(
double));
404 for (
int i = 0; i < 6; i++)
405 s.write((
char *)&(needle.
m_tipPose[i]),
sizeof(
double));
406 for (
int i = 0; i < 4; i++)
407 for (
int j = 0; j < 4; j++)
408 s.write((
char *)&(needle.
m_worldMtip[i][j]),
sizeof(
double));
418 if (strcmp(c,
"usNeedleModelBaseTip")) {
419 vpException e(vpException::ioError,
"Stream does not contain usNeedleModelBaseTip data");
422 for (
int i = 0; i < 6; i++)
423 s.read((
char *)&(needle.
m_basePose[i]),
sizeof(
double));
424 for (
int i = 0; i < 4; i++)
425 for (
int j = 0; j < 4; j++)
426 s.read((
char *)&(needle.
m_worldMbase[i][j]),
sizeof(
double));
427 for (
int i = 0; i < 6; i++)
428 s.read((
char *)&(needle.
m_tipPose[i]),
sizeof(
double));
429 for (
int i = 0; i < 4; i++)
430 for (
int j = 0; j < 4; j++)
431 s.read((
char *)&(needle.
m_worldMtip[i][j]),
sizeof(
double));
vpPoseVector getBasePose() const
Parameters setters and getters.
void setBasePose(double tx, double ty, double tz, double thetax, double thetay, double thetaz)
Command of the needle.
void moveTipWorldFrame(const vpColVector &command, double time)
vpColVector getTipDirection() const
vpColVector getTipPosition() const
vpHomogeneousMatrix getWorldMtip() const
void moveTip(const vpColVector &control, double time)
vpHomogeneousMatrix getWorldMbase() const
vpPoseVector getTipPose() const
vpColVector getBaseDirection() const
virtual usNeedleModelBaseTip * clone() const
usNeedleModelBaseTip()
Constructors, destructors.
vpHomogeneousMatrix m_worldMtip
virtual ~usNeedleModelBaseTip()
void moveBaseWorldFrame(const vpColVector &command, double time)
vpColVector getBasePosition() const
void setTipPose(double tx, double ty, double tz, double thetax, double thetay, double thetaz)
void moveBase(const vpColVector &control, double time)
vpHomogeneousMatrix m_worldMbase
virtual usNeedleModelBaseTip & operator=(const usNeedleModelBaseTip &needle)