LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
asyncPosControllerBuilder.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
17
18namespace okapi {
20 public:
28 const std::shared_ptr<Logger> &ilogger = Logger::getDefaultLogger());
29
37
45
52 AsyncPosControllerBuilder &withMotor(const std::shared_ptr<AbstractMotor> &imotor);
53
61
69
76 AsyncPosControllerBuilder &withSensor(const std::shared_ptr<RotarySensor> &isensor);
77
86
95 AsyncPosControllerBuilder &withDerivativeFilter(std::unique_ptr<Filter> iderivativeFilter);
96
104
113
122
129 AsyncPosControllerBuilder &withLogger(const std::shared_ptr<Logger> &ilogger);
130
142
155
161 std::shared_ptr<AsyncPositionController<double, double>> build();
162
163 private:
164 std::shared_ptr<Logger> logger;
165
166 bool hasMotors{false}; // Used to verify motors were passed
167 std::shared_ptr<AbstractMotor> motor;
168
169 bool sensorsSetByUser{false}; // Used so motors don't overwrite sensors set manually
170 std::shared_ptr<RotarySensor> sensor;
171
172 bool hasGains{false}; // Whether gains were passed, no gains means integrated control
173 IterativePosPIDController::Gains gains;
174 std::unique_ptr<Filter> derivativeFilter = std::make_unique<PassthroughFilter>();
175
176 bool gearsetSetByUser{false}; // Used so motor's don't overwrite a gearset set manually
177 AbstractMotor::GearsetRatioPair pair{AbstractMotor::gearset::invalid};
178
179 bool maxVelSetByUser{false}; // Used so motors don't overwrite maxVelocity
180 double maxVelocity{600};
181
182 TimeUtilFactory timeUtilFactory = TimeUtilFactory();
183 std::shared_ptr<Logger> controllerLogger = Logger::getDefaultLogger();
184
185 bool isParentedToCurrentTask{true};
186
187 std::shared_ptr<AsyncPosIntegratedController> buildAPIC();
188 std::shared_ptr<AsyncPosPIDController> buildAPPC();
189};
190} // namespace okapi
std::shared_ptr< AsyncPositionController< double, double > > build()
Builds the AsyncPositionController.
AsyncPosControllerBuilder & withSensor(const std::shared_ptr< RotarySensor > &isensor)
Sets the sensor.
AsyncPosControllerBuilder & withGains(const IterativePosPIDController::Gains &igains)
Sets the controller gains, causing the builder to generate an AsyncPosPIDController.
AsyncPosControllerBuilder & withDerivativeFilter(std::unique_ptr< Filter > iderivativeFilter)
Sets the derivative filter which filters the derivative term before it is scaled by kD.
AsyncPosControllerBuilder & withGearset(const AbstractMotor::GearsetRatioPair &igearset)
Sets the gearset.
AsyncPosControllerBuilder & withMotor(const std::shared_ptr< AbstractMotor > &imotor)
Sets the motor.
AsyncPosControllerBuilder & notParentedToCurrentTask()
Prevents parenting the internal tasks started by this builder to the current task,...
AsyncPosControllerBuilder & withMotor(const MotorGroup &imotor)
Sets the motor.
AsyncPosControllerBuilder & withSensor(const ADIEncoder &isensor)
Sets the sensor.
AsyncPosControllerBuilder(const std::shared_ptr< Logger > &ilogger=Logger::getDefaultLogger())
A builder that creates async position controllers.
AsyncPosControllerBuilder & withLogger(const std::shared_ptr< Logger > &ilogger)
Sets the logger.
AsyncPosControllerBuilder & withSensor(const IntegratedEncoder &isensor)
Sets the sensor.
AsyncPosControllerBuilder & withMaxVelocity(double imaxVelocity)
Sets the maximum velocity.
AsyncPosControllerBuilder & parentedToCurrentTask()
Parents the internal tasks started by this builder to the current task, meaning they will be deleted ...
AsyncPosControllerBuilder & withTimeUtilFactory(const TimeUtilFactory &itimeUtilFactory)
Sets the TimeUtilFactory used when building the controller.
AsyncPosControllerBuilder & withMotor(const Motor &imotor)
Sets the motor.
static std::shared_ptr< Logger > getDefaultLogger()
A simple structure representing the full ratio between motor and wheel.