RaidZeroLib
Coroutine robot framework for VEX V5
Loading...
Searching...
No Matches
InertialSensor.hpp
1#pragma once
2#include "RaidZeroLib/api/Geometry/Rotation.hpp"
3#include "RaidZeroLib/api/Hardware/Device.hpp"
4#include "RaidZeroLib/api/Hardware/Sensor.hpp"
5#include "RaidZeroLib/api/Units/Units.hpp"
6
7namespace rz {
8
17class InertialSensor final : public Device, public Sensor<Rotation> {
18 public:
19 explicit InertialSensor(std::uint8_t port);
20
21 [[nodiscard]] bool connected() const override;
22 [[nodiscard]] bool calibrating() const;
23
24 protected:
25 [[nodiscard]] Rotation raw() const override;
26 [[nodiscard]] std::uint32_t epoch() const override { return deviceEpoch(); }
27
28 private:
29 bool poll() override;
30 void onConnect() override;
31
32 Angle heading{};
33 bool isCalibrating = false;
34};
35
36} // namespace rz
virtual void onConnect()
Applies configuration. Called when the device first connects and after every reconnect.
Definition Device.hpp:40
std::uint8_t port() const noexcept
Definition Device.hpp:20
std::uint32_t deviceEpoch() const noexcept
Increments on every (re)connection.
Definition Device.hpp:26
Device(std::uint8_t port, std::string_view kind)
virtual bool poll()=0
Reads the hardware into cached members. Returns false if the read failed (keep old values).
Rotation raw() const override
This tick's reading from the source; the last good value while disconnected. May restart after a reco...
InertialSensor(std::uint8_t port)
bool calibrating() const
bool connected() const override
std::uint32_t epoch() const override
Increments every time the source reconnects. Readings across a reconnect are not comparable.
Definition InertialSensor.hpp:26
Immutable planar rotation about the Z axis.
Definition Rotation.hpp:16
au::QuantityD< au::Radians > Angle
Definition Units.hpp:13
Definition DriverControl.hpp:11