1#include "state_representation/space/cartesian/CartesianTwist.hpp"
2#include "state_representation/exceptions/EmptyStateException.hpp"
6using namespace exceptions;
9 this->
set_type(StateType::CARTESIAN_TWIST);
14 this->
set_type(StateType::CARTESIAN_TWIST);
18 const std::string& name,
const Eigen::Vector3d& linear_velocity,
const std::string& reference
20 this->
set_type(StateType::CARTESIAN_TWIST);
25 const std::string& name,
const Eigen::Vector3d& linear_velocity,
const Eigen::Vector3d& angular_velocity,
26 const std::string& reference
28 this->
set_type(StateType::CARTESIAN_TWIST);
34 const std::string& name,
const Eigen::Matrix<double, 6, 1>& twist,
const std::string& reference
36 this->
set_type(StateType::CARTESIAN_TWIST);
41 this->
set_type(StateType::CARTESIAN_TWIST);
62 Eigen::Matrix<double, 6, 1> random = Eigen::Matrix<double, 6, 1>::Random();
71 if (
data.size() != 6) {
73 "Input is of incorrect size: expected 6, given " + std::to_string(
data.size()));
83 double max_linear,
double max_angular,
double linear_noise_ratio,
double angular_noise_ratio
86 this->clamp_state_variable(max_linear, CartesianStateVariable::LINEAR_VELOCITY, linear_noise_ratio);
88 this->clamp_state_variable(max_angular, CartesianStateVariable::ANGULAR_VELOCITY, angular_noise_ratio);
92 double max_linear,
double max_angular,
double linear_noise_ratio,
double angular_noise_ratio
95 result.
clamp(max_linear, max_angular, linear_noise_ratio, angular_noise_ratio);
126 return twist * lambda;
139 double period = dt.count();
143 Eigen::Quaterniond angular_displacement = Eigen::Quaterniond::Identity();
145 if (angular_norm > 1e-4) {
146 double theta = angular_norm * period * 0.5;
147 angular_displacement.w() = cos(theta);
170 double period = dt.count();
Class to define acceleration in Cartesian space as 3D linear and angular acceleration vectors.
Class to define Cartesian pose in Cartesian space as 3D position and quaternion based orientation.
Class to represent a state in Cartesian space.
void set_zero()
Set the State to a zero value.
CartesianState inverse() const
Compute the inverse of the current Cartesian state.
void set_orientation(const Eigen::Quaterniond &orientation)
Setter of the orientation.
const Eigen::Vector3d & get_linear_velocity() const
Getter of the linear velocity attribute.
void set_angular_acceleration(const Eigen::Vector3d &angular_acceleration)
Setter of the angular velocity attribute.
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.
Eigen::Matrix< double, 6, 1 > get_twist() const
Getter of the 6d twist from linear and angular velocity attributes.
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.
void set_linear_acceleration(const Eigen::Vector3d &linear_acceleration)
Setter of the linear acceleration attribute.
void set_position(const Eigen::Vector3d &position)
Setter of the position.
std::string to_string() const override
Convert the state to its string representation.
void set_twist(const Eigen::Matrix< double, 6, 1 > &twist)
Setter of the linear and angular velocities from a 6d twist vector.
CartesianState & operator+=(const CartesianState &state)
Add inplace another Cartesian state.
CartesianState operator-() const
Negate a Cartesian state.
const Eigen::Vector3d & get_angular_velocity() const
Getter of the angular velocity attribute.
CartesianState & operator-=(const CartesianState &state)
Compute inplace the difference with another Cartesian state.
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.
void set_linear_velocity(const Eigen::Vector3d &linear_velocity)
Setter of the linear velocity attribute.
void set_angular_velocity(const Eigen::Vector3d &angular_velocity)
Setter of the angular velocity attribute.
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 twist in Cartesian space as 3D linear and angular velocity vectors.
std::vector< double > norms(const CartesianStateVariable &state_variable_type=CartesianStateVariable::TWIST) const override
Compute the norms of the state variable specified by the input type (default is full twist)
Eigen::VectorXd data() const override
Returns the twist data as an Eigen vector.
CartesianTwist clamped(double max_linear, double max_angular, double noise_ratio=0, double angular_noise_ratio=0) const
Return the clamped twist.
static CartesianTwist Random(const std::string &name, const std::string &reference="world")
Constructor for a random twist.
friend CartesianTwist operator*(double lambda, const CartesianTwist &twist)
Scale a Cartesian twist by a scalar.
static CartesianTwist Zero(const std::string &name, const std::string &reference="world")
Constructor for the zero twist.
void set_data(const Eigen::VectorXd &data) override
Set the twist data from an Eigen vector.
void clamp(double max_linear, double max_angular, double linear_noise_ratio=0, double angular_noise_ratio=0)
Clamp inplace the magnitude of the twist to the values in argument.
CartesianTwist copy() const
Return a copy of the Cartesian twist.
CartesianTwist()
Empty constructor.
CartesianTwist normalized(const CartesianStateVariable &state_variable_type=CartesianStateVariable::TWIST) const
Compute the normalized twist at the state variable given in argument (default is full twist)
CartesianTwist operator/(double lambda) const
Scale a Cartesian twist by a scalar.
CartesianTwist inverse() const
Compute the inverse of the current Cartesian twist.
CartesianTwist operator-() const
Negate a Cartesian twist.
CartesianTwist & operator/=(double lambda)
Scale inplace by a scalar.
const std::string & get_reference_frame() const
Getter of the reference frame as const reference.
const std::string & get_name() const
Getter of the name attribute.
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)