3#include "state_representation/space/SpatialState.hpp"
4#include "state_representation/exceptions/IncompatibleSizeException.hpp"
15enum class CartesianStateVariable {
40 const CartesianState& s1,
const CartesianState& s2,
41 const CartesianStateVariable& state_variable_type = CartesianStateVariable::ALL
58 explicit CartesianState(
const std::string& name,
const std::string& reference =
"world");
110 Eigen::Matrix<double, 7, 1>
get_pose()
const;
131 Eigen::Matrix<double, 6, 1>
get_twist()
const;
151 const Eigen::Vector3d&
get_force()
const;
161 Eigen::Matrix<double, 6, 1>
get_wrench()
const;
166 virtual Eigen::VectorXd
data()
const;
171 Eigen::ArrayXd
array()
const;
191 void set_position(
const double& x,
const double& y,
const double& z);
215 void set_orientation(
const double& w,
const double& x,
const double& y,
const double& z);
220 void set_pose(
const Eigen::Vector3d& position,
const Eigen::Quaterniond& orientation);
227 void set_pose(
const Eigen::Matrix<double, 7, 1>& pose);
234 void set_pose(
const std::vector<double>& pose);
269 void set_twist(
const Eigen::Matrix<double, 6, 1>& twist);
274 void set_twist(
const std::vector<double>& twist);
319 void set_force(
const Eigen::Vector3d& force);
324 void set_force(
const std::vector<double>& force);
329 void set_force(
const double& x,
const double& y,
const double& z);
334 void set_torque(
const Eigen::Vector3d& torque);
339 void set_torque(
const std::vector<double>& torque);
344 void set_torque(
const double& x,
const double& y,
const double& z);
349 void set_wrench(
const Eigen::Matrix<double, 6, 1>& wrench);
354 void set_wrench(
const std::vector<double>& wrench);
359 virtual void set_data(
const Eigen::VectorXd&
data)
override;
364 virtual void set_data(
const std::vector<double>&
data)
override;
378 void clamp_state_variable(
double max_norm,
const CartesianStateVariable& state_variable_type,
double noise_ratio = 0);
393 const CartesianState& state,
const CartesianStateVariable& state_variable_type = CartesianStateVariable::ALL
411 void reset()
override;
428 void normalize(
const CartesianStateVariable& state_variable_type = CartesianStateVariable::ALL);
442 virtual std::vector<double>
443 norms(
const CartesianStateVariable& state_variable_type = CartesianStateVariable::ALL)
const;
493 Eigen::Vector3d
operator*(
const Eigen::Vector3d& vector)
const;
558 Eigen::VectorXd
get_state_variable(
const CartesianStateVariable& state_variable_type)
const;
565 void set_state_variable(
const Eigen::VectorXd& new_value,
const CartesianStateVariable& state_variable_type);
572 void set_state_variable(
const std::vector<double>& new_value,
const CartesianStateVariable& state_variable_type);
580 Eigen::Vector3d position_;
581 Eigen::Quaterniond orientation_;
582 Eigen::Vector3d linear_velocity_;
583 Eigen::Vector3d angular_velocity_;
584 Eigen::Vector3d linear_acceleration_;
585 Eigen::Vector3d angular_acceleration_;
586 Eigen::Vector3d force_;
587 Eigen::Vector3d torque_;
592 std::swap(state1.position_, state2.position_);
593 std::swap(state1.orientation_, state2.orientation_);
594 std::swap(state1.linear_velocity_, state2.linear_velocity_);
595 std::swap(state1.angular_velocity_, state2.angular_velocity_);
596 std::swap(state1.linear_acceleration_, state2.linear_acceleration_);
597 std::swap(state1.angular_acceleration_, state2.angular_acceleration_);
598 std::swap(state1.force_, state2.force_);
599 std::swap(state1.torque_, state2.torque_);
Class to represent a state in Cartesian space.
void set_zero()
Set the State to a zero value.
const Eigen::Vector3d & get_force() const
Getter of the force attribute.
void set_acceleration(const Eigen::Matrix< double, 6, 1 > &acceleration)
Setter of the linear and angular acceleration from a 6d acceleration vector.
CartesianState inverse() const
Compute the inverse of the current Cartesian state.
Eigen::ArrayXd array() const
Return the data vector as an Eigen Array.
const Eigen::Vector3d & get_torque() const
Getter of the torque attribute.
static CartesianState Random(const std::string &name, const std::string &reference="world")
Constructor for a random Cartesian state.
void set_state_variable(const Eigen::VectorXd &new_value, const CartesianStateVariable &state_variable_type)
Setter of the variable value corresponding to the input.
void set_orientation(const Eigen::Quaterniond &orientation)
Setter of the orientation.
friend std::ostream & operator<<(std::ostream &os, const CartesianState &state)
Overload the ostream operator for printing.
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.
const Eigen::Vector3d & get_position() const
Getter of the position attribute.
void normalize(const CartesianStateVariable &state_variable_type=CartesianStateVariable::ALL)
Normalize inplace the state at the state variable given in argument. Default is full state.
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.
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.
friend double dist(const CartesianState &s1, const CartesianState &s2, const CartesianStateVariable &state_variable_type)
Compute the distance between two Cartesian states.
CartesianState()
Empty constructor.
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.
const Eigen::Vector3d & get_linear_acceleration() const
Getter of the linear acceleration attribute.
Eigen::Matrix4d get_transformation_matrix() const
Getter of a pose from position and orientation attributes.
void set_linear_acceleration(const Eigen::Vector3d &linear_acceleration)
Setter of the linear acceleration attribute.
void clamp_state_variable(double max_norm, const CartesianStateVariable &state_variable_type, double noise_ratio=0)
Clamp inplace the norm of the a specific state variable.
Eigen::Matrix< double, 7, 1 > get_pose() const
Getter of the pose from position and orientation attributes.
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_wrench(const Eigen::Matrix< double, 6, 1 > &wrench)
Setter of the force and torque from a 6d wrench vector.
const Eigen::Quaterniond & get_orientation() const
Getter of the orientation attribute.
Eigen::Matrix< double, 6, 1 > get_wrench() const
Getter of the 6d wrench from force and torque attributes.
Eigen::VectorXd get_state_variable(const CartesianStateVariable &state_variable_type) const
Getter of the variable value corresponding to the input.
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.
CartesianState & operator=(const CartesianState &state)
Copy assignment operator that has to be defined to the custom assignment operator.
virtual Eigen::VectorXd data() const
Return the data as the concatenation of all the state variables in a single vector.
const Eigen::Vector3d & get_angular_velocity() const
Getter of the angular velocity attribute.
void set_pose(const Eigen::Vector3d &position, const Eigen::Quaterniond &orientation)
Setter of the pose from both position and orientation.
CartesianState copy() const
Return a copy of the 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.
virtual void set_data(const Eigen::VectorXd &data) override
Set the data of the state from all the state variables in a single Eigen vector.
Eigen::Vector4d get_orientation_coefficients() const
Getter of the orientation attribute as Vector4d of coefficients.
CartesianState & operator*=(const CartesianState &state)
Transform inplace a Cartesian state into the current reference frame.
const Eigen::Vector3d & get_angular_acceleration() const
Getter of the angular acceleration attribute.
CartesianState operator/(double lambda) const
Scale a Cartesian state by a scalar.
std::vector< double > to_std_vector() const
Return the state as a std vector.
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.
Eigen::Matrix< double, 6, 1 > get_acceleration() const
Getter of the 6d acceleration from linear and angular acceleration attributes.
friend void swap(CartesianState &state1, CartesianState &state2)
Swap the values of two Cartesian states.
void reset() override
Reset the object to a post-construction state.
CartesianState operator+(const CartesianState &state) const
Add another Cartesian state.
Core state variables and objects.
double dist(const CartesianState &s1, const CartesianState &s2, const CartesianStateVariable &state_variable_type=CartesianStateVariable::ALL)
Compute the distance between two Cartesian states.
void swap(AnalogIOState &state1, AnalogIOState &state2)