31 #include <boost/make_shared.hpp> 45 novatel_gps_msgs::TrackstatPtr
48 uint32_t num_chans =
ParseUInt32(&bin_msg.data_[12]);
52 std::stringstream error;
53 error <<
"Unexpected trackstat message size: " << bin_msg.data_.size();
57 uint16_t solution_status =
ParseUInt16(&bin_msg.data_[0]);
60 std::stringstream error;
61 error <<
"Unknown solution status: " << solution_status;
65 novatel_gps_msgs::TrackstatPtr ros_msg = boost::make_shared<novatel_gps_msgs::Trackstat>();
70 std::stringstream error;
71 error <<
"Unknown position type: " << pos_type;
75 ros_msg->cutoff =
ParseFloat(&bin_msg.data_[8]);
77 for (uint32_t i = 0; i < num_chans; i++)
82 novatel_gps_msgs::TrackstatChannel chan;
83 chan.prn =
ParseInt16(&bin_msg.data_[chan_offset]);
84 chan.glofreq =
ParseInt16(&bin_msg.data_[chan_offset+2]);
85 chan.ch_tr_status =
ParseUInt32(&bin_msg.data_[chan_offset+4]);
86 chan.psr =
ParseDouble(&bin_msg.data_[chan_offset+8]);
87 chan.doppler =
ParseFloat(&bin_msg.data_[chan_offset+16]);
88 chan.c_no =
ParseFloat(&bin_msg.data_[chan_offset+20]);
89 chan.locktime =
ParseFloat(&bin_msg.data_[chan_offset+24]);
90 chan.psr_res =
ParseFloat(&bin_msg.data_[chan_offset+28]);
91 uint32_t reject =
ParseUInt32(&bin_msg.data_[chan_offset+32]);
98 chan.reject =
"BADHEALTH";
101 chan.reject =
"OLDEPHEMERIS";
104 chan.reject =
"ELEVATIONERROR";
107 chan.reject =
"MISCLOSURE";
110 chan.reject =
"NODIFFCORR";
113 chan.reject =
"NOEPHEMERIS";
116 chan.reject =
"INVALIDCODE";
119 chan.reject =
"LOCKEDOUT";
122 chan.reject =
"LOWPOWER";
125 chan.reject =
"OBSL2";
128 chan.reject =
"UNKNOWN";
131 chan.reject =
"NOIONOCORR";
134 chan.reject =
"NOTUSED";
137 chan.reject =
"OBSL1";
140 chan.reject =
"OBSE1";
143 chan.reject =
"OBSL5";
146 chan.reject =
"OBSE5";
149 chan.reject =
"OBSB2";
152 chan.reject =
"OBSB1";
155 chan.reject =
"OBSB3";
158 chan.reject =
"NOSIGNALMATCH";
161 chan.reject =
"SUPPLEMENTARY";
167 chan.reject =
"BAD_INTEGRITY";
170 chan.reject =
"LOSSOFLOCK";
173 chan.reject =
"NOAMBIGUITY";
177 std::stringstream error;
178 error <<
"Unexpected channel status: " << reject;
182 chan.psr_weight =
ParseFloat(&bin_msg.data_[chan_offset+36]);
184 ros_msg->channels.push_back(chan);
190 novatel_gps_msgs::TrackstatPtr
195 std::stringstream error;
196 error <<
"Unexpected number of body fields in TRACKSTAT log: " << sentence.body.size();
200 uint32_t n_channels = 0;
205 std::stringstream error;
206 error <<
"Size of TRACKSTAT log did not match expected size.";
211 novatel_gps_msgs::TrackstatPtr
msg = boost::make_shared<novatel_gps_msgs::Trackstat>();
212 msg->solution_status = sentence.body[0];
213 msg->position_type = sentence.body[1];
214 valid &=
ParseFloat(sentence.body[2], msg->cutoff);
216 msg->channels.resize(n_channels);
217 for (
size_t i = 0; i < static_cast<size_t>(n_channels); ++i)
220 novatel_gps_msgs::TrackstatChannel& channel = msg->channels[i];
221 valid &=
ParseInt16(sentence.body[offset], channel.prn);
222 valid &=
ParseInt16(sentence.body[offset+1], channel.glofreq);
223 valid &=
ParseUInt32(sentence.body[offset+2], channel.ch_tr_status, 16);
224 valid &=
ParseDouble(sentence.body[offset+3], channel.psr);
225 valid &=
ParseFloat(sentence.body[offset+4], channel.doppler);
226 valid &=
ParseFloat(sentence.body[offset+5], channel.c_no);
227 valid &=
ParseFloat(sentence.body[offset+6], channel.locktime);
228 valid &=
ParseFloat(sentence.body[offset+7], channel.psr_res);
229 channel.reject = sentence.body[offset+8];
230 valid &=
ParseFloat(sentence.body[offset+9], channel.psr_weight);
235 std::stringstream error;
236 error <<
"Error parsing TRACKSTAT log.";
uint16_t ParseUInt16(const uint8_t *buffer)
Converts a buffer containing 2 bytes into an unsigned 16-bit int.
static constexpr uint16_t MESSAGE_ID
double ParseDouble(const uint8_t *buffer)
Converts a buffer containing 8 bytes into a double.
const std::string POSITION_TYPES[]
uint32_t ParseUInt32(const uint8_t *buffer)
Converts a buffer containing 4 bytes into an unsigned 32-bit int.
static constexpr size_t ASCII_BODY_FIELDS
float ParseFloat(const uint8_t *buffer)
Converts a buffer containing 4 bytes into a float.
uint32_t GetMessageId() const override
const std::string SOLUTION_STATUSES[]
novatel_gps_msgs::TrackstatPtr ParseBinary(const BinaryMessage &bin_msg) noexcept(false) override
Converts bin_msg into a ROS message pointer and returns it.
static constexpr size_t BINARY_CHANNEL_LENGTH
const size_t MAX_SOLUTION_STATUS
novatel_gps_msgs::TrackstatPtr ParseAscii(const NovatelSentence &sentence) noexcept(false) override
Converts sentence into a ROS message pointer and returns it.
static const std::string MESSAGE_NAME
static constexpr size_t ASCII_CHANNEL_FIELDS
static constexpr size_t BINARY_BODY_LENGTH
int16_t ParseInt16(const uint8_t *buffer)
Converts a buffer containing 2 bytes into a signed 16-bit int.
const std::string GetMessageName() const override