mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-03-23 18:13:49 +08:00
mavsdk_tests: add events to log
This commit is contained in:
@@ -52,6 +52,7 @@ AutopilotTester::AutopilotTester() :
|
||||
|
||||
AutopilotTester::~AutopilotTester()
|
||||
{
|
||||
_events->unsubscribe_events(_events_handle);
|
||||
_should_exit = true;
|
||||
_real_time_report_thread.join();
|
||||
}
|
||||
@@ -76,14 +77,26 @@ void AutopilotTester::connect(const std::string uri)
|
||||
_offboard.reset(new Offboard(system));
|
||||
_param.reset(new Param(system));
|
||||
_telemetry.reset(new Telemetry(system));
|
||||
_events.reset(new Events(system));
|
||||
_mavlink_passthrough.reset(new MavlinkPassthrough(system));
|
||||
|
||||
_events_handle = _events->subscribe_events([](const Events::Event & event) {
|
||||
std::cout << "[" << event.log_level << "] " << event.message << std::endl;
|
||||
|
||||
if (!event.description.empty()) {
|
||||
std::cout << " Description: " << event.description << std::endl;
|
||||
}
|
||||
|
||||
std::cout << " Event name: " << event.event_namespace << "/" << event.event_name
|
||||
<< std::endl;
|
||||
});
|
||||
}
|
||||
|
||||
void AutopilotTester::wait_until_ready()
|
||||
{
|
||||
std::cout << time_str() << "Waiting for system to be ready (system health ok & able to arm)" << std::endl;
|
||||
|
||||
// Wiat until the system is healthy
|
||||
// Wait until the system is healthy
|
||||
CHECK(poll_condition_with_timeout(
|
||||
[this]() { return _telemetry->health_all_ok(); }, std::chrono::seconds(30)));
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include <mavsdk/plugins/offboard/offboard.h>
|
||||
#include <mavsdk/plugins/telemetry/telemetry.h>
|
||||
#include <mavsdk/plugins/param/param.h>
|
||||
#include <mavsdk/plugins/events/events.h>
|
||||
#include "catch2/catch.hpp"
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
@@ -293,6 +294,7 @@ private:
|
||||
std::unique_ptr<mavsdk::Offboard> _offboard{};
|
||||
std::unique_ptr<mavsdk::Param> _param{};
|
||||
std::unique_ptr<mavsdk::Telemetry> _telemetry{};
|
||||
std::unique_ptr<mavsdk::Events> _events{};
|
||||
|
||||
Telemetry::GroundTruth _home{NAN, NAN, NAN};
|
||||
|
||||
@@ -300,4 +302,6 @@ private:
|
||||
|
||||
std::atomic<bool> _should_exit {false};
|
||||
std::thread _real_time_report_thread {};
|
||||
|
||||
mavsdk::Events::EventsHandle _events_handle{};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user