How to add a new GPS receiver to Apollo system
Editor to share with you how to add a new GPS receiver in the Apollo system, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
Brief introduction
A GPS receiver is a device that receives information from a GPS satellite and then calculates the geographic location, speed and precise time of the device based on that information. Such equipment usually includes a receiver, an IMU (Inertial measurement unit, inertial measurement unit), an interface for wheel encoders, and a fusion engine that fuses data from various sensors.
Novatel cards are used by default in Apollo systems, which details how to add and use a new GPS receiver.
To add a new GPS receiver
Follow these steps to add a new GPS receiver:
Implement the data parser of the new GPS receiver by inheriting the base class "Parser"
Add a new interface to the new GPS receiver in the Parser class
In the file config.proto, add a new data format for the new GPS receiver
In the function create_parser (see file data_parser.cpp), add a new parser instance for the new GPS receiver
Let's use the above method to add a u-blox GPS receiver.
Step one
Implement a new data parser for the new GPS receiver by inheriting the class "Parser":
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 _ buffer; size_t _ total_length = 0;: apollo::drivers::gnss::Gnss _ gnss :: apollo::drivers::gnss::Imu _ imu;:: apollo::drivers::gnss::Ins _ ins;}
Step two
In the Parser class, add a new interface for the new GPS receiver:
Add the function 'create_ublox':' to the Parser class
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 (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 ();}
Step three
In the config.proto file, add a new data format definition for the new GPS receiver:
Add UBLOX_TEXT and UBLOX_BINARY to the configuration file (modules/drivers/gnss/proto/config.proto)
Enum Format {UNKNOWN = 0; NMEA = 1; RTCM_V2 = 2; RTCM_V3 = 3; NOVATEL_TEXT = 10; NOVATEL_BINARY = 11; UBLOX_TEXT = 20; UBLOX_BINARY = 21;}.
Step 4
In the function create_parser (see data_parser.cpp), add a new parser instance for the new GPS receiver. We will implement the above steps by adding code that handles config::Stream::UBLOX_BINARY, as shown below.
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 }} above is all the content of the article "how to add a new GPS receiver in Apollo system". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!