RaidZeroLib
Coroutine robot framework for VEX V5
Toggle main menu visibility
Loading...
Searching...
No Matches
RotationSensor.hpp
1
#pragma once
2
#include "RaidZeroLib/api/Hardware/Device.hpp"
3
#include "RaidZeroLib/api/Hardware/Direction.hpp"
4
#include "RaidZeroLib/api/Hardware/Sensor.hpp"
5
#include "RaidZeroLib/api/Units/Units.hpp"
6
7
namespace
rz
{
8
10
class
RotationSensor
final :
public
Device
,
public
Sensor
<Angle> {
11
public
:
12
struct
Config
{
14
Direction
positive
=
Direction::Counterclockwise
;
15
};
16
17
explicit
RotationSensor
(std::uint8_t
port
) :
RotationSensor
(
port
,
Config
{}) {}
18
RotationSensor
(std::uint8_t
port
,
Config
config);
19
20
[[nodiscard]]
bool
connected
()
const override
{
return
deviceConnected
(); }
21
22
protected
:
23
[[nodiscard]]
Angle
raw
()
const override
;
24
[[nodiscard]] std::uint32_t
epoch
()
const override
{
return
deviceEpoch
(); }
25
26
private
:
27
bool
poll
()
override
;
28
29
Config config;
30
Angle
position{};
31
};
32
33
}
// namespace rz
rz::Device::deviceConnected
bool deviceConnected() const noexcept
Whether this tick's read succeeded.
Definition
Device.hpp:23
rz::Device::port
std::uint8_t port() const noexcept
Definition
Device.hpp:20
rz::Device::deviceEpoch
std::uint32_t deviceEpoch() const noexcept
Increments on every (re)connection.
Definition
Device.hpp:26
rz::Device::Device
Device(std::uint8_t port, std::string_view kind)
rz::Device::poll
virtual bool poll()=0
Reads the hardware into cached members. Returns false if the read failed (keep old values).
rz::RotationSensor::connected
bool connected() const override
Definition
RotationSensor.hpp:20
rz::RotationSensor::RotationSensor
RotationSensor(std::uint8_t port)
Definition
RotationSensor.hpp:17
rz::RotationSensor::RotationSensor
RotationSensor(std::uint8_t port, Config config)
rz::RotationSensor::epoch
std::uint32_t epoch() const override
Increments every time the source reconnects. Readings across a reconnect are not comparable.
Definition
RotationSensor.hpp:24
rz::RotationSensor::raw
Angle raw() const override
This tick's reading from the source; the last good value while disconnected. May restart after a reco...
rz::Sensor< Angle >::Sensor
Sensor()=default
rz::Direction
Direction
A way a shaft can turn, seen looking at the face the shaft comes out of.
Definition
Direction.hpp:6
rz::Direction::Counterclockwise
@ Counterclockwise
Definition
Direction.hpp:8
rz::Angle
au::QuantityD< au::Radians > Angle
Definition
Units.hpp:13
rz
Definition
DriverControl.hpp:11
rz::RotationSensor::Config
Definition
RotationSensor.hpp:12
rz::RotationSensor::Config::positive
Direction positive
The way the shaft turns, looking at the sensor's front face, for the angle to count up.
Definition
RotationSensor.hpp:14
RaidZeroLib
impl
Pros
Hardware
RotationSensor.hpp
Generated by
1.18.0