RML  1.0
Robotics Mathematical Library
Loading...
Searching...
No Matches
ArmModel.h
Go to the documentation of this file.
1
8#ifndef __ARMMODEL_H__
9#define __ARMMODEL_H__
10
11#include "RMLExceptions.h"
12#include "RobotLink.h"
13#include "Types.h"
14#include <algorithm>
15#include <eigen3/Eigen/Dense>
16#include <unordered_map>
17#include <vector>
18
19namespace rml {
20
21//typedef std::pair<int, Eigen::TransformationMatrix> IndexedTMat;
22typedef std::pair<std::string, Eigen::TransformationMatrix> IndexedTMat;
23
55class ArmModel {
56public:
61 ArmModel(const std::string id) noexcept(false);
65 virtual ~ArmModel();
75 void AddJointLink(JointType type, const Eigen::Vector3d& axis, const Eigen::TransformationMatrix& baseTransf, double jointLimMin, double jointLimMax);
90 virtual void JointsPosition(const Eigen::VectorXd q) noexcept(false);
95 virtual auto JointsPosition() const -> const Eigen::VectorXd& { return q_moving_; }
100 virtual void JointsVelocity(const Eigen::VectorXd qdot) noexcept(false);
105 virtual auto JointsVelocity() const -> const Eigen::VectorXd& { return q_dot_moving_; }
110 void JointsAcceleration(const Eigen::VectorXd qddot) noexcept(false);
115 auto JointsAcceleration() const -> const Eigen::VectorXd& { return q_ddot_moving_; }
122 void AttachRigidBodyFrame(std::string frameID, std::string attachedFrameID, Eigen::TransformationMatrix attachedFrameID_T_frameID) noexcept(false);
130 /*
131 * For CartesianJacobian, TransformationMatrix, Jacobian and ManipulabilityJacobian the id must be provieded according the following logic:
132 *
133 * * Joint Frame: armID + FrameID::Joint + joint°;
134 *
135 * * Rigid Body: armID + "_" + frameID
136 */
137 Eigen::TransformationMatrix TransformationMatrix(const std::string& frameID) noexcept(false);
144 Eigen::TransformationMatrix TransformationMatrix(const std::string& frameID_j, const std::string& frameID_k);
150 virtual Eigen::MatrixXd Jacobian(const std::string& frameID) noexcept(false);
156 Eigen::MatrixXd ManipulabilityJacobian(const std::string& frameID);
161 virtual auto NumJoints() const -> unsigned int { return movingNumJoints_; }
166 auto dJdq() const -> const std::vector<Eigen::MatrixXd>& { return dJdq_; }
172 RobotLink& Link(int jointIndex) noexcept(false);
176 auto IsModelInitialized() const -> bool { return modelInitialized_; }
181 auto ControlVector() const -> const Eigen::VectorXd& { return controlRef_; }
186 void ControlVector(const Eigen::VectorXd controlRef) noexcept(false);
191 double Manipulability(const std::string& frameID);
197 Eigen::MatrixXd DexterityJacobian(const std::string& frameID);
202 double Dexterity(const std::string& frameID);
207 auto ID() const -> const std::string& { return id_; }
212 auto ID() -> std::string& { return id_; }
213
218 std::vector<std::string> GetRigidBodyFrameIDs() const noexcept;
219
224 std::vector<std::string> GetJointFrameIDs() const noexcept;
225
230 std::vector<std::string> GetJacobianFrameIDs() const noexcept;
231
236 std::string GetEndEffectorFrameID() const noexcept;
237
238protected:
246 virtual void EvaluatedJdqNumeric();
251 virtual Eigen::MatrixXd EvaluateManipulability(const std::string& frameID);
256 virtual Eigen::MatrixXd EvaluateDexterity(const std::string& frameID);
268 Eigen::MatrixXd EvaluateRigidBodyJacobian(const std::string& frameID);
275 Eigen::MatrixXd EvaluateBase2JointJacobian(unsigned int jointIndex);
280 void ForwardDirectGeometry(unsigned int jointNumber);
286 void BackwardDirectGeometry(unsigned int jointNumber, unsigned int endEffectorIndex);
287
290 unsigned int totalNumJoints_; //<! links number (fixedLink+movingJoints)
291 unsigned int movingNumJoints_;
292 std::vector<unsigned int> movingJoints_;
293 std::vector<RobotLink> links_;
294 std::unordered_map<std::string, IndexedTMat> rigidBodyFrames_; //<! map of the attached body frames
295 std::unordered_map<std::string, Eigen::MatrixXd> jacobians_; //<! map of the jacobians
296 std::unordered_map<std::string, Eigen::TransformationMatrix> transformation_; //<! map of the transformations
297 std::unordered_map<std::string, Eigen::MatrixXd> manipulabilityJacobians_;
298 std::unordered_map<std::string, double> manipulability_;
299 Eigen::VectorXd q_total_; //<! vector of links position
300 Eigen::VectorXd q_moving_; //<! vector of moving joints position
301 Eigen::VectorXd q_dot_moving_; //<! vector of moving joints velocity
302 Eigen::VectorXd q_ddot_moving_; //<! vector of moving joints acceleration
303 Eigen::VectorXd controlRef_; //<! control vector
304 std::vector<Eigen::TransformationMatrix> baseTei_; //<! vector of transformation matrix from base to joint ??
305 std::vector<Eigen::TransformationMatrix> biTei_; //<! vector of transformation matrix from joint i-1 to joint i ??
306 Eigen::TransformationMatrix baseTbi_; //<! transformation matrix from base to joint i ??
308 Eigen::Vector3d base_ki_;
309 std::vector<Eigen::Vector6d> h_;
310 std::vector<Eigen::MatrixXd> dJdq_;
311 Eigen::MatrixXd djdqJpinv_;
312 Eigen::RotationMatrix I3_;
314 std::string id_;
315 std::unordered_map<std::string, Eigen::MatrixXd> dexterityJacobians_;
316 std::unordered_map<std::string, double> dexterity_;
317 Eigen::MatrixXd Jdjdq_;
319};
320}
321
322#endif /* __ARMMODEL_H__ */
This class extends the Eigen::Matrix4d.
Definition TransfMatrix.h:26
Arm Model class for serial kinematic chains (manipulators).
Definition ArmModel.h:55
std::vector< unsigned int > movingJoints_
vector containing the indexes of the moving joints
Definition ArmModel.h:292
virtual void JointsVelocity(const Eigen::VectorXd qdot) noexcept(false)
Set the moving joints velocity.
unsigned int movingNumJoints_
moving joints number
Definition ArmModel.h:291
void AddFixedLink(const Eigen::TransformationMatrix &baseTransf)
Adds a fixed link to the kinematic chain of the model.
auto ID() const -> const std::string &
Method returning the arm id.
Definition ArmModel.h:207
Eigen::VectorXd q_ddot_moving_
Definition ArmModel.h:302
auto ControlVector() const -> const Eigen::VectorXd &
Method returning the arm control vector.
Definition ArmModel.h:181
void ControlVector(const Eigen::VectorXd controlRef) noexcept(false)
Method setting the arm control vector.
Eigen::MatrixXd EvaluateBase2JointJacobian(unsigned int jointIndex)
Evaluates the jacobian matrix (w.r.t. robot base) of the specified joint.
std::string GetEndEffectorFrameID() const noexcept
Method returning the end-effector frame ID.
virtual ~ArmModel()
Default destructor.
virtual void JointsPosition(const Eigen::VectorXd q) noexcept(false)
Set the joint position.
double Manipulability(const std::string &frameID)
Method returning the arm manipulability.
std::vector< std::string > GetRigidBodyFrameIDs() const noexcept
Method returning the list of rigid body frame IDs.
std::string id_
arm id
Definition ArmModel.h:314
Eigen::TransformationMatrix Tz_
transformation matrix for rotation or prismatic joint
Definition ArmModel.h:307
std::unordered_map< std::string, IndexedTMat > rigidBodyFrames_
Definition ArmModel.h:294
void EvaluateTotalForwardGeometry()
Method evaluating the total forward geometry for the arm.
std::vector< std::string > GetJacobianFrameIDs() const noexcept
Method returning the list of Jacobian frame IDs.
auto IsModelInitialized() const -> bool
Method returning true if the model is initialized false otherwise.
Definition ArmModel.h:176
ArmModel(const std::string id) noexcept(false)
Default constructor.
bool modelInitialized_
boolean stating whether the model is initialized
Definition ArmModel.h:288
std::vector< RobotLink > links_
vector of the arm links
Definition ArmModel.h:293
Eigen::TransformationMatrix TransformationMatrix(const std::string &frameID) noexcept(false)
Method returning the transformation matrix related to the input frameID wrt to the arm base.
virtual Eigen::MatrixXd Jacobian(const std::string &frameID) noexcept(false)
Method returning the jacobian related to the input frameID wrt to the arm base.
Eigen::VectorXd q_total_
Definition ArmModel.h:299
std::unordered_map< std::string, Eigen::MatrixXd > dexterityJacobians_
map of the manipulability jacobians
Definition ArmModel.h:315
bool modelReadFromFile_
boolean stating whether the model is read from file
Definition ArmModel.h:313
Eigen::TransformationMatrix EvaluateRigidBodyTransf(const std::string &frameID)
Method returning the attached body frame wrt to the arm base.
std::unordered_map< std::string, double > manipulability_
map of the manipulability values
Definition ArmModel.h:298
Eigen::VectorXd q_dot_moving_
Definition ArmModel.h:301
Eigen::TransformationMatrix TransformationMatrix(const std::string &frameID_j, const std::string &frameID_k)
Method returing a transformation matrix from frameID_j to frameID_k, i.e. jTk.
std::vector< Eigen::TransformationMatrix > baseTei_
Definition ArmModel.h:304
std::unordered_map< std::string, Eigen::MatrixXd > jacobians_
Definition ArmModel.h:295
void AddJointLink(JointType type, const Eigen::Vector3d &axis, const Eigen::TransformationMatrix &baseTransf, double jointLimMin, double jointLimMax)
Adds a link to the kinematic chain of the model.
std::unordered_map< std::string, Eigen::MatrixXd > manipulabilityJacobians_
map of the manipulability jacobians
Definition ArmModel.h:297
virtual Eigen::MatrixXd EvaluateManipulability(const std::string &frameID)
Evaluates the manipulability measure and its Jacobian This method returns the manipulability measure ...
Eigen::VectorXd q_moving_
Definition ArmModel.h:300
std::vector< Eigen::MatrixXd > dJdq_
dJdq evaluated numerically
Definition ArmModel.h:310
Eigen::MatrixXd Jdjdq_
jacobian * djdq
Definition ArmModel.h:317
void AttachRigidBodyFrame(std::string frameID, std::string attachedFrameID, Eigen::TransformationMatrix attachedFrameID_T_frameID) noexcept(false)
Method adding a rigid body frame to a joint.
RobotLink & Link(int jointIndex) noexcept(false)
Method returning the arm link.
auto dJdq() const -> const std::vector< Eigen::MatrixXd > &
Method returning dJdq evaluated numerically.
Definition ArmModel.h:166
virtual void EvaluatedJdqNumeric()
Evaluates numerically the Jacobian derivative w.r.t. joint variations.
virtual Eigen::MatrixXd EvaluateDexterity(const std::string &frameID)
Evaluates the dexterity measure and its Jacobian This method returns the dexterity measure and its Ja...
bool isMapInitialized_
boolean stating whether the transformation and jacobian maps are initialized
Definition ArmModel.h:289
Eigen::VectorXd controlRef_
Definition ArmModel.h:303
Eigen::MatrixXd djdqJpinv_
djdq * jacobian pseudoinverse
Definition ArmModel.h:311
Eigen::Vector3d base_ki_
Definition ArmModel.h:308
void BackwardDirectGeometry(unsigned int jointNumber, unsigned int endEffectorIndex)
Backward Direct Geometry from the input joint number to the input end effector index.
void JointsAcceleration(const Eigen::VectorXd qddot) noexcept(false)
Set the moving joints acceleration.
void ForwardDirectGeometry(unsigned int jointNumber)
Method performing the forward direct geometry untill the input joint number.
virtual auto NumJoints() const -> unsigned int
Method returning the arm number of moving joints.
Definition ArmModel.h:161
std::vector< Eigen::TransformationMatrix > biTei_
Definition ArmModel.h:305
Eigen::MatrixXd ManipulabilityJacobian(const std::string &frameID)
Method returning the manipulability jacobian related to the input frameID wrt to the arm base.
virtual auto JointsPosition() const -> const Eigen::VectorXd &
Get the moving joint position.
Definition ArmModel.h:95
auto JointsAcceleration() const -> const Eigen::VectorXd &
Get moving joints acceleration.
Definition ArmModel.h:115
Eigen::TransformationMatrix baseTbi_
Definition ArmModel.h:306
std::vector< std::string > GetJointFrameIDs() const noexcept
Method returning the list of joint frame IDs.
std::unordered_map< std::string, double > dexterity_
map of the manipulability values
Definition ArmModel.h:316
auto ID() -> std::string &
Method setting the arm id.
Definition ArmModel.h:212
Eigen::MatrixXd DexterityJacobian(const std::string &frameID)
Method returning the dexterity jacobian related to the input frameID wrt to the arm base.
double Dexterity(const std::string &frameID)
Method returning the arm dexterity.
virtual auto JointsVelocity() const -> const Eigen::VectorXd &
Get the moving joints velocity.
Definition ArmModel.h:105
Eigen::MatrixXd EvaluateRigidBodyJacobian(const std::string &frameID)
Method returning the attached body frame jacobian wrt to the arm base.
std::vector< Eigen::Vector6d > h_
Definition ArmModel.h:309
std::unordered_map< std::string, Eigen::TransformationMatrix > transformation_
Definition ArmModel.h:296
Eigen::MatrixXd Jpinvdjpinvdq_
jacobian pseudoinverse * djpinvdq
Definition ArmModel.h:318
Eigen::RotationMatrix I3_
identity matrix
Definition ArmModel.h:312
unsigned int totalNumJoints_
Definition ArmModel.h:290
This namespace is used to extend the Eigen Dense library functionalities.
Definition RotMatrix.h:13
Types and algorithms for robotic mobile manipulation.
Definition ArmModel.h:19
JointType
Used to describe the type of joint.
Definition RobotLink.h:21
std::pair< std::string, Eigen::TransformationMatrix > IndexedTMat
Definition ArmModel.h:22