60 const std::shared_ptr<AbstractMotor> &iright);
72 const Motor &itopRight,
73 const Motor &ibottomRight,
74 const Motor &ibottomLeft);
100 const std::shared_ptr<AbstractMotor> &itopRight,
101 const std::shared_ptr<AbstractMotor> &ibottomRight,
102 const std::shared_ptr<AbstractMotor> &ibottomLeft);
146 const std::shared_ptr<AbstractMotor> &iright,
147 const std::shared_ptr<AbstractMotor> &imiddle);
220 const std::shared_ptr<ContinuousRotarySensor> &iright);
231 const std::shared_ptr<ContinuousRotarySensor> &iright,
232 const std::shared_ptr<ContinuousRotarySensor> &imiddle);
267 const QLength &imoveThreshold = 0_mm,
268 const QAngle &iturnThreshold = 0_deg);
283 const QLength &imoveThreshold = 0_mm,
284 const QAngle &iturnThreshold = 0_deg);
298 const QLength &imoveThreshold = 0_mm,
299 const QAngle &iturnThreshold = 0_deg);
310 std::unique_ptr<Filter> idistanceFilter,
311 std::unique_ptr<Filter> iturnFilter = std::make_unique<PassthroughFilter>(),
312 std::unique_ptr<Filter> iangleFilter = std::make_unique<PassthroughFilter>());
371 double iatTargetDerivative = 5,
372 const QTime &iatTargetTime = 250_ms);
422 std::shared_ptr<ChassisController>
build();
433 std::shared_ptr<Logger> logger;
435 struct SkidSteerMotors {
436 std::shared_ptr<AbstractMotor>
left;
437 std::shared_ptr<AbstractMotor>
right;
440 struct XDriveMotors {
441 std::shared_ptr<AbstractMotor> topLeft;
442 std::shared_ptr<AbstractMotor> topRight;
443 std::shared_ptr<AbstractMotor> bottomRight;
444 std::shared_ptr<AbstractMotor> bottomLeft;
447 struct HDriveMotors {
448 std::shared_ptr<AbstractMotor> left;
449 std::shared_ptr<AbstractMotor> right;
450 std::shared_ptr<AbstractMotor> middle;
453 enum class DriveMode { SkidSteer, XDrive, HDrive };
455 bool hasMotors{
false};
456 DriveMode driveMode{DriveMode::SkidSteer};
457 SkidSteerMotors skidSteerMotors;
458 XDriveMotors xDriveMotors;
459 HDriveMotors hDriveMotors;
461 bool sensorsSetByUser{
false};
462 std::shared_ptr<ContinuousRotarySensor> leftSensor{
nullptr};
463 std::shared_ptr<ContinuousRotarySensor> rightSensor{
nullptr};
464 std::shared_ptr<ContinuousRotarySensor> middleSensor{
nullptr};
466 bool hasGains{
false};
467 IterativePosPIDController::Gains distanceGains;
468 std::unique_ptr<Filter> distanceFilter = std::make_unique<PassthroughFilter>();
469 IterativePosPIDController::Gains angleGains;
470 std::unique_ptr<Filter> angleFilter = std::make_unique<PassthroughFilter>();
471 IterativePosPIDController::Gains turnGains;
472 std::unique_ptr<Filter> turnFilter = std::make_unique<PassthroughFilter>();
473 TimeUtilFactory chassisControllerTimeUtilFactory = TimeUtilFactory();
474 TimeUtilFactory closedLoopControllerTimeUtilFactory = TimeUtilFactory();
475 TimeUtilFactory odometryTimeUtilFactory = TimeUtilFactory();
479 bool differentOdomScales{
false};
484 std::shared_ptr<Odometry> odometry;
486 QLength moveThreshold;
487 QAngle turnThreshold;
489 bool maxVelSetByUser{
false};
490 double maxVelocity{600};
492 double maxVoltage{12000};
494 bool isParentedToCurrentTask{
true};
496 std::shared_ptr<ChassisControllerPID> buildCCPID();
497 std::shared_ptr<ChassisControllerIntegrated> buildCCI();
498 std::shared_ptr<DefaultOdomChassisController>
499 buildDOCC(std::shared_ptr<ChassisController> chassisController);
501 std::shared_ptr<ChassisModel> makeChassisModel();
502 std::shared_ptr<SkidSteerModel> makeSkidSteerModel();
503 std::shared_ptr<XDriveModel> makeXDriveModel();
504 std::shared_ptr<HDriveModel> makeHDriveModel();
ChassisControllerBuilder & withSensors(const ADIEncoder &ileft, const ADIEncoder &iright)
Sets the sensors.
ChassisControllerBuilder & withMotors(const Motor &itopLeft, const Motor &itopRight, const Motor &ibottomRight, const Motor &ibottomLeft)
Sets the motors using an x-drive layout.
ChassisControllerBuilder & withSensors(const std::shared_ptr< ContinuousRotarySensor > &ileft, const std::shared_ptr< ContinuousRotarySensor > &iright)
Sets the sensors.
ChassisControllerBuilder & withSensors(const RotationSensor &ileft, const RotationSensor &iright, const RotationSensor &imiddle)
Sets the sensors.
ChassisControllerBuilder & withChassisControllerTimeUtilFactory(const TimeUtilFactory &itimeUtilFactory)
Sets the TimeUtilFactory used when building a ChassisController.
ChassisControllerBuilder & withMotors(const Motor &ileft, const Motor &iright)
Sets the motors using a skid-steer layout.
ChassisControllerBuilder & notParentedToCurrentTask()
Prevents parenting the internal tasks started by this builder to the current task,...
ChassisControllerBuilder & withDimensions(const AbstractMotor::GearsetRatioPair &igearset, const ChassisScales &iscales)
Sets the chassis dimensions.
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.
ChassisControllerBuilder & withMotors(const std::shared_ptr< AbstractMotor > &ileft, const std::shared_ptr< AbstractMotor > &iright)
Sets the motors using a skid-steer layout.
ChassisControllerBuilder(const std::shared_ptr< Logger > &ilogger=Logger::getDefaultLogger())
A builder that creates ChassisControllers.
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.
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.
ChassisControllerBuilder & withSensors(const ADIEncoder &ileft, const ADIEncoder &iright, const ADIEncoder &imiddle)
Sets the sensors.
ChassisControllerBuilder & withClosedLoopControllerTimeUtilFactory(const TimeUtilFactory &itimeUtilFactory)
Sets the TimeUtilFactory used when building a ClosedLoopController.
std::shared_ptr< ChassisController > build()
Builds the ChassisController.
ChassisControllerBuilder & withMotors(const MotorGroup &itopLeft, const MotorGroup &itopRight, const MotorGroup &ibottomRight, const MotorGroup &ibottomLeft)
Sets the motors using an x-drive layout.
ChassisControllerBuilder & withMotors(const MotorGroup &ileft, const MotorGroup &iright, const Motor &imiddle)
Sets the motors using an h-drive layout.
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.
ChassisControllerBuilder & withMaxVoltage(double imaxVoltage)
Sets the max voltage.
ChassisControllerBuilder & withClosedLoopControllerTimeUtil(double iatTargetError=50, double iatTargetDerivative=5, const QTime &iatTargetTime=250_ms)
Creates a new ConfigurableTimeUtilFactory with the given parameters.
ChassisControllerBuilder & withSensors(const std::shared_ptr< ContinuousRotarySensor > &ileft, const std::shared_ptr< ContinuousRotarySensor > &iright, const std::shared_ptr< ContinuousRotarySensor > &imiddle)
Sets the sensors.
ChassisControllerBuilder & withMotors(const MotorGroup &ileft, const MotorGroup &iright)
Sets the motors using a skid-steer layout.
ChassisControllerBuilder & withSensors(const IntegratedEncoder &ileft, const IntegratedEncoder &iright, const ADIEncoder &imiddle)
Sets the sensors.
std::shared_ptr< OdomChassisController > buildOdometry()
Builds the OdomChassisController.
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.
ChassisControllerBuilder & withMotors(const MotorGroup &ileft, const MotorGroup &iright, const MotorGroup &imiddle)
Sets the motors using an h-drive layout.
ChassisControllerBuilder & withMotors(const Motor &ileft, const Motor &iright, const Motor &imiddle)
Sets the motors using an h-drive layout.
ChassisControllerBuilder & withOdometryTimeUtilFactory(const TimeUtilFactory &itimeUtilFactory)
Sets the TimeUtilFactory used when building an Odometry.
ChassisControllerBuilder & withLogger(const std::shared_ptr< Logger > &ilogger)
Sets the logger used for the ChassisController and ClosedLoopControllers.
ChassisControllerBuilder & withGains(const IterativePosPIDController::Gains &idistanceGains, const IterativePosPIDController::Gains &iturnGains)
Sets the PID controller gains, causing the builder to generate a ChassisControllerPID.
ChassisControllerBuilder & withSensors(const RotationSensor &ileft, const RotationSensor &iright)
Sets the sensors.
ChassisControllerBuilder & parentedToCurrentTask()
Parents the internal tasks started by this builder to the current task, meaning they will be deleted ...
ChassisControllerBuilder & withSensors(const IntegratedEncoder &ileft, const IntegratedEncoder &iright)
Sets the sensors.
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.
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.
ChassisControllerBuilder & withMaxVelocity(double imaxVelocity)
Sets the max velocity.
static std::shared_ptr< Logger > getDefaultLogger()
static constexpr std::int32_t imev5GreenTPR
The ticks per rotation of the V5 motor with a green gearset.
StateMode
The mode for the OdomState calculated by Odometry.
@ FRAME_TRANSFORMATION
+x is forward, +y is right, 0 degrees is along +x
A simple structure representing the full ratio between motor and wheel.