Go to the documentation of this file.
7 #include "../../runtime/Runtime.hpp"
8 #include "../../sensors/odometer/Odometer.hpp"
9 #include "../simple/SimpleCar.hpp"
113 void setSpeed(
float speed)
override;
143 unsigned long frequency
193 bool mCruiseControlEnabled{
false };
194 float mProportional{ 0 };
195 float mIntegral{ 0 };
196 float mDerivative{ 0 };
197 unsigned long mFrequency{ 0 };
198 unsigned long mPreviousUpdate{ 0 };
199 float mTargetSpeed{ 0 };
200 float mPreviousControlledSpeed{ 0 };
201 float mIntegratedError{ 0 };
202 float mPreviousError{ 0 };
204 bool areOdometersAttached();
205 bool areOdometersDirectional();
206 float controlMotorSpeed(
const float& previousSpeed,
207 const float& targetSpeed,
208 const float& currentSpeed);
const int kOdometersNotAttachedError
long getDistance()
Gets the car's travelled distance.
const unsigned long kDefaultPidFrequency
void disableCruiseControl()
Disable cruise control.
DistanceCar(Runtime &runtime, Control &control, Odometer &odometer)
Constructs a car equipped with a distance sensor.
void enableCruiseControl(float proportional=smartcarlib::constants::car::kDefaultProportional, float integral=smartcarlib::constants::car::kDefaultIntegral, float derivative=smartcarlib::constants::car::kDefaultDerivative, unsigned long frequency=smartcarlib::constants::car::kDefaultPidFrequency)
Enables the car to move with a stable speed using the odometers.
const auto kBreakSpeedScale
const float kDefaultProportional
const float kDefaultIntegral
virtual void update()
Adjusts the cruise control speed.
void overrideMotorSpeed(int firstMotorSpeed, int secondMotorSpeed) override
Sets the motor speed individually as a percentage of the motors` total power unless cruise control is...
void setSpeed(float speed) override
Sets the car's speed in meters per second if cruise control is enabled otherwise as a percentage of t...
float getSpeed()
Gets the car's current speed in meters per second.
const float kDefaultDerivative