Control Libraries 6.3.4
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
state_representation::Jacobian Class Reference

Class to define a robot Jacobian matrix. More...

#include <Jacobian.hpp>

Inheritance diagram for state_representation::Jacobian:
state_representation::State

Public Member Functions

 Jacobian ()
 Empty constructor for a Jacobian. More...
 
 Jacobian (const std::string &robot_name, unsigned int nb_joints, const std::string &frame, const std::string &reference_frame="world")
 Constructor with name, number of joints, frame name and reference frame provided. More...
 
 Jacobian (const std::string &robot_name, const std::vector< std::string > &joint_names, const std::string &frame, const std::string &reference_frame="world")
 Constructor with name, joint names, frame name and reference frame provided. More...
 
 Jacobian (const std::string &robot_name, const std::string &frame, const Eigen::MatrixXd &data, const std::string &reference_frame="world")
 Constructor with name, frame, Jacobian matrix and reference frame provided. More...
 
 Jacobian (const std::string &robot_name, const std::vector< std::string > &joint_names, const std::string &frame, const Eigen::MatrixXd &data, const std::string &reference_frame="world")
 Constructor with name, joint names, frame name, Jacobian matrix and reference frame provided. More...
 
 Jacobian (const Jacobian &jacobian)
 Copy constructor of a Jacobian. More...
 
Jacobianoperator= (const Jacobian &jacobian)
 Copy assignment operator that have to be defined to the custom assignment operator. More...
 
unsigned int rows () const
 Getter of the number of rows attribute. More...
 
Eigen::VectorXd row (unsigned int index) const
 Accessor of the row data at given index. More...
 
unsigned int cols () const
 Getter of the number of columns attribute. More...
 
Eigen::VectorXd col (unsigned int index) const
 Accessor of the column data at given index. More...
 
const std::vector< std::string > & get_joint_names () const
 Getter of the joint_names attribute. More...
 
void set_joint_names (unsigned int nb_joints)
 Setter of the joint_names attribute from the number of joints. More...
 
void set_joint_names (const std::vector< std::string > &joint_names)
 Setter of the joint_names attribute from a vector of joint names. More...
 
const std::string & get_frame () const
 Getter of the frame attribute. More...
 
const std::string & get_reference_frame () const
 Getter of the reference_frame attribute. More...
 
void set_reference_frame (const CartesianPose &reference_frame)
 Setter of the reference_frame attribute from a CartesianPose Update the value of the data matrix accordingly by changing the reference frame of each columns. This means that the computation needs to be compatible, i.e. the previous reference frame should match the name of the new reference frame as input. More...
 
const Eigen::MatrixXd & data () const
 Getter of the data attribute. More...
 
void set_data (const Eigen::MatrixXd &data) override
 Setter of the data attribute. More...
 
bool is_compatible (const State &state) const override
 Check if the Jacobian matrix is compatible for operations with the state given as argument. More...
 
void initialize () override
 Initialize the matrix to a zero value. More...
 
Jacobian transpose () const
 Return the transpose of the Jacobian matrix. More...
 
Jacobian inverse () const
 Return the inverse of the Jacobian matrix If the matrix is not invertible, an error is thrown advising to use the pseudoinverse function instead. More...
 
Jacobian pseudoinverse () const
 Return the pseudoinverse of the Jacobian matrix. More...
 
Eigen::MatrixXd operator* (const Eigen::MatrixXd &matrix) const
 Overload the * operator with an arbitrary matrix. More...
 
Eigen::MatrixXd operator* (const Jacobian &jacobian) const
 Overload the * operator with another Jacobian. More...
 
CartesianTwist operator* (const JointVelocities &dq) const
 Overload the * operator with a JointVelocities. More...
 
JointVelocities operator* (const CartesianTwist &twist) const
 Overload the * operator with a CartesianTwist. More...
 
JointTorques operator* (const CartesianWrench &wrench) const
 Overload the * operator with a CartesianWrench. More...
 
Eigen::MatrixXd solve (const Eigen::MatrixXd &matrix) const
 Solve the system X = inv(J)*M to obtain X which is more efficient than multiplying with the pseudo-inverse. More...
 
JointVelocities solve (const CartesianTwist &twist) const
 Solve the system dX = J*dq to obtain dq which is more efficient than multiplying with the pseudo-inverse. More...
 
