33 #include <boost/make_shared.hpp> 47 novatel_gps_msgs::RangePtr
53 std::stringstream error;
54 error <<
"Unexpected range message size: " << bin_msg.data_.size();
57 novatel_gps_msgs::RangePtr ros_msg = boost::make_shared<novatel_gps_msgs::Range>();
59 ros_msg->novatel_msg_header = h_parser.
ParseBinary(bin_msg);
60 ros_msg->novatel_msg_header.message_name =
"RANGE";
62 ros_msg->numb_of_observ = num_obs;
63 ros_msg->info.reserve(num_obs);
64 for(
int i = 0; i < num_obs; i++)
68 novatel_gps_msgs::RangeInformation info;
70 info.prn_number =
ParseUInt16(&bin_msg.data_[obs_offset]);
71 info.glofreq =
ParseUInt16(&bin_msg.data_[obs_offset+2]);
72 info.psr =
ParseDouble(&bin_msg.data_[obs_offset+4]);
73 info.psr_std =
ParseFloat(&bin_msg.data_[obs_offset+12]);
74 info.adr =
ParseDouble(&bin_msg.data_[obs_offset+16]);
75 info.adr_std =
ParseFloat(&bin_msg.data_[obs_offset+24]);
76 info.dopp =
ParseFloat(&bin_msg.data_[obs_offset+28]);
77 info.noise_density_ratio =
ParseFloat(&bin_msg.data_[obs_offset+32]);
78 info.locktime =
ParseFloat(&bin_msg.data_[obs_offset+36]);
79 info.tracking_status =
ParseUInt32(&bin_msg.data_[obs_offset+40]);
81 ros_msg->info.push_back(info);
86 novatel_gps_msgs::RangePtr
89 novatel_gps_msgs::RangePtr
msg = boost::make_shared<novatel_gps_msgs::Range>();
91 msg->novatel_msg_header = h_parser.
ParseAscii(sentence);
92 if (!
ParseInt32(sentence.body[0], msg->numb_of_observ, 10))
94 std::stringstream error;
95 error <<
"Unable to parse number of observations in RANGE log.";
98 uint32_t numb_of_observ =
static_cast<uint32_t
>(msg->numb_of_observ);
99 if (sentence.body.size() != 1 + numb_of_observ *
ASCII_FIELDS)
101 std::stringstream error;
102 error <<
"Did not find expected number of observations in RANGE log.";
106 valid &=
ParseInt32(sentence.body[0], msg->numb_of_observ, 10);
107 msg->info.resize(numb_of_observ);
108 for (
int i = 0, index = 0; index < numb_of_observ; i += 10, index++)
110 valid &=
ParseUInt16(sentence.body[i + 1], msg->info[index].prn_number, 10);
111 valid &=
ParseUInt16(sentence.body[i + 2], msg->info[index].glofreq, 10);
112 valid &=
ParseDouble(sentence.body[i + 3], msg->info[index].psr);
113 valid &=
ParseFloat(sentence.body[i + 4], msg->info[index].psr_std);
114 valid &=
ParseDouble(sentence.body[i + 5], msg->info[index].adr);
115 valid &=
ParseFloat(sentence.body[i + 6], msg->info[index].adr_std);
116 valid &=
ParseFloat(sentence.body[i + 7], msg->info[index].dopp);
117 valid &=
ParseFloat(sentence.body[i + 8], msg->info[index].noise_density_ratio);
118 valid &=
ParseFloat(sentence.body[i + 9], msg->info[index].locktime);
119 std::string track =
"0x" + sentence.body[i + 10];
120 valid &=
ParseUInt32(track, msg->info[index].tracking_status, 16);
static constexpr size_t ASCII_FIELDS
uint16_t ParseUInt16(const uint8_t *buffer)
Converts a buffer containing 2 bytes into an unsigned 16-bit int.
novatel_gps_msgs::RangePtr ParseBinary(const BinaryMessage &bin_msg) override
Converts bin_msg into a ROS message pointer and returns it.
double ParseDouble(const uint8_t *buffer)
Converts a buffer containing 8 bytes into a double.
uint32_t GetMessageId() const override
uint32_t ParseUInt32(const uint8_t *buffer)
Converts a buffer containing 4 bytes into an unsigned 32-bit int.
float ParseFloat(const uint8_t *buffer)
Converts a buffer containing 4 bytes into a float.
int32_t ParseInt32(const uint8_t *buffer)
Converts a buffer containing 4 bytes into a signed 32-bit int.
novatel_gps_msgs::RangePtr ParseAscii(const NovatelSentence &sentence) override
Converts sentence into a ROS message pointer and returns it.
const std::string GetMessageName() const override
static constexpr uint16_t MESSAGE_ID
static const std::string MESSAGE_NAME
static constexpr size_t BINARY_OBSERVATION_SIZE