LightLib
PROS library for VEX V5: EKF/MCL localization, RAMSETE path following, high-level chassis API
Loading...
Searching...
No Matches
okapi::ChassisControllerBuilder Class Reference

#include <chassisControllerBuilder.hpp>

Public Member Functions

 ChassisControllerBuilder (const std::shared_ptr< Logger > &ilogger=Logger::getDefaultLogger())
 A builder that creates ChassisControllers.
 
ChassisControllerBuilderwithMotors (const Motor &ileft, const Motor &iright)
 Sets the motors using a skid-steer layout.
 
ChassisControllerBuilderwithMotors (const MotorGroup &ileft, const MotorGroup &iright)
 Sets the motors using a skid-steer layout.
 
ChassisControllerBuilderwithMotors (const std::shared_ptr< AbstractMotor > &ileft, const std::shared_ptr< AbstractMotor > &iright)
 Sets the motors using a skid-steer layout.
 
ChassisControllerBuilderwithMotors (const Motor &itopLeft, const Motor &itopRight, const Motor &ibottomRight, const Motor &ibottomLeft)
 Sets the motors using an x-drive layout.
 
ChassisControllerBuilderwithMotors (const MotorGroup &itopLeft, const MotorGroup &itopRight, const MotorGroup &ibottomRight, const MotorGroup &ibottomLeft)
 Sets the motors using an x-drive layout.
 
ChassisControllerBuilderwithMotors (const std::shared_ptr< AbstractMotor > &itopLeft, const std::shared_ptr< AbstractMotor > &itopRight, const std::shared_ptr< AbstractMotor > &ibottomRight, const std::shared_ptr< AbstractMotor > &ibottomLeft)
 Sets the motors using an x-drive layout.
 
ChassisControllerBuilderwithMotors (const Motor &ileft, const Motor &iright, const Motor &imiddle)
 Sets the motors using an h-drive layout.
 
ChassisControllerBuilderwithMotors (const MotorGroup &ileft, const MotorGroup &iright, const MotorGroup &imiddle)
 Sets the motors using an h-drive layout.
 
ChassisControllerBuilderwithMotors (const MotorGroup &ileft, const MotorGroup &iright, const Motor &imiddle)
 Sets the motors using an h-drive layout.
 
ChassisControllerBuilderwithMotors (const std::shared_ptr< AbstractMotor > &ileft, const std::shared_ptr< AbstractMotor > &iright, const std::shared_ptr< AbstractMotor > &imiddle)
 Sets the motors using an h-drive layout.
 
ChassisControllerBuilderwithSensors (const ADIEncoder &ileft, const ADIEncoder &iright)
 Sets the sensors.
 
ChassisControllerBuilderwithSensors (const ADIEncoder &ileft, const ADIEncoder &iright, const ADIEncoder &imiddle)
 Sets the sensors.
 
ChassisControllerBuilderwithSensors (const RotationSensor &ileft, const RotationSensor &iright)
 Sets the sensors.
 
ChassisControllerBuilderwithSensors (const RotationSensor &ileft, const RotationSensor &iright, const RotationSensor &imiddle)
 Sets the sensors.
 
ChassisControllerBuilderwithSensors (const IntegratedEncoder &ileft, const IntegratedEncoder &iright)
 Sets the sensors.
 
ChassisControllerBuilderwithSensors (const IntegratedEncoder &ileft, const IntegratedEncoder &iright, const ADIEncoder &imiddle)
 Sets the sensors.
 
ChassisControllerBuilderwithSensors (const std::shared_ptr< ContinuousRotarySensor > &ileft, const std::shared_ptr< ContinuousRotarySensor > &iright)
 Sets the sensors.
 
ChassisControllerBuilderwithSensors (const std::shared_ptr< ContinuousRotarySensor > &ileft, const std::shared_ptr< ContinuousRotarySensor > &iright, const std::shared_ptr< ContinuousRotarySensor > &imiddle)
 Sets the sensors.
 
ChassisControllerBuilderwithGains (const IterativePosPIDController::Gains &idistanceGains, const IterativePosPIDController::Gains &iturnGains)
 Sets the PID controller gains, causing the builder to generate a ChassisControllerPID.
 
