Fang-Robotics-MCB
Fang Robotics Team Codebase
Loading...
Searching...
No Matches
wrapped_encoder.hpp
Go to the documentation of this file.
1/*****************************************************************************/
2/********** !!! WARNING: CODE GENERATED BY TAPROOT. DO NOT EDIT !!! **********/
3/*****************************************************************************/
4
5/*
6 * Copyright (c) 2025 Advanced Robotics at the University of Washington <robomstr@uw.edu>
7 *
8 * This file is part of Taproot.
9 *
10 * Taproot is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * Taproot is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with Taproot. If not, see <https://www.gnu.org/licenses/>.
22 */
23
24#ifndef TAPROOT_WRAPPED_ENCODER_HPP_
25#define TAPROOT_WRAPPED_ENCODER_HPP_
26
28#include "tap/util_macros.hpp"
29
30namespace tap::encoder
31{
36{
37public:
47 bool isInverted,
48 uint32_t encoderResolution,
49 float gearRatio = 1,
50 uint32_t encoderHomePosition = 0);
51
52 void initialize() override{};
53
55
60
61 float getVelocity() const override;
62
63 void alignWith(EncoderInterface* other) override;
64
65 void resetEncoderValue() override;
66
68
69#if defined(PLATFORM_HOSTED) && defined(ENV_UNIT_TESTS)
70 bool isOnline() const override { return true; }
71#else
72protected:
73#endif
74
79 void updateEncoderValue(uint32_t encoderActual);
80
85
90
92
93 const uint32_t encoderResolution;
94
95 const float gearRatio;
96
97private:
102 tap::algorithms::WrappedFloat encoderHomePosition;
103
108
112 uint64_t lastUpdateTime;
113
114 uint64_t deltaTime;
115};
116
117} // namespace tap::encoder
118
119#endif // TAPROOT_WRAPPED_ENCODER_HPP_
Definition wrapped_float.hpp:51
Definition encoder_interface.hpp:32
virtual bool isOnline() const =0
Definition wrapped_encoder.hpp:36
tap::algorithms::WrappedFloat getPosition() const override
Definition wrapped_encoder.cpp:58
bool inverted
Definition wrapped_encoder.hpp:91
const float gearRatio
Definition wrapped_encoder.hpp:95
mockable tap::algorithms::WrappedFloat getEncoder() const
Definition wrapped_encoder.hpp:59
const uint32_t encoderResolution
Definition wrapped_encoder.hpp:93
void alignWith(EncoderInterface *other) override
Definition wrapped_encoder.cpp:79
tap::algorithms::WrappedFloat encoder
Definition wrapped_encoder.hpp:84
void updateEncoderValue(uint32_t encoderActual)
Definition wrapped_encoder.cpp:90
tap::algorithms::WrappedFloat position
Definition wrapped_encoder.hpp:89
void initialize() override
Definition wrapped_encoder.hpp:52
float getVelocity() const override
Definition wrapped_encoder.cpp:69
void resetEncoderValue() override
Definition wrapped_encoder.cpp:50
Definition encoder_interface.hpp:30
#define mockable
Wrap class functions that are not already virtual in this function if you wish to mock them.
Definition util_macros.hpp:38
#define DISALLOW_COPY_AND_ASSIGN(Typename)
Definition util_macros.hpp:27