LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
asyncPosIntegratedController.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
12
13namespace okapi {
19 public:
31 AsyncPosIntegratedController(const std::shared_ptr<AbstractMotor> &imotor,
33 std::int32_t imaxVelocity,
34 const TimeUtil &itimeUtil,
35 const std::shared_ptr<Logger> &ilogger = Logger::getDefaultLogger());
36
40 void setTarget(double itarget) override;
41
47 double getTarget() override;
48
52 double getProcessValue() const override;
53
57 double getError() const override;
58
67 bool isSettled() override;
68
73 void reset() override;
74
79 void flipDisable() override;
80
87 void flipDisable(bool iisDisabled) override;
88
94 bool isDisabled() const override;
95
100 void waitUntilSettled() override;
101
108 void controllerSet(double ivalue) override;
109
113 void tarePosition() override;
114
120 void setMaxVelocity(std::int32_t imaxVelocity) override;
121
125 virtual void stop();
126
127 protected:
128 std::shared_ptr<Logger> logger;
130 std::shared_ptr<AbstractMotor> motor;
132 std::int32_t maxVelocity;
133 double lastTarget{0};
134 double offset{0};
136 bool hasFirstTarget{false};
137 std::unique_ptr<SettledUtil> settledUtil;
138
143 virtual void resumeMovement();
144};
145} // namespace okapi
Closed-loop controller that uses the V5 motor's onboard control to move.
virtual void stop()
Stops the motor mid-movement.
virtual void resumeMovement()
Resumes moving after the controller is reset.
bool isSettled() override
Returns whether the controller has settled at the target.
void reset() override
Resets the controller's internal state so it is similar to when it was first initialized,...
void tarePosition() override
Sets the "absolute" zero position of the controller to its current position.
AsyncPosIntegratedController(const std::shared_ptr< AbstractMotor > &imotor, const AbstractMotor::GearsetRatioPair &ipair, std::int32_t imaxVelocity, const TimeUtil &itimeUtil, const std::shared_ptr< Logger > &ilogger=Logger::getDefaultLogger())
Closed-loop controller that uses the V5 motor's onboard control to move.
void flipDisable(bool iisDisabled) override
Sets whether the controller is off or on.
double getProcessValue() const override
double getError() const override
Returns the last error of the controller.
void setMaxVelocity(std::int32_t imaxVelocity) override
Sets a new maximum velocity in motor RPM [0-600].
bool isDisabled() const override
Returns whether the controller is currently disabled.
double getTarget() override
Gets the last set target, or the default target if none was set.
void flipDisable() override
Changes whether the controller is off or on.
void waitUntilSettled() override
Blocks the current task until the controller has settled.
void controllerSet(double ivalue) override
Writes the value of the controller output.
void setTarget(double itarget) override
Sets the target for the controller.
static std::shared_ptr< Logger > getDefaultLogger()
Utility class for holding an AbstractTimer, AbstractRate, and SettledUtil together in one class since...
Definition timeUtil.hpp:18
A simple structure representing the full ratio between motor and wheel.