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>
81 inline Eigen::Matrix<double, 3, 1>
dirtyOmega(
const Eigen::Matrix<double, 4, 1> &q_k,
82 const Eigen::Matrix<double, 4, 1> &q_km1,
88 return Eigen::Vector3d::Zero();
90 if (q_k.isZero(0) || q_km1.isZero(0))
92 return Eigen::Vector3d::Zero();
95 Eigen::Matrix<double, 4, 1> dq = ov_core::quat_multiply(q_k, ov_core::Inv(q_km1));
96 return (2.0 / dt) * dq.head<3>();
112 static const Eigen::Matrix3d R{
113 (Eigen::Matrix3d() << 1, 0, 0, 0, -1, 0, 0, 0, -1).finished()};
175 void publish(std::shared_ptr<ov_msckf::State> state,
176 std::map<
double, std::vector<std::shared_ptr<ov_core::Feature>>> used_features_map = {});
204 double V_uncertainty,
206 double current_velocity,
224 double calcQuality(
const std::map<
double, std::vector<std::shared_ptr<ov_core::Feature>>> &used_features_map,
225 std::unordered_map<
size_t, std::shared_ptr<ov_type::Landmark>> &slam_features,
226 std::shared_ptr<ov_msckf::State> state);
237 first_packet = first_packet_;
258 bool first_packet =
true;
261 vio_data_t vio_packet;
264 std::shared_ptr<ov_msckf::State> past_state;
267 Eigen::Matrix<double, 4, 1> past_q_I_G;
360 void healthCheckLoop();
368 void analyzeErrorCodes();
376 void checkSystemConnectivity();
384 void monitorSystemPerformance();
392 void checkAutoResetConditions();
400 void checkVINSResetRequest();
415 std::atomic<bool> running_{
false};
418 std::thread health_thread_;
421 uint32_t last_error_codes_{0};
424 uint8_t last_vio_state_{0};
427 bool last_imu_connected_{
false};
430 bool last_cam_connected_{
false};
433 bool first_camera_connection_seen_{
false};
436 int64_t last_health_check_ns_{0};
439 uint64_t health_check_count_{0};
442 mutable std::mutex health_mutex_;
445 const uint64_t INIT_FAILURE_TIMEOUT_NS = 2000000000;
448 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.
void publish(std::shared_ptr< ov_msckf::State > state, std::map< double, std::vector< std::shared_ptr< ov_core::Feature > > > used_features_map={})
Publish VIO data.
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 V_uncertainty, double yawrate, double current_velocity, double vel_x, double vel_y)
Check if auto-reset should be triggered.
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.
Main namespace for VOXL OpenVINS server components.
ANG_VEL_TYPE
Types of angular velocity calculations.
@ IMU_BIAS
IMU bias-corrected angular velocity.
@ QUAT_DIRTY
Dirty quaternion-based angular velocity.
@ RPY_DIRTY
Dirty roll-pitch-yaw based angular velocity.
const Eigen::Matrix3d & R_OV_FRD()
Get OpenVINS to FRD coordinate frame transformation matrix.
Eigen::Matrix< double, 3, 1 > dirtyOmega(const Eigen::Matrix< double, 4, 1 > &q_k, const Eigen::Matrix< double, 4, 1 > &q_km1, double dt)
Calculate dirty angular velocity from quaternions.