class
ChassisControllerBuilder
Contents
Constructors, destructors, conversion operators
-
ChassisControllerBuilder(const std::shared_ptr<Logger>& ilogger = Logger::
getDefaultLogger()) explicit - A builder that creates ChassisControllers.
Public functions
- auto withMotors(const Motor& ileft, const Motor& iright) -> ChassisControllerBuilder&
- Sets the motors using a skid-steer layout.
- auto withMotors(const MotorGroup& ileft, const MotorGroup& iright) -> ChassisControllerBuilder&
- Sets the motors using a skid-steer layout.
- auto withMotors(const std::shared_ptr<AbstractMotor>& ileft, const std::shared_ptr<AbstractMotor>& iright) -> ChassisControllerBuilder&
- Sets the motors using a skid-steer layout.
- auto withMotors(const Motor& itopLeft, const Motor& itopRight, const Motor& ibottomRight, const Motor& ibottomLeft) -> ChassisControllerBuilder&
- Sets the motors using an x-drive layout.
- auto withMotors(const MotorGroup& itopLeft, const MotorGroup& itopRight, const MotorGroup& ibottomRight, const MotorGroup& ibottomLeft) -> ChassisControllerBuilder&
- Sets the motors using an x-drive layout.
- auto 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) -> ChassisControllerBuilder&
- Sets the motors using an x-drive layout.
- auto withMotors(const Motor& ileft, const Motor& iright, const Motor& imiddle) -> ChassisControllerBuilder&
- Sets the motors using an h-drive layout.
- auto withMotors(const MotorGroup& ileft, const MotorGroup& iright, const MotorGroup& imiddle) -> ChassisControllerBuilder&
- Sets the motors using an h-drive layout.
- auto withMotors(const MotorGroup& ileft, const MotorGroup& iright, const Motor& imiddle) -> ChassisControllerBuilder&
- Sets the motors using an h-drive layout.
- auto withMotors(const std::shared_ptr<AbstractMotor>& ileft, const std::shared_ptr<AbstractMotor>& iright, const std::shared_ptr<AbstractMotor>& imiddle) -> ChassisControllerBuilder&
- Sets the motors using an h-drive layout.
- auto withSensors(const ADIEncoder& ileft, const ADIEncoder& iright) -> ChassisControllerBuilder&
- Sets the sensors.
- auto withSensors(const ADIEncoder& ileft, const ADIEncoder& iright, const ADIEncoder& imiddle) -> ChassisControllerBuilder&
- Sets the sensors.
- auto withSensors(const RotationSensor& ileft, const RotationSensor& iright) -> ChassisControllerBuilder&
- Sets the sensors.
- auto withSensors(const RotationSensor& ileft, const RotationSensor& iright, const RotationSensor& imiddle) -> ChassisControllerBuilder&
- Sets the sensors.
- auto withSensors(const IntegratedEncoder& ileft, const IntegratedEncoder& iright) -> ChassisControllerBuilder&
- Sets the sensors.
- auto withSensors(const IntegratedEncoder& ileft, const IntegratedEncoder& iright, const ADIEncoder& imiddle) -> ChassisControllerBuilder&
- Sets the sensors.
- auto withSensors(const std::shared_ptr<ContinuousRotarySensor>& ileft, const std::shared_ptr<ContinuousRotarySensor>& iright) -> ChassisControllerBuilder&
- Sets the sensors.
- auto withSensors(const std::shared_ptr<ContinuousRotarySensor>& ileft, const std::shared_ptr<ContinuousRotarySensor>& iright, const std::shared_ptr<ContinuousRotarySensor>& imiddle) -> ChassisControllerBuilder&
- Sets the sensors.
-
auto withGains(const IterativePosPIDController::
Gains& idistanceGains, const IterativePosPIDController:: Gains& iturnGains) -> ChassisControllerBuilder& - Sets the PID controller gains, causing the builder to generate a ChassisControllerPID.
-
auto withGains(const IterativePosPIDController::
Gains& idistanceGains, const IterativePosPIDController:: Gains& iturnGains, const IterativePosPIDController:: Gains& iangleGains) -> ChassisControllerBuilder& - Sets the PID controller gains, causing the builder to generate a ChassisControllerPID.
-
auto withOdometry(const StateMode& imode = StateMode::
FRAME_TRANSFORMATION, const QLength& imoveThreshold = 0_mm, const QAngle& iturnThreshold = 0_deg) -> ChassisControllerBuilder& - Sets the odometry information, causing the builder to generate an Odometry variant.
-
auto withOdometry(const ChassisScales& iodomScales,
const StateMode& imode = StateMode::
FRAME_TRANSFORMATION, const QLength& imoveThreshold = 0_mm, const QAngle& iturnThreshold = 0_deg) -> ChassisControllerBuilder& - Sets the odometry information, causing the builder to generate an Odometry variant.
-
auto withOdometry(std::shared_ptr<Odometry> iodometry,
const StateMode& imode = StateMode::
FRAME_TRANSFORMATION, const QLength& imoveThreshold = 0_mm, const QAngle& iturnThreshold = 0_deg) -> ChassisControllerBuilder& - Sets the odometry information, causing the builder to generate an Odometry variant.
- auto withDerivativeFilters(std::unique_ptr<Filter> idistanceFilter, std::unique_ptr<Filter> iturnFilter = std::make_unique<PassthroughFilter>(), std::unique_ptr<Filter> iangleFilter = std::make_unique<PassthroughFilter>()) -> ChassisControllerBuilder&
- Sets the derivative filters.
-
auto withDimensions(const AbstractMotor::
GearsetRatioPair& igearset, const ChassisScales& iscales) -> ChassisControllerBuilder& - Sets the chassis dimensions.
- auto withMaxVelocity(double imaxVelocity) -> ChassisControllerBuilder&
- Sets the max velocity.
- auto withMaxVoltage(double imaxVoltage) -> ChassisControllerBuilder&
- Sets the max voltage.
- auto withChassisControllerTimeUtilFactory(const TimeUtilFactory& itimeUtilFactory) -> ChassisControllerBuilder&
- Sets the TimeUtilFactory used when building a ChassisController.
- auto withClosedLoopControllerTimeUtilFactory(const TimeUtilFactory& itimeUtilFactory) -> ChassisControllerBuilder&
- Sets the TimeUtilFactory used when building a ClosedLoopController.
- auto withClosedLoopControllerTimeUtil(double iatTargetError = 50, double iatTargetDerivative = 5, const QTime& iatTargetTime = 250_ms) -> ChassisControllerBuilder&
- Creates a new ConfigurableTimeUtilFactory with the given parameters.
- auto withOdometryTimeUtilFactory(const TimeUtilFactory& itimeUtilFactory) -> ChassisControllerBuilder&
- Sets the TimeUtilFactory used when building an Odometry.
- auto withLogger(const std::shared_ptr<Logger>& ilogger) -> ChassisControllerBuilder&
- Sets the logger used for the ChassisController and ClosedLoopControllers.
- auto parentedToCurrentTask() -> ChassisControllerBuilder&
- 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() -> ChassisControllerBuilder&
- 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<ChassisController>
- Builds the ChassisController.
- auto buildOdometry() -> std::shared_ptr<OdomChassisController>
- Builds the OdomChassisController.
Function documentation
okapi:: ChassisControllerBuilder:: ChassisControllerBuilder(const std::shared_ptr<Logger>& ilogger = Logger:: getDefaultLogger()) explicit
A builder that creates ChassisControllers.
Parameters | |
---|---|
ilogger | The logger this instance will log to. |
Use this to create your ChassisController.
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withMotors(const Motor& ileft,
const Motor& iright)
Sets the motors using a skid-steer layout.
Parameters | |
---|---|
ileft | The left motor. |
iright | The right motor. |
Returns | An ongoing builder. |
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withMotors(const MotorGroup& ileft,
const MotorGroup& iright)
Sets the motors using a skid-steer layout.
Parameters | |
---|---|
ileft | The left motor. |
iright | The right motor. |
Returns | An ongoing builder. |
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 | |
---|---|
ileft | The left motor. |
iright | The right motor. |
Returns | An ongoing builder. |
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 | |
---|---|
itopLeft | The top left motor. |
itopRight | The top right motor. |
ibottomRight | The bottom right motor. |
ibottomLeft | The bottom left motor. |
Returns | An ongoing builder. |
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 | |
---|---|
itopLeft | The top left motor. |
itopRight | The top right motor. |
ibottomRight | The bottom right motor. |
ibottomLeft | The bottom left motor. |
Returns | An ongoing builder. |
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 | |
---|---|
itopLeft | The top left motor. |
itopRight | The top right motor. |
ibottomRight | The bottom right motor. |
ibottomLeft | The bottom left motor. |
Returns | An ongoing builder. |
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withMotors(const Motor& ileft,
const Motor& iright,
const Motor& imiddle)
Sets the motors using an h-drive layout.
Parameters | |
---|---|
ileft | The left motor. |
iright | The right motor. |
imiddle | The middle motor. |
Returns | An ongoing builder. |
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withMotors(const MotorGroup& ileft,
const MotorGroup& iright,
const MotorGroup& imiddle)
Sets the motors using an h-drive layout.
Parameters | |
---|---|
ileft | The left motor. |
iright | The right motor. |
imiddle | The middle motor. |
Returns | An ongoing builder. |
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withMotors(const MotorGroup& ileft,
const MotorGroup& iright,
const Motor& imiddle)
Sets the motors using an h-drive layout.
Parameters | |
---|---|
ileft | The left motor. |
iright | The right motor. |
imiddle | The middle motor. |
Returns | An ongoing builder. |
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 | |
---|---|
ileft | The left motor. |
iright | The right motor. |
imiddle | The middle motor. |
Returns | An ongoing builder. |
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withSensors(const ADIEncoder& ileft,
const ADIEncoder& iright)
Sets the sensors.
Parameters | |
---|---|
ileft | The left side sensor. |
iright | The right side sensor. |
Returns | An ongoing builder. |
The default sensors are the motor's integrated encoders.
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withSensors(const ADIEncoder& ileft,
const ADIEncoder& iright,
const ADIEncoder& imiddle)
Sets the sensors.
Parameters | |
---|---|
ileft | The left side sensor. |
iright | The right side sensor. |
imiddle | The middle sensor. |
Returns | An ongoing builder. |
The default sensors are the motor's integrated encoders.
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withSensors(const RotationSensor& ileft,
const RotationSensor& iright)
Sets the sensors.
Parameters | |
---|---|
ileft | The left side sensor. |
iright | The right side sensor. |
Returns | An ongoing builder. |
The default sensors are the motor's integrated encoders.
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withSensors(const RotationSensor& ileft,
const RotationSensor& iright,
const RotationSensor& imiddle)
Sets the sensors.
Parameters | |
---|---|
ileft | The left side sensor. |
iright | The right side sensor. |
imiddle | The middle sensor. |
Returns | An ongoing builder. |
The default sensors are the motor's integrated encoders.
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withSensors(const IntegratedEncoder& ileft,
const IntegratedEncoder& iright)
Sets the sensors.
Parameters | |
---|---|
ileft | The left side sensor. |
iright | The right side sensor. |
Returns | An ongoing builder. |
The default sensors are the motor's integrated encoders.
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withSensors(const IntegratedEncoder& ileft,
const IntegratedEncoder& iright,
const ADIEncoder& imiddle)
Sets the sensors.
Parameters | |
---|---|
ileft | The left side sensor. |
iright | The right side sensor. |
imiddle | The middle sensor. |
Returns | An ongoing builder. |
The default sensors are the motor's integrated encoders.
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withSensors(const std::shared_ptr<ContinuousRotarySensor>& ileft,
const std::shared_ptr<ContinuousRotarySensor>& iright)
Sets the sensors.
Parameters | |
---|---|
ileft | The left side sensor. |
iright | The right side sensor. |
Returns | An ongoing builder. |
The default sensors are the motor's integrated encoders.
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.
Parameters | |
---|---|
ileft | The left side sensor. |
iright | The right side sensor. |
imiddle | The middle sensor. |
Returns | An ongoing builder. |
The default sensors are the motor's integrated encoders.
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withGains(const IterativePosPIDController:: Gains& idistanceGains,
const IterativePosPIDController:: Gains& iturnGains)
Sets the PID controller gains, causing the builder to generate a ChassisControllerPID.
Parameters | |
---|---|
idistanceGains | The distance controller's gains. |
iturnGains | The turn controller's gains. |
Returns | An ongoing builder. |
Uses the turn controller's gains for the angle controller's gains.
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 | |
---|---|
idistanceGains | The distance controller's gains. |
iturnGains | The turn controller's gains. |
iangleGains | The angle controller's gains. |
Returns | An ongoing builder. |
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 | |
---|---|
imode | The new default StateMode used to interpret target points and query the Odometry state. |
imoveThreshold | The minimum length movement. |
iturnThreshold | The minimum angle turn. |
Returns | An ongoing builder. |
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 | |
---|---|
iodomScales | The ChassisScales used just for odometry (if they are different than those for the drive). |
imode | The new default StateMode used to interpret target points and query the Odometry state. |
imoveThreshold | The minimum length movement. |
iturnThreshold | The minimum angle turn. |
Returns | An ongoing builder. |
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 | |
---|---|
iodometry | The odometry object. |
imode | The new default StateMode used to interpret target points and query the Odometry state. |
imoveThreshold | The minimum length movement. |
iturnThreshold | The minimum angle turn. |
Returns | An ongoing builder. |
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.
Parameters | |
---|---|
idistanceFilter | The distance controller's filter. |
iturnFilter | The turn controller's filter. |
iangleFilter | The angle controller's filter. |
Returns | An ongoing builder. |
Uses a PassthroughFilter by default.
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withDimensions(const AbstractMotor:: GearsetRatioPair& igearset,
const ChassisScales& iscales)
Sets the chassis dimensions.
Parameters | |
---|---|
igearset | The gearset in the drive motors. |
iscales | The ChassisScales for the base. |
Returns | An ongoing builder. |
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withMaxVelocity(double imaxVelocity)
Sets the max velocity.
Parameters | |
---|---|
imaxVelocity | The max velocity. |
Returns | An ongoing builder. |
Overrides the max velocity of the gearset.
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withMaxVoltage(double imaxVoltage)
Sets the max voltage.
Parameters | |
---|---|
imaxVoltage | The max voltage. |
Returns | An ongoing builder. |
The default is 12000
.
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withChassisControllerTimeUtilFactory(const TimeUtilFactory& itimeUtilFactory)
Sets the TimeUtilFactory used when building a ChassisController.
Parameters | |
---|---|
itimeUtilFactory | The TimeUtilFactory. |
Returns | An ongoing builder. |
This instance will be given to the ChassisController (not to controllers it uses). The default is the static TimeUtilFactory.
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withClosedLoopControllerTimeUtilFactory(const TimeUtilFactory& itimeUtilFactory)
Sets the TimeUtilFactory used when building a ClosedLoopController.
Parameters | |
---|---|
itimeUtilFactory | The TimeUtilFactory. |
Returns | An ongoing builder. |
This instance will be given to any ClosedLoopController instances. The default is the static TimeUtilFactory.
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withClosedLoopControllerTimeUtil(double iatTargetError = 50,
double iatTargetDerivative = 5,
const QTime& iatTargetTime = 250_ms)
Creates a new ConfigurableTimeUtilFactory with the given parameters.
Parameters | |
---|---|
iatTargetError | The minimum error to be considered settled. |
iatTargetDerivative | The minimum error derivative to be considered settled. |
iatTargetTime | The minimum time within atTargetError to be considered settled. |
Returns | An ongoing builder. |
Given to any ClosedLoopController instances.
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withOdometryTimeUtilFactory(const TimeUtilFactory& itimeUtilFactory)
Sets the TimeUtilFactory used when building an Odometry.
Parameters | |
---|---|
itimeUtilFactory | The TimeUtilFactory. |
Returns | An ongoing builder. |
The default is the static TimeUtilFactory.
ChassisControllerBuilder& okapi:: ChassisControllerBuilder:: withLogger(const std::shared_ptr<Logger>& ilogger)
Sets the logger used for the ChassisController and ClosedLoopControllers.
Parameters | |
---|---|
ilogger | The logger. |
Returns | An ongoing builder. |
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.
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.
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.
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<ChassisController> okapi:: ChassisControllerBuilder:: build()
Builds the ChassisController.
Returns | A fully built ChassisController. |
---|
Throws a std::runtime_exception if no motors were set or if no dimensions were set.
std::shared_ptr<OdomChassisController> okapi:: ChassisControllerBuilder:: buildOdometry()
Builds the OdomChassisController.
Returns | A fully built OdomChassisController. |
---|
Throws a std::runtime_exception if no motors were set, if no dimensions were set, or if no odometry information was passed.