5 #define DEG2RAD (3.14159 / 180.0) 66 for (uint32_t
i = 0;
i <
sizeof(
baudrates)/
sizeof(uint32_t);
i++)
70 uint32_t timeout_ms(1000);
71 uint32_t start_ms =
millis();
72 uint32_t now_ms =
millis();
75 while (now_ms < start_ms + timeout_ms)
116 DBG(
"Setting baudrate to %d\n", baudrate);
121 out_message_.
CFG_PRT.inProtoMask = CFG_PRT_t::IN_UBX | CFG_PRT_t::IN_NMEA | CFG_PRT_t::IN_RTCM;
123 out_message_.
CFG_PRT.mode = CFG_PRT_t::CHARLEN_8BIT | CFG_PRT_t::PARITY_NONE | CFG_PRT_t::STOP_BITS_1;
144 DBG(
"Setting dynamic mode\n");
155 DBG(
"Setting nav rate to %d\n", period_ms);
165 DBG(
"Requesting %x:%x message at %d hz\n", msg_cls, msg_id, rate);
172 uint64_t time_recieved =
micros();
216 length_ |=
static_cast<uint16_t
>(byte) << 8;
263 DBG(
"failed to parse message\n");
275 uint32_t day_s = 24*60*60;
276 uint32_t year_s = 365*day_s;
277 uint32_t elapsed_years = time.year-1970;
278 uint32_t elapsed_leap_days = (elapsed_years+1)/4;
279 if (time.year % 4 == 0)
282 uint32_t elapsed_days;
293 elapsed_days = 31+28;
296 elapsed_days = 31+28+31;
299 elapsed_days = 31+28+31+30;
302 elapsed_days = 31+28+31+30+31;
305 elapsed_days = 31+28+31+30+31+30;
308 elapsed_days = 31+28+31+30+31+30+31;
311 elapsed_days = 31+28+31+30+31+30+31+31;
314 elapsed_days = 31+28+31+30+31+30+31+31+30;
317 elapsed_days = 31+28+31+30+31+30+31+31+30+31;
320 elapsed_days = 31+28+31+30+31+30+31+31+30+31+30;
325 elapsed_days += time.day-1;
326 return elapsed_years * year_s + (elapsed_days+elapsed_leap_days)*day_s + (time.hour*60+time.min)*60 + time.sec;
339 #pragma GCC diagnostic push 340 #pragma GCC diagnostic ignored "-Wmissing-field-initializers" //Ignore warning about leaving struct fields blank 388 #pragma GCC diagnostic pop //End ignore blank struct initalizers 477 const UBX_message_t payload, uint8_t &ck_a, uint8_t &ck_b)
const 492 ck_a += (len >> 8) & 0xFF;
496 for (
int i = 0;
i < len;
i ++)
#define UBLOX_BUFFER_SIZE
void calculate_checksum(const uint8_t msg_cls, const uint8_t msg_id, const uint16_t len, const UBX_message_t payload, uint8_t &ck_a, uint8_t &ck_b) const
void register_rx_callback(void(*cb)(uint8_t data)) override
void set_baudrate(const uint32_t baudrate)
volatile uint32_t num_messages_received_
NAV_POSECEF_t NAV_POSECEF
volatile uint32_t millis(void)
void delayMicroseconds(uint32_t us)
void enable_message(uint8_t msg_cls, uint8_t msg_id, uint8_t rate)
uint64_t rosflight_timestamp
void put_byte(uint8_t ch) override
uint8_t buffer[UBLOX_BUFFER_SIZE]
UBX_message_t out_message_
volatile uint64_t micros(void)
parse_state_t parse_state_
uint32_t current_baudrate_
const NAV_PVT_t & read_raw()
bool send_message(uint8_t msg_class, uint8_t msg_id, UBX_message_t &message, uint16_t len)
void set_nav_rate(uint8_t period_ms)
NAV_VELECEF_t NAV_VELECEF
GNSSPosECEF read_pos_ecef()
bool set_mode(uint32_t baud, uart_mode_t mode)
const uint32_t baudrates[5]
uint64_t last_pvt_timestamp
void read_cb(uint8_t byte)
GNSSVelECEF read_vel_ecef()
void write(const uint8_t *ch, uint8_t len) override
uint64_t convert_to_unix(UBLOX::GNSS_TIME_T time)
UBX_message_t in_message_