Instrument Neutral Distributed Interface INDI 2.2.5
indiimuinterface.h
Go to the documentation of this file.
1/*
2 IMU Interface
3 Copyright (C) 2025 Jasem Mutlaq ([email protected])
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
19*/
20
21#pragma once
22
23#include "indibase.h"
24#include "indipropertynumber.h"
25#include "indipropertyswitch.h"
26#include "indipropertytext.h"
27#include "indipropertylight.h"
28#include <stdint.h>
29#include <string>
30#include <vector>
31
32namespace INDI
33{
34
36{
37 public:
53
62
70
78
86
95
104
112
121
128
135
141
149
157
163
170
174 uint32_t GetCapability() const
175 {
176 return imuCapability;
177 }
178
183 void SetCapability(uint32_t cap)
184 {
185 imuCapability = cap;
186 }
187
189 {
190 return imuCapability & IMU_HAS_ORIENTATION;
191 }
193 {
194 return imuCapability & IMU_HAS_ACCELERATION;
195 }
197 {
198 return imuCapability & IMU_HAS_GYROSCOPE;
199 }
201 {
202 return imuCapability & IMU_HAS_MAGNETOMETER;
203 }
205 {
206 return imuCapability & IMU_HAS_CALIBRATION;
207 }
209 {
210 return imuCapability & IMU_HAS_TEMPERATURE;
211 }
213 {
214 return imuCapability & IMU_HAS_STABILITY_MON;
215 }
216
217 protected:
218 explicit IMUInterface(DefaultDevice *defaultDevice);
219 virtual ~IMUInterface() = default;
220
226 void initProperties(const std::string &groupName);
227
232 bool updateProperties();
233
235 bool processNumber(const std::string &dev, const std::string &name, double values[], char *names[], int n);
236
238 bool processSwitch(const std::string &dev, const std::string &name, ISState *states, char *names[], int n);
239
241 bool processText(const std::string &dev, const std::string &name, char *texts[], char *names[], int n);
242
248 bool saveConfigItems(FILE *fp);
249
258 virtual bool SetOrientationData(double roll, double pitch, double yaw, double w = 0.0);
259
267 virtual bool SetAccelerationData(double x, double y, double z);
268
276 virtual bool SetGyroscopeData(double x, double y, double z);
277
285 virtual bool SetMagnetometerData(double x, double y, double z);
286
295 virtual bool SetCalibrationStatus(int sys, int gyro, int accel, int mag);
296
301 virtual bool StartCalibration();
302
307 virtual bool SaveCalibrationData();
308
313 virtual bool LoadCalibrationData();
314
319 virtual bool ResetCalibration();
320
326 virtual bool SetPowerMode(const std::string &mode);
327
333 virtual bool SetOperationMode(const std::string &mode);
334
340 virtual bool SetDistanceUnits(bool metric);
341
347 virtual bool SetAngularUnits(bool degrees);
348
354 virtual bool SetUpdateRate(double rate);
355
363 virtual bool SetDeviceInfo(const std::string &chipID, const std::string &firmwareVersion, const std::string &sensorStatus);
364
370 virtual bool SetTemperature(double temperature);
371
378 virtual bool SetStabilityMonitoring(double vibrationLevel, double stabilityThreshold);
379
380 // Core Sensor Data Properties
385
386 // Calibration Properties
389
390 // Configuration Properties
396 INDI::PropertyNumber DataThresholdNP {1}; // Data change threshold
397
398 // Status and Info Properties
399 INDI::PropertyText DeviceInfoTP {DEVICE_INFO_PROPERTY_COUNT}; // Chip ID, firmware version, sensor status
401
402 // Astronomical-Specific Properties (moved to driver level)
404
405 private:
406 uint32_t imuCapability = 0;
407 DefaultDevice *m_defaultDevice { nullptr };
408
409 protected:
410 const std::string IMU_TAB {"IMU"};
411 const std::string CALIBRATION_TAB {"Calibration"};
412 const std::string STATUS_TAB {"Status"};
413 const std::string COORDINATES_TAB {"Coordinates"};
414};
415
416}
double temperature
Class to provide extended functionality for devices in addition to the functionality provided by INDI...
virtual bool ResetCalibration()
ResetCalibration Reset calibration data.
bool processSwitch(const std::string &dev, const std::string &name, ISState *states, char *names[], int n)
Process IMU switch properties.
virtual bool SetOrientationData(double roll, double pitch, double yaw, double w=0.0)
SetOrientationData Set the orientation data (Roll, Pitch, Yaw, Quaternion W)
const std::string IMU_TAB
virtual bool SetStabilityMonitoring(double vibrationLevel, double stabilityThreshold)
SetStabilityMonitoring Set vibration level and alert threshold.
virtual bool SaveCalibrationData()
SaveCalibrationData Save the current calibration data.
INDI::PropertyNumber TemperatureNP
bool saveConfigItems(FILE *fp)
saveConfigItems Save IMU properties in config file
virtual bool SetGyroscopeData(double x, double y, double z)
SetGyroscopeData Set the angular velocity data.
bool processText(const std::string &dev, const std::string &name, char *texts[], char *names[], int n)
Process IMU text properties.
INDI::PropertyNumber OrientationNP
INDI::PropertySwitch AngularUnitsSP
virtual bool SetAccelerationData(double x, double y, double z)
SetAccelerationData Set the linear acceleration data.
INDI::PropertyNumber StabilityMonitoringNP
uint32_t GetCapability() const
GetIMUCapability returns the capability of the IMU device.
virtual bool LoadCalibrationData()
LoadCalibrationData Load previously saved calibration data.
virtual bool SetAngularUnits(bool degrees)
SetAngularUnits Set the angular units for sensor data.
INDI::PropertyNumber UpdateRateNP
virtual bool SetTemperature(double temperature)
SetTemperature Set the internal chip temperature.
virtual bool SetMagnetometerData(double x, double y, double z)
SetMagnetometerData Set the magnetic field strength data.
INDI::PropertyText DeviceInfoTP
INDI::PropertyNumber AccelerationNP
INDI::PropertySwitch CalibrationControlSP
INDI::PropertyLight CalibrationStatusLP
virtual bool StartCalibration()
StartCalibration Initiate the calibration sequence.
virtual bool SetDeviceInfo(const std::string &chipID, const std::string &firmwareVersion, const std::string &sensorStatus)
SetDeviceInfo Set chip ID, firmware version, and sensor status.
INDI::PropertyNumber GyroscopeNP
const std::string COORDINATES_TAB
virtual bool SetCalibrationStatus(int sys, int gyro, int accel, int mag)
SetCalibrationStatus Set the calibration status for each sensor.
virtual bool SetDistanceUnits(bool metric)
SetUnits Set the units for sensor data.
bool updateProperties()
updateProperties Define or Delete IMU properties based on the connection status of the base device
bool processNumber(const std::string &dev, const std::string &name, double values[], char *names[], int n)
Process IMU number properties.
virtual bool SetPowerMode(const std::string &mode)
SetPowerMode Set the power mode of the IMU sensor.
virtual ~IMUInterface()=default
virtual bool SetUpdateRate(double rate)
SetUpdateRate Set the sensor polling frequency.
const std::string STATUS_TAB
INDI::PropertyNumber DataThresholdNP
INDI::PropertyNumber MagnetometerNP
INDI::PropertySwitch OperationModeSP
INDI::PropertySwitch DistanceUnitsSP
INDI::PropertySwitch PowerModeSP
void SetCapability(uint32_t cap)
SetIMUCapability sets the IMU capabilities. All capabilities must be initialized.
const std::string CALIBRATION_TAB
void initProperties(const std::string &groupName)
Initialize IMU properties. It is recommended to call this function within initProperties() of your pr...
virtual bool SetOperationMode(const std::string &mode)
SetOperationMode Set the operation mode of the IMU sensor.
ISState
Switch state.
Definition indiapi.h:148
Namespace to encapsulate INDI client, drivers, and mediator classes.
Holds the capabilities of an IMU device.