class
AsyncPosControllerBuilder
Contents
Constructors, destructors, conversion operators
-
AsyncPosControllerBuilder(const std::shared_ptr<Logger>& ilogger = Logger::
getDefaultLogger()) explicit - A builder that creates async position controllers.
Public functions
- auto withMotor(const Motor& imotor) -> AsyncPosControllerBuilder&
- Sets the motor.
- auto withMotor(const MotorGroup& imotor) -> AsyncPosControllerBuilder&
- Sets the motor.
- auto withMotor(const std::shared_ptr<AbstractMotor>& imotor) -> AsyncPosControllerBuilder&
- Sets the motor.
- auto withSensor(const ADIEncoder& isensor) -> AsyncPosControllerBuilder&
- Sets the sensor.
- auto withSensor(const IntegratedEncoder& isensor) -> AsyncPosControllerBuilder&
- Sets the sensor.
- auto withSensor(const std::shared_ptr<RotarySensor>& isensor) -> AsyncPosControllerBuilder&
- Sets the sensor.
-
auto withGains(const IterativePosPIDController::
Gains& igains) -> AsyncPosControllerBuilder& - Sets the controller gains, causing the builder to generate an AsyncPosPIDController.
- auto withDerivativeFilter(std::unique_ptr<Filter> iderivativeFilter) -> AsyncPosControllerBuilder&
- Sets the derivative filter which filters the derivative term before it is scaled by kD.
-
auto withGearset(const AbstractMotor::
GearsetRatioPair& igearset) -> AsyncPosControllerBuilder& - Sets the gearset.
- auto withMaxVelocity(double imaxVelocity) -> AsyncPosControllerBuilder&
- Sets the maximum velocity.
- auto withTimeUtilFactory(const TimeUtilFactory& itimeUtilFactory) -> AsyncPosControllerBuilder&
- Sets the TimeUtilFactory used when building the controller.
- auto withLogger(const std::shared_ptr<Logger>& ilogger) -> AsyncPosControllerBuilder&
- Sets the logger.
- auto parentedToCurrentTask() -> AsyncPosControllerBuilder&
- Parents the internal tasks started by this builder to the current task, meaning they will be deleted once the current task is deleted.
- auto notParentedToCurrentTask() -> AsyncPosControllerBuilder&
- Prevents parenting the internal tasks started by this builder to the current task, meaning they will not be deleted once the current task is deleted.
- auto build() -> std::shared_ptr<AsyncPositionController<double, double>>
- Builds the AsyncPositionController.
Function documentation
okapi:: AsyncPosControllerBuilder:: AsyncPosControllerBuilder(const std::shared_ptr<Logger>& ilogger = Logger:: getDefaultLogger()) explicit
A builder that creates async position controllers.
Parameters | |
---|---|
ilogger | The logger this instance will log to. |
Use this to create an AsyncPosIntegratedController or an AsyncPosPIDController.
AsyncPosControllerBuilder& okapi:: AsyncPosControllerBuilder:: withMotor(const Motor& imotor)
Sets the motor.
Parameters | |
---|---|
imotor | The motor. |
Returns | An ongoing builder. |
AsyncPosControllerBuilder& okapi:: AsyncPosControllerBuilder:: withMotor(const MotorGroup& imotor)
Sets the motor.
Parameters | |
---|---|
imotor | The motor. |
Returns | An ongoing builder. |
AsyncPosControllerBuilder& okapi:: AsyncPosControllerBuilder:: withMotor(const std::shared_ptr<AbstractMotor>& imotor)
Sets the motor.
Parameters | |
---|---|
imotor | The motor. |
Returns | An ongoing builder. |
AsyncPosControllerBuilder& okapi:: AsyncPosControllerBuilder:: withSensor(const ADIEncoder& isensor)
Sets the sensor.
Parameters | |
---|---|
isensor | The sensor. |
Returns | An ongoing builder. |
The default sensor is the motor's integrated encoder.
AsyncPosControllerBuilder& okapi:: AsyncPosControllerBuilder:: withSensor(const IntegratedEncoder& isensor)
Sets the sensor.
Parameters | |
---|---|
isensor | The sensor. |
Returns | An ongoing builder. |
The default sensor is the motor's integrated encoder.
AsyncPosControllerBuilder& okapi:: AsyncPosControllerBuilder:: withSensor(const std::shared_ptr<RotarySensor>& isensor)
Sets the sensor.
Parameters | |
---|---|
isensor | The sensor. |
Returns | An ongoing builder. |
The default sensor is the motor's integrated encoder.
AsyncPosControllerBuilder& okapi:: AsyncPosControllerBuilder:: withGains(const IterativePosPIDController:: Gains& igains)
Sets the controller gains, causing the builder to generate an AsyncPosPIDController.
Parameters | |
---|---|
igains | The gains. |
Returns | An ongoing builder. |
This does not set the integrated control's gains.
AsyncPosControllerBuilder& okapi:: AsyncPosControllerBuilder:: withDerivativeFilter(std::unique_ptr<Filter> iderivativeFilter)
Sets the derivative filter which filters the derivative term before it is scaled by kD.
Parameters | |
---|---|
iderivativeFilter | The derivative filter. |
Returns | An ongoing builder. |
The filter is ignored when using integrated control. The default derivative filter is a PassthroughFilter.
AsyncPosControllerBuilder& okapi:: AsyncPosControllerBuilder:: withGearset(const AbstractMotor:: GearsetRatioPair& igearset)
Sets the gearset.
Parameters | |
---|---|
igearset | The gearset. |
Returns | An ongoing builder. |
The default gearset is derived from the motor's.
AsyncPosControllerBuilder& okapi:: AsyncPosControllerBuilder:: withMaxVelocity(double imaxVelocity)
Sets the maximum velocity.
Parameters | |
---|---|
imaxVelocity | The maximum velocity. |
Returns | An ongoing builder. |
The default maximum velocity is derived from the motor's gearset. This parameter is ignored when using an AsyncPosPIDController.
AsyncPosControllerBuilder& okapi:: AsyncPosControllerBuilder:: withTimeUtilFactory(const TimeUtilFactory& itimeUtilFactory)
Sets the TimeUtilFactory used when building the controller.
Parameters | |
---|---|
itimeUtilFactory | The TimeUtilFactory. |
Returns | An ongoing builder. |
The default is the static TimeUtilFactory.
AsyncPosControllerBuilder& okapi:: AsyncPosControllerBuilder:: withLogger(const std::shared_ptr<Logger>& ilogger)
Sets the logger.
Parameters | |
---|---|
ilogger | The logger. |
Returns | An ongoing builder. |
AsyncPosControllerBuilder& okapi:: AsyncPosControllerBuilder:: parentedToCurrentTask()
Parents the internal tasks started by this builder to the current task, meaning they will be deleted once the current task is deleted.
Returns | An ongoing builder. |
---|
The initialize
and competition_initialize
tasks are never parented to. This is the default behavior.
Read more about this in the builders and tasks tutorial.
AsyncPosControllerBuilder& okapi:: AsyncPosControllerBuilder:: notParentedToCurrentTask()
Prevents parenting the internal tasks started by this builder to the current task, meaning they will not be deleted once the current task is deleted.
Returns | An ongoing builder. |
---|
This can cause runaway tasks, but is sometimes the desired behavior (e.x., if you want to use this builder once in autonomous
and then again in opcontrol
).
Read more about this in the builders and tasks tutorial.
std::shared_ptr<AsyncPositionController<double, double>> okapi:: AsyncPosControllerBuilder:: build()
Builds the AsyncPositionController.
Returns | A fully built AsyncPositionController. |
---|
Throws a std::runtime_exception is no motors were set.