溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Apollo系統(tǒng)中怎么添加新的GPS接收器

發(fā)布時(shí)間:2021-12-18 16:07:58 來源:億速云 閱讀:118 作者:小新 欄目:云計(jì)算

小編給大家分享一下Apollo系統(tǒng)中怎么添加新的GPS接收器,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

簡介

GPS接收器是一種從GPS衛(wèi)星上接收信息,然后根據(jù)這些信息計(jì)算設(shè)備地理位置、速度和精確時(shí)間的設(shè)備。這種設(shè)備通常包括一個(gè)接收器,一個(gè)IMU(Inertial measurement unit,慣性測量單元),一個(gè)針對輪編碼器的接口以及一個(gè)將各傳感器獲取的數(shù)據(jù)融合到一起的融合引擎。

Apollo系統(tǒng)中默認(rèn)使用Novatel 板卡,該說明詳細(xì)介紹如何添加并使用一個(gè)新的GPS接收器。

添加新GPS接收器的步

請按照下面的步驟添加新的GPS接收器:

  1. 通過繼承基類“Parser”,實(shí)現(xiàn)新GPS接收器的數(shù)據(jù)解析器

  2. 在Parser類中為新GPS接收器添加新接口

  3. 在文件config.proto中, 為新GPS接收器添加新數(shù)據(jù)格式

  4. 在函數(shù)create_parser(見文件data_parser.cpp), 為新GPS接收器添加新解析器實(shí)例

下面讓我們用上面的方法來添加u-blox GPS接收器。

步驟一

通過繼承類“Parser”,為新GPS接收器實(shí)現(xiàn)新的數(shù)據(jù)解析器:

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類中添加函數(shù)‘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接收器添加新的數(shù)據(jù)格式定義:

在配置文件(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;
    }
... ...

步驟四

在函數(shù)create_parser(見data_parser.cpp), 為新GPS接收器添加新解析器實(shí)例. 我們將通過添加處理config::Stream::UBLOX_BINARY的代碼實(shí)現(xiàn)上面的步驟,具體如下。

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系統(tǒng)中怎么添加新的GPS接收器”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI