00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _ROBOT_CONTROL_KINEMATICS_IKOR_
00026 #define _ROBOT_CONTROL_KINEMATICS_IKOR_
00027
00028 #include <robot/control/kinematics/kinematics>
00029
00030 #include <sstream>
00031
00032 #include <robot/KinematicChain>
00033 #include <robot/control/kinematics/InverseKinematicsSolver>
00034 #include <robot/control/kinematics/FullSpaceSolver>
00035 #include <robot/control/kinematics/BetaFormConstraints>
00036
00037
00038
00039 namespace robot {
00040 namespace control {
00041 namespace kinematics {
00042
00043
00044
00045
00046
00047 class IKOR : public InverseKinematicsSolver
00048 {
00049 public:
00050 IKOR(const robot::KinematicChain& chain, const Vector& jointWeights = Vector(),
00051 bool nonHolonomicPlatformActive=false, Real platformL=0);
00052
00053 virtual String className() const { return String("IKOR"); }
00054
00055
00056
00057 void setFullSpaceSolver(ref<FullSpaceSolver> fsp) { solver=fsp; }
00058
00059
00060 class JointLimitBetaConstraint : public BetaFormConstraints::BetaFormConstraint
00061 {
00062 public:
00063 JointLimitBetaConstraint(Int j, Real dist, const Matrix& gs)
00064 : BetaFormConstraint(matrixRow(gs,j)/dist), j(j), dist(dist) { setName(className()); }
00065
00066 JointLimitBetaConstraint(const JointLimitBetaConstraint& jlc)
00067 : BetaFormConstraint(jlc), j(j), dist(dist) {}
00068
00069 virtual String className() const { return String("JointLimitBetaConstraint"); }
00070
00071 Int j;
00072 Real dist;
00073
00074 virtual String toString() const
00075 { return String("j:")+base::intToString(j)+" d:"+base::realToString(dist); }
00076
00077 };
00078
00079
00080 class PushAwayBetaConstraint : public BetaFormConstraints::BetaFormConstraint
00081 {
00082 public:
00083
00084 PushAwayBetaConstraint(Int v, Real Xvx,
00085 const Vector& n, Real L,
00086 const Matrix& gs,
00087 const robot::KinematicChain& chain, const Vector& q);
00088
00089 PushAwayBetaConstraint(const PushAwayBetaConstraint& pac)
00090 : BetaFormConstraint(pac), v(v), Xvx(Xvx), n(n), L(L) {}
00091
00092 virtual String className() const { return String("PushAwayBetaConstraint"); }
00093
00094 Int v;
00095 Real Xvx;
00096 Vector n;
00097 Real L;
00098
00099 virtual String toString() const
00100 { std::ostringstream str;
00101 str << "v:" << v << " Xvx:" << Xvx << " n:" << n << " L:" << L;
00102 return str.str();
00103 }
00104 };
00105
00106
00107 class RankLossBetaConstraint : public BetaFormConstraints::BetaFormConstraint
00108 {
00109 public:
00110 RankLossBetaConstraint(Int row, const Matrix& A, const Vector& b, const Matrix& gs);
00111 RankLossBetaConstraint(const RankLossBetaConstraint& rlc)
00112 : BetaFormConstraint(rlc), row(row) {}
00113
00114 virtual String className() const { return String("RankLossBetaConstraint"); }
00115
00116 Int row;
00117
00118 virtual String toString() const { return String("row:")+base::intToString(row); }
00119 };
00120
00121
00122
00123
00124
00125 virtual Vector solve(const Vector& dx, const Vector& x, const Vector& q,
00126 const base::Matrix& J,
00127 OptimizationMethod optMethod = Lagrangian,
00128 OptimizationCriterion optCriterion = LeastNorm,
00129 OptimizationConstraints optConstraints = OptimizationConstraints(JointLimits),
00130 base::Orient::Representation orientationRepresentation = base::Orient::EulerRPY);
00131
00132 virtual bool isConstraintTypeSupported(OptimizationConstraint optConstraint,
00133 OptimizationMethod optMethod = DefaultMethod,
00134 OptimizationCriterion optCriterion = DefaultCriterion);
00135
00136
00137 virtual void setProximitySensorData(const array<LinkProximityData>& proximityData, Real d);
00138
00139
00140
00141
00142
00143
00144
00145 virtual void setParameter(const String& name, Real value);
00146
00147 protected:
00148 ref<FullSpaceSolver> solver;
00149 robot::KinematicChain chain;
00150 Vector weights;
00151 bool nonHolonomicPlatformActive;
00152 Real L;
00153
00154
00155
00156
00157 array<LinkProximityData> proximitySensorData;
00158 Real d;
00159
00160
00161 void weightedLeastNorm(Matrix& B, Vector& dZr, Vector weights);
00162
00163 void addDependentRowConstraints(const array<Int>& rows, const Matrix& gs, const Matrix& A, const Vector& b, ref<BetaFormConstraints> constraints);
00164 void addJointLimitConstraints(const Matrix& gs, const Vector& q, const Vector& dq, ref<BetaFormConstraints> constraints);
00165
00166 void addNonholonomicConstraint(const Matrix& gs, const Vector& q, ref<BetaFormConstraints> constraints);
00167
00168 void addObstacleAvoidanceConstraints(const Matrix& gs, const Vector& q, const Vector& dq, ref<BetaFormConstraints> constraints);
00169 };
00170
00171
00172 }
00173 }
00174 }
00175
00176 #endif