1#include "state_representation/space/cartesian/CartesianWrench.hpp"
2#include "state_representation/exceptions/EmptyStateException.hpp"
6using namespace exceptions;
9 this->
set_type(StateType::CARTESIAN_WRENCH);
14 this->
set_type(StateType::CARTESIAN_WRENCH);
19 this->
set_type(StateType::CARTESIAN_WRENCH);
24 const std::string& name,
const Eigen::Vector3d& force,
const Eigen::Vector3d& torque,
const std::string& reference
26 this->
set_type(StateType::CARTESIAN_WRENCH);
32 const std::string& name,
const Eigen::Matrix<double, 6, 1>& wrench,
const std::string& reference
34 this->
set_type(StateType::CARTESIAN_WRENCH);
39 this->
set_type(StateType::CARTESIAN_WRENCH);
55 Eigen::Matrix<double, 6, 1> random = Eigen::Matrix<double, 6, 1>::Random();
64 if (
data.size() != 6) {
66 "Input is of incorrect size: expected 6, given " + std::to_string(
data.size()));
75void CartesianWrench::clamp(
double max_force,
double max_torque,
double force_noise_ratio,
double torque_noise_ratio) {
77 this->clamp_state_variable(max_force, CartesianStateVariable::FORCE, force_noise_ratio);
79 this->clamp_state_variable(max_torque, CartesianStateVariable::TORQUE, torque_noise_ratio);
83 double max_force,
double max_torque,
double force_noise_ratio,
double torque_noise_ratio
86 result.
clamp(max_force, max_torque, force_noise_ratio, torque_noise_ratio);
109 return wrench * lambda;
Class to represent a state in Cartesian space.
void set_zero()
Set the State to a zero value.
virtual std::vector< double > norms(const CartesianStateVariable &state_variable_type=CartesianStateVariable::ALL) const
Compute the norms of the state variable specified by the input type. Default is full state.
void set_force(const Eigen::Vector3d &force)
Setter of the force attribute.
CartesianState normalized(const CartesianStateVariable &state_variable_type=CartesianStateVariable::ALL) const
Compute the normalized state at the state variable given in argument. Default is full state.
static CartesianState Identity(const std::string &name, const std::string &reference="world")
Constructor for the identity Cartesian state (identity pose and 0 for the rest)
CartesianState & operator/=(double lambda)
Scale inplace by a scalar.
std::string to_string() const override
Convert the state to its string representation.
void set_wrench(const Eigen::Matrix< double, 6, 1 > &wrench)
Setter of the force and torque from a 6d wrench vector.
Eigen::Matrix< double, 6, 1 > get_wrench() const
Getter of the 6d wrench from force and torque attributes.
CartesianState & operator+=(const CartesianState &state)
Add inplace another Cartesian state.
CartesianState operator-() const
Negate a Cartesian state.
CartesianState & operator-=(const CartesianState &state)
Compute inplace the difference with another Cartesian state.
void set_torque(const Eigen::Vector3d &torque)
Setter of the torque attribute.
CartesianState & operator*=(const CartesianState &state)
Transform inplace a Cartesian state into the current reference frame.
CartesianState operator/(double lambda) const
Scale a Cartesian state by a scalar.
friend CartesianState operator*(double lambda, const CartesianState &state)
Scale a Cartesian state by a scalar.
CartesianState operator+(const CartesianState &state) const
Add another Cartesian state.
Class to define wrench in Cartesian space as 3D force and torque vectors.
Eigen::VectorXd data() const override
Returns the wrench data as an Eigen vector.
friend CartesianWrench operator*(double lambda, const CartesianWrench &wrench)
Scale a Cartesian wrench by a scalar.
CartesianWrench()
Empty constructor.
CartesianWrench normalized(const CartesianStateVariable &state_variable_type=CartesianStateVariable::WRENCH) const
Compute the normalized wrench at the state variable given in argument (default is full wrench)
CartesianWrench operator/(double lambda) const
Scale a Cartesian wrench by a scalar.
static CartesianWrench Zero(const std::string &name, const std::string &reference="world")
Constructor for the zero wrench.
void set_data(const Eigen::VectorXd &data) override
Set the wrench data from an Eigen vector.
CartesianWrench clamped(double max_force, double max_torque, double force_noise_ratio=0, double torque_noise_ratio=0) const
Return the clamped wrench.
std::vector< double > norms(const CartesianStateVariable &state_variable_type=CartesianStateVariable::WRENCH) const override
Compute the norms of the state variable specified by the input type (default is full wrench)
CartesianWrench copy() const
Return a copy of the Cartesian wrench.
CartesianWrench operator-() const
Negate a Cartesian wrench.
void clamp(double max_force, double max_torque, double force_noise_ratio=0, double torque_noise_ratio=0)
Clamp inplace the magnitude of the wrench to the values in argument.
CartesianWrench & operator/=(double lambda)
Scale inplace by a scalar.
static CartesianWrench Random(const std::string &name, const std::string &reference="world")
Constructor for a random wrench.
void set_type(const StateType &type)
Setter of the state type attribute.
Core state variables and objects.
std::ostream & operator<<(std::ostream &os, const AnalogIOState &state)
CartesianAcceleration operator*(double lambda, const CartesianAcceleration &acceleration)