![]() |
RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
|
A vehicle composed of several Motors, providing drive and steering by coordinating the motors it owns. More...
#include <Vehicle.h>
Public Member Functions | |
| Vehicle (const Vehicle &)=delete | |
| Vehicle & | operator= (const Vehicle &)=delete |
| Vehicle (const unsigned int numberOfMotors, const unsigned int *motorPinNumbers=nullptr, MotorAlignment *motorAlignments=nullptr) | |
| Builds a vehicle, constructing one Motor per triplet of pin numbers (enable, drive-one, drive-two), with optional per-motor alignments. More... | |
| virtual | ~Vehicle () |
| Destroys the vehicle, turning it off and deleting the motors it owns. More... | |
| virtual void | TurnOn () override |
| Turns the vehicle on by turning on all its motors. More... | |
| virtual void | TurnOff () override |
| Turns the vehicle off by turning off all its motors. More... | |
| virtual void | ProcessRawValues () override |
| No-op: a vehicle is an output device with no raw values to process. More... | |
| virtual std::string | ToString () const override |
| Serializes every motor's description into one string. More... | |
| void | TurnOnMotors () |
| Turns on every motor the vehicle owns. More... | |
| void | TurnOffMotors () |
| Turns off every motor the vehicle owns. More... | |
| void | MoveForward () |
| Drives every motor forward, enabling them first. More... | |
| void | MoveBackward () |
| Drives every motor backward, enabling them first. More... | |
| void | TurnLeft () |
| Steers the vehicle left: left-aligned motors reverse and right-aligned motors drive forward. More... | |
| void | TurnRight () |
| Steers the vehicle right: left-aligned motors drive forward and right-aligned motors reverse. More... | |
| Motor * | GetMotor (int index) const |
| Gets the motor at the given index, or nullptr if the index is out of range. More... | |
Public Member Functions inherited from RumPi::BaseComponent | |
| BaseComponent () | |
| Builds a base component with an unknown type and an empty name. More... | |
| virtual | ~BaseComponent () |
| Virtual destructor so deleting a component through a BaseComponent* also cleans up the concrete subclass. More... | |
| virtual void | TurnOn ()=0 |
| Turns the component on (e.g. More... | |
| virtual void | TurnOff ()=0 |
| Turns the component off. More... | |
| virtual std::string | ToString () const =0 |
| Serializes the component's current readings to a string (usually JSON). More... | |
| virtual void | ProcessRawValues ()=0 |
| Reads and processes the component's latest raw values (called once per poll). More... | |
| virtual EComponentType | GetComponentType () const |
| Gets the component's type. More... | |
| const std::string & | GetName () const |
| Gets the component's unique per-instance name. More... | |
| void | SetName (const std::string &name) |
| Sets the component's unique per-instance name. More... | |
Private Attributes | |
| std::vector< Motor * > | myMotors |
| The motors this vehicle owns and drives. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from RumPi::BaseComponent | |
| static std::string | ComponentTypeToString (const EComponentType theComponentTypeToConvert) |
| Maps an EComponentType to its string name. More... | |
| static EComponentType | StringToComponentType (const std::string &theComponentTypeName) |
| Maps a type name back to its EComponentType (the inverse of ComponentTypeToString), so the client can turn the type carried on the wire back into a value it can look an icon up with. More... | |
Protected Attributes inherited from RumPi::BaseComponent | |
| EComponentType | myComponentType |
| The kind of component this is (set by each concrete subclass). More... | |
| std::string | myName |
| A unique per-instance name, assigned when the component is added to the manager. More... | |
A vehicle composed of several Motors, providing drive and steering by coordinating the motors it owns.
|
delete |
| RumPi::Vehicle::Vehicle | ( | const unsigned int | numberOfMotors, |
| const unsigned int * | motorPinNumbers = nullptr, |
||
| MotorAlignment * | motorAlignments = nullptr |
||
| ) |
Builds a vehicle, constructing one Motor per triplet of pin numbers (enable, drive-one, drive-two), with optional per-motor alignments.
| [in] | numberOfMotors | The number of motors to build. |
| [in] | motorPinNumbers | The motor pin numbers, ordered {En, DrvOne, DrvTwo} per motor. |
| [in] | motorAlignments | The per-motor alignments, or nullptr for none. |
|
virtual |
| Motor * RumPi::Vehicle::GetMotor | ( | int | index | ) | const |
Gets the motor at the given index, or nullptr if the index is out of range.
| [in] | index | The index of the motor to get. |
| void RumPi::Vehicle::MoveBackward | ( | ) |
Drives every motor backward, enabling them first.
| void RumPi::Vehicle::MoveForward | ( | ) |
Drives every motor forward, enabling them first.
|
overridevirtual |
No-op: a vehicle is an output device with no raw values to process.
Implements RumPi::BaseComponent.
|
overridevirtual |
Serializes every motor's description into one string.
Implements RumPi::BaseComponent.
| void RumPi::Vehicle::TurnLeft | ( | ) |
Steers the vehicle left: left-aligned motors reverse and right-aligned motors drive forward.
|
overridevirtual |
Turns the vehicle off by turning off all its motors.
Implements RumPi::BaseComponent.
| void RumPi::Vehicle::TurnOffMotors | ( | ) |
Turns off every motor the vehicle owns.
|
overridevirtual |
Turns the vehicle on by turning on all its motors.
Implements RumPi::BaseComponent.
| void RumPi::Vehicle::TurnOnMotors | ( | ) |
Turns on every motor the vehicle owns.
| void RumPi::Vehicle::TurnRight | ( | ) |
Steers the vehicle right: left-aligned motors drive forward and right-aligned motors reverse.
|
private |
The motors this vehicle owns and drives.