You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.3 KiB
57 lines
1.3 KiB
#pragma once |
|
|
|
#include <freertos/FreeRTOS.h> |
|
#include <freertos/semphr.h> |
|
#include <freertos/task.h> |
|
#include <stdint.h> |
|
|
|
namespace ugv { |
|
namespace io { |
|
|
|
enum GpsFixQual { |
|
GPS_FIX_INVALID = 0, // invalid gps fix |
|
GPS_FIX_GPS = 1, // GPS fix |
|
GPS_FIX_DGPS = 2, // differential GPS fix |
|
GPS_FIX_PPS = 3, // PPS fix |
|
GPS_FIX_RTK = 4, // Real Time Kinematic fix |
|
GPS_FIX_FRTK = 5, // Float Real Time Kinematic fix |
|
GPS_FIX_ESTIMATED = 6, // Estimated fix |
|
GPS_FIX_MANUAL = 7, // Manual fix |
|
GPS_FIX_SIMULATED = 8, // Simulated fix |
|
}; |
|
|
|
struct GpsData { |
|
TickType_t last_update; |
|
bool valid; |
|
GpsFixQual fix_quality; |
|
uint8_t num_satellites; |
|
|
|
float latitude; // degrees +/- |
|
float longitude; // degrees +/- |
|
float altitude; // meters |
|
float speed; // knots |
|
float course; // degrees clockwise of north |
|
}; |
|
|
|
class UART_GPS { |
|
public: |
|
explicit UART_GPS(); |
|
~UART_GPS(); |
|
|
|
void Init(); |
|
|
|
void GetData(GpsData& data); |
|
|
|
private: |
|
TaskHandle_t task_; |
|
SemaphoreHandle_t mutex_; |
|
GpsData data_; |
|
|
|
esp_err_t WriteCommand(const char* cmd, size_t len); |
|
void ProcessLine(const char* line, size_t len); |
|
|
|
static void GPS_Task(void* arg); |
|
}; |
|
|
|
} // namespace io |
|
} // namespace ugv
|
|
|