1#include "state_representation/space/cartesian/CartesianTwist.hpp"
2#include "state_representation/exceptions/EmptyStateException.hpp"
4using namespace state_representation::exceptions;
8 this->
set_type(StateType::CARTESIAN_TWIST);
13 this->
set_type(StateType::CARTESIAN_TWIST);
17 const std::string& name,
const Eigen::Vector3d& linear_velocity,
const std::string& reference
19 this->
set_type(StateType::CARTESIAN_TWIST);
24 const std::string& name,
const Eigen::Vector3d& linear_velocity,
const Eigen::Vector3d& angular_velocity,
25 const std::string& reference
27 this->
set_type(StateType::CARTESIAN_TWIST);
33 const std::string& name,
const Eigen::Matrix<double, 6, 1>& twist,
const std::string& reference
35 this->
set_type(StateType::CARTESIAN_TWIST);
41 this->
set_type(StateType::CARTESIAN_TWIST);
61 Eigen::Matrix<double, 6, 1> random = Eigen::Matrix<double, 6, 1>::Random();
101CartesianTwist& CartesianTwist::operator*=(
const Eigen::Matrix<double, 6, 6>& lambda) {
120 double period = dt.count();
124 Eigen::Quaterniond angular_displacement = Eigen::Quaterniond::Identity();
126 if (angular_norm > 1e-4) {
127 double theta = angular_norm * period * 0.5;
128 angular_displacement.w() = cos(theta);
141 double period = dt.count();
149 double max_linear,
double max_angular,
double linear_noise_ratio,
double angular_noise_ratio
152 this->clamp_state_variable(max_linear, CartesianStateVariable::LINEAR_VELOCITY, linear_noise_ratio);
154 this->clamp_state_variable(max_angular, CartesianStateVariable::ANGULAR_VELOCITY, angular_noise_ratio);
158 double max_linear,
double max_angular,
double linear_noise_ratio,
double angular_noise_ratio
161 result.
clamp(max_linear, max_angular, linear_noise_ratio, angular_noise_ratio);
175 if (
data.size() != 6) {
177 "Input is of incorrect size: expected 6, given " + std::to_string(
data.size()));
192 os <<
"Empty CartesianTwist";
206 return state.operator*(twist);
210 return twist * lambda;
Class to define acceleration in cartesian space as 3D linear and angular acceleration vectors.
Class to define CartesianPose 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 CartesianState.
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.
CartesianState operator-(const CartesianState &state) const
Overload the - operator.
Eigen::Matrix< double, 6, 1 > get_twist() const
Getter of the 6d twist from linear and angular velocity attributes.
static CartesianState Identity(const std::string &name, const std::string &reference="world")
Constructor for the identity CartesianState (identity pose and 0 for the rest)
CartesianState & operator/=(double lambda)
Overload the /= operator with 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.
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)
Overload the += operator.
const Eigen::Vector3d & get_angular_velocity() const
Getter of the angular velocity attribute.
CartesianState & operator-=(const CartesianState &state)
Overload the -= operator.
CartesianState & operator*=(const CartesianState &state)
Overload the *= operator with another state by deriving the equations of motions.
CartesianState operator/(double lambda) const
Overload the / operator with 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)
Overload the * operator with a scalar.
CartesianState operator+(const CartesianState &state) const
Overload the + operator.
Class to define twist in cartesian space as 3D linear and angular velocity vectors.
friend CartesianTwist operator*(const CartesianState &state, const CartesianTwist &twist)
Overload the * operator with a CartesianState.
CartesianTwist & operator+=(const CartesianTwist &twist)
Overload the += operator.
CartesianTwist operator-(const CartesianTwist &twist) const
Overload the - operator with a 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.
CartesianTwist & operator-=(const CartesianTwist &twist)
Overload the -= operator.
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 operator+(const CartesianTwist &twist) const
Overload the + operator with a twist.
CartesianTwist copy() const
Return a copy of the CartesianTwist.
CartesianTwist()
Empty constructor.
CartesianTwist operator/(double lambda) const
Overload the / operator with a scalar.
CartesianTwist inverse() const
Compute the inverse of the current CartesianTwist.
CartesianTwist & operator/=(double lambda)
Overload the /= operator with 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 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)