ChassisControllerBuilderwithGains (const IterativePosPIDController::Gains &idistanceGains, const IterativePosPIDController::Gains &iturnGains, const IterativePosPIDController::Gains &iangleGains)
 Sets the PID controller gains, causing the builder to generate a ChassisControllerPID.
 
ChassisControllerBuilderwithOdometry (const StateMode &imode=StateMode::FRAME_TRANSFORMATION, const QLength &imoveThreshold=0_mm, const QAngle &iturnThreshold=0_deg)
 Sets the odometry information, causing the builder to generate an Odometry variant.
 
ChassisControllerBuilderwithOdometry (const ChassisScales &iodomScales, const StateMode &imode=StateMode::FRAME_TRANSFORMATION, const QLength &imoveThreshold=0_mm, const QAngle &iturnThreshold=0_deg)
 Sets the odometry information, causing the builder to generate an Odometry variant.
 
ChassisControllerBuilderwithOdometry (std::shared_ptr< Odometry > iodometry, const StateMode &imode=StateMode::FRAME_TRANSFORMATION, const QLength &imoveThreshold=0_mm, const QAngle &iturnThreshold=0_deg)
 Sets the odometry information, causing the builder to generate an Odometry variant.
 
ChassisControllerBuilderwithDerivativeFilters (std::unique_ptr< Filter > idistanceFilter, std::unique_ptr< Filter > iturnFilter=std::make_unique< PassthroughFilter >(), std::unique_ptr< Filter > iangleFilter=std::make_unique< PassthroughFilter >())
 Sets the derivative filters.
 
ChassisControllerBuilderwithDimensions (const AbstractMotor::GearsetRatioPair &igearset, const ChassisScales &iscales)
 Sets the chassis dimensions.
 
ChassisControllerBuilderwithMaxVelocity (double imaxVelocity)
 Sets the max velocity.
 
ChassisControllerBuilderwithMaxVoltage (double imaxVoltage)
 Sets the max voltage.
 
ChassisControllerBuilderwithChassisControllerTimeUtilFactory (const TimeUtilFactory &itimeUtilFactory)
 Sets the TimeUtilFactory used when building a ChassisController.
 
ChassisControllerBuilderwithClosedLoopControllerTimeUtilFactory (const TimeUtilFactory &itimeUtilFactory)
 Sets the TimeUtilFactory used when building a ClosedLoopController.
 
ChassisControllerBuilderwithClosedLoopControllerTimeUtil (double iatTargetError=50, double iatTargetDerivative=5, const QTime &iatTargetTime=250_ms)
 Creates a new ConfigurableTimeUtilFactory with the given parameters.
 
ChassisControllerBuilderwithOdometryTimeUtilFactory (const TimeUtilFactory &itimeUtilFactory)
 Sets the TimeUtilFactory used when building an Odometry.
 
ChassisControllerBuilderwithLogger (const std::shared_ptr< Logger > &ilogger)
 Sets the logger used for the ChassisController and ClosedLoopControllers.
 
ChassisControllerBuilderparentedToCurrentTask ()
 Parents the internal tasks started by this builder to the current task, meaning they will be deleted once the current task is deleted.
 
ChassisControllerBuildernotParentedToCurrentTask ()
 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.
 
std::shared_ptr< ChassisControllerbuild ()
 Builds the ChassisController.
 
std::shared_ptr< OdomChassisControllerbuildOdometry ()
 Builds the OdomChassisController.
 

Detailed Description

Definition at line 24 of file chassisControllerBuilder.hpp.

Constructor & Destructor Documentation

◆ ChassisControllerBuilder()

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

A builder that creates ChassisControllers.

Use this to create your ChassisController.

Parameters
iloggerThe logger this instance will log to.

Member Function Documentation

◆ build()

std::shared_ptr< ChassisController > okapi::ChassisControllerBuilder::build ( )

Builds the ChassisController.

Throws a std::runtime_exception if no motors were set or if no dimensions were set.

Returns
A fully built ChassisController.

◆ buildOdometry()

std::shared_ptr< OdomChassisController > okapi::ChassisControllerBuilder::buildOdometry ( )

Builds the OdomChassisController.

Throws a std::runtime_exception if no motors were set, if no dimensions were set, or if no odometry information was passed.

Returns
A fully built OdomChassisController.

