23#include <modal_pipe.h>
24#include <modal_json.h>
25#include <voxl_common_config.h>
26#include <core/VioManager.h>
27#include <core/VioManagerOptions.h>
28#include <types/LandmarkRepresentation.h>
30#include <state/State.h>
31#include <state/StateHelper.h>
32#include <types/Landmark.h>
33#include <types/Type.h>
34#include <feat/Feature.h>
39#include <Eigen/Eigenvalues>
63 inline Eigen::Matrix<double, 3, 1>
dirtyOmega(
const Eigen::Matrix<double, 4, 1> &q0,
64 const Eigen::Matrix<double, 4, 1> &q1,
70 if (dt <= 0.0)
return Eigen::Vector3d::Zero();
71 if (q0.isZero(0) || q1.isZero(0))
return Eigen::Vector3d::Zero();
74 Eigen::Matrix<double, 4, 1> dq = ov_core::quat_multiply(q1, ov_core::Inv(q0));
81 double w = std::clamp(dq.w(), -1.0, 1.0);
82 double sin_half = std::sqrt(std::max(1.0 - w * w, 0.0));
86 return (2.0 / dt) * dq.head<3>();
89 double theta = 2.0 * std::acos(w);
90 Eigen::Vector3d axis = dq.head<3>() / sin_half;
91 return axis * (theta / dt);
107 static const Eigen::Matrix3d R{
108 (Eigen::Matrix3d() << 1, 0, 0, 0, -1, 0, 0, 0, -1).finished()};
172 void publish(std::shared_ptr<ov_msckf::State> state,
173 const std::map<
double, std::vector<std::shared_ptr<ov_core::Feature>>> &used_features_map = {});
201 double current_velocity,
226 double calcQuality(
const std::map<
double, std::vector<std::shared_ptr<ov_core::Feature>>> &used_features_map,
227 std::unordered_map<
size_t, std::shared_ptr<ov_type::Landmark>> &slam_features,
228 std::shared_ptr<ov_msckf::State> state);
239 first_packet = first_packet_;
260 bool first_packet =
true;
265 bool prev_initialized =
false;
270 Eigen::Matrix3d ned_rot_zero = Eigen::Matrix3d::Identity();
273 vio_data_t vio_packet;
276 Eigen::Matrix<double, 4, 1> past_q_I_G;
284 static constexpr int QUAL_MAX_CAMS = 4;
285 double qual_ema = -1.0;
286 double qual_ema_t = 0.0;
287 double qual_src_key = 0.0;
288 size_t qual_src_size = 0;
289 size_t qual_src_map_size = 0;
379 void healthCheckLoop();
387 void analyzeErrorCodes();
395 void checkSystemConnectivity();
403 void monitorSystemPerformance();
411 void checkAutoResetConditions();
419 void checkVINSResetRequest();
443 std::atomic<bool> running_{
false};
446 std::thread health_thread_;
449 uint32_t last_error_codes_{0};
452 uint8_t last_vio_state_{0};
455 bool last_imu_connected_{
false};
458 bool last_cam_connected_{
false};
461 bool first_camera_connection_seen_{
false};
464 int64_t last_health_check_ns_{0};
467 uint64_t health_check_count_{0};
470 mutable std::mutex health_mutex_;
473 const uint64_t INIT_FAILURE_TIMEOUT_NS = 2000000000;
476 uint64_t time_of_last_reset = 0;
Common definitions and utilities for the VOXL OpenVINS server.
Global variable declarations and constants for VOXL OpenVINS server.
Health monitoring system for VOXL OpenVINS.
void start()
Start the health check system.
bool isRunning() const
Check if health monitoring is running.
static void clearErrorCodes(uint32_t error_mask)
Clear specific error codes.
void stop()
Stop the health check system.
static HealthCheck & getInstance()
Get singleton instance.
Singleton class for publishing VIO data.
void set_first_packet(bool first_packet_)
Set the first packet flag.
static Publisher & getInstance()
Get singleton instance.
static void ov_vio_control_pipe_cb(int ch, char *string, int bytes, void *context)
Control pipe callback function.
void stop()
Stop the publisher.
void start()
Start the publisher.
bool should_auto_reset(std::shared_ptr< ov_msckf::State > state, int quality, int n_features, double yawrate, double current_velocity, double vel_x, double vel_y)
Check if auto-reset should be triggered.
void publish(std::shared_ptr< ov_msckf::State > state, const std::map< double, std::vector< std::shared_ptr< ov_core::Feature > > > &used_features_map={})
Publish VIO data.
double calcQuality(const std::map< double, std::vector< std::shared_ptr< ov_core::Feature > > > &used_features_map, std::unordered_map< size_t, std::shared_ptr< ov_type::Landmark > > &slam_features, std::shared_ptr< ov_msckf::State > state)
Calculate Quality of the VIO state (async-aware per-camera freshness ledger)
Main namespace for VOXL OpenVINS server components.
Eigen::Matrix< double, 3, 1 > dirtyOmega(const Eigen::Matrix< double, 4, 1 > &q0, const Eigen::Matrix< double, 4, 1 > &q1, double dt)
Calculate angular velocity from consecutive quaternions.
const Eigen::Matrix3d & R_OV_FRD()
Get OpenVINS to FRD coordinate frame transformation matrix.