double & operator() (unsigned int row, unsigned int col)
 Overload the () operator in a non const fashion to modify the value at given (row, col) More...
 
const double & operator() (unsigned int row, unsigned int col) const
 Overload the () operator const fashion to access the value at given (row, col) More...
 
Jacobian copy () const
 Return a copy of the JointPositions. More...
 
- Public Member Functions inherited from state_representation::State
 State ()
 Empty constructor. More...
 
 State (const StateType &type)
 Constructor only specifying the type of the state from the StateType enumeration. More...
 
 State (const StateType &type, const std::string &name, const bool &empty=true)
 Constructor with name specification. More...
 
 State (const State &state)
 Copy constructor from another State. More...
 
virtual ~State ()=default
 Virtual destructor.
 
Stateoperator= (const State &state)
 Copy assignment operator that have to be defined to the custom assignment operator. More...
 
const StateTypeget_type () const
 Getter of the type attribute. More...
 
bool is_empty () const
 Getter of the empty attribute. More...
 
void set_empty (bool empty=true)
 Setter of the empty attribute. More...
 
void set_filled ()
 Setter of the empty attribute to false and also reset the timestamp. More...
 
const std::chrono::time_point< std::chrono::steady_clock > & get_timestamp () const
 Getter of the timestamp attribute. More...
 
void set_timestamp (const std::chrono::time_point< std::chrono::steady_clock > &timepoint)
 Setter of the timestamp attribute. More...
 
void reset_timestamp ()
 Reset the timestamp attribute to now. More...
 
const std::string & get_name () const
 Getter of the name as const reference. More...
 
virtual void set_name (const std::string &name)
 Setter of the name. More...
 
template<typename DurationT >
bool is_deprecated (const std::chrono::duration< int64_t, DurationT > &time_delay)
 Check if the state is deprecated given a certain time delay. More...
 
virtual bool is_compatible (const State &state) const
 Check if the state is compatible for operations with the state given as argument. More...
 
virtual void initialize ()
 Initialize the State to a zero value. More...
 
virtual void set_data (const Eigen::VectorXd &data)
 Set the data of the state from a single Eigen vector. More...
 
virtual void set_data (const std::vector< double > &data)
 Set the data of the state from a single std vector. More...
 
virtual void set_data (const Eigen::MatrixXd &data)
 Set the data of the state from an Eigen matrix. More...
 
 operator bool () const noexcept
 Boolean operator for the truthiness of a state. More...
 

Static Public Member Functions

static Jacobian Random (const std::string &robot_name, unsigned int nb_joints, const std::string &frame, const std::string &reference_frame="world")
 Constructor for a random Jacobian. More...
 
static Jacobian Random (const std::string &robot_name, const std::vector< std::string > &joint_names, const std::string &frame, const std::string &reference_frame="world")
 Constructor for a random Jacobian. More...
 

Friends

void swap (Jacobian &jacobian1, Jacobian &jacobian2)
 Swap the values of the two Jacobian. More...
 
std::ostream & operator<< (std::ostream &os, const Jacobian &jacobian)
 Overload the ostream operator for printing. More...
 
Jacobian operator* (const CartesianPose &pose, const Jacobian &jacobian)
 Overload the * operator with a CartesianPose on left side. This is equivalent to a changing of reference frame of the Jacobian. More...
 
Eigen::MatrixXd operator* (const Eigen::MatrixXd &matrix, const Jacobian &jacobian)
 Overload the * operator with an arbitrary matrix on the left side. More...
 

Additional Inherited Members

- Protected Member Functions inherited from state_representation::State
void set_type (const StateType &type)
 Override the state type. More...
 

Detailed Description

Class to define a robot Jacobian matrix.

Definition at line 20 of file Jacobian.hpp.

Constructor & Destructor Documentation

◆ Jacobian() [1/6]

state_representation::Jacobian::Jacobian ( )

Empty constructor for a Jacobian.

Definition at line 7 of file Jacobian.cpp.

◆ Jacobian() [2/6]

state_representation::Jacobian::Jacobian ( const std::string &  robot_name,
unsigned int  nb_joints,
const std::string &  frame,
const std::string &  reference_frame = "world" 
)

Constructor with name, number of joints, frame name and reference frame provided.

