37 #include <boost/spirit/include/qi_binary.hpp> 47 namespace qi = boost::spirit::qi;
55 while (angle < -180.0)
65 qi::parse(buffer, buffer + 8, qi::little_bin_double, val);
82 qi::parse(buffer, buffer + 4, qi::little_bin_float, val);
106 qi::parse(buffer, buffer + 2, qi::little_word, val);
115 bool parseInt16(
const std::string&
string, int16_t& value, int32_t base)
125 intermd <= std::numeric_limits<int16_t>::max() &&
126 intermd >= std::numeric_limits<int16_t>::min())
128 value =
static_cast<int16_t
>(intermd);
138 qi::parse(buffer, buffer + 4, qi::little_dword, val);
147 bool parseInt32(
const std::string&
string, int32_t& value, int32_t base)
157 bool parseUInt8(
const std::string&
string, uint8_t& value, int32_t base)
167 intermd <= std::numeric_limits<uint8_t>::max())
169 value =
static_cast<uint8_t
>(intermd);
179 qi::parse(buffer, buffer + 2, qi::little_word, val);
188 bool parseUInt16(
const std::string&
string, uint16_t& value, int32_t base)
198 intermd <= std::numeric_limits<uint16_t>::max())
200 value =
static_cast<uint16_t
>(intermd);
210 qi::parse(buffer, buffer + 4, qi::little_dword, val);
219 bool parseUInt32(
const std::string&
string, uint32_t& value, int32_t base)
231 uint32_t hours =
static_cast<uint32_t
>(utc_double) / 10000;
232 uint32_t minutes = (
static_cast<uint32_t
>(utc_double) - hours * 10000) / 100;
234 utc_double -
static_cast<double>(hours * 10000 + minutes * 100);
235 seconds +=
static_cast<double>(hours * 3600 + minutes * 60);
246 uint32_t whole_degrees =
static_cast<uint32_t
>(dms) / 100;
247 double minutes = dms -
static_cast<double>(whole_degrees * 100);
248 double degrees =
static_cast<double>(whole_degrees) + minutes / 60.0;
270 time_t time_now = time(0);
276 timeinfo = gmtime(&time_now);
278 uint32_t hours =
static_cast<uint32_t
>(utc_double) / 10000;
279 uint32_t minutes = (
static_cast<uint32_t
>(utc_double) - hours * 10000) / 100;
281 (
static_cast<uint32_t
>(utc_double) - hours * 10000 - minutes * 100);
284 timeinfo->tm_hour = hours;
285 timeinfo->tm_min = minutes;
286 timeinfo->tm_sec = seconds;
298 time_t date = timegm(timeinfo);
312 double cy = std::cos(yaw * 0.5);
313 double sy = std::sin(yaw * 0.5);
314 double cp = std::cos(pitch * 0.5);
315 double sp = std::sin(pitch * 0.5);
316 double cr = std::cos(roll * 0.5);
317 double sr = std::sin(roll * 0.5);
320 q.w = cr * cp * cy + sr * sp * sy;
321 q.x = sr * cp * cy - cr * sp * sy;
322 q.y = cr * sp * cy + sr * cp * sy;
323 q.z = cr * cp * sy - sr * sp * cy;
332 if (period_user == 0)
334 else if (period_user < 1000)
335 return "msec" + std::to_string(period_user);
336 else if (period_user <= 60000)
337 return "sec" + std::to_string(period_user / 1000);
339 return "min" + std::to_string(period_user / 60000);
344 uint16_t
getId(
const uint8_t* buffer)
348 static uint16_t mask = 8191;
uint32_t getTow(const uint8_t *buffer)
Get the time of week in ms of the SBF message.
bool toFloat(const std::string &string, float &value)
Interprets the contents of "string" as a floating point number of type float.
uint16_t getCrc(const uint8_t *buffer)
Get the CRC of the SBF message.
bool toDouble(const std::string &string, double &value)
Interprets the contents of "string" as a floating point number of type double It stores the "string"'...
float parseFloat(const uint8_t *buffer)
Converts a 4-byte-buffer into a float.
double convertUTCDoubleToSeconds(double utc_double)
Converts UTC time from the without-colon-delimiter format to the number-of-seconds-since-midnight for...
bool toUInt32(const std::string &string, uint32_t &value, int32_t base=10)
Interprets the contents of "string" as a floating point number of whatever unsigned integer type your...
double wrapAngle180to180(double angle)
Wraps an angle between -180 and 180 degrees.
std::string convertUserPeriodToRxCommand(uint32_t period_user)
Transforms the input polling period [milliseconds] into a std::string number that can be appended to ...
uint16_t getLength(const uint8_t *buffer)
Get the length of the SBF message.
uint16_t getWnc(const uint8_t *buffer)
Get the GPS week counter of the SBF message.
uint16_t parseUInt16(const uint8_t *buffer)
Converts a 2-byte-buffer into an unsigned 16-bit integer.
Declares lower-level string utility functions used when parsing messages.
uint32_t parseUInt32(const uint8_t *buffer)
Converts a 4-byte-buffer into an unsigned 32-bit integer.
double convertDMSToDegrees(double dms)
Converts latitude or longitude from the DMS notation (in the without-colon-delimiter format)...
Declares utility functions used when parsing messages.
geometry_msgs::Quaternion QuaternionMsg
QuaternionMsg convertEulerToQuaternion(double yaw, double pitch, double roll)
Transforms Euler angles to a quaternion.
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...
bool toInt32(const std::string &string, int32_t &value, int32_t base=10)
Interprets the contents of "string" as a floating point number of whatever integer type your system h...
double parseDouble(const uint8_t *buffer)
Converts an 8-byte-buffer into a double.
int16_t parseInt16(const uint8_t *buffer)
Converts a 2-byte-buffer into a signed 16-bit integer.
uint16_t getId(const uint8_t *buffer)
Get the ID of the SBF message.
int32_t parseInt32(const uint8_t *buffer)
Converts a 4-byte-buffer into a signed 32-bit integer.
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. ...