This example tests the Jacobian computation associated to the needle insertion models.
#include <visp3/core/vpConfig.h>
#include <iostream>
#include <stdlib.h>
#include <string>
#include <vector>
#include <visp3/core/vpColVector.h>
#include <visp3/core/vpHomogeneousMatrix.h>
#include <visp3/core/vpImage.h>
#include <visp3/core/vpMatrix.h>
#include <visp3/core/vpRGBa.h>
#include <visp3/ustk_needle_modeling/usNeedleInsertionModelRayleighRitzSpline.h>
#include <visp3/ustk_needle_modeling/usNeedleInsertionModelVirtualSprings.h>
#include <visp3/ustk_needle_modeling/usNeedleJacobians.h>
int main()
{
std::cout << "Start test testUsNeedleJacobians" << std::endl;
for(int i=0 ; i<20 ; i++)
{
needleRR.
moveBase(0.0005,0,0.001,0.0001,0,0);
needleVS.
moveBase(0.0005,0,0.001,0.0001,0,0);
}
vpMatrix JRR;
vpMatrix JVS;
std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToWorldTipVelocity<usNeedleInsertionModelRayleighRitzSpline>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToWorldTipVelocity<usNeedleInsertionModelRayleighRitzSpline>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToTipVelocity<usNeedleInsertionModelRayleighRitzSpline>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTipVelocity<usNeedleInsertionModelRayleighRitzSpline>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToWorldTipVelocity<usNeedleInsertionModelVirtualSprings>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToWorldTipVelocity<usNeedleInsertionModelVirtualSprings>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToTipVelocity<usNeedleInsertionModelVirtualSprings>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTipVelocity<usNeedleInsertionModelVirtualSprings>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToBendingEnergy<usNeedleInsertionModelRayleighRitzSpline>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToBendingEnergy<usNeedleInsertionModelRayleighRitzSpline>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToBendingEnergy<usNeedleInsertionModelVirtualSprings>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToBendingEnergy<usNeedleInsertionModelVirtualSprings>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTissueEnergy<usNeedleInsertionModelRayleighRitzSpline>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToTissueEnergy<usNeedleInsertionModelRayleighRitzSpline>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToNeedleInsertionPointVelocity<usNeedleInsertionModelRayleighRitzSpline>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToSurfaceTissueStretch<usNeedleInsertionModelRayleighRitzSpline>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToMaxTissueStretch<usNeedleInsertionModelRayleighRitzSpline>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToMeanTissueStretch<usNeedleInsertionModelRayleighRitzSpline>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTissueEnergy<usNeedleInsertionModelVirtualSprings>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToTissueEnergy<usNeedleInsertionModelVirtualSprings>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToNeedleInsertionPointVelocity<usNeedleInsertionModelVirtualSprings>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToSurfaceTissueStretch<usNeedleInsertionModelVirtualSprings>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToMaxTissueStretch<usNeedleInsertionModelVirtualSprings>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToMeanTissueStretch<usNeedleInsertionModelVirtualSprings>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToPointVelocity<usNeedleInsertionModelRayleighRitzSpline>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToPointVelocity<usNeedleInsertionModelRayleighRitzSpline>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToPointVelocity<usNeedleInsertionModelVirtualSprings>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToPointVelocity<usNeedleInsertionModelVirtualSprings>" << std::endl;
target[0] += 0.01;
target[2] += 0.02;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTransversalTargetDistance<usNeedleInsertionModelRayleighRitzSpline>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTargetAngle<usNeedleInsertionModelRayleighRitzSpline>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTransversalTargetDistance<usNeedleInsertionModelVirtualSprings>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTargetAngle<usNeedleInsertionModelVirtualSprings>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianSpringVelocityToPointVelocity<usNeedleInsertionModelVirtualSprings>" << std::endl;
point[0] += 0.005;
std::vector<vpColVector> points;
for(int i=0 ; i<10 ; i++)
{
point[2] += 0.002;
points.push_back(point);
}
std::cout << "done: usNeedleJacobians::getJacobianSpringVelocityToPointsDistance<usNeedleInsertionModelVirtualSprings>" << std::endl;
std::vector<double> l;
std::cout << "done: usNeedleJacobians::getJacobianRestPathPointVelocityToPointsVelocity<usNeedleInsertionModelRayleighRitzSpline>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianRestPathPointVelocityToPointsDistance<usNeedleInsertionModelRayleighRitzSpline>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianStiffnessPerUnitLengthToPointsDistance<usNeedleInsertionModelRayleighRitzSpline>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianStiffnessPerUnitLengthToPointsDistance<usNeedleInsertionModelVirtualSprings>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianStiffnessPerUnitLengthToPointsVelocity<usNeedleInsertionModelRayleighRitzSpline>" << std::endl;
std::cout << "done: usNeedleJacobians::getJacobianStiffnessPerUnitLengthToPointsVelocity<usNeedleInsertionModelVirtualSprings>" << std::endl;
return 0;
}
int getNbSegments() const
Parameters setters and getters.
vpColVector getPoint(double param) const
Measure curve information.
bool moveBase(const vpColVector &v, double time)
void loadPreset(const ModelPreset preset)
Parameters saving and loading.
bool setBasePose(const vpPoseVector &p)
The following methods should be redefined in the derived classes.
const usTissueModelSpline & accessTissue() const
Tissue parameters.
const usNeedleModelSpline & accessNeedle() const
Parameters setters and getters.
void setPathUpdateType(PathUpdateType type)
Model behavior.
void setSurfaceAtTip()
Control of the tissue.
bool setBasePose(const vpPoseVector &p)
The following methods should be redefined in the derived classes.
void loadPreset(const ModelPreset preset)
Parameters saving and loading.
const usNeedleModelSpline & accessNeedle() const
Model parameters.
vpColVector getTipPosition() const
double getFullLength() const
const usBSpline3D & accessPath() const
bool getJacobianSpringVelocityToPointsDistance(const NeedleInsertionModel &model, vpMatrix &J, int spring, const std::vector< vpColVector > &points)
Springs to distance from points (nbPointsx6)
bool getJacobianBaseVelocityToTissueEnergy(const NeedleInsertionModel &model, vpMatrix &J)
Base to tissue deformation energy (1x6)
bool getJacobianBaseVelocityToTransversalTargetDistance(const NeedleInsertionModel &model, vpMatrix &J, const vpColVector &target)
Base to features (1x6)
bool getJacobianBaseVelocityToTipVelocity(const NeedleInsertionModel &model, vpMatrix &J)
bool getJacobianWorldBaseVelocityToTissueEnergy(const NeedleInsertionModel &model, vpMatrix &J)
bool getJacobianBaseVelocityToPointVelocity(const NeedleInsertionModel &model, vpMatrix &J, double l)
Base to needle point (3x6)
bool getJacobianBaseVelocityToSurfaceTissueStretch(const NeedleInsertionModel &model, vpMatrix &J)
bool getJacobianRestPathPointVelocityToPointsVelocity(const NeedleInsertionModel &model, vpMatrix &J, int restPoint, const std::vector< double > &l)
Rest path points to model point (3x3)
bool getJacobianWorldBaseVelocityToTipVelocity(const NeedleInsertionModel &model, vpMatrix &J)
Base to tip.
bool getJacobianRestPathPointVelocityToPointsDistance(const NeedleInsertionModel &model, vpMatrix &J, int restPoint, const std::vector< vpColVector > &points)
Rest path points distance from points (nbPointsx3)
bool getJacobianBaseVelocityToNeedleInsertionPointVelocity(const NeedleInsertionModel &model, vpMatrix &J)
bool getJacobianBaseVelocityToBendingEnergy(const NeedleInsertionModel &model, vpMatrix &J)
Base to bending energy (1x6)
bool getJacobianSpringVelocityToPointVelocity(const NeedleInsertionModel &model, vpMatrix &J, int spring, double l)
Springs to needle point (3x6)
bool getJacobianWorldBaseVelocityToBendingEnergy(const NeedleInsertionModel &model, vpMatrix &J)
bool getJacobianBaseVelocityToTargetAngle(const NeedleInsertionModel &model, vpMatrix &J, const vpColVector &target)
bool getJacobianWorldBaseVelocityToPointVelocity(const NeedleInsertionModel &model, vpMatrix &J, double l)
bool getJacobianBaseVelocityToMaxTissueStretch(const NeedleInsertionModel &model, vpMatrix &J)
bool getJacobianWorldBaseVelocityToWorldTipVelocity(const NeedleInsertionModel &model, vpMatrix &J)
Base to tip (manipulation Jacobian) (6x6)
bool getJacobianStiffnessPerUnitLengthToPointsVelocity(const NeedleInsertionModel &model, vpMatrix &J, const std::vector< double > &l)
Stiffness per unit length to needle point ( (3*nbPoints)x1 matrix)
bool getJacobianStiffnessPerUnitLengthToPointsDistance(const NeedleInsertionModel &model, vpMatrix &J, const std::vector< vpColVector > &points)
Stiffness per unit length to distance from points (nbPointsx1)
bool getJacobianBaseVelocityToWorldTipVelocity(const NeedleInsertionModel &model, vpMatrix &J)
bool getJacobianBaseVelocityToMeanTissueStretch(const NeedleInsertionModel &model, vpMatrix &J)