小編給大家分享一下Apollo系統中怎么添加新的GPS接收器,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
簡介
GPS接收器是一種從GPS衛星上接收信息,然后根據這些信息計算設備地理位置、速度和精確時間的設備。這種設備通常包括一個接收器,一個IMU(Inertial measurement unit,慣性測量單元),一個針對輪編碼器的接口以及一個將各傳感器獲取的數據融合到一起的融合引擎。
Apollo系統中默認使用Novatel 板卡,該說明詳細介紹如何添加并使用一個新的GPS接收器。
添加新GPS接收器的步驟
請按照下面的步驟添加新的GPS接收器:
通過繼承基類“Parser”,實現新GPS接收器的數據解析器
在Parser類中為新GPS接收器添加新接口
在文件config.proto中, 為新GPS接收器添加新數據格式
在函數create_parser(見文件data_parser.cpp), 為新GPS接收器添加新解析器實例
下面讓我們用上面的方法來添加u-blox GPS接收器。
步驟一
通過繼承類“Parser”,為新GPS接收器實現新的數據解析器:
class UbloxParser : public Parser { public: UbloxParser(); virtual MessageType get_message(MessagePtr& message_ptr); private: bool verify_checksum(); Parser::MessageType prepare_message(MessagePtr& message_ptr); // The handle_xxx functions return whether a message is ready. bool handle_esf_raw(const ublox::EsfRaw* raw, size_t data_size); bool handle_esf_ins(const ublox::EsfIns* ins); bool handle_hnr_pvt(const ublox::HnrPvt* pvt); bool handle_nav_att(const ublox::NavAtt *att); bool handle_nav_pvt(const ublox::NavPvt* pvt); bool handle_nav_cov(const ublox::NavCov *cov); bool handle_rxm_rawx(const ublox::RxmRawx *raw); double _gps_seconds_base = -1.0; double _gyro_scale = 0.0; double _accel_scale = 0.0; float _imu_measurement_span = 0.0; int _imu_frame_mapping = 5; double _imu_measurement_time_previous = -1.0; std::vector<uint8_t> _buffer; size_t _total_length = 0; ::apollo::drivers::gnss::Gnss _gnss; ::apollo::drivers::gnss::Imu _imu; ::apollo::drivers::gnss::Ins _ins; };
步驟二
在Parser類中,為新GPS接收器添加新的接口:
在Parser類中添加函數‘create_ublox‘:
class Parser { public: // Return a pointer to a NovAtel parser. The caller should take ownership. static Parser* create_novatel(); // Return a pointer to a u-blox parser. The caller should take ownership. static Parser* create_ublox(); virtual ~Parser() {} // Updates the parser with new data. The caller must keep the data valid until get_message() // returns NONE. void update(const uint8_t* data, size_t length) { _data = data; _data_end = data + length; } void update(const std::string& data) { update(reinterpret_cast<const uint8_t*>(data.data()), data.size()); } enum class MessageType { NONE, GNSS, GNSS_RANGE, IMU, INS, WHEEL, EPHEMERIDES, OBSERVATION, GPGGA, }; // Gets a parsed protobuf message. The caller must consume the message before calling another // get_message() or update(); virtual MessageType get_message(MessagePtr& message_ptr) = 0; protected: Parser() {} // Point to the beginning and end of data. Do not take ownership. const uint8_t* _data = nullptr; const uint8_t* _data_end = nullptr; private: DISABLE_COPY_AND_ASSIGN(Parser); }; Parser* Parser::create_ublox() { return new UbloxParser(); }
步驟三
在config.proto文件中, 為新的GPS接收器添加新的數據格式定義:
在配置文件(modules/drivers/gnss/proto/config.proto)中添加UBLOX_TEXT
and UBLOX_BINARY
enum Format { UNKNOWN = 0; NMEA = 1; RTCM_V2 = 2; RTCM_V3 = 3; NOVATEL_TEXT = 10; NOVATEL_BINARY = 11; UBLOX_TEXT = 20; UBLOX_BINARY = 21; } ... ...
步驟四
在函數create_parser
(見data_parser.cpp), 為新GPS接收器添加新解析器實例. 我們將通過添加處理config::Stream::UBLOX_BINARY
的代碼實現上面的步驟,具體如下。
Parser* create_parser(config::Stream::Format format, bool is_base_station = false) { switch (format) { case config::Stream::NOVATEL_BINARY: return Parser::create_novatel(); case config::Stream::UBLOX_BINARY: return Parser::create_ubloxl(); default: return nullptr; } }
以上是“Apollo系統中怎么添加新的GPS接收器”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。