mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-20 21:43:12 -07:00
Add Orientation Tracker
This commit is contained in:
parent
88c03aa744
commit
32e1539c22
6 changed files with 182 additions and 8 deletions
43
lib/include/chiaki/orientation.h
Normal file
43
lib/include/chiaki/orientation.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
// SPDX-License-Identifier: LicenseRef-AGPL-3.0-only-OpenSSL
|
||||
|
||||
#ifndef CHIAKI_ORIENTATION_H
|
||||
#define CHIAKI_ORIENTATION_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Quaternion orientation from accelerometer and gyroscope
|
||||
* using Madgwick's algorithm.
|
||||
* See: http://www.x-io.co.uk/node/8#open_source_ahrs_and_imu_algorithms
|
||||
*/
|
||||
typedef struct chiaki_orientation_t
|
||||
{
|
||||
float x, y, z, w;
|
||||
} ChiakiOrientation;
|
||||
|
||||
CHIAKI_EXPORT void chiaki_orientation_init(ChiakiOrientation *orient);
|
||||
CHIAKI_EXPORT void chiaki_orientation_update(ChiakiOrientation *orient, float gx, float gy, float gz, float ax, float ay, float az, float time_step_sec);
|
||||
|
||||
/**
|
||||
* Extension of ChiakiOrientation, also tracking an absolute timestamp
|
||||
*/
|
||||
typedef struct chiaki_orientation_tracker_t
|
||||
{
|
||||
ChiakiOrientation orient;
|
||||
uint32_t timestamp;
|
||||
bool first_sample;
|
||||
} ChiakiOrientationTracker;
|
||||
|
||||
CHIAKI_EXPORT void chiaki_orientation_tracker_init(ChiakiOrientationTracker *tracker);
|
||||
CHIAKI_EXPORT void chiaki_orientation_tracker_update(ChiakiOrientationTracker *tracker,
|
||||
float gx, float gy, float gz, float ax, float ay, float az, uint32_t timestamp_us);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CHIAKI_ORIENTATION_H
|
Loading…
Add table
Add a link
Reference in a new issue