Control Libraries 6.3.4
Loading...
Searching...
No Matches
JointPositions.hpp
1#pragma once
2
3#include "state_representation/space/joint/JointState.hpp"
4#include "state_representation/space/joint/JointVelocities.hpp"
5
6namespace state_representation {
7class JointVelocities;
8
13class JointPositions : public JointState {
14private:
16
17public:
18 const Eigen::VectorXd& get_velocities() const = delete;
19 double get_velocity(unsigned int joint_index) const = delete;
20 double get_velocity(const std::string& joint_name) const = delete;
21 void set_velocities(const Eigen::VectorXd& velocities) = delete;
22 void set_velocities(const std::vector<double>& velocities) = delete;
23 void set_velocity(double velocity, unsigned int joint_index) const = delete;
24 void set_velocity(double velocity, const std::string& joint_name) const = delete;
25 const Eigen::VectorXd& get_accelerations() const = delete;
26 double get_acceleration(unsigned int joint_index) const = delete;
27 double get_acceleration(const std::string& joint_name) const = delete;
28 void set_accelerations(const Eigen::VectorXd& accelerations) = delete;
29 void set_accelerations(const std::vector<double>& accelerations) = delete;
30 void set_acceleration(double acceleration, unsigned int joint_index) const = delete;
31 void set_acceleration(double acceleration, const std::string& joint_name) const = delete;
32 const Eigen::VectorXd& get_torques() const = delete;
33 double get_torque(unsigned int joint_index) const = delete;
34 double get_torque(const std::string& joint_name) const = delete;
35 void set_torques(const Eigen::VectorXd& torques) = delete;
36 void set_torques(const std::vector<double>& torques) = delete;
37 void set_torque(double torque, unsigned int joint_index) const = delete;
38 void set_torque(double torque, const std::string& joint_name) const = delete;
39
43 explicit JointPositions();
44
50 explicit JointPositions(const std::string& robot_name, unsigned int nb_joints = 0);
51
57 explicit JointPositions(const std::string& robot_name, const std::vector<std::string>& joint_names);
58
64 explicit JointPositions(const std::string& robot_name, const Eigen::VectorXd& positions);
65
72 explicit JointPositions(
73 const std::string& robot_name, const std::vector<std::string>& joint_names, const Eigen::VectorXd& positions
74 );
75
79 JointPositions(const JointPositions& positions);
80
84 JointPositions(const JointState& state);
85
90 JointPositions(const JointVelocities& velocities);
91
98 static JointPositions Zero(const std::string& robot_name, unsigned int nb_joints);
99
106 static JointPositions Zero(const std::string& robot_name, const std::vector<std::string>& joint_names);
107
114 static JointPositions Random(const std::string& robot_name, unsigned int nb_joints);
115
122 static JointPositions Random(const std::string& robot_name, const std::vector<std::string>& joint_names);
123
129 JointPositions& operator=(const JointPositions& positions) = default;
130
136 JointPositions& operator+=(const JointPositions& positions);
137
143 JointPositions operator+(const JointPositions& positions) const;
144
150 JointPositions& operator-=(const JointPositions& positions);
151
157 JointPositions operator-(const JointPositions& positions) const;
158
164 JointPositions& operator*=(double lambda);
165
171 JointPositions operator*(double lambda) const;
172
178 JointPositions& operator*=(const Eigen::ArrayXd& lambda);
179
185 JointPositions operator*(const Eigen::ArrayXd& lambda) const;
186
192 JointPositions& operator*=(const Eigen::MatrixXd& lambda);
193
199 JointPositions operator*(const Eigen::MatrixXd& lambda) const;
200
206 JointPositions& operator/=(double lambda);
207
213 JointPositions operator/(double lambda) const;
214
220 JointVelocities operator/(const std::chrono::nanoseconds& dt) const;
221
226 JointPositions copy() const;
227
232 Eigen::VectorXd data() const override;
233
238 virtual void set_data(const Eigen::VectorXd& data) override;
239
244 virtual void set_data(const std::vector<double>& data) override;
245
252 void clamp(double max_absolute_value, double noise_ratio = 0.);
253
261 JointPositions clamped(double max_absolute_value, double noise_ratio = 0.) const;
262
269 void clamp(const Eigen::ArrayXd& max_absolute_value_array, const Eigen::ArrayXd& noise_ratio_array);
270
278 JointPositions clamped(const Eigen::ArrayXd& max_absolute_value_array, const Eigen::ArrayXd& noise_ratio_array) const;
279
286 friend std::ostream& operator<<(std::ostream& os, const JointPositions& positions);
287
293 friend JointPositions operator*(double lambda, const JointPositions& positions);
294
300 friend JointPositions operator*(const Eigen::ArrayXd& lambda, const JointPositions& positions);
301
307 friend JointPositions operator*(const Eigen::MatrixXd& lambda, const JointPositions& positions);
308};
309}// namespace state_representation
Class to define a positions of the joints.
void clamp(double max_absolute_value, double noise_ratio=0.)
Clamp inplace the magnitude of the positions to the value in argument.
friend std::ostream & operator<<(std::ostream &os, const JointPositions &positions)
Overload the ostream operator for printing.
static JointPositions Zero(const std::string &robot_name, unsigned int nb_joints)
Constructor for the zero JointPositions.
Eigen::VectorXd data() const override
Returns the positions data as an Eigen vector.
JointPositions & operator=(const JointPositions &positions)=default
Copy assignment operator that have to be defined to the custom assignment operator.
JointPositions & operator*=(double lambda)
Overload the *= operator with a double gain.
virtual void set_data(const Eigen::VectorXd &data) override
Set the positions data from an Eigen vector.
JointPositions & operator-=(const JointPositions &positions)
Overload the -= operator.
JointPositions & operator+=(const JointPositions &positions)
Overload the += operator.
JointPositions operator/(double lambda) const
Overload the / operator with a scalar.
JointPositions clamped(double max_absolute_value, double noise_ratio=0.) const
Return the position clamped to the value in argument.
static JointPositions Random(const std::string &robot_name, unsigned int nb_joints)
Constructor for the random JointPositions.
JointPositions operator+(const JointPositions &positions) const
Overload the + operator.
friend JointPositions operator*(double lambda, const JointPositions &positions)
Overload the * operator with a scalar.
JointPositions copy() const
Return a copy of the JointPositions.
JointPositions operator-(const JointPositions &positions) const
Overload the - operator.
JointPositions & operator/=(double lambda)
Overload the /= operator with a scalar.
Class to define a state in joint space.
Definition: JointState.hpp:36
void clamp_state_variable(double max_absolute_value, const JointStateVariable &state_variable_type, double noise_ratio=0)
Clamp inplace the magnitude of the a specific joint state variable.
Definition: JointState.cpp:379
Class to define velocities of the joints.
Core state variables and objects.