Parameters
robot_namethe name of the associated robot
nb_jointsthe number of joints of the robot
framethe name of the frame at which the Jacobian is computed
reference_framethe name of the reference frame in which the Jacobian is expressed (default "world")

Definition at line 11 of file Jacobian.cpp.

◆ Jacobian() [3/6]

state_representation::Jacobian::Jacobian ( const std::string &  robot_name,
const std::vector< std::string > &  joint_names,
const std::string &  frame,
const std::string &  reference_frame = "world" 
)

Constructor with name, joint names, frame name and reference frame provided.

Parameters
robot_namethe name of the associated robot
joint_namesthe vector of joint names of the robot
framethe name of the frame at which the Jacobian is computed
reference_framethe name of the reference frame in which the Jacobian is expressed (default "world")

Definition at line 25 of file Jacobian.cpp.

◆ Jacobian() [4/6]

state_representation::Jacobian::Jacobian ( const std::string &  robot_name,
const std::string &  frame,
const Eigen::MatrixXd &  data,
const std::string &  reference_frame = "world" 
)

Constructor with name, frame, Jacobian matrix and reference frame provided.

Parameters
robot_namethe name of the associated robot
framethe name of the frame at which the Jacobian is computed
datathe values of the Jacobian matrix
reference_framethe name of the reference frame in which the Jacobian is expressed (default "world")

Definition at line 38 of file Jacobian.cpp.

◆ Jacobian() [5/6]

state_representation::Jacobian::Jacobian ( const std::string &  robot_name,
const std::vector< std::string > &  joint_names,
const std::string &  frame,
const Eigen::MatrixXd &  data,
const std::string &  reference_frame = "world" 
)

Constructor with name, joint names, frame name, Jacobian matrix and reference frame provided.

Parameters
robot_namethe name of the associated robot
joint_namesthe vector of joint names of the robot
framethe name of the frame at which the Jacobian is computed
datathe values of the Jacobian matrix
reference_framethe name of the reference frame in which the Jacobian is expressed (default "world")

Definition at line 46 of file Jacobian.cpp.

◆ Jacobian() [6/6]

state_representation::Jacobian::Jacobian ( const Jacobian jacobian)

Copy constructor of a Jacobian.

Definition at line 55 of file Jacobian.cpp.

Member Function Documentation

◆ col()

Eigen::VectorXd state_representation::Jacobian::col ( unsigned int  index) const
inline

Accessor of the column data at given index.

Parameters
indexthe index of the desired column
Returns
the column vector at index

Definition at line 356 of file Jacobian.hpp.

◆ cols()

unsigned int state_representation::Jacobian::cols ( ) const
inline

Getter of the number of columns attribute.

Returns
the number of cols

Definition at line 348 of file Jacobian.hpp.

◆ copy()

Jacobian state_representation::Jacobian::copy ( ) const

Return a copy of the JointPositions.

Returns
the copy

Definition at line 258 of file Jacobian.cpp.

◆ data()

const Eigen::MatrixXd & state_representation::Jacobian::data ( ) const
inline

Getter of the data attribute.

Definition at line 392 of file Jacobian.hpp.

◆ get_frame()

const std::string & state_representation::Jacobian::get_frame ( ) const
inline

Getter of the frame attribute.

Definition at line 384 of file Jacobian.hpp.

◆ get_joint_names()

const std::vector< std::string > & state_representation::Jacobian::get_joint_names ( ) const
inline

Getter of the joint_names attribute.

Definition at line 360 of file Jacobian.hpp.

◆ get_reference_frame()

const std::string & state_representation::Jacobian::get_reference_frame ( ) const
inline

Getter of the reference_frame attribute.

Definition at line 388 of file Jacobian.hpp.

◆ initialize()

void state_representation::Jacobian::initialize ( )
overridevirtual

Initialize the matrix to a zero value.

Reimplemented from state_representation::State.

Definition at line 64 of file Jacobian.cpp.

◆ inverse()

Jacobian state_representation::Jacobian::inverse ( ) const

Return the inverse of the Jacobian matrix If the matrix is not invertible, an error is thrown advising to use the pseudoinverse function instead.

Returns
the inverse of the Jacobian

Definition at line 145 of file Jacobian.cpp.

◆ is_compatible()

