Orocos KDL
chainhdsolver_vereshchagin.hpp
1// Copyright (C) 2009 Ruben Smits <ruben dot smits at intermodalics dot eu>
2
3// Version: 1.0
4// Author: Ruben Smits <ruben dot smits at intermodalics dot eu>
5// Author: Herman Bruyninckx
6// Author: Azamat Shakhimardanov
7// Maintainer: Ruben Smits <ruben dot smits at intermodalics dot eu>
8// URL: http://www.orocos.org/kdl
9
10// This library is free software; you can redistribute it and/or
11// modify it under the terms of the GNU Lesser General Public
12// License as published by the Free Software Foundation; either
13// version 2.1 of the License, or (at your option) any later version.
14
15// This library is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18// Lesser General Public License for more details.
19
20// You should have received a copy of the GNU Lesser General Public
21// License along with this library; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
24#ifndef KDL_CHAINHDSOLVER_VERESHCHAGIN_HPP
25#define KDL_CHAINHDSOLVER_VERESHCHAGIN_HPP
26
27#include "chainidsolver.hpp"
28#include "frames.hpp"
29#include "articulatedbodyinertia.hpp"
30
31#include<Eigen/StdVector>
32
33namespace KDL
34{
406
408{
409 typedef std::vector<Twist> Twists;
410 typedef std::vector<Frame> Frames;
411 typedef Eigen::Matrix<double, 6, 1 > Vector6d;
412 typedef Eigen::Matrix<double, 6, 6 > Matrix6d;
413 typedef Eigen::Matrix<double, 6, Eigen::Dynamic> Matrix6Xd;
414
415public:
423 ChainHdSolver_Vereshchagin(const Chain& chain, const Twist &root_acc, const unsigned int nc);
424
428
446 int CartToJnt(const JntArray &q, const JntArray &q_dot, JntArray &q_dotdot, const Jacobian& alfa, const JntArray& beta, const Wrenches& f_ext, const JntArray &ff_torques, JntArray &constraint_torques);
447
450
468 int setDriverWeights(const Eigen::VectorXd& w_f_ext, const Eigen::VectorXd& w_ff_torques);
469
470 //Returns cartesian acceleration of links in base coordinates
471 void getTransformedLinkAcceleration(Twists& x_dotdot);
472
473 // Returns total torque acting on each joint (constraints + nature + external forces)
474 void getTotalTorque(JntArray &total_tau);
475
476 // Returns magnitude of the constraint forces acting on the end-effector: Lagrange Multiplier
477 void getContraintForceMagnitude(Eigen::VectorXd &nu_);
478
479 /*
480 //Returns cartesian positions of links in base coordinates
481 void getLinkCartesianPose(Frames& x_base);
482 //Returns cartesian velocities of links in base coordinates
483 void getLinkCartesianVelocity(Twists& xDot_base);
484 //Returns cartesian acceleration of links in base coordinates
485 void getLinkCartesianAcceleration(Twists& xDotDot_base);
486 //Returns cartesian positions of links in link tip coordinates
487 void getLinkPose(Frames& x_local);
488 //Returns cartesian velocities of links in link tip coordinates
489 void getLinkVelocity(Twists& xDot_local);
490 //Returns cartesian acceleration of links in link tip coordinates
491 void getLinkAcceleration(Twists& xDotdot_local);
492 //Acceleration energy due to unit constraint forces at the end-effector
493 void getLinkUnitForceAccelerationEnergy(Eigen::MatrixXd& M);
494 //Acceleration energy due to arm configuration: bias force plus input joint torques
495 void getLinkBiasForceAcceleratoinEnergy(Eigen::VectorXd& G);
496
497 void getLinkUnitForceMatrix(Matrix6Xd& E_tilde);
498
499 void getLinkBiasForceMatrix(Wrenches& R_tilde);
500
501 void getJointBiasAcceleration(JntArray &bias_q_dotdot);
502 */
503private:
508 void initial_upwards_sweep(const JntArray &q, const JntArray &q_dot, const JntArray &q_dotdot, const Wrenches& f_ext);
513 void downwards_sweep(const Jacobian& alfa, const JntArray& ff_torques);
518 void constraint_calculation(const JntArray& beta);
523 void final_upwards_sweep(JntArray &q_dotdot, JntArray &constraint_torques);
524
525private:
526 const Chain& chain;
527 unsigned int nj;
528 unsigned int ns;
529 unsigned int nc;
530 Twist acc_root;
531 Jacobian alfa_N;
532 Jacobian alfa_N2;
533 Eigen::MatrixXd M_0_inverse;
534 Eigen::MatrixXd Um;
535 Eigen::MatrixXd Vm;
536 JntArray beta_N;
537 Eigen::VectorXd nu;
538 Eigen::VectorXd nu_sum;
539 Eigen::VectorXd Sm;
540 Eigen::VectorXd tmpm;
541 Eigen::VectorXd total_torques; // all the contributions that are felt at the joint: constraints + nature + external forces
542 Wrench qdotdot_sum;
543 Frame F_total;
544 Eigen::VectorXd w_f_ext, w_ff_torques; //per-constraint-direction driver weights, see setDriverWeights
545 Matrix6Xd alpha_root; //alfa in root coordinates, torques above forces
546
547 struct segment_info
548 {
549 Frame F; //local pose with respect to previous link in segments coordinates
550 Frame F_base; // pose of a segment in root coordinates
551 Twist Z; //Unit twist
552 Twist v; //twist
553 Twist acc; //acceleration twist
554 Wrench U; //wrench p of the bias forces (in cartesian space)
555 Wrench R; //wrench p of the bias forces
556 Wrench R_tilde; //vector of wrench p of the bias forces (new) in matrix form
557 Twist C; //constraint
558 Twist A; //constraint
559 ArticulatedBodyInertia H; //I (expressed in 6*6 matrix)
560 ArticulatedBodyInertia P; //I (expressed in 6*6 matrix)
561 ArticulatedBodyInertia P_tilde; //I (expressed in 6*6 matrix)
562 Wrench PZ; //vector U[i] = I_A[i]*S[i]
563 Wrench PC; //vector E[i] = I_A[i]*c[i]
564 double D; //vector D[i] = S[i]^T*U[i]
565 Matrix6Xd E; //matrix with virtual unit constraint force due to acceleration constraints
566 Matrix6Xd E_tilde;
567 Eigen::MatrixXd M; //acceleration energy already generated at link i
568 Eigen::VectorXd G; //magnitude of the constraint forces already generated at link i
569 Eigen::VectorXd EZ; //K[i] = Etiltde'*Z
570 double nullspaceAccComp; //Azamat: constribution of joint space u[i] forces to joint space acceleration
571 double constAccComp; //Azamat: constribution of joint space constraint forces to joint space acceleration
572 double biasAccComp; //Azamat: constribution of joint space bias forces to joint space acceleration
573 double totalBias; //Azamat: R+PC (centrepital+coriolis) in joint subspace
574 double u; //vector u[i] = torques(i) - S[i]^T*(p_A[i] + I_A[i]*C[i]) in joint subspace. Azamat: In code u[i] = torques(i) - s[i].totalBias
575
576 //Per-driver contributions, tracked alongside the totals above so that
577 //constraint_calculation() can credit each driver only partially.
578 //Sum of the channels plus the rigid-body bias terms == the totals.
579 Wrench U_fext, R_fext, R_tilde_fext;
580 Wrench U_ff, R_ff, R_tilde_ff;
581 double u_fext, u_ff;
582 Eigen::VectorXd G_fext, G_ff;
583
584 segment_info(unsigned int nc):
585 D(0),nullspaceAccComp(0),constAccComp(0),biasAccComp(0),totalBias(0),u(0),
586 u_fext(0),u_ff(0)
587 {
588 E.resize(6, nc);
589 E_tilde.resize(6, nc);
590 G.resize(nc);
591 M.resize(nc, nc);
592 EZ.resize(nc);
593 E.setZero();
594 E_tilde.setZero();
595 M.setZero();
596 G.setZero();
597 EZ.setZero();
598 G_fext.resize(nc);
599 G_ff.resize(nc);
600 G_fext.setZero();
601 G_ff.setZero();
602 };
603 };
604
605 std::vector<segment_info, Eigen::aligned_allocator<segment_info> > results;
606
607};
608}
609
610#endif // KDL_CHAINHDSOLVER_VERESHCHAGIN_HPP
6D Inertia of a articulated body
Definition articulatedbodyinertia.hpp:40
void getTotalTorque(JntArray &total_tau)
ChainHdSolver_Vereshchagin(const Chain &chain, const Twist &root_acc, const unsigned int nc)
virtual void updateInternalDataStructures()
int CartToJnt(const JntArray &q, const JntArray &q_dot, JntArray &q_dotdot, const Jacobian &alfa, const JntArray &beta, const Wrenches &f_ext, const JntArray &ff_torques, JntArray &constraint_torques)
~ChainHdSolver_Vereshchagin()
Definition chainhdsolver_vereshchagin.hpp:425
void getContraintForceMagnitude(Eigen::VectorXd &nu_)
void getTransformedLinkAcceleration(Twists &x_dotdot)
int setDriverWeights(const Eigen::VectorXd &w_f_ext, const Eigen::VectorXd &w_ff_torques)
This class encapsulates a serial kinematic interconnection structure. It is built out of segments.
Definition chain.hpp:35
represents a frame transformation in 3D space (rotation + translation)
Definition frames.hpp:572
Definition jacobian.hpp:37
Definition jntarray.hpp:70
Definition solveri.hpp:85
represents both translational and rotational velocities.
Definition frames.hpp:723
represents both translational and rotational acceleration.
Definition frames.hpp:882
Definition articulatedbodyinertia.hpp:32
std::vector< Wrench > Wrenches
Definition chainfdsolver.hpp:34