Smartcar Shield
Loading...
Searching...
No Matches
SimpleCar.cpp
Go to the documentation of this file.
1#include "SimpleCar.hpp"
2#include "../../utilities/Utilities.hpp"
3
5using namespace smartcarlib::utils;
6
8 : mControl(control)
9{
10}
11
12void SimpleCar::setSpeed(float speed)
13{
14 mControl.setSpeed(getConstrain(static_cast<int>(speed), kMinControlSpeed, kMaxControlSpeed));
15}
16
17void SimpleCar::setAngle(int angle)
18{
20}
21
22void SimpleCar::overrideMotorSpeed(int firstMotorSpeed, int secondMotorSpeed)
23{
26}
Interface to generalize all classes that can provide a way to control a Car.
Definition Control.hpp:24
virtual void overrideMotorSpeed(int firstMotorSpeed, int secondMotorSpeed)=0
Set the motor speed individually as a percentage of the motors` total power.
virtual void setSpeed(int speed)=0
Sets the driving speed as percentage of the total motor speed where the sign represents the direction...
virtual void setAngle(int angle)=0
Sets the driving angle in degrees [-90, 90].
void setAngle(int angle) override
Set the car's driving angle.
Definition SimpleCar.cpp:17
void setSpeed(float speed) override
Sets the car's driving speed as a percentage of the motors total speed where the sign indicates direc...
Definition SimpleCar.cpp:12
void overrideMotorSpeed(int firstMotorSpeed, int secondMotorSpeed) override
Set the motor speed individually as a percentage of the motors` total power.
Definition SimpleCar.cpp:22
SimpleCar(Control &control)
Constructs a simple car.
Definition SimpleCar.cpp:7
constexpr AnyNumber getConstrain(AnyNumber number, AnyNumber min, AnyNumber max)
Limit the number between a range.
Definition Utilities.hpp:46