33 #ifndef __usNeedleJacobians_h_
34 #define __usNeedleJacobians_h_
39 #include <visp3/core/vpColVector.h>
40 #include <visp3/core/vpExponentialMap.h>
41 #include <visp3/core/vpMatrix.h>
42 #include <visp3/core/vpPoseVector.h>
43 #include <visp3/core/vpRotationMatrix.h>
50 template<
class NeedleInsertionModel>
51 bool getJacobian(NeedleInsertionModel model, std::function<
bool(NeedleInsertionModel&,
const vpColVector&)> InputVectorMethod, std::function<vpColVector(
const NeedleInsertionModel&)> OutputVectorMethod, std::function<vpColVector(
const vpColVector&,
const vpColVector&,
const double step)> DifferenceMethod, vpMatrix &J,
const vpColVector &discretizationStep,
bool centeredDifference=
true);
53 template<
class NeedleInsertionModel>
54 bool getJacobianScalarToScalar(NeedleInsertionModel model, std::function<
bool(NeedleInsertionModel&,
double)> InputScalarMethod, std::function<
double(
const NeedleInsertionModel&)> OutputScalarMethod, vpMatrix &J,
double discretizationStep = 1e-5,
bool centeredDifference=
true);
56 template<
class NeedleInsertionModel>
57 bool getJacobianScalarToVector(NeedleInsertionModel model, std::function<
bool(NeedleInsertionModel&,
double)> InputScalarMethod, std::function<vpColVector(
const NeedleInsertionModel&)> OutputVectorMethod, vpMatrix &J,
double discretizationStep = 1e-5,
bool centeredDifference=
true);
59 template<
class NeedleInsertionModel>
60 bool getJacobianVectorToScalar(NeedleInsertionModel model, std::function<
bool(NeedleInsertionModel&,
const vpColVector&)> InputVectorMethod, std::function<
double(
const NeedleInsertionModel&)> OutputScalarMethod, vpMatrix &J,
const vpColVector &discretizationStep,
bool centeredDifference=
true);
62 template<
class NeedleInsertionModel>
63 bool getJacobianVectorToVector(NeedleInsertionModel model, std::function<
bool(NeedleInsertionModel&,
const vpColVector&)> InputVectorMethod, std::function<vpColVector(
const NeedleInsertionModel&)> OutputVectorMethod, vpMatrix &J,
const vpColVector &discretizationStep,
bool centeredDifference=
true);
65 template<
class NeedleInsertionModel>
66 bool getJacobianVectorToPose(NeedleInsertionModel model, std::function<
bool(NeedleInsertionModel&,
const vpColVector&)> InputVectorMethod, std::function<vpHomogeneousMatrix(
const NeedleInsertionModel&)> OutputVectorMethod, vpMatrix &J,
const vpColVector &discretizationStep,
bool centeredDifference=
true);
70 template<
class NeedleInsertionModel>
73 template<
class NeedleInsertionModel>
76 template<
class NeedleInsertionModel>
79 template<
class NeedleInsertionModel>
84 template<
class NeedleInsertionModel>
87 template<
class NeedleInsertionModel>
92 template<
class NeedleInsertionModel>
95 template<
class NeedleInsertionModel>
98 template<
class NeedleInsertionModel>
101 template<
class NeedleInsertionModel>
104 template<
class NeedleInsertionModel>
107 template<
class NeedleInsertionModel>
112 template<
class NeedleInsertionModel>
115 template<
class NeedleInsertionModel>
120 template<
class NeedleInsertionModel>
123 template<
class NeedleInsertionModel>
128 template<
class NeedleInsertionModel>
133 template<
class NeedleInsertionModel>
138 template<
class NeedleInsertionModel>
143 template<
class NeedleInsertionModel>
148 template<
class NeedleInsertionModel>
153 template<
class NeedleInsertionModel>
162 template<
class NeedleInsertionModel>
163 bool getJacobian(NeedleInsertionModel model, std::function<
bool(NeedleInsertionModel&,
const vpColVector&)> InputVectorMethod, std::function<vpColVector(
const NeedleInsertionModel&)> OutputVectorMethod, std::function<vpColVector(
const vpColVector&,
const vpColVector&,
const double step)> DifferenceMethod, vpMatrix &J,
const vpColVector &discretizationStep,
bool centeredDifference)
167 double stepFactor = (centeredDifference?2:1);
168 NeedleInsertionModel SimulationNeedle(model);
170 int dim = discretizationStep.size();
171 vpColVector test(OutputVectorMethod(SimulationNeedle));
172 vpMatrix M(test.size(), dim);
175 if(!centeredDifference) v2 = OutputVectorMethod(model);
176 for(
int i=0 ; i<dim ; i++)
178 vpColVector input(dim,0);
180 input[i] = discretizationStep[i];
182 SimulationNeedle = model;
183 if(!InputVectorMethod(SimulationNeedle, input))
return false;
185 vpColVector v1 = OutputVectorMethod(SimulationNeedle);
187 if(centeredDifference)
189 input[i] = -discretizationStep[i];
191 SimulationNeedle = model;
192 if(!InputVectorMethod(SimulationNeedle, input))
return false;
194 v2 = OutputVectorMethod(SimulationNeedle);
197 M.insert(DifferenceMethod(v1,v2,stepFactor*discretizationStep[i]), 0,i);
205 template<
class NeedleInsertionModel>
206 bool getJacobianScalarToScalar(NeedleInsertionModel model, std::function<
bool(NeedleInsertionModel&,
double)> InputScalarMethod, std::function<
double(
const NeedleInsertionModel&)> OutputScalarMethod, vpMatrix &J,
double discretizationStep,
bool centeredDifference)
210 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputVectorMethod = [&InputScalarMethod](NeedleInsertionModel& m,
const vpColVector& v)
212 return InputScalarMethod(m, v[0]);
215 std::function<vpColVector(
const NeedleInsertionModel&)> OutputVectorMethod = [&OutputScalarMethod](
const NeedleInsertionModel& m)
217 return vpColVector(1,OutputScalarMethod(m));
220 std::function<vpColVector(
const vpColVector&,
const vpColVector&,
const double step)> DifferenceMethod = [](
const vpColVector& v1,
const vpColVector& v2,
const double step)
222 return 1./step*(v1-v2);
224 vpColVector vectorDiscretizationStep(1,discretizationStep);
226 return getJacobian(model, InputVectorMethod, OutputVectorMethod, DifferenceMethod, J, vectorDiscretizationStep, centeredDifference);
229 template<
class NeedleInsertionModel>
230 bool getJacobianScalarToVector(NeedleInsertionModel model, std::function<
bool(NeedleInsertionModel&,
double)> InputScalarMethod, std::function<vpColVector(
const NeedleInsertionModel&)> OutputVectorMethod, vpMatrix &J,
double discretizationStep,
bool centeredDifference)
234 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputVectorMethod = [&InputScalarMethod](NeedleInsertionModel& m,
const vpColVector& v)
236 return InputScalarMethod(m, v[0]);
239 std::function<vpColVector(
const vpColVector&,
const vpColVector&,
const double step)> DifferenceMethod = [](
const vpColVector& v1,
const vpColVector& v2,
const double step)
241 return 1./step*(v1-v2);
243 vpColVector vectorDiscretizationStep(1,discretizationStep);
245 return getJacobian(model, InputVectorMethod, OutputVectorMethod, DifferenceMethod, J, vectorDiscretizationStep, centeredDifference);
248 template<
class NeedleInsertionModel>
249 bool getJacobianVectorToScalar(NeedleInsertionModel model, std::function<
bool(NeedleInsertionModel&,
const vpColVector&)> InputVectorMethod, std::function<
double(
const NeedleInsertionModel&)> OutputScalarMethod, vpMatrix &J,
const vpColVector &discretizationStep,
bool centeredDifference)
253 std::function<vpColVector(
const NeedleInsertionModel&)> OutputVectorMethod = [&OutputScalarMethod](
const NeedleInsertionModel& m)
255 return vpColVector(1,OutputScalarMethod(m));
258 std::function<vpColVector(
const vpColVector&,
const vpColVector&,
const double step)> DifferenceMethod = [](
const vpColVector& v1,
const vpColVector& v2,
const double step)
260 return 1./step*(v1-v2);
263 return getJacobian(model, InputVectorMethod, OutputVectorMethod, DifferenceMethod, J, discretizationStep, centeredDifference);
266 template<
class NeedleInsertionModel>
267 bool getJacobianVectorToVector(NeedleInsertionModel model, std::function<
bool(NeedleInsertionModel&,
const vpColVector&)> InputVectorMethod, std::function<vpColVector(
const NeedleInsertionModel&)> OutputVectorMethod, vpMatrix &J,
const vpColVector &discretizationStep,
bool centeredDifference)
271 std::function<vpColVector(
const vpColVector&,
const vpColVector&,
const double step)> DifferenceMethod = [](
const vpColVector& v1,
const vpColVector& v2,
const double step)
273 return 1./step*(v1-v2);
276 return getJacobian(model, InputVectorMethod, OutputVectorMethod, DifferenceMethod, J, discretizationStep, centeredDifference);
279 template<
class NeedleInsertionModel>
280 bool getJacobianVectorToPose(NeedleInsertionModel model, std::function<
bool(NeedleInsertionModel&,
const vpColVector&)> InputVectorMethod, std::function<vpHomogeneousMatrix(
const NeedleInsertionModel&)> OutputVectorMethod, vpMatrix &J,
const vpColVector &discretizationStep,
bool centeredDifference)
284 std::function<vpColVector(
const NeedleInsertionModel&)> trueOutputVectorMethod = [&OutputVectorMethod](
const NeedleInsertionModel& m)
286 return vpColVector(vpPoseVector(OutputVectorMethod(m)));
289 std::function<vpColVector(
const vpColVector&,
const vpColVector&,
const double step)> DifferenceMethod = [](
const vpColVector& v1,
const vpColVector& v2,
const double step)
291 vpHomogeneousMatrix H1(v1[0], v1[1], v1[2], v1[3], v1[4], v1[5]);
292 vpHomogeneousMatrix H2(v2[0], v2[1], v2[2], v2[3], v2[4], v2[5]);
293 return vpExponentialMap::inverse(H2.inverse()*H1, step);
296 return getJacobian(model, InputVectorMethod, trueOutputVectorMethod, DifferenceMethod, J, discretizationStep, centeredDifference);
301 template<
class NeedleInsertionModel>
304 vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength());
305 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputFunction = [](NeedleInsertionModel& n,
const vpColVector& v)
307 n.accessNeedle().moveBaseWorldFrame(v);
308 return n.updateState();
310 std::function<vpHomogeneousMatrix(
const NeedleInsertionModel&)> OutputFunction = [](
const NeedleInsertionModel& n)
312 return n.accessNeedle().getWorldMtip();
320 template<
class NeedleInsertionModel>
323 vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength());
324 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputFunction = [](NeedleInsertionModel& n,
const vpColVector& v)
326 n.accessNeedle().moveBase(v);
327 return n.updateState();
329 std::function<vpHomogeneousMatrix(
const NeedleInsertionModel&)> OutputFunction = [](
const NeedleInsertionModel& n)
331 return n.accessNeedle().getWorldMtip();
339 template<
class NeedleInsertionModel>
351 vpRotationMatrix worldRtip(model.accessNeedle().getWorldMtip());
353 vpMatrix Jtranslation(M, 0,0, 3,6);
354 vpMatrix Jrotation(M, 3,0, 3,6);
356 Jtranslation =
static_cast<vpMatrix
>(worldRtip) * Jtranslation;
357 Jrotation =
static_cast<vpMatrix
>(worldRtip) * Jrotation;
360 J.insert(Jtranslation, 0,0);
361 J.insert(Jrotation, 3,0);
367 template<
class NeedleInsertionModel>
379 vpRotationMatrix worldRtip(model.accessNeedle().getWorldMtip());
381 vpMatrix Jtranslation(M, 0,0, 3,6);
382 vpMatrix Jrotation(M, 3,0, 3,6);
384 Jtranslation =
static_cast<vpMatrix
>(worldRtip) * Jtranslation;
385 Jrotation =
static_cast<vpMatrix
>(worldRtip) * Jrotation;
388 J.insert(Jtranslation, 0,0);
389 J.insert(Jrotation, 3,0);
397 template<
class NeedleInsertionModel>
400 vpColVector discretStep(6, 1e-5*model.accessNeedle().getParametricLength());
401 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputFunction = [](NeedleInsertionModel& n,
const vpColVector& v)
403 n.accessNeedle().moveBase(v);
404 return n.updateState();
406 std::function<double(
const NeedleInsertionModel&)> OutputFunction = [](
const NeedleInsertionModel& n){
return n.accessNeedle().getBendingEnergy();};
410 template<
class NeedleInsertionModel>
413 vpColVector discretStep(6, 1e-5*model.accessNeedle().getParametricLength());
414 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputFunction = [](NeedleInsertionModel& n,
const vpColVector& v)
416 n.accessNeedle().moveBaseWorldFrame(v);
417 return n.updateState();
419 std::function<double(
const NeedleInsertionModel&)> OutputFunction = [](
const NeedleInsertionModel& n){
return n.accessNeedle().getBendingEnergy();};
425 template<
class NeedleInsertionModel>
428 vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength());
429 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputFunction = [](NeedleInsertionModel& n,
const vpColVector& v)
431 n.accessNeedle().moveBase(v);
432 return n.updateState();
434 std::function<double(
const NeedleInsertionModel&)> OutputFunction = [](
const NeedleInsertionModel& n){
return n.getTissueDeformationEnergy();};
438 template<
class NeedleInsertionModel>
441 vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength());
442 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputFunction = [](NeedleInsertionModel& n,
const vpColVector& v)
444 n.accessNeedle().moveBase(v);
445 return n.updateState();
447 std::function<double(
const NeedleInsertionModel&)> OutputFunction = [](
const NeedleInsertionModel& n){
return n.getTissueDeformationEnergy();};
451 template<
class NeedleInsertionModel>
454 vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength());
455 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputFunction = [](NeedleInsertionModel& n,
const vpColVector& v)
457 n.accessNeedle().moveBase(v);
458 return n.updateState();
460 std::function<vpColVector(
const NeedleInsertionModel&)> OutputFunction = [](
const NeedleInsertionModel& n){
return n.getNeedleInsertionPoint();};
464 template<
class NeedleInsertionModel>
467 vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength());
468 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputFunction = [](NeedleInsertionModel& n,
const vpColVector& v)
470 n.accessNeedle().moveBase(v);
471 return n.updateState();
473 std::function<vpColVector(
const NeedleInsertionModel&)> OutputFunction = [](
const NeedleInsertionModel& n)
475 vpColVector baseForceTorque = n.accessNeedle().getBaseStaticTorsor();
476 vpRotationMatrix bRw = n.accessNeedle().getWorldMbase().getRotationMatrix().inverse();
477 baseForceTorque.insert(0, bRw * vpColVector(baseForceTorque, 0,3));
478 baseForceTorque.insert(3, bRw * vpColVector(baseForceTorque, 3,3));
479 return baseForceTorque;
484 template<
class NeedleInsertionModel>
487 vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength());
488 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputFunction = [](NeedleInsertionModel& n,
const vpColVector& v)
490 n.accessNeedle().moveBase(v);
491 return n.updateState();
493 std::function<double(
const NeedleInsertionModel&)> OutputFunction = [](
const NeedleInsertionModel& n){
return n.getInsertionDepth();};
497 template<
class NeedleInsertionModel>
500 vpColVector e = model.getNeedleInsertionPoint() - model.getTissueInsertionPoint();
501 double norm = e.frobeniusNorm();
502 if(norm <= std::numeric_limits<double>::epsilon())
return false;
514 template<
class NeedleInsertionModel>
517 vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength());
518 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputFunction = [](NeedleInsertionModel& n,
const vpColVector& v)
520 n.accessNeedle().moveBase(v);
521 return n.updateState();
523 std::function<double(
const NeedleInsertionModel&)> OutputFunction = [](
const NeedleInsertionModel& n){
return n.getMaxTissueStretch();};
527 template<
class NeedleInsertionModel>
530 vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength());
531 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputFunction = [](NeedleInsertionModel& n,
const vpColVector& v)
533 n.accessNeedle().moveBase(v);
534 return n.updateState();
536 std::function<double(
const NeedleInsertionModel&)> OutputFunction = [](
const NeedleInsertionModel& n){
return n.getMeanTissueStretch();};
542 template<
class NeedleInsertionModel>
545 vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength());
546 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputFunction = [](NeedleInsertionModel& n,
const vpColVector& v)
548 n.accessNeedle().moveBase(v);
549 return n.updateState();
551 std::function<vpColVector(
const NeedleInsertionModel&)> OutputFunction = [l](
const NeedleInsertionModel& n){
return n.accessNeedle().getPoint(l);};
555 template<
class NeedleInsertionModel>
558 vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength());
559 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputFunction = [](NeedleInsertionModel& n,
const vpColVector& v)
561 n.accessNeedle().moveBaseWorldFrame(v);
562 return n.updateState();
564 std::function<vpColVector(
const NeedleInsertionModel&)> OutputFunction = [l](
const NeedleInsertionModel& n){
return n.accessNeedle().getPoint(l);};
570 template<
class NeedleInsertionModel>
573 vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength());
574 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputFunction = [](NeedleInsertionModel& n,
const vpColVector& v)
576 n.accessNeedle().moveBase(v);
577 return n.updateState();
579 std::function<double(
const NeedleInsertionModel&)> OutputFunction = [target](
const NeedleInsertionModel& n)
583 v = n.accessNeedle().getWorldMtip().inverse()*v;
584 return sqrt(v[0]*v[0]+v[1]*v[1]);
589 template<
class NeedleInsertionModel>
592 vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength());
593 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputFunction = [](NeedleInsertionModel& n,
const vpColVector& v)
595 n.accessNeedle().moveBase(v);
596 return n.updateState();
598 std::function<double(
const NeedleInsertionModel&)> OutputFunction = [target](
const NeedleInsertionModel& n)
602 v = n.accessNeedle().getWorldMtip().inverse()*v;
603 return atan2(sqrt(v[0]*v[0]+v[1]*v[1]),v[2]);
610 template<
class NeedleInsertionModel>
613 vpColVector discretStep(3, 1e-6);
614 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputFunction = [spring](NeedleInsertionModel& n,
const vpColVector& v){
return n.moveSpringPosition(spring, v,
true);};
615 std::function<vpColVector(
const NeedleInsertionModel&)> OutputFunction = [l](
const NeedleInsertionModel& n){
return n.accessNeedle().getPoint(l);};
621 template<
class NeedleInsertionModel>
624 vpColVector discretStep(3, 1e-6);
625 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputFunction = [spring](NeedleInsertionModel& n,
const vpColVector& v){
return n.moveSpringPosition(spring, v,
true);};
626 std::function<vpColVector(
const NeedleInsertionModel&)> OutputFunction = [points](
const NeedleInsertionModel& n)
628 int m = points.size();
630 for(
int i=0 ; i<m ; i++)
632 P[i] = n.accessNeedle().getDistanceFromPoint(points.at(i));
641 template<
class NeedleInsertionModel>
644 vpColVector discretStep(3, 1e-6);
645 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputFunction = [restPoint](NeedleInsertionModel& n,
const vpColVector& v)
647 int m = n.accessTissue().accessPath().getNbSegments()+1;
648 if(restPoint<0 || restPoint>=m || v.size()!=3)
return false;
649 std::vector<vpColVector> P(m);
650 std::vector<double> lengths(m-1);
651 for(
int i=0 ; i<m-1 ; i++)
653 P.at(i) = n.accessTissue().accessPath().accessSegment(i).getStartPoint();
654 lengths.at(i) = n.accessTissue().accessPath().accessSegment(i).getParametricLength();
656 P.back() = n.accessTissue().accessPath().accessLastSegment().getEndPoint();
658 P.at(restPoint) += v;
659 n.accessTissue().accessPath().defineFromPoints(P,lengths,1);
663 std::function<vpColVector(
const NeedleInsertionModel&)> OutputFunction = [l](
const NeedleInsertionModel& n)
666 vpColVector P(3*m,1);
667 for(
int i=0 ; i<m ; i++)
669 P.insert(3*i, n.accessNeedle().getPoint(l.at(i)));
678 template<
class NeedleInsertionModel>
681 vpColVector discretStep(3, 1e-6);
682 std::function<bool(NeedleInsertionModel&,
const vpColVector&)> InputFunction = [restPoint](NeedleInsertionModel& n,
const vpColVector& v)
684 int m = n.accessTissue().accessPath().getNbSegments()+1;
685 if(restPoint<0 || restPoint>=m || v.size()!=3)
return false;
686 std::vector<vpColVector> P(m);
687 std::vector<double> lengths(m-1);
688 for(
int i=0 ; i<m-1 ; i++)
690 P.at(i) = n.accessTissue().accessPath().accessSegment(i).getStartPoint();
691 lengths.at(i) = n.accessTissue().accessPath().accessSegment(i).getParametricLength();
693 P.back() = n.accessTissue().accessPath().accessLastSegment().getEndPoint();
695 P.at(restPoint) += v;
699 std::function<vpColVector(
const NeedleInsertionModel&)> OutputFunction = [points](
const NeedleInsertionModel& n)
701 int m = points.size();
703 for(
int i=0 ; i<m ; i++)
705 P[i] = n.accessNeedle().getDistanceFromPoint(points.at(i));
714 template<
class NeedleInsertionModel>
717 double discretStep = 0.01*model.getStiffnessPerUnitLength();
718 std::function<bool(NeedleInsertionModel&,
double)> InputFunction = [](NeedleInsertionModel& n,
double dK)
720 n.setStiffnessPerUnitLength(n.getStiffnessPerUnitLength()+dK);
721 return n.updateState();
723 std::function<vpColVector(
const NeedleInsertionModel&)> OutputFunction = [points](
const NeedleInsertionModel& n)
725 vpColVector d(points.size());
726 for(
unsigned int i=0 ; i<points.size() ; i++) d[i] = n.accessNeedle().getDistanceFromPoint(points.at(i));
734 template<
class NeedleInsertionModel>
737 double discretStep = 0.01*model.getStiffnessPerUnitLength();
738 std::function<bool(NeedleInsertionModel&,
double)> InputFunction = [](NeedleInsertionModel& n,
double dK)
740 n.setStiffnessPerUnitLength(n.getStiffnessPerUnitLength()+dK);
741 return n.updateState();
743 std::function<vpColVector(
const NeedleInsertionModel&)> OutputFunction = [l](
const NeedleInsertionModel& n)
746 vpColVector P(3*m,1);
747 for(
int i=0 ; i<m ; i++)
749 P.insert(3*i, n.accessNeedle().getPoint(l.at(i)));
758 template<
class NeedleInsertionModel>
761 double discretStep = 0.01*model.getStiffnessPerUnitLength(i);
762 std::function<bool(NeedleInsertionModel&,
double)> InputFunction = [i](NeedleInsertionModel& n,
double dK)
764 n.setStiffnessPerUnitLength(i, n.getStiffnessPerUnitLength(i)+dK);
765 return n.updateState();
767 std::function<vpColVector(
const NeedleInsertionModel&)> OutputFunction = [l](
const NeedleInsertionModel& n)
770 vpColVector P(3*m,1);
771 for(
int i=0 ; i<m ; i++)
773 P.insert(3*i, n.accessNeedle().getPoint(l.at(i)));
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 getJacobianBaseVelocityToInsertionLength(const NeedleInsertionModel &model, vpMatrix &J)
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 getJacobianScalarToVector(NeedleInsertionModel model, std::function< bool(NeedleInsertionModel &, double)> InputScalarMethod, std::function< vpColVector(const NeedleInsertionModel &)> OutputVectorMethod, vpMatrix &J, double discretizationStep=1e-5, bool centeredDifference=true)
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 getJacobianVectorToVector(NeedleInsertionModel model, std::function< bool(NeedleInsertionModel &, const vpColVector &)> InputVectorMethod, std::function< vpColVector(const NeedleInsertionModel &)> OutputVectorMethod, vpMatrix &J, const vpColVector &discretizationStep, bool centeredDifference=true)
bool getJacobianScalarToScalar(NeedleInsertionModel model, std::function< bool(NeedleInsertionModel &, double)> InputScalarMethod, std::function< double(const NeedleInsertionModel &)> OutputScalarMethod, vpMatrix &J, double discretizationStep=1e-5, bool centeredDifference=true)
bool getJacobianWorldBaseVelocityToTipVelocity(const NeedleInsertionModel &model, vpMatrix &J)
Base to tip.
bool getJacobianVectorToScalar(NeedleInsertionModel model, std::function< bool(NeedleInsertionModel &, const vpColVector &)> InputVectorMethod, std::function< double(const NeedleInsertionModel &)> OutputScalarMethod, vpMatrix &J, const vpColVector &discretizationStep, bool centeredDifference=true)
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 getJacobian(NeedleInsertionModel model, std::function< bool(NeedleInsertionModel &, const vpColVector &)> InputVectorMethod, std::function< vpColVector(const NeedleInsertionModel &)> OutputVectorMethod, std::function< vpColVector(const vpColVector &, const vpColVector &, const double step)> DifferenceMethod, vpMatrix &J, const vpColVector &discretizationStep, bool centeredDifference=true)
Generic Jacobians.
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 getJacobianBaseVelocityToBaseForceTorque(const NeedleInsertionModel &model, vpMatrix &J)
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)
bool getJacobianVectorToPose(NeedleInsertionModel model, std::function< bool(NeedleInsertionModel &, const vpColVector &)> InputVectorMethod, std::function< vpHomogeneousMatrix(const NeedleInsertionModel &)> OutputVectorMethod, vpMatrix &J, const vpColVector &discretizationStep, bool centeredDifference=true)