3#include "state_representation/State.hpp"
4#include "state_representation/exceptions/IncompatibleSizeException.hpp"
5#include "state_representation/space/joint/JointTorques.hpp"
6#include "state_representation/space/joint/JointVelocities.hpp"
7#include "state_representation/space/cartesian/CartesianTwist.hpp"
8#include "state_representation/space/cartesian/CartesianWrench.hpp"
22 std::vector<std::string> joint_names_;
24 std::string reference_frame_;
27 Eigen::MatrixXd data_;
42 Jacobian(
const std::string& robot_name,
43 unsigned int nb_joints,
44 const std::string& frame,
45 const std::string& reference_frame =
"world");
54 Jacobian(
const std::string& robot_name,
55 const std::vector<std::string>& joint_names,
56 const std::string& frame,
57 const std::string& reference_frame =
"world");
66 Jacobian(
const std::string& robot_name,
67 const std::string& frame,
68 const Eigen::MatrixXd&
data,
69 const std::string& reference_frame =
"world");
79 Jacobian(
const std::string& robot_name,
80 const std::vector<std::string>& joint_names,
81 const std::string& frame,
82 const Eigen::MatrixXd&
data,
83 const std::string& reference_frame =
"world");
99 unsigned int nb_joints,
100 const std::string& frame,
101 const std::string& reference_frame =
"world");
112 const std::vector<std::string>& joint_names,
113 const std::string& frame,
114 const std::string& reference_frame =
"world");
134 unsigned int rows()
const;
141 Eigen::VectorXd
row(
unsigned int index)
const;
147 unsigned int cols()
const;
154 Eigen::VectorXd
col(
unsigned int index)
const;
193 const Eigen::MatrixXd&
data()
const;
236 Eigen::MatrixXd
operator*(
const Eigen::MatrixXd& matrix)
const;
271 Eigen::MatrixXd
solve(
const Eigen::MatrixXd& matrix)
const;
325 friend Eigen::MatrixXd
operator*(
const Eigen::MatrixXd& matrix,
const Jacobian& jacobian);
329 swap(
static_cast<State&
>(jacobian1),
static_cast<State&
>(jacobian2));
330 std::swap(jacobian1.joint_names_, jacobian2.joint_names_);
331 std::swap(jacobian1.frame_, jacobian2.frame_);
332 std::swap(jacobian1.reference_frame_, jacobian2.reference_frame_);
333 std::swap(jacobian1.cols_, jacobian2.cols_);
334 std::swap(jacobian1.rows_, jacobian2.rows_);
335 std::swap(jacobian1.data_, jacobian2.data_);
353 return this->data_.row(index);
357 return this->data_.col(index);
361 return this->joint_names_;
365 if (this->joint_names_.size() != nb_joints) {
367 + std::to_string(this->joint_names_.size())
368 +
" got " + std::to_string(nb_joints));
370 for (
unsigned int i = 0; i < nb_joints; ++i) {
371 this->joint_names_[i] =
"joint" + std::to_string(i);
376 if (this->joint_names_.size() != joint_names.size()) {
378 + std::to_string(this->joint_names_.size())
379 +
" got " + std::to_string(joint_names.size()));
381 this->joint_names_ = joint_names;
389 return this->reference_frame_;
397 if (this->
rows() != data.rows() || this->cols() !=
data.cols()) {
399 + std::to_string(this->rows_) +
"x" + std::to_string(this->cols_)
400 +
" got " + std::to_string(
data.rows()) +
"x"
401 + std::to_string(
data.cols()));
408 if (
row > this->rows_) {
409 throw std::out_of_range(
"Given row is out of range: number of rows is " + std::to_string(this->rows_));
411 if (
col > this->cols_) {
412 throw std::out_of_range(
"Given column is out of range: number of columns is " + std::to_string(this->cols_));
414 return this->data_(
row,
col);
418 if (
row > this->rows_) {
419 throw std::out_of_range(
"Given row is out of range: number of rows is " + std::to_string(this->rows_));
421 if (
col > this->cols_) {
422 throw std::out_of_range(
"Given column is out of range: number of columns is " + std::to_string(this->cols_));
424 return this->data_(
row,
col);
Class to define CartesianPose in cartesian space as 3D position and quaternion based orientation.
Class to define twist in cartesian space as 3D linear and angular velocity vectors.
Class to define wrench in cartesian space as 3D force and torque vectors.
Class to define a robot Jacobian matrix.
friend void swap(Jacobian &jacobian1, Jacobian &jacobian2)
Swap the values of the two Jacobian.
Jacobian copy() const
Return a copy of the JointPositions.
const std::vector< std::string > & get_joint_names() const
Getter of the joint_names attribute.
Eigen::VectorXd row(unsigned int index) const
Accessor of the row data at given index.
const Eigen::MatrixXd & data() const
Getter of the data attribute.
Jacobian pseudoinverse() const
Return the pseudoinverse of the Jacobian matrix.
unsigned int cols() const
Getter of the number of columns attribute.
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-in...
const std::string & get_reference_frame() const
Getter of the reference_frame attribute.
unsigned int rows() const
Getter of the number of rows attribute.
void set_reference_frame(const CartesianPose &reference_frame)
Setter of the reference_frame attribute from a CartesianPose Update the value of the data matrix acco...
const std::string & get_frame() const
Getter of the frame attribute.
friend Jacobian operator*(const CartesianPose &pose, const Jacobian &jacobian)
Overload the * operator with a CartesianPose on left side. This is equivalent to a changing of refere...
Jacobian inverse() const
Return the inverse of the Jacobian matrix If the matrix is not invertible, an error is thrown advisin...
void set_joint_names(unsigned int nb_joints)
Setter of the joint_names attribute from the number of joints.
Jacobian & operator=(const Jacobian &jacobian)
Copy assignment operator that have to be defined to the custom assignment operator.
void set_data(const Eigen::MatrixXd &data) override
Setter of the data attribute.
bool is_compatible(const State &state) const override
Check if the Jacobian matrix is compatible for operations with the state given as argument.
Jacobian()
Empty constructor for a Jacobian.
Jacobian transpose() const
Return the transpose of the Jacobian matrix.
void initialize() override
Initialize the matrix to a zero value.
double & operator()(unsigned int row, unsigned int col)
Overload the () operator in a non const fashion to modify the value at given (row,...
Eigen::VectorXd col(unsigned int index) const
Accessor of the column data at given index.
friend std::ostream & operator<<(std::ostream &os, const Jacobian &jacobian)
Overload the ostream operator for printing.
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.
Class to define torques of the joints.
Class to define velocities of the joints.
Abstract class to represent a state.
void set_filled()
Setter of the empty attribute to false and also reset the timestamp.
Core state variables and objects.
void swap(CartesianState &state1, CartesianState &state2)