fwt_software/include/fgc/IImuSource.h

32 lines
934 B
C++

#pragma once
#include "fgc/MtiProtocol.h" // ImuSample
#include <optional>
namespace fgc {
// Abstraction over the orientation/inertial sensor (Xsens MTi). Implemented by
// MtiImuSource (RS-232/UART binary stream) and MockImuSource (synthetic). Runs
// on its own thread; start() must not block the control loop.
class IImuSource {
public:
virtual ~IImuSource() = default;
virtual void start() = 0;
virtual void stop() = 0;
// Whether a valid, recent reading is available.
virtual bool connected() const = 0;
// Latest reading, or nullopt if none/stale.
virtual std::optional<ImuSample> sample() = 0;
// Device configuration read back during start-up (output mode/settings,
// sample rate, identity, XKF scenario). nullopt if not yet known or the
// backend cannot report it.
virtual std::optional<ImuDeviceConfig> config() const { return std::nullopt; }
};
} // namespace fgc