bool state_representation::Jacobian::is_compatible ( const State state) const
overridevirtual

Check if the Jacobian matrix is compatible for operations with the state given as argument.

Parameters
statethe state to check compatibility with

Reimplemented from state_representation::State.

Definition at line 88 of file Jacobian.cpp.

◆ operator()() [1/2]

double & state_representation::Jacobian::operator() ( unsigned int  row,
unsigned int  col 
)
inline

Overload the () operator in a non const fashion to modify the value at given (row, col)

Parameters
rowthe index of the row
theindex of the column
Returns
the reference to the value at the given row and column

Definition at line 407 of file Jacobian.hpp.

◆ operator()() [2/2]

const double & state_representation::Jacobian::operator() ( unsigned int  row,
unsigned int  col 
) const
inline

Overload the () operator const fashion to access the value at given (row, col)

Parameters
rowthe index of the row
theindex of the column
Returns
the const reference to the value at the given row and column

Definition at line 417 of file Jacobian.hpp.

◆ operator*() [1/5]

JointVelocities state_representation::Jacobian::operator* ( const CartesianTwist twist) const

Overload the * operator with a CartesianTwist.

Parameters
twistthe cartesian velocity to multiply with
Returns
this result into a JointVelocities

Definition at line 200 of file Jacobian.cpp.

◆ operator*() [2/5]

JointTorques state_representation::Jacobian::operator* ( const CartesianWrench wrench) const

Overload the * operator with a CartesianWrench.

Parameters
wrenchthe cartesian wrench to multiply with
Returns
this result into a JointTorques

Definition at line 215 of file Jacobian.cpp.

◆ operator*() [3/5]

Eigen::MatrixXd state_representation::Jacobian::operator* ( const Eigen::MatrixXd &  matrix) const

Overload the * operator with an arbitrary matrix.

Parameters
matrixthe matrix to multiply with
Returns
the Jacobian matrix multiplied by the matrix in parameter

Definition at line 166 of file Jacobian.cpp.

◆ operator*() [4/5]

Eigen::MatrixXd state_representation::Jacobian::operator* ( const Jacobian jacobian) const

Overload the * operator with another Jacobian.

Parameters
jacobianthe Jacobian to multiply with
Returns
the current Jacobian multiplied by the one in parameter

Definition at line 177 of file Jacobian.cpp.

◆ operator*() [5/5]

CartesianTwist state_representation::Jacobian::operator* ( const JointVelocities dq) const

Overload the * operator with a JointVelocities.

Parameters
dqthe joint velocity to multiply with
Returns
this result into the CartesianTwist of the end effector

Definition at line 185 of file Jacobian.cpp.

◆ operator=()

Jacobian & state_representation::Jacobian::operator= ( const Jacobian jacobian)
inline

Copy assignment operator that have to be defined to the custom assignment operator.

Parameters
jacobianthe Jacobian with value to assign
Returns
reference to the current Jacobian with new values

Definition at line 338 of file Jacobian.hpp.

◆ pseudoinverse()

Jacobian state_representation::Jacobian::pseudoinverse ( ) const

Return the pseudoinverse of the Jacobian matrix.

Returns
the pseudoinverse of the Jacobian

Definition at line 157 of file Jacobian.cpp.

◆ Random() [1/2]

Jacobian state_representation::Jacobian::Random ( const std::string &  robot_name,
const std::vector< std::string > &  joint_names,
const std::string &  frame,
const std::string &  reference_frame = "world" 
)
static

Constructor for a random Jacobian.

Parameters
robot_namethe name of the associated robot
joint_namesthe vector of joint names of the robot
framethe name of the frame at which the Jacobian is computed
reference_framethe name of the reference frame in which the Jacobian is expressed (default "world")
Returns
Jacobian with random data values

Definition at line 79 of file Jacobian.cpp.

◆ Random() [2/2]

Jacobian state_representation::Jacobian::Random ( const std::string &  robot_name,
unsigned int  nb_joints,
const std::string &  frame,
const std::string &  reference_frame = "world" 
)
static

Constructor for a random Jacobian.

Parameters
robot_namethe name of the associated robot
nb_jointsthe number of joints of the robot
framethe name of the frame at which the Jacobian is computed
reference_framethe name of the reference frame in which the Jacobian is expressed (default "world")
Returns
Jacobian with random data values

