.. _program_listing_file__tmp_ws_src_novatel_gps_driver_novatel_gps_driver_include_novatel_gps_driver_novatel_gps.h: Program Listing for File novatel_gps.h ====================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/novatel_gps_driver/novatel_gps_driver/include/novatel_gps_driver/novatel_gps.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // ***************************************************************************** // // Copyright (c) 2019, Southwest Research Institute® (SwRI®) // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of Southwest Research Institute® (SwRI®) nor the // names of its contributors may be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE // ARE DISCLAIMED. IN NO EVENT SHALL SOUTHWEST RESEARCH INSTITUTE BE LIABLE FOR ANY // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // ***************************************************************************** #ifndef NOVATEL_GPS_DRIVER_NOVATEL_GPS_H_ #define NOVATEL_GPS_DRIVER_NOVATEL_GPS_H_ // std libraries #include #include #include #include #include // Boost #include #include // ROS #include #include // Messages #include #include #include #include // Other libraries #include #include // Local include files #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace novatel_gps_driver { typedef std::map NovatelMessageOpts; class NovatelGps { public: enum ConnectionType { SERIAL, TCP, UDP, PCAP, INVALID }; enum ReadResult { READ_SUCCESS = 0, READ_INSUFFICIENT_DATA = 1, READ_TIMEOUT = 2, READ_INTERRUPTED = 3, READ_ERROR = -1, READ_PARSE_FAILED = -2 }; explicit NovatelGps(rclcpp::Node& Node); ~NovatelGps(); bool Connect(const std::string& device, ConnectionType connection); bool Connect(const std::string& device, ConnectionType connection, NovatelMessageOpts const& opts); void Disconnect(); std::string ErrorMsg() const { return error_msg_; } void GetFixMessages(std::vector& fix_messages); void GetGpggaMessages(std::vector& gpgga_messages); void GetGpgsaMessages(std::vector& gpgsa_messages); void GetGpgsvMessages(std::vector& gpgsv_messages); void GetGphdtMessages(std::vector& gphdt_messages); void GetGprmcMessages(std::vector& gprmc_messages); void GetNovatelHeading2Messages(std::vector& headings); void GetNovatelDualAntennaHeadingMessages(std::vector& headings); void GetNovatelPsrdop2Messages(std::vector& psrdop2_messages); void GetImuMessages(std::vector& imu_messages); void GetInscovMessages(std::vector& inscov_messages); void GetInspvaMessages(std::vector& inspva_messages); void GetInspvaxMessages(std::vector& inspvax_messages); void GetInsstdevMessages(std::vector& insstdev_messages); void GetNovatelCorrectedImuData(std::vector& imu_messages); void GetNovatelPositions(std::vector& positions); void GetNovatelXYZPositions(std::vector& positions); void GetNovatelUtmPositions(std::vector& utm_positions); void GetNovatelVelocities(std::vector& velocities); void GetRangeMessages(std::vector& range_messages); void GetTimeMessages(std::vector& time_messages); void GetTrackstatMessages(std::vector& trackstat_msgs); void GetClockSteeringMessages(std::vector& clocksteering_msgs); bool IsConnected() { return is_connected_; } static ConnectionType ParseConnection(const std::string& connection); void ApplyVehicleBodyRotation(const bool& apply_rotation); ReadResult ProcessData(); void SetImuRate(double imu_rate, bool force = true); void SetSerialBaud(int32_t serial_baud); bool Write(const std::string& command); double gpsfix_sync_tol_; //seconds bool wait_for_sync_; // wait until a bestvel has arrived before publishing bestpos private: bool Configure(NovatelMessageOpts const& opts); bool CreateIpConnection(const std::string& endpoint, NovatelMessageOpts const& opts); bool CreateSerialConnection(const std::string& device, NovatelMessageOpts const& opts); bool CreatePcapConnection(const std::string& device, NovatelMessageOpts const& opts); template inline void DrainQueue(Input& in, Output& out) { out.clear(); std::move(std::make_move_iterator(in.begin()), std::make_move_iterator(in.end()), std::back_inserter(out)); in.clear(); } void GenerateImuMessages(); NovatelGps::ReadResult ParseBinaryMessage(const BinaryMessage& msg, const rclcpp::Time& stamp) noexcept(false); NovatelGps::ReadResult ParseNmeaSentence(const NmeaSentence& sentence, const rclcpp::Time& stamp, double most_recent_utc_time) noexcept(false); NovatelGps::ReadResult ParseNovatelSentence(const NovatelSentence& sentence, const rclcpp::Time& stamp) noexcept(false); ReadResult ReadData(); static constexpr uint16_t DEFAULT_TCP_PORT = 3001; static constexpr uint16_t DEFAULT_UDP_PORT = 3002; static constexpr size_t MAX_BUFFER_SIZE = 100; static constexpr size_t SYNC_BUFFER_SIZE = 10; static constexpr uint32_t SECONDS_PER_WEEK = 604800; static constexpr double IMU_TOLERANCE_S = 0.0002; static constexpr double DEGREES_TO_RADIANS = M_PI / 180.0; rclcpp::Node& node_; ConnectionType connection_; std::string error_msg_; bool is_connected_; bool imu_rate_forced_; double utc_offset_; // Serial connection int32_t serial_baud_; swri_serial_util::SerialPort serial_; // TCP / UDP connections boost::asio::io_service io_service_; boost::asio::ip::tcp::socket tcp_socket_; std::shared_ptr udp_socket_; std::shared_ptr udp_endpoint_; // Data buffers std::vector data_buffer_; std::string nmea_buffer_; std::array socket_buffer_; pcap_t* pcap_; bpf_program pcap_packet_filter_; char pcap_errbuf_[MAX_BUFFER_SIZE]; std::vector last_tcp_packet_; NovatelMessageExtractor extractor_; // Message parsers BestposParser bestpos_parser_; BestxyzParser bestxyz_parser_; BestutmParser bestutm_parser_; BestvelParser bestvel_parser_; Heading2Parser heading2_parser_; DualAntennaHeadingParser dual_antenna_heading_parser_; ClockSteeringParser clocksteering_parser_; CorrImuDataParser corrimudata_parser_; GpggaParser gpgga_parser_; GpgsaParser gpgsa_parser_; GpgsvParser gpgsv_parser_; GphdtParser gphdt_parser_; GprmcParser gprmc_parser_; InscovParser inscov_parser_; InspvaParser inspva_parser_; InspvaxParser inspvax_parser_; InsstdevParser insstdev_parser_; Psrdop2Parser psrdop2_parser_; RangeParser range_parser_; TimeParser time_parser_; TrackstatParser trackstat_parser_; // Message buffers boost::circular_buffer clocksteering_msgs_; boost::circular_buffer corrimudata_msgs_; boost::circular_buffer gpgga_msgs_; boost::circular_buffer gpgsa_msgs_; boost::circular_buffer gpgsv_msgs_; boost::circular_buffer gphdt_msgs_; boost::circular_buffer gprmc_msgs_; boost::circular_buffer imu_msgs_; boost::circular_buffer inscov_msgs_; boost::circular_buffer inspva_msgs_; boost::circular_buffer inspvax_msgs_; boost::circular_buffer insstdev_msgs_; boost::circular_buffer novatel_positions_; boost::circular_buffer novatel_xyz_positions_; boost::circular_buffer novatel_utm_positions_; boost::circular_buffer novatel_velocities_; boost::circular_buffer bestpos_sync_buffer_; boost::circular_buffer bestvel_sync_buffer_; boost::circular_buffer heading2_msgs_; boost::circular_buffer dual_antenna_heading_msgs_; boost::circular_buffer psrdop2_msgs_; boost::circular_buffer range_msgs_; boost::circular_buffer time_msgs_; boost::circular_buffer trackstat_msgs_; novatel_gps_driver::Psrdop2Parser::MessageType latest_psrdop2_; // IMU data synchronization queues std::queue corrimudata_queue_; std::queue inspva_queue_; novatel_gps_driver::InsstdevParser::MessageType latest_insstdev_; novatel_gps_driver::InscovParser::MessageType latest_inscov_; double imu_rate_; // Additional Options bool apply_vehicle_body_rotation_; }; } #endif //NOVATEL_GPS_DRIVER_NOVATEL_GPS_H_