30 #include "Eigen/src/Core/GlobalFunctions.h" 31 #include "Eigen/src/Core/Matrix.h" 32 #include "Eigen/src/Core/util/Constants.h" 33 #include "Eigen/src/Geometry/Quaternion.h" 34 #include <Eigen/Dense> 56 state.
v = Eigen::Vector3d::Zero();
57 state.
w = Eigen::Vector3d::Zero();
58 state.
v_dot = Eigen::Vector3d::Zero();
59 state.
w_dot = Eigen::Vector3d::Zero();
77 auto fill = [](
auto& vec,
const auto& first,
const auto& second) {
78 vec.push_back(first.x());
79 vec.push_back(first.y());
80 vec.push_back(first.z());
82 vec.push_back(second.w());
83 vec.push_back(second.x());
84 vec.push_back(second.y());
85 vec.push_back(second.z());
92 if (std::isnan(state.
v.x()) || std::isnan(state.
v.y()) || std::isnan(state.
v.z()) || std::isnan(state.
w.x()) ||
93 std::isnan(state.
w.y()) || std::isnan(state.
w.z()))
97 Eigen::Quaterniond q_dot;
98 Eigen::Vector3d tmp = state.
q.inverse() * state.
w;
99 Eigen::Quaterniond omega(0, tmp.x(), tmp.y(), tmp.z());
100 q_dot.coeffs() = 0.5 * (omega * state.
q).coeffs();
102 fill(spline_state.
velocity, state.
q.inverse() * state.
v, q_dot);
105 if (std::isnan(state.
v_dot.x()) || std::isnan(state.
v_dot.y()) || std::isnan(state.
v_dot.z()) ||
106 std::isnan(state.
w_dot.x()) || std::isnan(state.
w_dot.y()) || std::isnan(state.
w_dot.z()))
110 Eigen::Quaterniond q_ddot;
111 tmp = state.
q.inverse() * state.
w_dot;
112 Eigen::Quaterniond omega_dot(0, tmp.x(), tmp.y(), tmp.z());
113 q_ddot.coeffs() = 0.5 * (omega_dot * state.
q).coeffs() + 0.5 * (omega * q_dot).coeffs();
139 Eigen::Quaterniond omega;
140 omega.coeffs() = 2.0 * (q_dot * state.
q.inverse()).coeffs();
143 state.
w = Eigen::Vector3d(omega.x(), omega.y(), omega.z());
152 Eigen::Quaterniond omega_dot;
153 omega_dot.coeffs() = 2.0 * ((q_ddot * state.
q.inverse()).coeffs() -
154 ((q_dot * state.
q.inverse()) * (q_dot * state.
q.inverse())).coeffs());
157 state.
w_dot = Eigen::Vector3d(omega_dot.x(), omega_dot.y(), omega_dot.z());
160 state.
v = state.
q * state.
v;
161 state.
w = state.
q * state.
w;
171 for (
size_t i = 0; i < state.
position.size(); ++i)
176 for (
size_t i = 0; i < state.
velocity.size(); ++i)
Eigen::Vector3d p
position
std::vector< Scalar > acceleration
Eigen::Vector3d w
angular velocity,
void sample(const Time &time, State &state) const
QuinticSplineSegment::Time Time
Relative time in seconds.
void sample(const Time &time, CartesianState &state) const
Sample the CartesianState at the given time.
CartesianTrajectorySegment::Time Time
Eigen::Vector3d v
linear velocity,
QuinticSplineSegment::State SplineState
State of a 7-dimensional Spline.
std::ostream & operator<<(std::ostream &os, const CartesianTrajectorySegment::SplineState &state)
Stream operator for testing and debugging.
CartesianTrajectorySegment::SplineState convert(const CartesianState &state)
Convert a CartesianState into a ros_controllers_cartesian::SplineState.
Eigen::Vector3d v_dot
linear acceleration,
CartesianTrajectorySegment()=delete
Cartesian state with pose, velocity and acceleration.
std::vector< Scalar > position
Eigen::Quaterniond q
rotation
Eigen::Vector3d w_dot
angular acceleration,
std::vector< Scalar > velocity