class mrpt::kinematics::CKinematicChain
Overview
A open-loop kinematic chain model, suitable to robotic manipulators.
Each link is parameterized with standard Denavit-Hartenberg standard parameterization [theta, d, a, alpha].
The orientation of the first link can be modified with setOriginPose(), which defaults to standard XYZ axes with +Z pointing upwards.
See also:
CPose3D
#include <mrpt/kinematics/CKinematicChain.h> class CKinematicChain: public mrpt::serialization::CSerializable { public: // methods size_t size() const; void clear(); void addLink(double theta, double d, double a, double alpha, bool is_prismatic); void removeLink(size_t idx); const TKinematicLink& getLink(size_t idx) const; TKinematicLink& getLinkRef(size_t idx); void setOriginPose(const mrpt::poses::CPose3D& new_pose); const mrpt::poses::CPose3D& getOriginPose() const; template <class VECTOR> void getConfiguration(VECTOR& v) const; template <class VECTOR> void setConfiguration(const VECTOR& v); void getAs3DObject(mrpt::opengl::CSetOfObjects::Ptr& inout_gl_obj, std::vector<mrpt::poses::CPose3D>* out_all_poses = nullptr) const; void update3DObject(std::vector<mrpt::poses::CPose3D>* out_all_poses = nullptr) const; void recomputeAllPoses(std::vector<mrpt::poses::CPose3D>& poses, const mrpt::poses::CPose3D& pose0 = mrpt::poses::CPose3D()) const; };
Methods
size_t size() const
Return the number of links.
void clear()
Erases all links and leave the robot arm empty.
void addLink(double theta, double d, double a, double alpha, bool is_prismatic)
Appends a new link to the robotic arm, with the given Denavit-Hartenberg parameters (see TKinematicLink for further details)
void removeLink(size_t idx)
Removes one link from the kinematic chain (0<=idx<N)
const TKinematicLink& getLink(size_t idx) const
Get a ref to a given link (read-only)
TKinematicLink& getLinkRef(size_t idx)
Get a ref to a given link (read-write)
void setOriginPose(const mrpt::poses::CPose3D& new_pose)
Can be used to define a first degree of freedom along a +Z axis which does not coincide with the global +Z axis.
const mrpt::poses::CPose3D& getOriginPose() const
Returns the current pose of the first link.
template <class VECTOR> void getConfiguration(VECTOR& v) const
Get all the DOFs of the arm at once, returning them in a vector with all the “q_i” values, which can be interpreted as rotations (radians) or displacements (meters) depending on links being “revolute” or “prismatic”.
The vector is automatically resized to the correct size (the number of links).
Parameters:
VECTOR |
Can be any Eigen vector, mrpt::math::CVectorDouble, or std::vector<double> |
template <class VECTOR> void setConfiguration(const VECTOR& v)
Set all the DOFs of the arm at once, from a vector with all the “q_i” values, which are interpreted as rotations (radians) or displacements (meters) depending on links being “revolute” or “prismatic”.
Parameters:
std::exception |
If the size of the vector doesn’t match the number of links. |
VECTOR |
Can be any Eigen vector, mrpt::math::CVectorDouble, or std::vector<double> |
void getAs3DObject(mrpt::opengl::CSetOfObjects::Ptr& inout_gl_obj, std::vector<mrpt::poses::CPose3D>* out_all_poses = nullptr) const
Constructs a 3D representation of the kinematic chain, in its current state.
You can call update3DObject() to update the kinematic state of these OpenGL objects in the future, since an internal list of smart pointers to the constructed objects is kept internally. This is more efficient than calling this method again to build a new representation.
Parameters:
out_all_poses |
Optional output vector, will contain the poses in the format of recomputeAllPoses() |
See also:
void update3DObject(std::vector<mrpt::poses::CPose3D>* out_all_poses = nullptr) const
Read getAs3DObject() for a description.
Parameters:
out_all_poses |
Optional output vector, will contain the poses in the format of recomputeAllPoses() |
void recomputeAllPoses(std::vector<mrpt::poses::CPose3D>& poses, const mrpt::poses::CPose3D& pose0 = mrpt::poses::CPose3D()) const
Go thru all the links of the chain and compute the global pose of each link.
The “ground” link pose “pose0” defaults to the origin of coordinates, but anything else can be passed as the optional argument. The returned vector has N+1 elements (N=number of links), since [0] contains the base frame, [1] the pose after the first link, and so on.
The “ground” link pose “pose0” defaults to the origin of coordinates, but anything else can be passed as the optional argument.