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()
const;
205 bool areOdometersDirectional()
const;
206 float controlMotorSpeed(
float previousSpeed,
float targetSpeed,
float currentSpeed);
Interface to generalize all classes that can provide a way to control a Car.
A class to programmatically represent a vehicle equipped with odometers.
long getDistance()
Gets the car's travelled distance.
void overrideMotorSpeed(int firstMotorSpeed, int secondMotorSpeed) override
Sets the motor speed individually as a percentage of the motors` total power unless cruise control is...
virtual void update()
Adjusts the cruise control speed.
void disableCruiseControl()
Disable cruise control.
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.
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.
An interface to programmatically represent all odometers.
An interface to serve as a wrapper for the native runtime environment, greatly inspired by the Arduin...
A class to programmatically represent a very basic vehicle with two motors.
const float kDefaultIntegral
const float kDefaultProportional
const auto kBreakSpeedScale
const unsigned long kDefaultPidFrequency
const float kDefaultDerivative
const int kOdometersNotAttachedError