Skip to content

Commit

Permalink
rename to PolarisClientMavlink
Browse files Browse the repository at this point in the history
  • Loading branch information
dakejahl committed Apr 18, 2024
1 parent 824afa6 commit cfc8b5a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions src/PolarisRTKClient.cpp → src/PolarisClientMavlink.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include "PolarisRTKClient.hpp"
#include "PolarisClientMavlink.hpp"
#include <iomanip>
#include <iostream>
#include <future>
#include <regex>
#include <algorithm>

PolarisRTKClient::PolarisRTKClient(const PolarisRTKClient::Settings& settings)
PolarisClientMavlink::PolarisClientMavlink(const PolarisClientMavlink::Settings& settings)
: _settings(settings)
{
// Disable mavsdk noise
Expand All @@ -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>(mavsdk::Mavsdk::Configuration(1, MAV_COMP_ID_ONBOARD_COMPUTER,
Expand All @@ -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;

Expand Down Expand Up @@ -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) {
Expand All @@ -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?
Expand Down Expand Up @@ -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<point_one::polaris::PolarisClient>(_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
Expand Down
4 changes: 2 additions & 2 deletions src/PolarisRTKClient.hpp → src/PolarisClientMavlink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

#include <point_one/polaris/polaris_client.h>

class PolarisRTKClient
class PolarisClientMavlink
{
public:
struct Settings {
std::string mavsdk_connection_url;
std::string polaris_api_key;
};

PolarisRTKClient(const Settings& settings);
PolarisClientMavlink(const Settings& settings);

void RTCMCallback(const uint8_t* recv, size_t length);

Expand Down
8 changes: 4 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "PolarisRTKClient.hpp"
#include "PolarisClientMavlink.hpp"
#include <filesystem>
#include <signal.h>
#include <iostream>
Expand All @@ -22,7 +22,7 @@ static std::string get_user_name()
}

std::atomic<bool> _should_exit = false;
std::shared_ptr<PolarisRTKClient> _polaris_rtk_client;
std::shared_ptr<PolarisClientMavlink> _polaris_rtk_client;

int main(int argc, char* argv[])
{
Expand All @@ -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("<your_key_goes_here>")
};

_polaris_rtk_client = std::make_shared<PolarisRTKClient>(settings);
_polaris_rtk_client = std::make_shared<PolarisClientMavlink>(settings);

bool connected = false;

Expand Down

0 comments on commit cfc8b5a

Please sign in to comment.