VOXL OpenVINS Server 1.0
Visual Inertial Odometry Server for VOXL Platform
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
voxl::Publisher Class Reference

Singleton class for publishing VIO data. More...

#include <VoxlHK.h>

Public Member Functions

 Publisher (const Publisher &)=delete
 
Publisheroperator= (const Publisher &)=delete
 
void start ()
 Start the publisher.
 
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.
 
void stop ()
 Stop 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.
 
void set_first_packet (bool first_packet_)
 Set the first packet flag.
 
void publishBlank ()
 

Static Public Member Functions

static PublishergetInstance ()
 Get singleton instance.
 
static void ov_vio_control_pipe_cb (int ch, char *string, int bytes, void *context)
 Control pipe callback function.
 

Detailed Description

Singleton class for publishing VIO data.

This class manages the publication of VIO data to external systems through pipe interfaces. It implements the singleton pattern to ensure only one instance exists throughout the application lifecycle.

The publisher handles:

Definition at line 135 of file VoxlHK.h.

Member Function Documentation

◆ calcQuality()

double Publisher::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.

This function computes the quality score based on the features used at the current timestamp. The quality calculation considers:

  1. Grid distribution: 5x5 grid per camera with 50 features target (2 per grid)
  2. SLAM features: weighted by covariance largest eigenvalue and quality field
  3. MSCKF features: weighted by quality field and number of measurements
Parameters
used_features_mapMap of used features at the current timestamp
slam_featuresMap of SLAM features from the state
stateCurrent VIO state for covariance access
Returns
Quality score (0-100, higher is better)

This function computes the quality score based on the features used at the current timestamp. The quality calculation considers:

  1. Grid distribution: 5x5 grid per camera with 50 features target (2 per grid)
  2. Active SLAM features: weighted by covariance largest eigenvalue and quality field
  3. MSCKF features: weighted by quality field and number of measurements
Parameters
used_features_mapMap of used features at the current timestamp
slam_featuresMap of SLAM features from the state
stateCurrent VIO state for covariance access
Returns
Quality score (0-100, higher is better)

Definition at line 1177 of file VoxlPublisher.cpp.

Referenced by publish().

Here is the caller graph for this function:

◆ getInstance()

static Publisher & voxl::Publisher::getInstance ( )
inlinestatic

Get singleton instance.

Returns
Reference to the singleton Publisher instance

Definition at line 142 of file VoxlHK.h.

Referenced by _imu_data_handler_cb(), and main().

Here is the caller graph for this function:

◆ ov_vio_control_pipe_cb()

void Publisher::ov_vio_control_pipe_cb ( int  ch,
char *  string,
int  bytes,
void *  context 
)
static

Control pipe callback function.

Control-pipe callback for VIO commands.

Callback function to handle control pipe messages

This function is invoked every time a message is received on the VIO control pipe.

Parameters
chChannel id supplied by the pipe framework.
stringPointer to the received buffer.
bytesNumber of valid bytes in string.
contextUser context pointer supplied during registration.
Note
Matching is performed with the STR_MATCH() macro, which compares the prefix of string against the command literal.

Definition at line 92 of file VoxlPublisher.cpp.

References is_resetting, and reset_requested.

◆ publish()

void Publisher::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.

Publish VIO data to external systems.

Publishes the current VIO state and tracking information to external systems through the configured pipe interfaces.

Parameters
stateCurrent VIO state
used_features_mapMap of used features at current timestamp

This method formats and publishes the current VIO state and tracking information to external systems through the configured pipe interfaces.

The function performs the following operations:

  • Formats VIO data packet with current state information
  • Performs coordinate frame transformations (OpenVINS to FRD)
  • Calculates angular velocity from quaternion differences
  • Extracts and formats covariance matrices
  • Handles camera-to-IMU extrinsic parameters
  • Publishes both simple and extended VIO data packets

The coordinate frame transformation involves:

  • Converting from OpenVINS coordinate frame to Front-Right-Down (FRD)
  • Handling initialization state with NED rotation zeroing
  • Applying proper quaternion and rotation matrix transformations
Parameters
stateCurrent VIO state containing pose, velocity, and covariance

Definition at line 142 of file VoxlPublisher.cpp.

References alt_z, auto_reset_max_v_cov_instant, auto_reset_max_v_cov_timeout_s, auto_reset_max_velocity, auto_reset_min_feature_timeout_s, auto_reset_min_features, calcQuality(), voxl::dirtyOmega(), en_debug, EXTENDED_CH, fast_yaw_thresh, fast_yaw_timeout_s, frame_transform, has_acc_jerk, is_armed, is_resetting, non_static, ok_state_grace_timeout_s, quality_bad_to_good_count, quality_good_to_bad_count, quality_high_thresh, quality_initial_to_bad_count, quality_initial_to_good_count, quality_low_thresh_good, quality_low_thresh_initial, voxl::R_OV_FRD(), reset_num_counter, reset_requested, should_auto_reset(), SIMPLE_CH, vio_error_codes, vio_manager, and vio_state.

Referenced by _imu_data_handler_cb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ publishBlank()

void Publisher::publishBlank ( )

Definition at line 1460 of file VoxlPublisher.cpp.

◆ set_first_packet()

void voxl::Publisher::set_first_packet ( bool  first_packet_)
inline

Set the first packet flag.

This function sets the first packet flag to the provided value.

Parameters
first_packetThe value to set the first packet flag to

Definition at line 235 of file VoxlHK.h.

◆ should_auto_reset()

bool Publisher::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.

Evaluates current VIO state and error conditions to determine if an automatic reset should be triggered.

Parameters
stateCurrent VIO state
qualityCurrent quality value
n_featuresNumber of tracked features
V_uncertaintyVelocity uncertainty
yawrateCalculated yaw rate from angular velocity
current_velocityCurrent velocity magnitude
vel_xX-component of velocity
vel_yY-component of velocity
Returns
true if auto-reset should be triggered, false otherwise

This function evaluates the current VIO state and various error conditions to determine if an automatic reset should be triggered. It implements the same logic as the legacy code but in a more modular way.

Parameters
stateCurrent VIO state
qualityCurrent quality value
n_featuresNumber of tracked features
V_uncertaintyVelocity uncertainty
Returns
true if auto-reset should be triggered, false otherwise

Definition at line 1033 of file VoxlPublisher.cpp.

References auto_reset_max_v_cov_instant, auto_reset_max_v_cov_timeout_s, auto_reset_max_velocity, auto_reset_min_feature_timeout_s, auto_reset_min_features, en_auto_reset, en_debug, fast_yaw_thresh, fast_yaw_timeout_s, is_armed, and reset_num_counter.

Referenced by publish().

Here is the caller graph for this function:

◆ start()

void Publisher::start ( )

Start the publisher.

Initializes the publisher and prepares it for data transmission.

Initializes the publisher and prepares it for data transmission. Sets the first_packet flag to true to handle the initial angular velocity calculation.

Definition at line 52 of file VoxlPublisher.cpp.

References voxl::HealthCheck::getInstance(), voxl::HealthCheck::start(), and vio_state.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop()

void Publisher::stop ( )

Stop the publisher.

Stops the publisher and cleans up resources.

Stops the publisher and cleans up resources. Currently a placeholder for future cleanup operations.

Definition at line 70 of file VoxlPublisher.cpp.

References voxl::HealthCheck::getInstance(), and voxl::HealthCheck::stop().

Here is the call graph for this function:

The documentation for this class was generated from the following files: