okapi::AsyncVelControllerBuilder class

Constructors, destructors, conversion operators

AsyncVelControllerBuilder(const std::shared_ptr<Logger>& ilogger = Logger::getDefaultLogger()) explicit
A builder that creates async velocity controllers.

Public functions

auto withMotor(const Motor& imotor) -> AsyncVelControllerBuilder&
Sets the motor.
auto withMotor(const MotorGroup& imotor) -> AsyncVelControllerBuilder&
Sets the motor.
auto withMotor(const std::shared_ptr<AbstractMotor>& imotor) -> AsyncVelControllerBuilder&
Sets the motor.
auto withSensor(const ADIEncoder& isensor) -> AsyncVelControllerBuilder&
Sets the sensor.
auto withSensor(const IntegratedEncoder& isensor) -> AsyncVelControllerBuilder&
Sets the sensor.
auto withSensor(const std::shared_ptr<RotarySensor>& isensor) -> AsyncVelControllerBuilder&
Sets the sensor.
auto withGains(const IterativeVelPIDController::Gains& igains) -> AsyncVelControllerBuilder&
Sets the controller gains, causing the builder to generate an AsyncVelPIDController.
auto withVelMath(std::unique_ptr<VelMath> ivelMath) -> AsyncVelControllerBuilder&
Sets the VelMath which calculates and filters velocity.
auto withDerivativeFilter(std::unique_ptr<Filter> iderivativeFilter) -> AsyncVelControllerBuilder&
Sets the derivative filter which filters the derivative term before it is scaled by kD.
auto withGearset(const AbstractMotor::GearsetRatioPair& igearset) -> AsyncVelControllerBuilder&
Sets the gearset.
auto withMaxVelocity(double imaxVelocity) -> AsyncVelControllerBuilder&
Sets the maximum velocity.
auto withTimeUtilFactory(const TimeUtilFactory& itimeUtilFactory) -> AsyncVelControllerBuilder&
Sets the TimeUtilFactory used when building the controller.
auto withLogger(const std::shared_ptr<Logger>& ilogger) -> AsyncVelControllerBuilder&
Sets the logger.
auto parentedToCurrentTask() -> AsyncVelControllerBuilder&
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() -> AsyncVelControllerBuilder&
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<AsyncVelocityController<double, double>>
Builds the AsyncVelocityController.

Function documentation

okapi::AsyncVelControllerBuilder::AsyncVelControllerBuilder(const std::shared_ptr<Logger>& ilogger = Logger::getDefaultLogger()) explicit

A builder that creates async velocity controllers.

Parameters
ilogger The logger this instance will log to.

Use this to create an AsyncVelIntegratedController or an AsyncVelPIDController.

AsyncVelControllerBuilder& okapi::AsyncVelControllerBuilder::withMotor(const Motor& imotor)

Sets the motor.

Parameters
imotor The motor.
Returns An ongoing builder.

AsyncVelControllerBuilder& okapi::AsyncVelControllerBuilder::withMotor(const MotorGroup& imotor)

Sets the motor.

Parameters
imotor The motor.
Returns An ongoing builder.

AsyncVelControllerBuilder& okapi::AsyncVelControllerBuilder::withMotor(const std::shared_ptr<AbstractMotor>& imotor)

Sets the motor.

Parameters
imotor The motor.
Returns An ongoing builder.

AsyncVelControllerBuilder& okapi::AsyncVelControllerBuilder::withSensor(const ADIEncoder& isensor)

Sets the sensor.

Parameters
isensor The sensor.
Returns An ongoing builder.

The default sensor is the motor's integrated encoder.

AsyncVelControllerBuilder& okapi::AsyncVelControllerBuilder::withSensor(const IntegratedEncoder& isensor)

Sets the sensor.

Parameters
isensor The sensor.
Returns An ongoing builder.

The default sensor is the motor's integrated encoder.

AsyncVelControllerBuilder& okapi::AsyncVelControllerBuilder::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.

AsyncVelControllerBuilder& okapi::AsyncVelControllerBuilder::withGains(const IterativeVelPIDController::Gains& igains)

Sets the controller gains, causing the builder to generate an AsyncVelPIDController.

Parameters
igains The gains.
Returns An ongoing builder.

This does not set the integrated control's gains.

AsyncVelControllerBuilder& okapi::AsyncVelControllerBuilder::withVelMath(std::unique_ptr<VelMath> ivelMath)

Sets the VelMath which calculates and filters velocity.

Parameters
ivelMath The VelMath.
Returns An ongoing builder.

This is ignored when using integrated controller. If using a PID controller (by setting the gains), this is required.

AsyncVelControllerBuilder& okapi::AsyncVelControllerBuilder::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.

AsyncVelControllerBuilder& okapi::AsyncVelControllerBuilder::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.

AsyncVelControllerBuilder& okapi::AsyncVelControllerBuilder::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 AsyncVelPIDController.

AsyncVelControllerBuilder& okapi::AsyncVelControllerBuilder::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.

AsyncVelControllerBuilder& okapi::AsyncVelControllerBuilder::withLogger(const std::shared_ptr<Logger>& ilogger)

Sets the logger.

Parameters
ilogger The logger.
Returns An ongoing builder.

AsyncVelControllerBuilder& okapi::AsyncVelControllerBuilder::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.

AsyncVelControllerBuilder& okapi::AsyncVelControllerBuilder::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<AsyncVelocityController<double, double>> okapi::AsyncVelControllerBuilder::build()

Builds the AsyncVelocityController.

Returns A fully built AsyncVelocityController.

Throws a std::runtime_exception is no motors were set.