VOXL OpenVINS Server 0.7.0
Visual Inertial Odometry Server for VOXL Platform
Loading...
Searching...
No Matches
ImuMinimal.h
Go to the documentation of this file.
1/**
2 * @file ImuMinimal.h
3 * @brief IMU interface and data handling for VOXL OpenVINS
4 * @author Joao Leonardo Silva Cotta (@zauberflote1)
5 * @date 2025
6 * @version 1.0
7 *
8 * This header defines the IMU interface and callback functions for handling
9 * inertial measurement unit data in the VOXL OpenVINS system. It provides
10 * the connection to the IMU service and data processing capabilities.
11 */
12
13#ifndef IMU_MODULE_H
14#define IMU_MODULE_H
15
16// Standard includes
17#include <mutex>
18#include <functional>
19#include <optional>
20#include <array>
21
22// Third-party includes
23#include <modal_pipe.h>
24
25// Local includes
26#include "VoxlVars.h"
27#include "VoxlCommon.h"
28#include "VoxlHK.h"
29
30// ============================================================================
31// EXTERNAL DECLARATIONS
32// ============================================================================
33
34/** @brief Mutex for IMU data access synchronization */
35extern std::mutex imu_lock_mutex;
36
37// ============================================================================
38// CALLBACK FUNCTIONS
39// ============================================================================
40
41/**
42 * @brief Callback for IMU disconnect events
43 *
44 * This function is called when the IMU service disconnects. It handles
45 * the cleanup and state management required when IMU data becomes unavailable.
46 *
47 * @param ch Channel number (unused)
48 * @param context Context pointer (unused)
49 */
50void _imu_disconnect_cb(__attribute__((unused)) int ch,
51 __attribute__((unused)) void *context);
52
53/**
54 * @brief Handler for incoming IMU data
55 *
56 * This callback processes incoming IMU data, updates the system state,
57 * and triggers appropriate processing based on motion state. It serves
58 * as the primary entry point for all IMU data processing in the system.
59 *
60 * The function:
61 * - Extracts accelerometer and gyroscope measurements
62 * - Updates system timestamps and state
63 * - Triggers VIO processing when appropriate
64 * - Manages data synchronization with camera data
65 *
66 * @param ch Channel number (unused)
67 * @param data Pointer to IMU data buffer
68 * @param bytes Size of data buffer in bytes
69 * @param context Context pointer (unused)
70 */
71void _imu_data_handler_cb(__attribute__((unused)) int ch,
72 char *data, int bytes,
73 __attribute__((unused)) void *context);
74
75// ============================================================================
76// SERVICE MANAGEMENT
77// ============================================================================
78
79/**
80 * @brief Creates IMU pipe client and associated callbacks
81 *
82 * This function sets up the disconnect and data handler callbacks,
83 * and opens the client pipe connection to the IMU service. It initializes
84 * the complete IMU data pipeline for the VIO system.
85 *
86 * The function performs the following operations:
87 * - Sets up disconnect callback for graceful handling of service disconnection
88 * - Sets up data handler callback for processing incoming IMU measurements
89 * - Opens the client pipe connection to the IMU service
90 * - Configures the pipe for optimal data flow
91 *
92 * @return 0 on success, non-zero on failure
93 */
94int connect_imu_service(void);
95
96#endif // IMU_MODULE_H
void _imu_disconnect_cb(__attribute__((unused)) int ch, __attribute__((unused)) void *context)
Callback for IMU disconnect events.
void _imu_data_handler_cb(__attribute__((unused)) int ch, char *data, int bytes, __attribute__((unused)) void *context)
Handler for incoming IMU data.
int connect_imu_service(void)
Creates IMU pipe client and associated callbacks.
std::mutex imu_lock_mutex
Mutex for IMU data access synchronization.
Common definitions and utilities for the VOXL OpenVINS server.
Housekeeping and data publishing for VOXL OpenVINS.
Global variable declarations and constants for VOXL OpenVINS server.