34 #include <boost/make_shared.hpp> 54 std::stringstream error;
55 error <<
"Unexpected BESTPOS message length: " << bin_msg.data_.size();
58 novatel_gps_msgs::NovatelPositionPtr ros_msg =
59 boost::make_shared<novatel_gps_msgs::NovatelPosition>();
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;
83 ros_msg->undulation =
ParseFloat(&bin_msg.data_[32]);
84 uint16_t datum_id =
ParseUInt16(&bin_msg.data_[36]);
87 std::stringstream error;
88 error <<
"Unknown datum: " << datum_id;
91 ros_msg->datum_id =
DATUMS[datum_id];
92 ros_msg->lat_sigma =
ParseFloat(&bin_msg.data_[40]);
93 ros_msg->lon_sigma =
ParseFloat(&bin_msg.data_[44]);
94 ros_msg->height_sigma =
ParseFloat(&bin_msg.data_[48]);
95 ros_msg->base_station_id.resize(4);
96 std::copy(&bin_msg.data_[52], &bin_msg.data_[56], &ros_msg->base_station_id[0]);
97 ros_msg->diff_age =
ParseFloat(&bin_msg.data_[56]);
98 ros_msg->solution_age =
ParseFloat(&bin_msg.data_[60]);
99 ros_msg->num_satellites_tracked = bin_msg.data_[64];
100 ros_msg->num_satellites_used_in_solution = bin_msg.data_[65];
101 ros_msg->num_gps_and_glonass_l1_used_in_solution = bin_msg.data_[66];
102 ros_msg->num_gps_and_glonass_l1_and_l2_used_in_solution = bin_msg.data_[67];
104 ros_msg->extended_solution_status);
112 novatel_gps_msgs::NovatelPositionPtr
msg =
113 boost::make_shared<novatel_gps_msgs::NovatelPosition>();
115 msg->novatel_msg_header = h_parser.
ParseAscii(sentence);
119 std::stringstream error;
120 error <<
"Unexpected number of BESTPOS message fields: " << sentence.body.size();
126 msg->solution_status = sentence.body[0];
127 msg->position_type = sentence.body[1];
128 valid = valid &&
ParseDouble(sentence.body[2], msg->lat);
129 valid = valid &&
ParseDouble(sentence.body[3], msg->lon);
130 valid = valid &&
ParseDouble(sentence.body[4], msg->height);
131 valid = valid &&
ParseFloat(sentence.body[5], msg->undulation);
132 msg->datum_id = sentence.body[6];
133 valid = valid &&
ParseFloat(sentence.body[7], msg->lat_sigma);
134 valid = valid &&
ParseFloat(sentence.body[8], msg->lon_sigma);
135 valid = valid &&
ParseFloat(sentence.body[9], msg->height_sigma);
136 msg->base_station_id = sentence.body[10];
137 valid = valid &&
ParseFloat(sentence.body[11], msg->diff_age);
138 valid = valid &&
ParseFloat(sentence.body[12], msg->solution_age);
139 valid = valid &&
ParseUInt8(sentence.body[13], msg->num_satellites_tracked);
140 valid = valid &&
ParseUInt8(sentence.body[14], msg->num_satellites_used_in_solution);
141 valid = valid &&
ParseUInt8(sentence.body[15], msg->num_gps_and_glonass_l1_used_in_solution);
142 valid = valid &&
ParseUInt8(sentence.body[16], msg->num_gps_and_glonass_l1_and_l2_used_in_solution);
145 uint32_t extended_solution_status = 0;
146 valid = valid &&
ParseUInt32(sentence.body[18], extended_solution_status, 16);
148 extended_solution_status, msg->extended_solution_status);
151 uint32_t signal_mask = 0;
152 valid = valid &&
ParseUInt32(sentence.body[20], signal_mask, 16);
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 constexpr size_t ASCII_LENGTH
novatel_gps_msgs::NovatelPositionPtr ParseBinary(const BinaryMessage &bin_msg) override
Converts bin_msg into a ROS message pointer and returns it.
const size_t MAX_POSITION_TYPE
uint32_t GetMessageId() const override
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 const std::string MESSAGE_NAME
uint32_t ParseUInt32(const uint8_t *buffer)
Converts a buffer containing 4 bytes into an unsigned 32-bit int.
novatel_gps_msgs::NovatelPositionPtr ParseAscii(const NovatelSentence &sentence) override
Converts sentence into a ROS message pointer and returns it.
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
const std::string GetMessageName() const override
static constexpr uint16_t MESSAGE_ID
static constexpr size_t BINARY_LENGTH