◆ notParentedToCurrentTask()

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

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] (docs/tutorials/concepts/builders-and-tasks.md).

Returns
An ongoing builder.

◆ parentedToCurrentTask()

ChassisControllerBuilder & okapi::ChassisControllerBuilder::parentedToCurrentTask ( )

Parents the internal tasks started by this builder to the current task, meaning they will be deleted once the current task is deleted.

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] (docs/tutorials/concepts/builders-and-tasks.md).

Returns
An ongoing builder.

◆ withChassisControllerTimeUtilFactory()

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withChassisControllerTimeUtilFactory ( const TimeUtilFactory itimeUtilFactory)

Sets the TimeUtilFactory used when building a ChassisController.

This instance will be given to the ChassisController (not to controllers it uses). The default is the static TimeUtilFactory.

Parameters
itimeUtilFactoryThe TimeUtilFactory.
Returns
An ongoing builder.

◆ withClosedLoopControllerTimeUtil()

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withClosedLoopControllerTimeUtil ( double  iatTargetError = 50,
double  iatTargetDerivative = 5,
const QTime &  iatTargetTime = 250_ms 
)

Creates a new ConfigurableTimeUtilFactory with the given parameters.

Given to any ClosedLoopController instances.

Parameters
iatTargetErrorThe minimum error to be considered settled.
iatTargetDerivativeThe minimum error derivative to be considered settled.
iatTargetTimeThe minimum time within atTargetError to be considered settled.
Returns
An ongoing builder.

◆ withClosedLoopControllerTimeUtilFactory()

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withClosedLoopControllerTimeUtilFactory ( const TimeUtilFactory itimeUtilFactory)

Sets the TimeUtilFactory used when building a ClosedLoopController.

This instance will be given to any ClosedLoopController instances. The default is the static TimeUtilFactory.

Parameters
itimeUtilFactoryThe TimeUtilFactory.
Returns
An ongoing builder.

◆ withDerivativeFilters()

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withDerivativeFilters ( std::unique_ptr< Filter idistanceFilter,
std::unique_ptr< Filter iturnFilter = std::make_unique< PassthroughFilter >(),
std::unique_ptr< Filter iangleFilter = std::make_unique< PassthroughFilter >() 
)

Sets the derivative filters.

Uses a PassthroughFilter by default.

Parameters
idistanceFilterThe distance controller's filter.
iturnFilterThe turn controller's filter.
iangleFilterThe angle controller's filter.
Returns
An ongoing builder.

◆ withDimensions()

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withDimensions ( const AbstractMotor::GearsetRatioPair igearset,
const ChassisScales iscales 
)

Sets the chassis dimensions.

Parameters
igearsetThe gearset in the drive motors.
iscalesThe ChassisScales for the base.
Returns
An ongoing builder.

◆ withGains() [1/2]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withGains ( const IterativePosPIDController::Gains idistanceGains,
const IterativePosPIDController::Gains iturnGains 
)

Sets the PID controller gains, causing the builder to generate a ChassisControllerPID.

Uses the turn controller's gains for the angle controller's gains.

Parameters
idistanceGainsThe distance controller's gains.
iturnGainsThe turn controller's gains.
Returns
An ongoing builder.

◆ withGains() [2/2]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withGains ( const IterativePosPIDController::Gains idistanceGains,
const IterativePosPIDController::Gains iturnGains,
const IterativePosPIDController::Gains iangleGains 
)

Sets the PID controller gains, causing the builder to generate a ChassisControllerPID.

Parameters
idistanceGainsThe distance controller's gains.
iturnGainsThe turn controller's gains.
iangleGainsThe angle controller's gains.
Returns
An ongoing builder.

◆ withLogger()

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

Sets the logger used for the ChassisController and ClosedLoopControllers.

Parameters
iloggerThe logger.
Returns
An ongoing builder.

◆ withMaxVelocity()

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withMaxVelocity ( double  imaxVelocity)

Sets the max velocity.

Overrides the max velocity of the gearset.

Parameters
imaxVelocityThe max velocity.
Returns
An ongoing builder.

◆ withMaxVoltage()

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withMaxVoltage ( double  imaxVoltage)

Sets the max voltage.

The default is 12000.

Parameters
imaxVoltageThe max voltage.
Returns
An ongoing builder.

