#include <chrono>
#include <thread>
#include <spdlog/spdlog.h>
{
spdlog::info(
"IMU Update - Yaw: {:.2f}, Pitch: {:.2f}, Roll: {:.2f}", data.
ypr.
yaw, data.
ypr.
pitch, data.
ypr.
roll);
}
{
}
int main()
{
spdlog::set_level(spdlog::level::info);
spdlog::flush_on(spdlog::level::trace);
spdlog::error("Doly service stop failed");
return -1;
}
if (res < 0)
{
spdlog::error("Read settings failed with code: {}", res);
return -2;
}
int16_t gx, gy, gz, ax, ay, az;
if (res < 0)
{
spdlog::error("Get IMU offsets failed with code: {}", res);
return -3;
}
{
spdlog::error("ImuControl init failed");
return -2;
}
std::this_thread::sleep_for(std::chrono::seconds(30));
return 0;
}
Shared helper utilities and common types used across the Doly SDK.
Public API for Doly IMU (Inertial Measurement Unit) control.
GestureDirection
Direction associated with a detected gesture (where the motion came from).
Definition ImuEventListener.h:56
ImuGesture
High-level gesture types detected from IMU motion analysis.
Definition ImuEventListener.h:29
int8_t stopDolyService()
Stop the background Doly service (if running).
int8_t readSettings()
Read default settings from the platform settings file.
int8_t getImuOffsets(int16_t &gx, int16_t &gy, int16_t &gz, int16_t &ax, int16_t &ay, int16_t &az)
Retrieve IMU calibration offsets (gyro/accel).
int8_t dispose()
Dispose/stop the IMU subsystem and release resources.
float getVersion()
Get current library version.
int8_t init(uint8_t delay=0, int16_t gx=0, int16_t gy=0, int16_t gz=0, int16_t ax=0, int16_t ay=0, int16_t az=0)
Initialize the IMU subsystem.
void RemoveListenerUpdateEvent(void(*Imu_callback)(ImuData data))
Unregister a previously registered IMU update callback.
std::string getGestureStr(ImuGesture type)
Convert a gesture enum value to a human-readable string.
void RemoveListenerGestureEvent(void(*gesture_cb)(ImuGesture type, GestureDirection from))
Unregister a previously registered gesture callback.
void AddListenerUpdateEvent(void(*Imu_callback)(ImuData data))
Register a static/free function to receive IMU update events.
void AddListenerGestureEvent(void(*gesture_cb)(ImuGesture type, GestureDirection from))
Register a static/free function to receive gesture events.
std::string getDirectionStr(GestureDirection from)
Convert a direction enum value to a human-readable string.
Latest IMU reading snapshot returned by the IMU subsystem.
Definition ImuEventListener.h:91
YawPitchRoll ypr
Definition ImuEventListener.h:93
float yaw
Definition ImuEventListener.h:80
float pitch
Definition ImuEventListener.h:81
float roll
Definition ImuEventListener.h:82