34 #include <boost/make_shared.hpp> 54 std::stringstream error;
55 error <<
"Unexpected BESTUTM message length: " << bin_msg.data_.size();
58 novatel_gps_msgs::NovatelUtmPositionPtr ros_msg =
59 boost::make_shared<novatel_gps_msgs::NovatelUtmPosition>();
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;
75 std::stringstream error;
76 error <<
"Unknown position type: " << pos_type;
80 ros_msg->lon_zone_number =
ParseUInt32(&bin_msg.data_[8]);
81 ros_msg->lat_zone_letter = (char)
ParseUInt32(&bin_msg.data_[12]);
82 ros_msg->northing =
ParseDouble(&bin_msg.data_[16]);
85 ros_msg->undulation =
ParseFloat(&bin_msg.data_[40]);
86 uint16_t datum_id =
ParseUInt16(&bin_msg.data_[44]);
89 std::stringstream error;
90 error <<
"Unknown datum: " << datum_id;
93 ros_msg->datum_id =
DATUMS[datum_id];
94 ros_msg->northing_sigma =
ParseFloat(&bin_msg.data_[48]);
95 ros_msg->easting_sigma =
ParseFloat(&bin_msg.data_[52]);
96 ros_msg->height_sigma =
ParseFloat(&bin_msg.data_[56]);
97 ros_msg->base_station_id.resize(4);
98 std::copy(&bin_msg.data_[60], &bin_msg.data_[64], &ros_msg->base_station_id[0]);
99 ros_msg->diff_age =
ParseFloat(&bin_msg.data_[64]);
100 ros_msg->solution_age =
ParseFloat(&bin_msg.data_[68]);
101 ros_msg->num_satellites_tracked = bin_msg.data_[72];
102 ros_msg->num_satellites_used_in_solution = bin_msg.data_[73];
103 ros_msg->num_gps_and_glonass_l1_used_in_solution = bin_msg.data_[74];
104 ros_msg->num_gps_and_glonass_l1_and_l2_used_in_solution = bin_msg.data_[75];
106 ros_msg->extended_solution_status);
114 novatel_gps_msgs::NovatelUtmPositionPtr
msg =
115 boost::make_shared<novatel_gps_msgs::NovatelUtmPosition>();
117 msg->novatel_msg_header = h_parser.
ParseAscii(sentence);
121 std::stringstream error;
122 error <<
"Unexpected number of BESTUTM message fields: " << sentence.body.size();
128 msg->solution_status = sentence.body[0];
129 msg->position_type = sentence.body[1];
130 valid = valid &&
ParseUInt32(sentence.body[2], msg->lon_zone_number);
131 msg->lat_zone_letter = sentence.body[3];
132 valid = valid &&
ParseDouble(sentence.body[4], msg->northing);
133 valid = valid &&
ParseDouble(sentence.body[5], msg->easting);
134 valid = valid &&
ParseDouble(sentence.body[6], msg->height);
135 valid = valid &&
ParseFloat(sentence.body[7], msg->undulation);
136 msg->datum_id = sentence.body[8];
137 valid = valid &&
ParseFloat(sentence.body[9], msg->northing_sigma);
138 valid = valid &&
ParseFloat(sentence.body[10], msg->easting_sigma);
139 valid = valid &&
ParseFloat(sentence.body[11], msg->height_sigma);
140 msg->base_station_id = sentence.body[12];
141 valid = valid &&
ParseFloat(sentence.body[13], msg->diff_age);
142 valid = valid &&
ParseFloat(sentence.body[14], msg->solution_age);
143 valid = valid &&
ParseUInt8(sentence.body[15], msg->num_satellites_tracked);
144 valid = valid &&
ParseUInt8(sentence.body[16], msg->num_satellites_used_in_solution);
145 valid = valid &&
ParseUInt8(sentence.body[17], msg->num_gps_and_glonass_l1_used_in_solution);
146 valid = valid &&
ParseUInt8(sentence.body[18], msg->num_gps_and_glonass_l1_and_l2_used_in_solution);
149 uint32_t extended_solution_status = 0;
150 valid = valid &&
ParseUInt32(sentence.body[20], extended_solution_status, 16);
152 extended_solution_status, msg->extended_solution_status);
155 uint32_t signal_mask = 0;
156 valid = valid &&
ParseUInt32(sentence.body[22], signal_mask, 16);
static constexpr size_t ASCII_LENGTH
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.
static const std::string MESSAGE_NAME
uint32_t GetMessageId() const override
const size_t MAX_POSITION_TYPE
const std::string DATUMS[]
double ParseDouble(const uint8_t *buffer)
Converts a buffer containing 8 bytes into a double.
const std::string POSITION_TYPES[]
static constexpr size_t BINARY_LENGTH
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.
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
static constexpr uint16_t MESSAGE_ID
novatel_gps_msgs::NovatelUtmPositionPtr ParseAscii(const NovatelSentence &sentence) override
Converts sentence into a ROS message pointer and returns it.
const std::string GetMessageName() const override
novatel_gps_msgs::NovatelUtmPositionPtr ParseBinary(const BinaryMessage &bin_msg) override
Converts bin_msg into a ROS message pointer and returns it.