◆ withMotors() [1/10]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withMotors ( const Motor ileft,
const Motor iright 
)

Sets the motors using a skid-steer layout.

Parameters
ileftThe left motor.
irightThe right motor.
Returns
An ongoing builder.

◆ withMotors() [2/10]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withMotors ( const Motor ileft,
const Motor iright,
const Motor imiddle 
)

Sets the motors using an h-drive layout.

Parameters
ileftThe left motor.
irightThe right motor.
imiddleThe middle motor.
Returns
An ongoing builder.

◆ withMotors() [3/10]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withMotors ( const Motor itopLeft,
const Motor itopRight,
const Motor ibottomRight,
const Motor ibottomLeft 
)

Sets the motors using an x-drive layout.

Parameters
itopLeftThe top left motor.
itopRightThe top right motor.
ibottomRightThe bottom right motor.
ibottomLeftThe bottom left motor.
Returns
An ongoing builder.

◆ withMotors() [4/10]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withMotors ( const MotorGroup ileft,
const MotorGroup iright 
)

Sets the motors using a skid-steer layout.

Parameters
ileftThe left motor.
irightThe right motor.
Returns
An ongoing builder.

◆ withMotors() [5/10]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withMotors ( const MotorGroup ileft,
const MotorGroup iright,
const Motor imiddle 
)

Sets the motors using an h-drive layout.

Parameters
ileftThe left motor.
irightThe right motor.
imiddleThe middle motor.
Returns
An ongoing builder.

◆ withMotors() [6/10]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withMotors ( const MotorGroup ileft,
const MotorGroup iright,
const MotorGroup imiddle 
)

Sets the motors using an h-drive layout.

Parameters
ileftThe left motor.
irightThe right motor.
imiddleThe middle motor.
Returns
An ongoing builder.

◆ withMotors() [7/10]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withMotors ( const MotorGroup itopLeft,
const MotorGroup itopRight,
const MotorGroup ibottomRight,
const MotorGroup ibottomLeft 
)

Sets the motors using an x-drive layout.

Parameters
itopLeftThe top left motor.
itopRightThe top right motor.
ibottomRightThe bottom right motor.
ibottomLeftThe bottom left motor.
Returns
An ongoing builder.

◆ withMotors() [8/10]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withMotors ( const std::shared_ptr< AbstractMotor > &  ileft,
const std::shared_ptr< AbstractMotor > &  iright 
)

Sets the motors using a skid-steer layout.

Parameters
ileftThe left motor.
irightThe right motor.
Returns
An ongoing builder.

◆ withMotors() [9/10]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withMotors ( const std::shared_ptr< AbstractMotor > &  ileft,
const std::shared_ptr< AbstractMotor > &  iright,
const std::shared_ptr< AbstractMotor > &  imiddle 
)

Sets the motors using an h-drive layout.

Parameters
ileftThe left motor.
irightThe right motor.
imiddleThe middle motor.
Returns
An ongoing builder.

◆ withMotors() [10/10]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withMotors ( const std::shared_ptr< AbstractMotor > &  itopLeft,
const std::shared_ptr< AbstractMotor > &  itopRight,
const std::shared_ptr< AbstractMotor > &  ibottomRight,
const std::shared_ptr< AbstractMotor > &  ibottomLeft 
)

Sets the motors using an x-drive layout.

Parameters
itopLeftThe top left motor.
itopRightThe top right motor.
ibottomRightThe bottom right motor.
ibottomLeftThe bottom left motor.
Returns
An ongoing builder.

◆ withOdometry() [1/3]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withOdometry ( const ChassisScales iodomScales,
const StateMode imode = StateMode::FRAME_TRANSFORMATION,
const QLength &  imoveThreshold = 0_mm,
const QAngle &  iturnThreshold = 0_deg 
)

Sets the odometry information, causing the builder to generate an Odometry variant.

Parameters
iodomScalesThe ChassisScales used just for odometry (if they are different than those for the drive).
imodeThe new default StateMode used to interpret target points and query the Odometry state.
imoveThresholdThe minimum length movement.
iturnThresholdThe minimum angle turn.
Returns
An ongoing builder.

