mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
mavsdk_tests: add events to log
This commit is contained in:
parent
1f65cc46b9
commit
d4be5d3ff0
@ -52,6 +52,7 @@ AutopilotTester::AutopilotTester() :
|
|||||||
|
|
||||||
AutopilotTester::~AutopilotTester()
|
AutopilotTester::~AutopilotTester()
|
||||||
{
|
{
|
||||||
|
_events->unsubscribe_events(_events_handle);
|
||||||
_should_exit = true;
|
_should_exit = true;
|
||||||
_real_time_report_thread.join();
|
_real_time_report_thread.join();
|
||||||
}
|
}
|
||||||
@ -76,14 +77,26 @@ void AutopilotTester::connect(const std::string uri)
|
|||||||
_offboard.reset(new Offboard(system));
|
_offboard.reset(new Offboard(system));
|
||||||
_param.reset(new Param(system));
|
_param.reset(new Param(system));
|
||||||
_telemetry.reset(new Telemetry(system));
|
_telemetry.reset(new Telemetry(system));
|
||||||
|
_events.reset(new Events(system));
|
||||||
_mavlink_passthrough.reset(new MavlinkPassthrough(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()
|
void AutopilotTester::wait_until_ready()
|
||||||
{
|
{
|
||||||
std::cout << time_str() << "Waiting for system to be ready (system health ok & able to arm)" << std::endl;
|
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(
|
CHECK(poll_condition_with_timeout(
|
||||||
[this]() { return _telemetry->health_all_ok(); }, std::chrono::seconds(30)));
|
[this]() { return _telemetry->health_all_ok(); }, std::chrono::seconds(30)));
|
||||||
|
|
||||||
|
|||||||
@ -45,6 +45,7 @@
|
|||||||
#include <mavsdk/plugins/offboard/offboard.h>
|
#include <mavsdk/plugins/offboard/offboard.h>
|
||||||
#include <mavsdk/plugins/telemetry/telemetry.h>
|
#include <mavsdk/plugins/telemetry/telemetry.h>
|
||||||
#include <mavsdk/plugins/param/param.h>
|
#include <mavsdk/plugins/param/param.h>
|
||||||
|
#include <mavsdk/plugins/events/events.h>
|
||||||
#include "catch2/catch.hpp"
|
#include "catch2/catch.hpp"
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@ -293,6 +294,7 @@ private:
|
|||||||
std::unique_ptr<mavsdk::Offboard> _offboard{};
|
std::unique_ptr<mavsdk::Offboard> _offboard{};
|
||||||
std::unique_ptr<mavsdk::Param> _param{};
|
std::unique_ptr<mavsdk::Param> _param{};
|
||||||
std::unique_ptr<mavsdk::Telemetry> _telemetry{};
|
std::unique_ptr<mavsdk::Telemetry> _telemetry{};
|
||||||
|
std::unique_ptr<mavsdk::Events> _events{};
|
||||||
|
|
||||||
Telemetry::GroundTruth _home{NAN, NAN, NAN};
|
Telemetry::GroundTruth _home{NAN, NAN, NAN};
|
||||||
|
|
||||||
@ -300,4 +302,6 @@ private:
|
|||||||
|
|
||||||
std::atomic<bool> _should_exit {false};
|
std::atomic<bool> _should_exit {false};
|
||||||
std::thread _real_time_report_thread {};
|
std::thread _real_time_report_thread {};
|
||||||
|
|
||||||
|
mavsdk::Events::EventsHandle _events_handle{};
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user