21 #ifndef MAV_MSGS_EIGEN_MAV_MSGS_H 22 #define MAV_MSGS_EIGEN_MAV_MSGS_H 24 #include <Eigen/Eigen> 37 :
attitude(Eigen::Quaterniond::Identity()),
38 thrust(Eigen::Vector3d::Zero()) {}
40 const Eigen::Vector3d& _thrust) {
45 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
54 angular_velocities = _angular_velocities;
57 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
65 : angular_rates(Eigen::Vector3d::Zero()),
66 thrust(Eigen::Vector3d::Zero()) {}
69 const Eigen::Vector3d _thrust)
70 : angular_rates(_angular_rates),
thrust(_thrust) {}
72 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
79 : torque(Eigen::Vector3d::Zero()),
thrust(Eigen::Vector3d::Zero()) {}
82 const Eigen::Vector3d _thrust)
83 : torque(_torque),
thrust(_thrust) {}
85 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
92 : roll(0.0), pitch(0.0), yaw_rate(0.0),
thrust(Eigen::Vector3d::Zero()) {}
95 const Eigen::Vector3d& _thrust)
96 : roll(_roll), pitch(_pitch), yaw_rate(_yaw_rate),
thrust(_thrust) {}
114 Eigen::aligned_allocator<EigenMavState>>
Vector;
115 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
119 : position_W(Eigen::Vector3d::Zero()),
120 velocity_W(Eigen::Vector3d::Zero()),
121 acceleration_B(Eigen::Vector3d::Zero()),
122 orientation_W_B(Eigen::Quaterniond::Identity()),
123 angular_velocity_B(Eigen::Vector3d::Zero()),
124 angular_acceleration_B(Eigen::Vector3d::Zero()) {}
127 const Eigen::Vector3d& velocity_W,
128 const Eigen::Vector3d& acceleration_B,
129 const Eigen::Quaterniond& orientation_W_B,
130 const Eigen::Vector3d& angular_velocity_B,
131 const Eigen::Vector3d& angular_acceleration_B)
132 : position_W(position_W),
133 velocity_W(velocity_W),
134 acceleration_B(acceleration_B),
135 orientation_W_B(orientation_W_B),
136 angular_velocity_B(angular_velocity_B),
137 angular_acceleration_B(angular_acceleration_B) {}
140 std::stringstream ss;
141 ss <<
"position: " << position_W.transpose() << std::endl
142 <<
"velocity: " << velocity_W.transpose() << std::endl
143 <<
"acceleration_body: " << acceleration_B.transpose() << std::endl
144 <<
"orientation (w-x-y-z): " << orientation_W_B.w() <<
" " 145 << orientation_W_B.x() <<
" " << orientation_W_B.y() <<
" " 146 << orientation_W_B.z() <<
" " << std::endl
147 <<
"angular_velocity_body: " << angular_velocity_B.transpose()
149 <<
"angular_acceleration_body: " << angular_acceleration_B.transpose()
165 Eigen::aligned_allocator<EigenTrajectoryPoint>>
Vector;
168 time_from_start_ns(0),
169 position_W(Eigen::Vector3d::Zero()),
170 velocity_W(Eigen::Vector3d::Zero()),
171 acceleration_W(Eigen::Vector3d::Zero()),
172 jerk_W(Eigen::Vector3d::Zero()),
173 snap_W(Eigen::Vector3d::Zero()),
174 orientation_W_B(Eigen::Quaterniond::Identity()),
175 angular_velocity_W(Eigen::Vector3d::Zero()),
176 angular_acceleration_W(Eigen::Vector3d::Zero()),
180 const Eigen::Vector3d& _position,
181 const Eigen::Vector3d& _velocity,
182 const Eigen::Vector3d& _acceleration,
183 const Eigen::Vector3d& _jerk,
184 const Eigen::Vector3d& _snap,
185 const Eigen::Quaterniond& _orientation,
186 const Eigen::Vector3d& _angular_velocity,
187 const Eigen::Vector3d& _angular_acceleration,
189 : time_from_start_ns(_time_from_start_ns),
190 position_W(_position),
191 velocity_W(_velocity),
192 acceleration_W(_acceleration),
195 orientation_W_B(_orientation),
196 angular_velocity_W(_angular_velocity),
197 angular_acceleration_W(_angular_acceleration),
198 degrees_of_freedom(_degrees_of_freedom) {}
201 const Eigen::Vector3d& _position,
202 const Eigen::Vector3d& _velocity,
203 const Eigen::Vector3d& _acceleration,
204 const Eigen::Vector3d& _jerk,
205 const Eigen::Vector3d& _snap,
206 const Eigen::Quaterniond& _orientation,
207 const Eigen::Vector3d& _angular_velocity,
209 : EigenTrajectoryPoint(_time_from_start_ns, _position, _velocity,
210 _acceleration, _jerk, _snap, _orientation,
211 _angular_velocity, Eigen::Vector3d::Zero(), _degrees_of_freedom) {}
213 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
229 inline double getYawRate()
const {
return angular_velocity_W.z(); }
230 inline double getYawAcc()
const {
return angular_acceleration_W.z(); }
236 angular_velocity_W.x() = 0.0;
237 angular_velocity_W.y() = 0.0;
238 angular_velocity_W.z() = yaw_rate;
241 angular_acceleration_W.x() = 0.0;
242 angular_acceleration_W.y() = 0.0;
243 angular_acceleration_W.z() = yaw_acc;
247 std::stringstream ss;
248 ss <<
"position: " << position_W.transpose() << std::endl
249 <<
"velocity: " << velocity_W.transpose() << std::endl
250 <<
"acceleration: " << acceleration_W.transpose() << std::endl
251 <<
"jerk: " << jerk_W.transpose() << std::endl
252 <<
"snap: " << snap_W.transpose() << std::endl
253 <<
"yaw: " << getYaw() << std::endl
254 <<
"yaw_rate: " << getYawRate() << std::endl
255 <<
"yaw_acc: " << getYawAcc() << std::endl;
285 position_W(Eigen::Vector3d::Zero()),
286 orientation_W_B(Eigen::Quaterniond::Identity()),
287 velocity_B(Eigen::Vector3d::Zero()),
288 angular_velocity_B(Eigen::Vector3d::Zero()) {}
291 const Eigen::Quaterniond& _orientation,
292 const Eigen::Vector3d& _velocity_body,
293 const Eigen::Vector3d& _angular_velocity)
294 : position_W(_position),
295 orientation_W_B(_orientation),
296 velocity_B(_velocity_body),
297 angular_velocity_B(_angular_velocity) {}
299 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
313 inline double getYawRate()
const {
return angular_velocity_B.z(); }
319 angular_velocity_B.x() = 0.0;
320 angular_velocity_B.y() = 0.0;
321 angular_velocity_B.z() = yaw_rate;
325 return orientation_W_B * velocity_B;
328 velocity_B = orientation_W_B.inverse() * velocity_world;
333 #define MAV_MSGS_CONCATENATE(x, y) x##y 334 #define MAV_MSGS_CONCATENATE2(x, y) MAV_MSGS_CONCATENATE(x, y) 335 #define MAV_MSGS_MAKE_ALIGNED_CONTAINERS(EIGEN_TYPE) \ 336 typedef std::vector<EIGEN_TYPE, Eigen::aligned_allocator<EIGEN_TYPE>> \ 337 MAV_MSGS_CONCATENATE2(EIGEN_TYPE, Vector); \ 338 typedef std::deque<EIGEN_TYPE, Eigen::aligned_allocator<EIGEN_TYPE>> \ 339 MAV_MSGS_CONCATENATE2(EIGEN_TYPE, Deque); 349 #endif // MAV_MSGS_EIGEN_MAV_MSGS_H Eigen::Vector3d acceleration_W
#define MAV_MSGS_MAKE_ALIGNED_CONTAINERS(EIGEN_TYPE)
Eigen::VectorXd normalized
Eigen::Vector3d getVelocityWorld() const
Eigen::Vector3d position_W
void setFromYawRate(double yaw_rate)
EigenRateThrust(const Eigen::Vector3d &_angular_rates, const Eigen::Vector3d _thrust)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW int64_t timestamp_ns
void setFromYawRate(double yaw_rate)
EigenMavState(const Eigen::Vector3d &position_W, const Eigen::Vector3d &velocity_W, const Eigen::Vector3d &acceleration_B, const Eigen::Quaterniond &orientation_W_B, const Eigen::Vector3d &angular_velocity_B, const Eigen::Vector3d &angular_acceleration_B)
std::string toString() const
EigenActuators(const Eigen::VectorXd &_angular_velocities)
MavActuation
Actuated degrees of freedom.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW EigenMavState()
Initializes all members to zero / identity.
Eigen::Vector3d velocity_B
EigenTrajectoryPoint(int64_t _time_from_start_ns, const Eigen::Vector3d &_position, const Eigen::Vector3d &_velocity, const Eigen::Vector3d &_acceleration, const Eigen::Vector3d &_jerk, const Eigen::Vector3d &_snap, const Eigen::Quaterniond &_orientation, const Eigen::Vector3d &_angular_velocity, const Eigen::Vector3d &_angular_acceleration, const MavActuation &_degrees_of_freedom=MavActuation::DOF4)
EigenOdometry(const Eigen::Vector3d &_position, const Eigen::Quaterniond &_orientation, const Eigen::Vector3d &_velocity_body, const Eigen::Vector3d &_angular_velocity)
std::vector< EigenMavState, Eigen::aligned_allocator< EigenMavState > > Vector
std::string toString() const
void setFromYaw(double yaw)
Eigen::Matrix< double, 6, 6 > twist_covariance_
Eigen::Matrix< double, 6, 6 > pose_covariance_
Eigen::Quaterniond orientation_W_B
void setVelocityWorld(const Eigen::Vector3d &velocity_world)
void getEulerAnglesFromQuaternion(const Eigen::Quaternion< double > &q, Eigen::Vector3d *euler_angles)
EigenAttitudeThrust(const Eigen::Quaterniond &_attitude, const Eigen::Vector3d &_thrust)
MavActuation degrees_of_freedom
EigenTrajectoryPoint(int64_t _time_from_start_ns, const Eigen::Vector3d &_position, const Eigen::Vector3d &_velocity, const Eigen::Vector3d &_acceleration, const Eigen::Vector3d &_jerk, const Eigen::Vector3d &_snap, const Eigen::Quaterniond &_orientation, const Eigen::Vector3d &_angular_velocity, const MavActuation &_degrees_of_freedom=MavActuation::DOF4)
EigenTorqueThrust(const Eigen::Vector3d &_torque, const Eigen::Vector3d _thrust)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Eigen::Vector3d angular_rates
Eigen::Vector3d velocity_W
Eigen::Vector3d angular_velocity_W
Eigen::VectorXd angular_velocities
EIGEN_MAKE_ALIGNED_OPERATOR_NEW int64_t timestamp_ns
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Eigen::VectorXd angles
EigenRollPitchYawrateThrust(double _roll, double _pitch, double _yaw_rate, const Eigen::Vector3d &_thrust)
double getYawRate() const
Eigen::Quaterniond orientation_W_B
std::vector< EigenTrajectoryPoint, Eigen::aligned_allocator< EigenTrajectoryPoint > > Vector
Eigen::Vector3d position_W
Eigen::Vector3d angular_acceleration_B
int64_t time_from_start_ns
double yawFromQuaternion(const Eigen::Quaterniond &q)
Extracts the yaw part from a quaternion, using RPY / euler (z-y'-z'') angles. RPY rotates about the f...
void getEulerAngles(Eigen::Vector3d *euler_angles) const
void setFromYawAcc(double yaw_acc)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Eigen::Quaterniond attitude
Eigen::Vector3d position_W
Container holding the state of a MAV: position, velocity, attitude and angular velocity. In addition, holds the acceleration expressed in body coordinates, which is what the accelerometer usually measures.
Eigen::Vector3d angular_velocity_B
double getYawRate() const
Eigen::Vector3d angular_acceleration_W
Eigen::Quaterniond orientation_W_B
EigenRollPitchYawrateThrust()
Eigen::Quaterniond quaternionFromYaw(double yaw)
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Eigen::Vector3d torque
Eigen::Vector3d velocity_W
void setFromYaw(double yaw)
Eigen::Vector3d angular_velocity_B
Eigen::Vector3d acceleration_B
EigenTrajectoryPoint operator*(const Eigen::Affine3d &lhs, const EigenTrajectoryPoint &rhs)