◆ withOdometry() [2/3]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withOdometry ( const StateMode imode = StateMode::FRAME_TRANSFORMATION,
const QLength &  imoveThreshold = 0_mm,
const QAngle &  iturnThreshold = 0_deg 
)

Sets the odometry information, causing the builder to generate an Odometry variant.

Parameters
imodeThe new default StateMode used to interpret target points and query the Odometry state.
imoveThresholdThe minimum length movement.
iturnThresholdThe minimum angle turn.
Returns
An ongoing builder.

◆ withOdometry() [3/3]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withOdometry ( std::shared_ptr< Odometry iodometry,
const StateMode imode = StateMode::FRAME_TRANSFORMATION,
const QLength &  imoveThreshold = 0_mm,
const QAngle &  iturnThreshold = 0_deg 
)

Sets the odometry information, causing the builder to generate an Odometry variant.

Parameters
iodometryThe odometry object.
imodeThe new default StateMode used to interpret target points and query the Odometry state.
imoveThresholdThe minimum length movement.
iturnThresholdThe minimum angle turn.
Returns
An ongoing builder.

◆ withOdometryTimeUtilFactory()

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withOdometryTimeUtilFactory ( const TimeUtilFactory itimeUtilFactory)

Sets the TimeUtilFactory used when building an Odometry.

The default is the static TimeUtilFactory.

Parameters
itimeUtilFactoryThe TimeUtilFactory.
Returns
An ongoing builder.

◆ withSensors() [1/8]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withSensors ( const ADIEncoder ileft,
const ADIEncoder iright 
)

Sets the sensors.

The default sensors are the motor's integrated encoders.

Parameters
ileftThe left side sensor.
irightThe right side sensor.
Returns
An ongoing builder.

◆ withSensors() [2/8]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withSensors ( const ADIEncoder ileft,
const ADIEncoder iright,
const ADIEncoder imiddle 
)

Sets the sensors.

The default sensors are the motor's integrated encoders.

Parameters
ileftThe left side sensor.
irightThe right side sensor.
imiddleThe middle sensor.
Returns
An ongoing builder.

◆ withSensors() [3/8]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withSensors ( const IntegratedEncoder ileft,
const IntegratedEncoder iright 
)

Sets the sensors.

The default sensors are the motor's integrated encoders.

Parameters
ileftThe left side sensor.
irightThe right side sensor.
Returns
An ongoing builder.

◆ withSensors() [4/8]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withSensors ( const IntegratedEncoder ileft,
const IntegratedEncoder iright,
const ADIEncoder imiddle 
)

Sets the sensors.

The default sensors are the motor's integrated encoders.

Parameters
ileftThe left side sensor.
irightThe right side sensor.
imiddleThe middle sensor.
Returns
An ongoing builder.

◆ withSensors() [5/8]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withSensors ( const RotationSensor ileft,
const RotationSensor iright 
)

Sets the sensors.

The default sensors are the motor's integrated encoders.

Parameters
ileftThe left side sensor.
irightThe right side sensor.
Returns
An ongoing builder.

◆ withSensors() [6/8]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withSensors ( const RotationSensor ileft,
const RotationSensor iright,
const RotationSensor imiddle 
)

Sets the sensors.

The default sensors are the motor's integrated encoders.

Parameters
ileftThe left side sensor.
irightThe right side sensor.
imiddleThe middle sensor.
Returns
An ongoing builder.

◆ withSensors() [7/8]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withSensors ( const std::shared_ptr< ContinuousRotarySensor > &  ileft,
const std::shared_ptr< ContinuousRotarySensor > &  iright 
)

Sets the sensors.

The default sensors are the motor's integrated encoders.

Parameters
ileftThe left side sensor.
irightThe right side sensor.
Returns
An ongoing builder.

◆ withSensors() [8/8]

ChassisControllerBuilder & okapi::ChassisControllerBuilder::withSensors ( const std::shared_ptr< ContinuousRotarySensor > &  ileft,
const std::shared_ptr< ContinuousRotarySensor > &  iright,
const std::shared_ptr< ContinuousRotarySensor > &  imiddle 
)

Sets the sensors.

The default sensors are the motor's integrated encoders.

Parameters
ileftThe left side sensor.
irightThe right side sensor.
imiddleThe middle sensor.
Returns
An ongoing builder.

The documentation for this class was generated from the following file: