1#include "state_representation/space/joint/JointPositions.hpp"
3#include "state_representation/exceptions/EmptyStateException.hpp"
5using namespace state_representation::exceptions;
9 this->
set_type(StateType::JOINT_POSITIONS);
14 this->
set_type(StateType::JOINT_POSITIONS);
19 this->
set_type(StateType::JOINT_POSITIONS);
25 this->
set_type(StateType::JOINT_POSITIONS);
29 const std::string& robot_name,
const std::vector<std::string>& joint_names,
const Eigen::VectorXd& positions
31 this->
set_type(StateType::JOINT_POSITIONS);
37 this->
set_type(StateType::JOINT_POSITIONS);
58 return JointPositions(robot_name, Eigen::VectorXd::Random(nb_joints));
62 return JointPositions(robot_name, joint_names, Eigen::VectorXd::Random(joint_names.size()));
128 double period = dt.count();
153 this->clamp_state_variable(max_absolute_value, JointStateVariable::POSITIONS, noise_ratio);
158 result.
clamp(max_absolute_value, noise_ratio);
162void JointPositions::clamp(
const Eigen::ArrayXd& max_absolute_value_array,
const Eigen::ArrayXd& noise_ratio_array) {
163 this->clamp_state_variable(max_absolute_value_array, JointStateVariable::POSITIONS, noise_ratio_array);
167 const Eigen::ArrayXd& max_absolute_value_array,
const Eigen::ArrayXd& noise_ratio_array
170 result.
clamp(max_absolute_value_array, noise_ratio_array);
176 os <<
"Empty JointPositions";
178 os << positions.
get_name() <<
" JointPositions" << std::endl;
180 for (
auto& n: positions.
get_names()) { os << n <<
", "; }
181 os <<
"]" << std::endl;
182 os <<
"positions: [";
183 for (
unsigned int i = 0; i < positions.
get_size(); ++i) { os << positions.
get_positions()(i) <<
", "; }
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.
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*=(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()
Empty constructor.
JointPositions & operator/=(double lambda)
Overload the /= operator with a scalar.
Class to define a state in joint space.
JointState operator+(const JointState &state) const
Overload the + operator.
void set_positions(const Eigen::VectorXd &positions)
Setter of the positions attribute.
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.
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.
const Eigen::VectorXd & get_positions() const
Getter of the positions attribute.
void set_velocities(const Eigen::VectorXd &velocities)
Setter of the velocities attribute.
JointState operator/(double lambda) const
Overload the / operator with a scalar.
Class to define velocities of the joints.
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)