LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
twoEncoderOdometry.hpp
Go to the documentation of this file.
1/*
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 */
6#pragma once
7
13#include <atomic>
14#include <memory>
15#include <valarray>
16
17namespace okapi {
19 public:
29 TwoEncoderOdometry(const TimeUtil &itimeUtil,
30 const std::shared_ptr<ReadOnlyChassisModel> &imodel,
31 const ChassisScales &ichassisScales,
32 const std::shared_ptr<Logger> &ilogger = Logger::getDefaultLogger());
33
34 virtual ~TwoEncoderOdometry() = default;
35
39 void setScales(const ChassisScales &ichassisScales) override;
40
44 void step() override;
45
53
60 void setState(const OdomState &istate,
61 const StateMode &imode = StateMode::FRAME_TRANSFORMATION) override;
62
66 std::shared_ptr<ReadOnlyChassisModel> getModel() override;
67
72
73 protected:
74 std::shared_ptr<Logger> logger;
75 std::unique_ptr<AbstractRate> rate;
76 std::unique_ptr<AbstractTimer> timer;
77 std::shared_ptr<ReadOnlyChassisModel> model;
80 std::valarray<std::int32_t> newTicks{0, 0, 0}, tickDiff{0, 0, 0}, lastTicks{0, 0, 0};
81 const std::int32_t maximumTickDiff{1000};
82
90 virtual OdomState odomMathStep(const std::valarray<std::int32_t> &itickDiff,
91 const QTime &ideltaT);
92};
93} // namespace okapi
static std::shared_ptr< Logger > getDefaultLogger()
Utility class for holding an AbstractTimer, AbstractRate, and SettledUtil together in one class since...
Definition timeUtil.hpp:18
void step() override
Do one odometry step.
void setScales(const ChassisScales &ichassisScales) override
Sets the drive and turn scales.
std::valarray< std::int32_t > lastTicks
ChassisScales getScales() override
virtual ~TwoEncoderOdometry()=default
std::valarray< std::int32_t > newTicks
OdomState getState(const StateMode &imode=StateMode::FRAME_TRANSFORMATION) const override
Returns the current state.
std::shared_ptr< ReadOnlyChassisModel > getModel() override
std::shared_ptr< Logger > logger
virtual OdomState odomMathStep(const std::valarray< std::int32_t > &itickDiff, const QTime &ideltaT)
Does the math, side-effect free, for one odom step.
TwoEncoderOdometry(const TimeUtil &itimeUtil, const std::shared_ptr< ReadOnlyChassisModel > &imodel, const ChassisScales &ichassisScales, const std::shared_ptr< Logger > &ilogger=Logger::getDefaultLogger())
TwoEncoderOdometry.
std::unique_ptr< AbstractRate > rate
const std::int32_t maximumTickDiff
std::unique_ptr< AbstractTimer > timer
std::valarray< std::int32_t > tickDiff
void setState(const OdomState &istate, const StateMode &imode=StateMode::FRAME_TRANSFORMATION) override
Sets a new state to be the current state.
std::shared_ptr< ReadOnlyChassisModel > model
StateMode
The mode for the OdomState calculated by Odometry.
Definition stateMode.hpp:12
@ FRAME_TRANSFORMATION
+x is forward, +y is right, 0 degrees is along +x