From cfc8b5ad4350fdedb18006e8ecd1872272c747a0 Mon Sep 17 00:00:00 2001 From: Jacob Dahl Date: Wed, 17 Apr 2024 21:48:49 -0800 Subject: [PATCH] rename to PolarisClientMavlink --- CMakeLists.txt | 2 +- ...sRTKClient.cpp => PolarisClientMavlink.cpp} | 18 +++++++++--------- ...sRTKClient.hpp => PolarisClientMavlink.hpp} | 4 ++-- src/main.cpp | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) rename src/{PolarisRTKClient.cpp => PolarisClientMavlink.cpp} (87%) rename src/{PolarisRTKClient.hpp => PolarisClientMavlink.hpp} (93%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f5756a..eb768a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ include_directories(third_party/tomlplusplus/) # Create executable add_executable(polaris-rtk-client src/main.cpp - src/PolarisRTKClient.cpp + src/PolarisClientMavlink.cpp ) target_link_libraries(polaris-rtk-client diff --git a/src/PolarisRTKClient.cpp b/src/PolarisClientMavlink.cpp similarity index 87% rename from src/PolarisRTKClient.cpp rename to src/PolarisClientMavlink.cpp index 0095041..e8c6048 100644 --- a/src/PolarisRTKClient.cpp +++ b/src/PolarisClientMavlink.cpp @@ -1,11 +1,11 @@ -#include "PolarisRTKClient.hpp" +#include "PolarisClientMavlink.hpp" #include #include #include #include #include -PolarisRTKClient::PolarisRTKClient(const PolarisRTKClient::Settings& settings) +PolarisClientMavlink::PolarisClientMavlink(const PolarisClientMavlink::Settings& settings) : _settings(settings) { // Disable mavsdk noise @@ -15,13 +15,13 @@ PolarisRTKClient::PolarisRTKClient(const PolarisRTKClient::Settings& settings) // }); } -void PolarisRTKClient::stop() +void PolarisClientMavlink::stop() { _polaris_client->Disconnect(); _should_exit = true; } -bool PolarisRTKClient::wait_for_mavsdk_connection(double timeout_ms) +bool PolarisClientMavlink::wait_for_mavsdk_connection(double timeout_ms) { std::cout << "Connecting to " << _settings.mavsdk_connection_url << std::endl; _mavsdk = std::make_shared(mavsdk::Mavsdk::Configuration(1, MAV_COMP_ID_ONBOARD_COMPUTER, @@ -48,7 +48,7 @@ bool PolarisRTKClient::wait_for_mavsdk_connection(double timeout_ms) return true; } -void PolarisRTKClient::RTCMCallback(const uint8_t* recv, size_t length) +void PolarisClientMavlink::RTCMCallback(const uint8_t* recv, size_t length) { std::cout << "Received data: size: " << length << std::endl; @@ -85,7 +85,7 @@ void PolarisRTKClient::RTCMCallback(const uint8_t* recv, size_t length) } } -void PolarisRTKClient::send_mavlink_gps_rtcm_data(const mavlink_gps_rtcm_data_t& msg) +void PolarisClientMavlink::send_mavlink_gps_rtcm_data(const mavlink_gps_rtcm_data_t& msg) { std::cout << "send_mavlink_gps_rtcm_data: " << int(msg.len) << std::endl; _mavlink_passthrough->queue_message([&](MavlinkAddress mavlink_address, uint8_t channel) { @@ -101,7 +101,7 @@ void PolarisRTKClient::send_mavlink_gps_rtcm_data(const mavlink_gps_rtcm_data_t& }); } -void PolarisRTKClient::handle_gps_raw_int(const mavlink_message_t& message) +void PolarisClientMavlink::handle_gps_raw_int(const mavlink_message_t& message) { if (_gps_position_set) { // TODO: unsubscribe? @@ -137,14 +137,14 @@ void PolarisRTKClient::handle_gps_raw_int(const mavlink_message_t& message) _ecef_position.updated = true; } -void PolarisRTKClient::run() +void PolarisClientMavlink::run() { std::srand(std::time(0)); std::string session_id = std::to_string(std::rand()); std::cout << "Session ID: " << session_id << std::endl; // Create polaris client _polaris_client = std::make_shared(_settings.polaris_api_key, session_id); - _polaris_client->SetRTCMCallback(std::bind(&PolarisRTKClient::RTCMCallback, this, std::placeholders::_1, std::placeholders::_2)); + _polaris_client->SetRTCMCallback(std::bind(&PolarisClientMavlink::RTCMCallback, this, std::placeholders::_1, std::placeholders::_2)); _polaris_client->RunAsync(); // Set up callbacks for GPS message so we can set position: SendECEFPosition diff --git a/src/PolarisRTKClient.hpp b/src/PolarisClientMavlink.hpp similarity index 93% rename from src/PolarisRTKClient.hpp rename to src/PolarisClientMavlink.hpp index 566ebb9..869c9d2 100644 --- a/src/PolarisRTKClient.hpp +++ b/src/PolarisClientMavlink.hpp @@ -7,7 +7,7 @@ #include -class PolarisRTKClient +class PolarisClientMavlink { public: struct Settings { @@ -15,7 +15,7 @@ class PolarisRTKClient std::string polaris_api_key; }; - PolarisRTKClient(const Settings& settings); + PolarisClientMavlink(const Settings& settings); void RTCMCallback(const uint8_t* recv, size_t length); diff --git a/src/main.cpp b/src/main.cpp index c626b17..f38c7e8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,4 @@ -#include "PolarisRTKClient.hpp" +#include "PolarisClientMavlink.hpp" #include #include #include @@ -22,7 +22,7 @@ static std::string get_user_name() } std::atomic _should_exit = false; -std::shared_ptr _polaris_rtk_client; +std::shared_ptr _polaris_rtk_client; int main(int argc, char* argv[]) { @@ -49,12 +49,12 @@ int main(int argc, char* argv[]) } // Setup the LogLoader - PolarisRTKClient::Settings settings = { + PolarisClientMavlink::Settings settings = { .mavsdk_connection_url = config["connection_url"].value_or("0.0.0"), .polaris_api_key = config["polaris_api_key"].value_or("") }; - _polaris_rtk_client = std::make_shared(settings); + _polaris_rtk_client = std::make_shared(settings); bool connected = false;