69 #include <boost/spirit/include/qi.hpp>
241 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x8108, 0x9129,
242 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 0x1231, 0x0210, 0x3273, 0x2252,
243 0x52b5, 0x4294, 0x72f7, 0x62d6, 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c,
244 0xf3ff, 0xe3de, 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
245 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 0x3653, 0x2672,
246 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 0xb75b, 0xa77a, 0x9719, 0x8738,
247 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861,
248 0x2802, 0x3823, 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
249 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 0xdbfd, 0xcbdc,
250 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5,
251 0x2c22, 0x3c03, 0x0c60, 0x1c41, 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b,
252 0x8d68, 0x9d49, 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
253 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 0x9188, 0x81a9,
254 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 0x1080, 0x00a1, 0x30c2, 0x20e3,
255 0x5004, 0x4025, 0x7046, 0x6067, 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c,
256 0xe37f, 0xf35e, 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
257 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 0x34e2, 0x24c3,
258 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xa7db, 0xb7fa, 0x8799, 0x97b8,
259 0xe75f, 0xf77e, 0xc71d, 0xd73c, 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676,
260 0x4615, 0x5634, 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
261 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 0xcb7d, 0xdb5c,
262 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 0x4a75, 0x5a54, 0x6a37, 0x7a16,
263 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b,
264 0x9de8, 0x8dc9, 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
265 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 0x6e17, 0x7e36,
266 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0};
268 namespace qi = boost::spirit::qi;
274 template <
typename T>
277 static_assert(std::is_same<uint16_t, T>::value ||
278 std::is_same<uint32_t, T>::value ||
279 std::is_same<float, T>::value || std::is_same<double, T>::value);
280 if (std::is_same<uint16_t, T>::value)
282 return (
s !=
static_cast<uint16_t
>(65535));
283 }
else if (std::is_same<uint32_t, T>::value)
285 return (
s != 4294967295u);
286 }
else if (std::is_same<float, T>::value)
288 return (
s != -2e10f);
289 }
else if (std::is_same<double, T>::value)
299 template <
typename Val>
303 std::is_same<uint16_t, Val>::value || std::is_same<uint32_t, Val>::value ||
304 std::is_same<uint64_t, Val>::value || std::is_same<float, Val>::value ||
305 std::is_same<double, Val>::value);
307 if (std::is_same<uint16_t, Val>::value)
310 }
else if (std::is_same<uint32_t, Val>::value)
313 }
else if (std::is_same<float, Val>::value)
316 }
else if (std::is_same<double, Val>::value)
327 template <
typename It,
typename Val>
331 std::is_same<int8_t, Val>::value || std::is_same<uint8_t, Val>::value ||
332 std::is_same<int16_t, Val>::value || std::is_same<uint16_t, Val>::value ||
333 std::is_same<int32_t, Val>::value || std::is_same<uint32_t, Val>::value ||
334 std::is_same<int64_t, Val>::value || std::is_same<uint64_t, Val>::value ||
335 std::is_same<float, Val>::value || std::is_same<double, Val>::value);
337 if (std::is_same<int8_t, Val>::value)
339 qi::parse(it, it + 1, qi::char_, val);
340 }
else if (std::is_same<uint8_t, Val>::value)
342 qi::parse(it, it + 1, qi::byte_, val);
343 }
else if ((std::is_same<int16_t, Val>::value) ||
344 (std::is_same<uint16_t, Val>::value))
346 qi::parse(it, it + 2, qi::little_word, val);
347 }
else if ((std::is_same<int32_t, Val>::value) ||
348 (std::is_same<uint32_t, Val>::value))
350 qi::parse(it, it + 4, qi::little_dword, val);
351 }
else if ((std::is_same<int64_t, Val>::value) ||
352 (std::is_same<uint64_t, Val>::value))
354 qi::parse(it, it + 8, qi::little_qword, val);
355 }
else if (std::is_same<float, Val>::value)
357 qi::parse(it, it + 4, qi::little_bin_float, val);
358 }
else if (std::is_same<double, Val>::value)
360 qi::parse(it, it + 8, qi::little_bin_double, val);
368 template <
typename It>
372 qi::parse(it, it + num, qi::repeat(num)[qi::char_], val);
374 val.erase(std::remove(val.begin(), val.end(),
'\0'), val.end());
381 template <
typename It,
typename Hdr>
399 block_header.id = ID & 8191;
400 block_header.revision = ID >> 13;
411 template <
typename It>
419 std::advance(it, sb2_length - 8);
426 template <
typename It>
441 std::to_string(msg.
n2));
446 std::advance(it, sb1_length - 12);
459 template <
typename It>
475 "Parse error: Too many ChannelSatInfo " + std::to_string(msg.
n));
482 for (
auto& satInfo : msg.
satInfo)
499 template <
typename It>
515 msg.
pdop = temp / 100.0;
517 msg.
tdop = temp / 100.0;
519 msg.
hdop = temp / 100.0;
521 msg.
vdop = temp / 100.0;
536 template <
typename It>
549 std::advance(it, sb2_length - 12);
556 template <
typename It>
574 std::advance(it, sb1_length - 20);
578 std::to_string(msg.n2));
581 msg.type2.resize(msg.n2);
582 for (
auto& type2 : msg.type2)
593 template <
typename It>
599 if (msg.block_header.id != 4027)
602 std::to_string(msg.block_header.id));
609 std::to_string(msg.n));
615 if (msg.block_header.revision > 0)
618 msg.type1.resize(msg.n);
619 for (
auto& type1 : msg.type1)
637 template <
typename It>
643 if (msg.block_header.id != 4245)
646 std::to_string(msg.block_header.id));
667 template <
typename It>
673 std::advance(it, sb_length - 7);
680 template <
typename It>
686 if (msg.block_header.id != 4092)
689 std::to_string(msg.block_header.id));
696 msg.rfband.resize(msg.n);
697 for (
auto& rfband : msg.rfband)
713 template <
typename It>
771 template <
typename It>
777 if (msg.block_header.id != 5914)
780 std::to_string(msg.block_header.id));
803 template <
typename It>
809 if (msg.block_header.id != 4006)
812 std::to_string(msg.block_header.id));
835 if (msg.block_header.revision > 0)
840 if (msg.block_header.revision > 1)
859 template <
typename It>
865 if (msg.block_header.id != 4007)
868 std::to_string(msg.block_header.id));
891 if (msg.block_header.revision > 0)
896 if (msg.block_header.revision > 1)
915 template <
typename It>
921 if (msg.block_header.id != 5938)
924 std::to_string(msg.block_header.id));
937 if (use_ros_axis_orientation)
940 msg.heading = -msg.heading + 90;
942 msg.pitch = -msg.pitch;
944 msg.pitch_dot = -msg.pitch_dot;
946 msg.heading_dot = -msg.heading_dot;
960 template <
typename It>
963 bool use_ros_axis_orientation)
967 if (msg.block_header.id != 5939)
970 std::to_string(msg.block_header.id));
981 if (use_ros_axis_orientation)
984 msg.cov_headroll = -msg.cov_headroll;
986 msg.cov_pitchroll = -msg.cov_pitchroll;
1000 template <
typename It>
1018 std::advance(it, sb_length - 52);
1025 template <
typename It>
1031 if (msg.block_header.id != 4043)
1034 std::to_string(msg.block_header.id));
1041 "Parse error: Too many VectorInfoCart " + std::to_string(msg.n));
1045 msg.vector_info_cart.resize(msg.n);
1046 for (
auto& vector_info_cart : msg.vector_info_cart)
1062 template <
typename It>
1080 std::advance(it, sb_length - 52);
1087 template <
typename It>
1093 if (msg.block_header.id != 4028)
1096 std::to_string(msg.block_header.id));
1103 "Parse error: Too many VectorInfoGeod " + std::to_string(msg.n));
1107 msg.vector_info_geod.resize(msg.n);
1108 for (
auto& vector_info_geod : msg.vector_info_geod)
1124 template <
typename It>
1127 bool use_ros_axis_orientation)
1131 if ((msg.block_header.id != 4225) && (msg.block_header.id != 4229))
1134 std::to_string(msg.block_header.id));
1149 if ((msg.sb_list & 1) != 0)
1160 if ((msg.sb_list & 2) != 0)
1165 if (use_ros_axis_orientation)
1168 msg.heading = -msg.heading + 90;
1170 msg.pitch = -msg.pitch;
1178 if ((msg.sb_list & 4) != 0)
1189 if ((msg.sb_list & 8) != 0)
1200 if ((msg.sb_list & 16) != 0)
1211 if ((msg.sb_list & 32) != 0)
1222 if ((msg.sb_list & 64) != 0)
1227 if (use_ros_axis_orientation)
1230 msg.heading_roll_cov = -msg.heading_roll_cov;
1232 msg.pitch_roll_cov = -msg.pitch_roll_cov;
1240 if ((msg.sb_list & 128) != 0)
1263 template <
typename It>
1269 if (msg.block_header.id != 5905)
1272 std::to_string(msg.block_header.id));
1299 template <
typename It>
1305 if (msg.block_header.id != 5906)
1308 std::to_string(msg.block_header.id));
1335 template <
typename It>
1341 if (msg.block_header.id != 5907)
1344 std::to_string(msg.block_header.id));
1371 template <
typename It>
1377 if (msg.block_header.id != 5908)
1380 std::to_string(msg.block_header.id));
1407 template <
typename It>
1423 "Parse error: Too many indicators " + std::to_string(msg.
n));
1428 std::vector<uint16_t> indicators;
1445 template <
typename It>
1452 std::advance(it, sb_length - 4);
1459 template <
typename It>
1480 "Parse error: Too many AGCState " + std::to_string(msg.
n));
1503 template <
typename It>
1509 if (msg.block_header.id != 5914)
1512 std::to_string(msg.block_header.id));
1535 template <
typename It>
1538 bool use_ros_axis_orientation)
1542 if ((msg.block_header.id != 4226) && (msg.block_header.id != 4230))
1545 std::to_string(msg.block_header.id));
1561 if ((msg.sb_list & 1) != 0)
1572 if ((msg.sb_list & 2) != 0)
1577 if (use_ros_axis_orientation)
1580 msg.heading = -msg.heading + 90;
1582 msg.pitch = -msg.pitch;
1590 if ((msg.sb_list & 4) != 0)
1601 if ((msg.sb_list & 8) != 0)
1612 if ((msg.sb_list & 16) != 0)
1623 if ((msg.sb_list & 32) != 0)
1634 if ((msg.sb_list & 64) != 0)
1639 if (use_ros_axis_orientation)
1642 msg.heading_roll_cov = -msg.heading_roll_cov;
1644 msg.pitch_roll_cov = -msg.pitch_roll_cov;
1652 if ((msg.sb_list & 128) != 0)
1675 template <
typename It>
1681 if (msg.block_header.id != 4224)
1684 std::to_string(msg.block_header.id));
1695 if (use_ros_axis_orientation)
1697 msg.ant_lever_arm_y = -msg.ant_lever_arm_y;
1698 msg.ant_lever_arm_z = -msg.ant_lever_arm_z;
1713 template <
typename It>
1716 bool use_ros_axis_orientation)
1720 if (msg.block_header.id != 4244)
1723 std::to_string(msg.block_header.id));
1731 if (use_ros_axis_orientation)
1733 msg.lever_arm_y = -msg.lever_arm_y;
1734 msg.lever_arm_z = -msg.lever_arm_z;
1748 template <
typename It>
1751 bool use_ros_axis_orientation,
bool& hasImuMeas)
1755 if (msg.block_header.id != 4050)
1758 std::to_string(msg.block_header.id));
1763 if (msg.sb_length != 28)
1766 "Parse error: Wrong sb_length " + std::to_string(msg.sb_length));
1770 msg.acceleration_x = std::numeric_limits<double>::quiet_NaN();
1771 msg.acceleration_y = std::numeric_limits<double>::quiet_NaN();
1772 msg.acceleration_z = std::numeric_limits<double>::quiet_NaN();
1774 msg.angular_rate_x = std::numeric_limits<double>::quiet_NaN();
1775 msg.angular_rate_y = std::numeric_limits<double>::quiet_NaN();
1776 msg.angular_rate_z = std::numeric_limits<double>::quiet_NaN();
1778 msg.velocity_x = std::numeric_limits<double>::quiet_NaN();
1779 msg.velocity_y = std::numeric_limits<double>::quiet_NaN();
1780 msg.velocity_z = std::numeric_limits<double>::quiet_NaN();
1782 msg.std_dev_x = std::numeric_limits<double>::quiet_NaN();
1783 msg.std_dev_y = std::numeric_limits<double>::quiet_NaN();
1784 msg.std_dev_z = std::numeric_limits<double>::quiet_NaN();
1786 msg.sensor_temperature = std::numeric_limits<float>::quiet_NaN();
1787 msg.zero_velocity_flag = std::numeric_limits<double>::quiet_NaN();
1789 msg.source.resize(msg.n);
1790 msg.sensor_model.resize(msg.n);
1791 msg.type.resize(msg.n);
1792 msg.obs_info.resize(msg.n);
1793 bool hasAcc =
false;
1794 bool hasOmega =
false;
1796 for (
size_t i = 0; i < msg.n; i++)
1803 switch (msg.type[i])
1826 msg.sensor_temperature = temp / 100.0f;
1828 msg.sensor_temperature = std::numeric_limits<float>::quiet_NaN();
1829 std::advance(it, 22);
1840 if (use_ros_axis_orientation)
1843 msg.velocity_y = -msg.velocity_y;
1845 msg.velocity_z = -msg.velocity_z;
1852 std::advance(it, 16);
1859 "Unknown external sensor measurement type in SBF ExtSensorMeas: " +
1860 std::to_string(msg.type[i]));
1861 std::advance(it, 24);
1871 hasImuMeas = hasAcc && hasOmega;