34 #include <boost/make_shared.hpp> 54 std::stringstream error;
55 error <<
"Unexpected BESTXYZ message length: " << bin_msg.data_.size();
58 novatel_gps_msgs::NovatelXYZPtr ros_msg =
59 boost::make_shared<novatel_gps_msgs::NovatelXYZ>();
61 ros_msg->novatel_msg_header = header_parser.
ParseBinary(bin_msg);
64 uint16_t solution_status =
ParseUInt16(&bin_msg.data_[0]);
67 std::stringstream error;
68 error <<
"Unknown solution status: " << solution_status;
76 std::stringstream error;
77 error <<
"Unknown position type: " << pos_type;
86 ros_msg->x_sigma =
ParseFloat(&bin_msg.data_[32]);
87 ros_msg->y_sigma =
ParseFloat(&bin_msg.data_[36]);
88 ros_msg->z_sigma =
ParseFloat(&bin_msg.data_[40]);
90 uint16_t vel_solution_status =
ParseUInt16(&bin_msg.data_[44]);
93 std::stringstream error;
94 error <<
"Unknown solution status: " << vel_solution_status;
99 uint16_t vel_type =
ParseUInt16(&bin_msg.data_[48]);
102 std::stringstream error;
103 error <<
"Unknown position type: " << vel_type;
112 ros_msg->x_vel_sigma =
ParseFloat(&bin_msg.data_[76]);
113 ros_msg->y_vel_sigma =
ParseFloat(&bin_msg.data_[80]);
114 ros_msg->z_vel_sigma =
ParseFloat(&bin_msg.data_[84]);
116 ros_msg->base_station_id.resize(4);
117 std::copy(&bin_msg.data_[88], &bin_msg.data_[92], &ros_msg->base_station_id[0]);
119 ros_msg->velocity_latency =
ParseFloat(&bin_msg.data_[92]);
121 ros_msg->diff_age =
ParseFloat(&bin_msg.data_[96]);
122 ros_msg->solution_age =
ParseFloat(&bin_msg.data_[100]);
124 ros_msg->num_satellites_tracked = bin_msg.data_[104];
125 ros_msg->num_satellites_used_in_solution = bin_msg.data_[105];
126 ros_msg->num_gps_and_glonass_l1_used_in_solution = bin_msg.data_[106];
127 ros_msg->num_gps_and_glonass_l1_and_l2_used_in_solution = bin_msg.data_[107];
130 ros_msg->extended_solution_status);
139 novatel_gps_msgs::NovatelXYZPtr
msg =
140 boost::make_shared<novatel_gps_msgs::NovatelXYZ>();
142 msg->novatel_msg_header = h_parser.
ParseAscii(sentence);
146 std::stringstream error;
147 error <<
"Unexpected number of BESTXYZ message fields: " << sentence.body.size();
153 msg->solution_status = sentence.body[0];
154 msg->position_type = sentence.body[1];
156 valid = valid &&
ParseDouble(sentence.body[2], msg->x);
157 valid = valid &&
ParseDouble(sentence.body[3], msg->y);
158 valid = valid &&
ParseDouble(sentence.body[4], msg->z);
160 valid = valid &&
ParseFloat(sentence.body[5], msg->x_sigma);
161 valid = valid &&
ParseFloat(sentence.body[6], msg->y_sigma);
162 valid = valid &&
ParseFloat(sentence.body[7], msg->z_sigma);
164 msg->velocity_solution_status = sentence.body[8];
165 msg->velocity_type = sentence.body[9];
167 valid = valid &&
ParseDouble(sentence.body[10], msg->x_vel);
168 valid = valid &&
ParseDouble(sentence.body[11], msg->y_vel);
169 valid = valid &&
ParseDouble(sentence.body[12], msg->z_vel);
171 valid = valid &&
ParseFloat(sentence.body[13], msg->x_vel_sigma);
172 valid = valid &&
ParseFloat(sentence.body[14], msg->y_vel_sigma);
173 valid = valid &&
ParseFloat(sentence.body[15], msg->z_vel_sigma);
175 msg->base_station_id = sentence.body[16];
176 valid = valid &&
ParseFloat(sentence.body[17], msg->velocity_latency);
178 valid = valid &&
ParseFloat(sentence.body[18], msg->diff_age);
179 valid = valid &&
ParseFloat(sentence.body[19], msg->solution_age);
180 valid = valid &&
ParseUInt8(sentence.body[20], msg->num_satellites_tracked);
181 valid = valid &&
ParseUInt8(sentence.body[21], msg->num_satellites_used_in_solution);
182 valid = valid &&
ParseUInt8(sentence.body[22], msg->num_gps_and_glonass_l1_used_in_solution);
183 valid = valid &&
ParseUInt8(sentence.body[23], msg->num_gps_and_glonass_l1_and_l2_used_in_solution);
186 uint32_t extended_solution_status = 0;
187 valid = valid &&
ParseUInt32(sentence.body[25], extended_solution_status, 16);
189 extended_solution_status, msg->extended_solution_status);
192 uint32_t signal_mask = 0;
193 valid = valid &&
ParseUInt32(sentence.body[27], signal_mask, 16);
const std::string GetMessageName() const override
uint16_t ParseUInt16(const uint8_t *buffer)
Converts a buffer containing 2 bytes into an unsigned 16-bit int.
bool ParseUInt8(const std::string &string, uint8_t &value, int32_t base=10)
Parses a string containing an integer number into a uint16_t.
const size_t MAX_POSITION_TYPE
double ParseDouble(const uint8_t *buffer)
Converts a buffer containing 8 bytes into a double.
static const std::string MESSAGE_NAME
static constexpr size_t ASCII_LENGTH
const std::string POSITION_TYPES[]
static constexpr uint16_t MESSAGE_ID
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.
uint32_t GetMessageId() const override
const std::string SOLUTION_STATUSES[]
void GetExtendedSolutionStatusMessage(uint32_t status, novatel_gps_msgs::NovatelExtendedSolutionStatus &msg)
void GetSignalsUsed(uint32_t mask, novatel_gps_msgs::NovatelSignalMask &msg)
const size_t MAX_SOLUTION_STATUS
novatel_gps_msgs::NovatelXYZPtr ParseBinary(const BinaryMessage &bin_msg) override
Converts bin_msg into a ROS message pointer and returns it.
novatel_gps_msgs::NovatelXYZPtr ParseAscii(const NovatelSentence &sentence) override
Converts sentence into a ROS message pointer and returns it.
static constexpr size_t BINARY_LENGTH