Go to the documentation of this file.
42 #include <boost/math/constants/constants.hpp>
59 const double pihalf = boost::math::constants::half_pi<double>();
76 return deg * boost::math::constants::degree<T>();
85 return deg * boost::math::constants::degree<T>() *
86 boost::math::constants::degree<T>();
95 return rad * boost::math::constants::radian<T>();
101 [[nodiscard]]
inline Eigen::Matrix3d
rpyToRot(
double roll,
double pitch,
105 double sa, ca, sb, cb, sc, cc;
108 sb = std::sin(pitch);
109 cb = std::cos(pitch);
113 M << cb * cc, -ca * sc + sa * sb * cc, sc * sa + ca * sb * cc, cb * sc,
114 ca * cc + sa * sb * sc, -sa * cc + ca * sb * sc, -sb, sa * cb, ca * cb;
124 return std::remainder(
angle, 360.0);
132 [[nodiscard]]
double parseDouble(
const uint8_t* buffer);
146 [[nodiscard]]
bool parseDouble(
const std::string&
string,
double& value);
153 [[nodiscard]]
float parseFloat(
const uint8_t* buffer);
167 [[nodiscard]]
bool parseFloat(
const std::string&
string,
float& value);
174 [[nodiscard]] int16_t
parseInt16(
const uint8_t* buffer);
190 [[nodiscard]]
bool parseInt16(
const std::string&
string, int16_t& value,
198 [[nodiscard]] int32_t
parseInt32(
const uint8_t* buffer);
214 [[nodiscard]]
bool parseInt32(
const std::string&
string, int32_t& value,
231 [[nodiscard]]
bool parseUInt8(
const std::string&
string, uint8_t& value,
239 [[nodiscard]] uint16_t
parseUInt16(
const uint8_t* buffer);
255 [[nodiscard]]
bool parseUInt16(
const std::string&
string, uint16_t& value,
263 [[nodiscard]] uint32_t
parseUInt32(
const uint8_t* buffer);
279 [[nodiscard]]
bool parseUInt32(
const std::string&
string, uint32_t& value,
321 [[nodiscard]]
inline Eigen::Quaterniond
328 double cy = std::cos(yaw * 0.5);
329 double sy = std::sin(yaw * 0.5);
330 double cp = std::cos(pitch * 0.5);
331 double sp = std::sin(pitch * 0.5);
332 double cr = std::cos(roll * 0.5);
333 double sr = std::sin(roll * 0.5);
335 return Eigen::Quaterniond(
336 cr * cp * cy + sr * sp * sy, sr * cp * cy - cr * sp * sy,
337 cr * sp * cy + sr * cp * sy, cr * cp * sy - sr * sp * cy);
373 quaternion.w = std::numeric_limits<double>::quiet_NaN();
374 quaternion.x = std::numeric_limits<double>::quiet_NaN();
375 quaternion.y = std::numeric_limits<double>::quiet_NaN();
376 quaternion.z = std::numeric_limits<double>::quiet_NaN();
381 v.x = std::numeric_limits<double>::quiet_NaN();
382 v.y = std::numeric_limits<double>::quiet_NaN();
383 v.z = std::numeric_limits<double>::quiet_NaN();
392 [[nodiscard]]
inline Eigen::Quaterniond
q_enu_ecef(
double lat,
double lon)
394 double sr = sin((
pihalf - lat) / 2.0);
395 double cr = cos((
pihalf - lat) / 2.0);
396 double sy = sin((lon +
pihalf) / 2.0);
397 double cy = cos((lon +
pihalf) / 2.0);
399 return Eigen::Quaterniond(cr * cy, sr * cy, sr * sy, cr * sy);
408 [[nodiscard]]
inline Eigen::Quaterniond
q_ned_ecef(
double lat,
double lon)
410 double sp = sin((-lat -
pihalf) / 2.0);
411 double cp = cos((-lat -
pihalf) / 2.0);
412 double sy = sin(lon / 2.0);
413 double cy = cos(lon / 2.0);
415 return Eigen::Quaterniond(cp * cy, -sp * sy, sp * cy, cp * sy);
424 [[nodiscard]]
inline Eigen::Matrix3d
R_enu_ecef(
double lat,
double lon)
428 double sin_lat = sin(lat);
429 double cos_lat = cos(lat);
430 double sin_lon = sin(lon);
431 double cos_lon = cos(lon);
434 R(0, 1) = -cos_lon * sin_lat;
435 R(0, 2) = cos_lon * cos_lat;
437 R(1, 1) = -sin_lon * sin_lat;
438 R(1, 2) = sin_lon * cos_lat;
452 [[nodiscard]]
inline Eigen::Matrix3d
R_ned_ecef(
double lat,
double lon)
456 double sin_lat = sin(lat);
457 double cos_lat = cos(lat);
458 double sin_lon = sin(lon);
459 double cos_lon = cos(lon);
461 R(0, 0) = -cos_lon * sin_lat;
463 R(0, 2) = -cos_lon * cos_lat;
464 R(1, 0) = -sin_lon * sin_lat;
466 R(1, 2) = -sin_lon * cos_lat;
490 [[nodiscard]] uint16_t
getCrc(
const std::vector<uint8_t>& message);
498 [[nodiscard]] uint16_t
getId(
const std::vector<uint8_t>& message);
506 [[nodiscard]] uint16_t
getLength(
const std::vector<uint8_t>& message);
514 [[nodiscard]] uint32_t
getTow(
const std::vector<uint8_t>& message);
522 [[nodiscard]] uint16_t
getWnc(
const std::vector<uint8_t>& message);
526 return std::isnan(val) ? -1.0 :
deg2radSq(val);
531 return std::isnan(val) ? 0.0 :
deg2radSq(val);
QuaternionMsg quaternionToQuaternionMsg(const Eigen::Quaterniond &q)
Transforms Euler angles to a QuaternionMsg.
uint32_t getTow(const std::vector< uint8_t > &message)
Get the time of week in ms of the SBF message.
double wrapAngle180to180(double angle)
Wraps an angle between -180 and 180 degrees.
std::time_t convertUTCtoUnix(double utc_double)
Converts UTC time from the without-colon-delimiter format to Unix Epoch time (a number-of-seconds-sin...
geometry_msgs::msg::Quaternion QuaternionMsg
std::string convertUserPeriodToRxCommand(uint32_t period_user)
Transforms the input polling period [milliseconds] into a std::string number that can be appended to ...
double convertCovariance(double val)
uint16_t getWnc(const std::vector< uint8_t > &message)
Get the GPS week counter of the SBF message.
int32_t parseInt32(const uint8_t *buffer)
Converts a 4-byte-buffer into a signed 32-bit integer.
float parseFloat(const uint8_t *buffer)
Converts a 4-byte-buffer into a float.
Eigen::Matrix3d R_enu_ecef(double lat, double lon)
Generates the matrix to rotate from local ENU to ECEF.
Eigen::Quaterniond convertEulerToQuaternion(double roll, double pitch, double yaw)
Transforms Euler angles to a quaternion.
uint16_t getLength(const std::vector< uint8_t > &message)
Get the length of the SBF message.
double convertUTCDoubleToSeconds(double utc_double)
Converts UTC time from the without-colon-delimiter format to the number-of-seconds-since-midnight for...
uint16_t getCrc(const std::vector< uint8_t > &message)
Get the CRC of the SBF message.
uint32_t parseUInt32(const uint8_t *buffer)
Converts a 4-byte-buffer into an unsigned 32-bit integer.
uint16_t parseUInt16(const uint8_t *buffer)
Converts a 2-byte-buffer into an unsigned 16-bit integer.
QuaternionMsg convertEulerToQuaternionMsg(double roll, double pitch, double yaw)
Convert Eigen quaternion to a QuaternionMsg.
geometry_msgs::msg::Vector3 Vector3Msg
Eigen::Matrix3d R_ned_ecef(double lat, double lon)
Generates the matrix to rotate from local NED to ECEF.
double convertAutoCovariance(double val)
uint16_t getId(const std::vector< uint8_t > &message)
Get the ID of the SBF message.
double convertDMSToDegrees(double dms)
Converts latitude or longitude from the DMS notation (in the without-colon-delimiter format),...
Eigen::Matrix3d rpyToRot(double roll, double pitch, double yaw)
Eigen::Quaterniond q_ned_ecef(double lat, double lon)
Generates the quaternion to rotate from local NED to ECEF.
Eigen::Quaterniond q_enu_ecef(double lat, double lon)
Generates the quaternion to rotate from local ENU to ECEF.
TF2SIMD_FORCE_INLINE tf2Scalar angle(const Quaternion &q1, const Quaternion &q2)
void setQuaternionNaN(QuaternionMsg &quaternion)
bool parseUInt8(const std::string &string, uint8_t &value, int32_t base=10)
Interprets the contents of "string" as a unsigned integer number of type uint8_t.
int16_t parseInt16(const uint8_t *buffer)
Converts a 2-byte-buffer into a signed 16-bit integer.
double parseDouble(const uint8_t *buffer)
Converts an 8-byte-buffer into a double.
void setVector3NaN(Vector3Msg &v)