Definition at line 70 of file Jacobian.cpp.

◆ row()

Eigen::VectorXd state_representation::Jacobian::row ( unsigned int  index) const
inline

Accessor of the row data at given index.

Parameters
indexthe index of the desired row
Returns
the row vector at index

Definition at line 352 of file Jacobian.hpp.

◆ rows()

unsigned int state_representation::Jacobian::rows ( ) const
inline

Getter of the number of rows attribute.

Returns
the number of rows

Definition at line 344 of file Jacobian.hpp.

◆ set_data()

void state_representation::Jacobian::set_data ( const Eigen::MatrixXd &  data)
inlineoverridevirtual

Setter of the data attribute.

Reimplemented from state_representation::State.

Definition at line 396 of file Jacobian.hpp.

◆ set_joint_names() [1/2]

void state_representation::Jacobian::set_joint_names ( const std::vector< std::string > &  joint_names)
inline

Setter of the joint_names attribute from a vector of joint names.

Definition at line 375 of file Jacobian.hpp.

◆ set_joint_names() [2/2]

void state_representation::Jacobian::set_joint_names ( unsigned int  nb_joints)
inline

Setter of the joint_names attribute from the number of joints.

Definition at line 364 of file Jacobian.hpp.

◆ set_reference_frame()

void state_representation::Jacobian::set_reference_frame ( const CartesianPose reference_frame)

Setter of the reference_frame attribute from a CartesianPose Update the value of the data matrix accordingly by changing the reference frame of each columns. This means that the computation needs to be compatible, i.e. the previous reference frame should match the name of the new reference frame as input.

Parameters
reference_framethe reference frame as a CartesianPose

Definition at line 133 of file Jacobian.cpp.

◆ solve() [1/2]

JointVelocities state_representation::Jacobian::solve ( const CartesianTwist twist) const

Solve the system dX = J*dq to obtain dq which is more efficient than multiplying with the pseudo-inverse.

Parameters
dXthe cartesian velocity to multiply with
Returns
this result into a JointVelocities

Definition at line 241 of file Jacobian.cpp.

◆ solve() [2/2]

Eigen::MatrixXd state_representation::Jacobian::solve ( const Eigen::MatrixXd &  matrix) const

Solve the system X = inv(J)*M to obtain X which is more efficient than multiplying with the pseudo-inverse.

Parameters
matrixthe matrix to solve the system with
Returns
result of X = J.solve(M) from Eigen decomposition

Definition at line 230 of file Jacobian.cpp.

◆ transpose()

Jacobian state_representation::Jacobian::transpose ( ) const

Return the transpose of the Jacobian matrix.

Returns
the Jacobian transposed

Definition at line 137 of file Jacobian.cpp.

Friends And Related Function Documentation

◆ operator* [1/2]

Jacobian operator* ( const CartesianPose pose,
const Jacobian jacobian 
)
friend

Overload the * operator with a CartesianPose on left side. This is equivalent to a changing of reference frame of the Jacobian.

Parameters
posethe CartesianPose to multiply with
jacobianthe Jacobian to be multiplied with the CartesianPose
Returns
the Jacobian expressed in the new reference frame

Definition at line 288 of file Jacobian.cpp.

◆ operator* [2/2]

Eigen::MatrixXd operator* ( const Eigen::MatrixXd &  matrix,
const Jacobian jacobian 
)
friend

Overload the * operator with an arbitrary matrix on the left side.

Parameters
matrixthe matrix to multiply with
jacobianthe jacobian matrix
Returns
the matrix multiplied by the jacobian matrix

Definition at line 318 of file Jacobian.cpp.

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const Jacobian jacobian 
)
friend

Overload the ostream operator for printing.

Parameters
osthe ostream to append the string representing the matrix to
jacobianthe Jacobian to print
Returns
the appended ostream

Definition at line 263 of file Jacobian.cpp.

◆ swap

void swap ( Jacobian jacobian1,
Jacobian jacobian2 
)
friend

Swap the values of the two Jacobian.

Parameters
jacobian1Jacobian to be swapped with 2
jacobian2Jacobian to be swapped with 1

Definition at line 328 of file Jacobian.hpp.


The documentation for this class was generated from the following files: