VOXL OpenVINS Server 1.0
Visual Inertial Odometry Server for VOXL Platform
Loading...
Searching...
No Matches
Macros | Functions | Variables
ImuMinimal.cpp File Reference

IMU interface and data handling implementation for VOXL OpenVINS. More...

#include "ImuMinimal.h"
#include <cstdio>
#include <state/State.h>
Include dependency graph for ImuMinimal.cpp:

Go to the source code of this file.

Macros

#define TS_PRINT(msg)
 

Functions

void _imu_data_handler_cb (int ch, char *data, int bytes, void *context)
 Handler for incoming IMU data.
 
void _imu_disconnect_cb (__attribute__((unused)) int ch, __attribute__((unused)) void *context)
 Callback for IMU disconnect events.
 
int connect_imu_service (void)
 Creates IMU pipe client and associated callbacks.
 

Variables

std::mutex imu_lock_mutex
 Mutex for IMU data access synchronization.
 

Detailed Description

IMU interface and data handling implementation for VOXL OpenVINS.

Author
Zauberflote
Date
2025
Version
1.0

This file implements the IMU interface and callback functions for handling inertial measurement unit data in the VOXL OpenVINS system. It provides the connection to the IMU service and data processing capabilities.

The implementation provides:

Definition in file ImuMinimal.cpp.

Macro Definition Documentation

◆ TS_PRINT

#define TS_PRINT (   msg)
Value:
do \
{ \
int64_t __ts = _apps_time_monotonic_ns(); \
printf("[TS %ld ns] %s\n", __ts, msg); \
} while (0)

Definition at line 82 of file ImuMinimal.cpp.

Function Documentation

◆ _imu_data_handler_cb()

void _imu_data_handler_cb ( int  ch,
char *  data,
int  bytes,
void *  context 
)

Handler for incoming IMU data.

This callback processes incoming IMU data, updates the system state, and triggers appropriate processing based on motion state. It serves as the primary entry point for all IMU data processing in the system.

The function performs the following operations:

  • Validates and parses IMU data packets
  • Updates frame transformation based on gravity direction
  • Converts IMU data to OpenVINS format
  • Performs batch processing to reduce mutex operations
  • Feeds IMU data to the VIO manager
  • Synchronizes camera data with IMU timestamps
  • Triggers VIO processing and data publishing

The function uses batch processing to minimize mutex contention at high IMU frequencies and ensures proper temporal synchronization between IMU and camera data.

Parameters
chChannel number (unused)
dataPointer to IMU data buffer
bytesSize of data buffer in bytes
contextContext pointer (unused)

Definition at line 114 of file ImuMinimal.cpp.

References active_callbacks, en_debug, frame_transform, CameraQueueFusion::getInstance(), voxl::Publisher::getInstance(), CameraQueueFusion::getSortedBatch(), imu_model, is_imu_connected, is_resetting, last_imu_timestamp_ns, voxl::Publisher::publish(), reset_cv, reset_mtx, vio_error_codes, and vio_manager.

Referenced by connect_imu_service().

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

◆ _imu_disconnect_cb()

void _imu_disconnect_cb ( __attribute__((unused)) int  ch,
__attribute__((unused)) void *  context 
)

Callback for IMU disconnect events.

This function is called when the IMU service disconnects. It handles the cleanup and state management required when IMU data becomes unavailable.

The function uses thread-safe mutex locking to ensure proper state management during disconnection events.

Parameters
chChannel number (unused)
contextContext pointer (unused)

Definition at line 283 of file ImuMinimal.cpp.

References IMU_CH, imu_lock_mutex, and is_imu_connected.

Referenced by connect_imu_service().

Here is the caller graph for this function:

◆ connect_imu_service()

int connect_imu_service ( void  )

Creates IMU pipe client and associated callbacks.

This function sets up the disconnect and data handler callbacks, and opens the client pipe connection to the IMU service. It initializes the complete IMU data pipeline for the VIO system.

The function performs the following operations:

  • Sets up disconnect callback for graceful handling of service disconnection
  • Sets up data handler callback for processing incoming IMU measurements
  • Configures thread priority for high-frequency IMU processing
  • Opens the client pipe connection to the IMU service
  • Configures the pipe for optimal data flow
  • Sets the IMU connection status flag
Returns
0 on success, -1 on failure

Definition at line 315 of file ImuMinimal.cpp.

References _imu_data_handler_cb(), _imu_disconnect_cb(), IMU_CH, imu_name, is_imu_connected, PROCESS_NAME, and vio_error_codes.

Here is the call graph for this function:

Variable Documentation

◆ imu_lock_mutex

std::mutex imu_lock_mutex

Mutex for IMU data access synchronization.

Mutex used to synchronize access to IMU data between multiple threads.

Definition at line 80 of file ImuMinimal.cpp.

Referenced by _imu_disconnect_cb().