Control Libraries 7.4.0
Loading...
Searching...
No Matches
Jacobian.hpp
1#pragma once
2
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"
9
10namespace state_representation {
11
12class CartesianTwist;
13class CartesianWrench;
14class JointVelocities;
15class JointTorques;
16
21class Jacobian : public State {
22public:
26 Jacobian();
27
36 const std::string& robot_name, unsigned int nb_joints, const std::string& frame,
37 const std::string& reference_frame = "world"
38 );
39
48 const std::string& robot_name, const std::vector<std::string>& joint_names, const std::string& frame,
49 const std::string& reference_frame = "world"
50 );
51
60 const std::string& robot_name, const std::string& frame, const Eigen::MatrixXd& data,
61 const std::string& reference_frame = "world"
62 );
63
73 const std::string& robot_name, const std::vector<std::string>& joint_names, const std::string& frame,
74 const Eigen::MatrixXd& data, const std::string& reference_frame = "world"
75 );
76
80 Jacobian(const Jacobian& jacobian);
81
90 static Jacobian Random(
91 const std::string& robot_name, unsigned int nb_joints, const std::string& frame,
92 const std::string& reference_frame = "world"
93 );
94
103 static Jacobian Random(
104 const std::string& robot_name, const std::vector<std::string>& joint_names, const std::string& frame,
105 const std::string& reference_frame = "world"
106 );
107
113 friend void swap(Jacobian& jacobian1, Jacobian& jacobian2);
114
120 Jacobian& operator=(const Jacobian& jacobian);
121
125 unsigned int rows() const;
126
132 Eigen::VectorXd row(unsigned int index) const;
133
137 unsigned int cols() const;
138
144 Eigen::VectorXd col(unsigned int index) const;
145
149 const std::vector<std::string>& get_joint_names() const;
150
154 const std::string& get_frame() const;
155
159 const std::string& get_reference_frame() const;
160
164 const Eigen::MatrixXd& data() const;
165
169 void set_joint_names(unsigned int nb_joints);
170
174 void set_joint_names(const std::vector<std::string>& joint_names);
175
179 void set_frame(const std::string& frame);
180
184 void set_reference_frame(const std::string& reference_frame);
185
189 void set_data(const Eigen::MatrixXd& data) override;
190
194 void set_zero();
195
199 Jacobian copy() const;
200
204 void reset() override;
205
212 Eigen::MatrixXd inverse() const;
213
221 Eigen::MatrixXd inverse(const Eigen::MatrixXd& matrix) const;
222
230 JointVelocities inverse(const CartesianTwist& twist) const;
231
236 bool is_incompatible(const State& state) const override;
237
242 Eigen::MatrixXd pseudoinverse() const;
243
249 Eigen::MatrixXd pseudoinverse(const Eigen::MatrixXd& matrix) const;
250
256 JointVelocities pseudoinverse(const CartesianTwist& twist) const;
257
262 Eigen::MatrixXd transpose() const;
263
269 JointTorques transpose(const CartesianWrench& wrench) const;
270
276 Eigen::MatrixXd operator*(const Eigen::MatrixXd& matrix) const;
277
284 friend Jacobian operator*(const Eigen::Matrix<double, 6, 6>& matrix, const Jacobian& jacobian);
285
292
300 friend Jacobian operator*(const CartesianPose& pose, const Jacobian& jacobian);
301
308 double& operator()(unsigned int row, unsigned int col);
309
316 const double& operator()(unsigned int row, unsigned int col) const;
317
324 friend std::ostream& operator<<(std::ostream& os, const Jacobian& jacobian);
325
326private:
327 std::vector<std::string> joint_names_;
328 std::string frame_;
329 std::string reference_frame_;
330 Eigen::MatrixXd data_;
331};
332
333inline void swap(Jacobian& jacobian1, Jacobian& jacobian2) {
334 swap(static_cast<State&>(jacobian1), static_cast<State&>(jacobian2));
335 std::swap(jacobian1.joint_names_, jacobian2.joint_names_);
336 std::swap(jacobian1.frame_, jacobian2.frame_);
337 std::swap(jacobian1.reference_frame_, jacobian2.reference_frame_);
338 std::swap(jacobian1.data_, jacobian2.data_);
339}
340}// namespace state_representation
Class to define Cartesian pose 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.
Definition Jacobian.hpp:21
friend void swap(Jacobian &jacobian1, Jacobian &jacobian2)
Swap the values of the two Jacobians.
Definition Jacobian.hpp:333
Jacobian copy() const
Return a copy of the Jacobian.
Definition Jacobian.cpp:162
const std::vector< std::string > & get_joint_names() const
Getter of the joint names attribute.
Definition Jacobian.cpp:101
void reset() override
Reset the object to a post-construction state.
Definition Jacobian.cpp:167
Eigen::VectorXd row(unsigned int index) const
Accessor of the row data at given index.
Definition Jacobian.cpp:89
const Eigen::MatrixXd & data() const
Getter of the data attribute.
Definition Jacobian.cpp:113
void set_frame(const std::string &frame)
Setter of the frame.
Definition Jacobian.cpp:140
void set_zero()
Set the Jacobian matrix to a zero value.
Definition Jacobian.cpp:156
Eigen::MatrixXd pseudoinverse() const
Return the pseudoinverse of the Jacobian matrix.
Definition Jacobian.cpp:245
unsigned int cols() const
Getter of the number of columns attribute.
Definition Jacobian.cpp:93
Eigen::MatrixXd transpose() const
Return the transpose of the Jacobian matrix.
Definition Jacobian.cpp:261
const std::string & get_reference_frame() const
Getter of the reference frame attribute.
Definition Jacobian.cpp:109
unsigned int rows() const
Getter of the number of rows attribute.
Definition Jacobian.cpp:85
Eigen::MatrixXd inverse() const
Return the inverse of the Jacobian matrix.
Definition Jacobian.cpp:172
const std::string & get_frame() const
Getter of the frame attribute.
Definition Jacobian.cpp:105
friend Jacobian operator*(const Eigen::Matrix< double, 6, 6 > &matrix, const Jacobian &jacobian)
Overload the * operator with a 6x6 matrix on the left side.
Definition Jacobian.cpp:277
void set_joint_names(unsigned int nb_joints)
Setter of the joint names attribute from the number of joints.
Definition Jacobian.cpp:118
Jacobian & operator=(const Jacobian &jacobian)
Copy assignment operator that has to be defined to the custom assignment operator.
Definition Jacobian.cpp:79
bool is_incompatible(const State &state) const override
Check if the Jacobian is incompatible for operations with the state given as argument.
Definition Jacobian.cpp:192
void set_data(const Eigen::MatrixXd &data) override
Setter of the data attribute.
Definition Jacobian.cpp:150
Jacobian()
Empty constructor for a Jacobian.
Definition Jacobian.cpp:19
void set_reference_frame(const std::string &reference_frame)
Setter of the reference frame.
Definition Jacobian.cpp:145
double & operator()(unsigned int row, unsigned int col)
Overload the () operator in a non const fashion to modify the value at given (row,...
Definition Jacobian.cpp:310
Eigen::VectorXd col(unsigned int index) const
Accessor of the column data at given index.
Definition Jacobian.cpp:97
friend std::ostream & operator<<(std::ostream &os, const Jacobian &jacobian)
Overload the ostream operator for printing.
Definition Jacobian.cpp:333
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.
Definition Jacobian.cpp:66
Class to define torques of the joints.
Class to define velocities of the joints.
Abstract class to represent a state.
Definition State.hpp:25
Core state variables and objects.
void swap(AnalogIOState &state1, AnalogIOState &state2)