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:
    // typedefs

    typedef std::shared_ptr<mrpt::kinematics ::CKinematicChain> Ptr;
    typedef std::shared_ptr<const mrpt::kinematics ::CKinematicChain> ConstPtr;
    typedef std::unique_ptr<mrpt::kinematics ::CKinematicChain> UniquePtr;
    typedef std::unique_ptr<const mrpt::kinematics ::CKinematicChain> ConstUniquePtr;

    // fields

    static constexpr const char* className = "mrpt::kinematics" "::" "CKinematicChain";

    // methods

    static constexpr auto getClassName();
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    static std::shared_ptr<CObject> CreateObject();

    template <typename... Args>
    static Ptr Create(Args&&... args);

    template <typename Alloc, typename... Args>
    static Ptr CreateAlloc(
        const Alloc& alloc,
        Args&&... args
        );

    template <typename... Args>
    static UniquePtr CreateUnique(Args&&... args);

    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    virtual mrpt::rtti::CObject* clone() const;
    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::viz::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;
};

Inherited Members

public:
    // typedefs

    typedef std::shared_ptr<CObject> Ptr;
    typedef std::shared_ptr<const CObject> ConstPtr;
    typedef std::shared_ptr<CSerializable> Ptr;
    typedef std::shared_ptr<const CSerializable> ConstPtr;

    // methods

    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();

Typedefs

typedef std::shared_ptr<mrpt::kinematics ::CKinematicChain> Ptr

A type for the associated smart pointer.

Methods

virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const

Returns information about the class of an object in runtime.

virtual mrpt::rtti::CObject* clone() const

Returns a deep copy (clone) of the object, indepently of its class.

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::viz::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:

update3DObject

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.