33 #include <visp3/ustk_needle_modeling/usTissueTranslationEstimatorUKF.h>
35 #include <visp3/ustk_core/usGeometryTools.h>
40 m_var_measure_p(1e-3),
41 m_var_measure_d(1e-3),
42 m_var_measure_f(1e-3),
43 m_var_measure_t(1e-6),
44 m_var_process_p(1e-3),
181 for (
int i = 0; i < 3; i++) p[i] =
m_state[i];
188 if ((vpColVector(
m_state, 0, 3) - vpColVector(vpColVector(
m_needle.
accessTissue().
getPose()), 0, 3)).frobeniusNorm() > std::numeric_limits<double>::epsilon()) std::cout <<
"usTissueTranslationEstimatorUKF::checkConsistency: the state does not correspond to the needle model, make sure you used the method 'setCurrentNeedle' to initialize the state" << std::endl;
191 if (measure.size() % 3 != 0)
throw vpException(vpException::notInitialized,
"usTissueTranslationEstimatorUKF::checkConsistency: measure is set as needle body points, but the mesure dimension is not a multiple of 3");
201 vpMatrix normalizedCovarianceMatrix;
202 normalizedCovarianceMatrix.eye(3);
206 normalizedCovarianceMatrix = normalizedCovarianceMatrix - d_ins * d_ins.t();
238 for (
int i = 0; i < 3; i++) {
247 for (
int i = 0; i < 3; i++) {
265 vpColVector propagatedSigmaPoint(sigmaPoint);
266 for (
int i = 0; i < 3; i++) propagatedSigmaPoint[i] +=
m_propagationTime * propagatedSigmaPoint[i + 3];
267 return propagatedSigmaPoint;
285 std::vector<int> index(nbPoints);
286 std::vector<double> l(nbPoints);
287 for (
int i = 0; i < nbPoints; i++) {
292 testNeedle.
accessTissue().
setPose(vpPoseVector(sigmaPoint[0], sigmaPoint[1], sigmaPoint[2], p[3], p[4], p[5]));
305 testNeedle.
accessTissue().
setPose(vpPoseVector(sigmaPoint[0], sigmaPoint[1], sigmaPoint[2], p[3], p[4], p[5]));
308 vpColVector measure(6);
319 testNeedle.
accessTissue().
setPose(vpPoseVector(sigmaPoint[0], sigmaPoint[1], sigmaPoint[2], p[3], p[4], p[5]));
328 throw vpException(vpException::notImplementedError,
"usTissueTranslationEstimatorUKF::computeMeasureFromSigmaPoint: measure type not implemented");
338 return vpColVector(state, 0, 3).frobeniusNorm();
342 return vpColVector(state, 0, 3).frobeniusNorm() +
m_propagationTime * vpColVector(state, 3, 3).frobeniusNorm();
346 return state.frobeniusNorm();
360 vpColVector measureL(6);
361 for (
int i = 0; i < 3; i++) measureL[i] = measure[i];
363 vpColVector d_init(measureCenter, 3, 3);
364 vpColVector d(measure, 3, 3);
365 double angle = fabs(atan2(vpColVector::crossProd(d_init, d).frobeniusNorm(), vpColVector::dotProd(d_init, d)));
366 measureL.insert(3, angle * vpColVector::crossProd(d_init, d).normalize());
const usPolynomialCurve3D & accessSegment(int i) const
const usTissueModelSpline & accessTissue() const
Tissue parameters.
const usNeedleModelSpline & accessNeedle() const
Parameters setters and getters.
virtual bool updateState()
bool IsNeedleInserted() const
Model parameters.
vpColVector getTipDirection() const
vpColVector getTipPosition() const
vpColVector getBaseStaticTorsor() const
Force at base.
vpColVector getDirection() const
vpPoseVector getPose() const
vpColVector getPoint(double parameter) const
bool setPose(const vpPoseVector &p)
vpPoseVector getPose() const
const usOrientedPlane3D & accessSurface() const
Parameters setters and getters.
void setTissuePositionProcessNoiseVariance(double sigma)
void setStateDynamicsType(StateDynamicsType type)
vpColVector propagateSigmaPoint(const vpColVector &sigmaPoint)
usTissueTranslationEstimatorUKF()
void setPropagationTime(double time)
void setPositionMeasureNoiseVariance(double sigma)
vpColVector measureLog(const vpColVector &measure, const vpColVector &measureCenter) const
void setTipDirectionMeasureNoiseVariance(double sigma)
void computeProcessNoiseCovarianceMatrix()
double getForceMeasureNoiseVariance() const
~usTissueTranslationEstimatorUKF()
usNeedleInsertionModelRayleighRitzSpline m_needle
void setTorqueMeasureNoiseVariance(double sigma)
vpColVector computeMeasureFromSigmaPoint(const vpColVector &sigmaPoint)
void setCurrentNeedle(const usNeedleInsertionModelRayleighRitzSpline &needle)
void setMeasureType(MeasureType type)
void computeMeasureNoiseCovarianceMatrix()
MeasureType m_measureType
void applyStateToNeedle(usNeedleInsertionModelRayleighRitzSpline &needle) const
double getTorqueMeasureNoiseVariance() const
@ LATERAL_TRANSLATIONS_ONLY
bool checkConsistency(const vpColVector &measure)
double getTipDirectionMeasureNoiseVariance() const
void setTissueVelocityProcessNoiseVariance(double sigma)
double getTissuePositionProcessNoiseVariance() const
void setTissueTranslationType(TissueTranslationType type)
double getPositionMeasureNoiseVariance() const
StateDynamicsType getStateDynamicsType() const
TissueTranslationType m_tissueTranslationType
@ TIP_POSITION_AND_DIRECTION
void setForceMeasureNoiseVariance(double sigma)
MeasureType getMeasureType() const
double stateNorm(const vpColVector &state) const
TissueTranslationType getTissueTranslationType() const
StateDynamicsType m_stateDynamicsType
double getTissueVelocityProcessNoiseVariance() const
bool m_computeMeasureNoiseCovarianceMatrixAutomatically
void setMeasureDimension(int dim)
vpMatrix m_measureNoiseCovarianceMatrix
bool m_computeProcessNoiseCovarianceMatrixAutomatically
virtual bool checkConsistency(const vpColVector &measure)
void setMeasureNoiseDimension(int dim)
void setStateDimension(int dim)
unsigned int m_measureDimension
vpMatrix m_processNoiseCovarianceMatrix