1#include "state_representation/space/joint/JointTorques.hpp"
3using namespace state_representation::exceptions;
7 this->
set_type(StateType::JOINT_TORQUES);
11 this->
set_type(StateType::JOINT_TORQUES);
16 this->
set_type(StateType::JOINT_TORQUES);
22 this->
set_type(StateType::JOINT_TORQUES);
26 const Eigen::VectorXd& torques) :
JointState(robot_name, joint_names) {
27 this->
set_type(StateType::JOINT_TORQUES);
33 this->
set_type(StateType::JOINT_TORQUES);
50 return JointTorques(robot_name, Eigen::VectorXd::Random(nb_joints));
54 return JointTorques(robot_name, joint_names, Eigen::VectorXd::Random(joint_names.size()));
133 this->clamp_state_variable(max_absolute_value, JointStateVariable::TORQUES, noise_ratio);
138 result.
clamp(max_absolute_value, noise_ratio);
142void JointTorques::clamp(
const Eigen::ArrayXd& max_absolute_value_array,
const Eigen::ArrayXd& noise_ratio_array) {
143 this->clamp_state_variable(max_absolute_value_array, JointStateVariable::TORQUES, noise_ratio_array);
147 const Eigen::ArrayXd& noise_ratio_array)
const {
149 result.
clamp(max_absolute_value_array, noise_ratio_array);
155 os <<
"Empty JointTorques";
157 os << torques.
get_name() <<
" JointTorques" << std::endl;
159 for (
auto& n : torques.
get_names()) { os << n <<
", "; }
160 os <<
"]" << std::endl;
162 for (
unsigned int i = 0; i < torques.
get_size(); ++i) { os << torques.
get_torques()(i) <<
", "; }
Class to define a state in joint space.
const Eigen::VectorXd & get_torques() const
Getter of the torques attribute.
JointState operator+(const JointState &state) const
Overload the + operator.
JointState & operator*=(double lambda)
Overload the *= operator with a double gain.
void set_zero()
Set the JointState to a zero value.
unsigned int get_size() const
Getter of the size from the attributes.
JointState operator-(const JointState &state) const
Overload the - operator.
static JointState Zero(const std::string &robot_name, unsigned int nb_joints)
Constructor for a zero JointState.
JointState & operator+=(const JointState &state)
Overload the += operator.
void set_torques(const Eigen::VectorXd &torques)
Setter of the torques attribute.
JointState & operator-=(const JointState &state)
Overload the -= operator.
void multiply_state_variable(const Eigen::ArrayXd &lambda, const JointStateVariable &state_variable_type)
Proxy function that multiply the specified state variable by an array of gain.
JointState & operator/=(double lambda)
Overload the /= operator with a scalar.
friend JointState operator*(double lambda, const JointState &state)
Overload the * operator with a scalar.
const std::vector< std::string > & get_names() const
Getter of the names attribute.
JointState operator/(double lambda) const
Overload the / operator with a scalar.
Class to define torques of the joints.
void clamp(double max_absolute_value, double noise_ratio=0.)
Clamp inplace the magnitude of the torque to the values in argument.
JointTorques copy() const
Return a copy of the JointTorques.
JointTorques & operator+=(const JointTorques &torques)
Overload the += operator.
JointTorques clamped(double max_absolute_value, double noise_ratio=0.) const
Return the torque clamped to the values in argument.
JointTorques()
Empty constructor.
virtual void set_data(const Eigen::VectorXd &data) override
Set the torques data from an Eigen vector.
static JointTorques Random(const std::string &robot_name, unsigned int nb_joints)
Constructor for the random JointTorques.
JointTorques operator+(const JointTorques &torques) const
Overload the + operator.
JointTorques & operator-=(const JointTorques &torques)
Overload the -= operator.
JointTorques operator-(const JointTorques &torques) const
Overload the - operator.
static JointTorques Zero(const std::string &robot_name, unsigned int nb_joints)
Constructor for the zero JointTorques.
JointTorques & operator/=(double lambda)
Overload the /= operator with a scalar.
JointTorques operator/(double lambda) const
Overload the / operator with a scalar.
JointTorques & operator*=(double lambda)
Overload the *= operator with a double gain.
Eigen::VectorXd data() const override
Returns the torques data as an Eigen vector.
friend JointTorques operator*(double lambda, const JointTorques &torques)
Overload the * operator with a scalar.
const std::string & get_name() const
Getter of the name as const reference.
void set_type(const StateType &type)
Override the state type.
bool is_empty() const
Getter of the empty attribute.
void set_empty(bool empty=true)
Setter of the empty attribute.
Core state variables and objects.
CartesianAcceleration operator*(const CartesianState &state, const CartesianAcceleration &acceleration)
std::ostream & operator<<(std::ostream &os, const Ellipsoid &ellipsoid)