RumPi 1.0
A self-assembling C++ sensor & actuator library for the Raspberry Pi 5
RumPi::Vehicle Class Reference

A vehicle composed of several Motors, providing drive and steering by coordinating the motors it owns. More...

#include <Vehicle.h>

Inheritance diagram for RumPi::Vehicle:
[legend]
Collaboration diagram for RumPi::Vehicle:
[legend]

Public Member Functions

 Vehicle (const Vehicle &)=delete
 
Vehicleoperator= (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...
 
MotorGetMotor (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...
 

Detailed Description

A vehicle composed of several Motors, providing drive and steering by coordinating the motors it owns.

Author
Eddie O'Hagan
Date
8/13/2026

Constructor & Destructor Documentation

◆ Vehicle() [1/2]

RumPi::Vehicle::Vehicle ( const Vehicle )
delete

◆ Vehicle() [2/2]

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.

Author
Eddie O'Hagan
Date
8/13/2026
Vehicle vehicle(2, motorPinNumbers, motorAlignments);
Vehicle(const Vehicle &)=delete
Parameters
[in]numberOfMotorsThe number of motors to build.
[in]motorPinNumbersThe motor pin numbers, ordered {En, DrvOne, DrvTwo} per motor.
[in]motorAlignmentsThe per-motor alignments, or nullptr for none.

◆ ~Vehicle()

RumPi::Vehicle::~Vehicle ( )
virtual

Destroys the vehicle, turning it off and deleting the motors it owns.

Author
Eddie O'Hagan
Date
8/13/2026
Vehicle* vehicle = new Vehicle(2, motorPinNumbers);
delete vehicle;

Member Function Documentation

◆ GetMotor()

Motor * RumPi::Vehicle::GetMotor ( int  index) const

Gets the motor at the given index, or nullptr if the index is out of range.

Author
Eddie O'Hagan
Date
8/13/2026
Motor* motor = vehicle.GetMotor(0);
Parameters
[in]indexThe index of the motor to get.
Returns
The motor at that index, or nullptr if out of range.

◆ MoveBackward()

void RumPi::Vehicle::MoveBackward ( )

Drives every motor backward, enabling them first.

Author
Eddie O'Hagan
Date
8/13/2026
vehicle.MoveBackward();

◆ MoveForward()

void RumPi::Vehicle::MoveForward ( )

Drives every motor forward, enabling them first.

Author
Eddie O'Hagan
Date
8/13/2026
vehicle.MoveForward();

◆ operator=()

Vehicle & RumPi::Vehicle::operator= ( const Vehicle )
delete

◆ ProcessRawValues()

void RumPi::Vehicle::ProcessRawValues ( )
overridevirtual

No-op: a vehicle is an output device with no raw values to process.

Author
Eddie O'Hagan
Date
8/13/2026
vehicle.ProcessRawValues();

Implements RumPi::BaseComponent.

◆ ToString()

std::string RumPi::Vehicle::ToString ( ) const
overridevirtual

Serializes every motor's description into one string.

Author
Eddie O'Hagan
Date
8/13/2026
std::string data = vehicle.ToString();
Returns
A string describing all of the vehicle's motors.

Implements RumPi::BaseComponent.

◆ TurnLeft()

void RumPi::Vehicle::TurnLeft ( )

Steers the vehicle left: left-aligned motors reverse and right-aligned motors drive forward.

Author
Eddie O'Hagan
Date
8/13/2026
vehicle.TurnLeft();

◆ TurnOff()

void RumPi::Vehicle::TurnOff ( )
overridevirtual

Turns the vehicle off by turning off all its motors.

Author
Eddie O'Hagan
Date
8/13/2026
vehicle.TurnOff();

Implements RumPi::BaseComponent.

◆ TurnOffMotors()

void RumPi::Vehicle::TurnOffMotors ( )

Turns off every motor the vehicle owns.

Author
Eddie O'Hagan
Date
8/13/2026
vehicle.TurnOffMotors();

◆ TurnOn()

void RumPi::Vehicle::TurnOn ( )
overridevirtual

Turns the vehicle on by turning on all its motors.

Author
Eddie O'Hagan
Date
8/13/2026
vehicle.TurnOn();

Implements RumPi::BaseComponent.

◆ TurnOnMotors()

void RumPi::Vehicle::TurnOnMotors ( )

Turns on every motor the vehicle owns.

Author
Eddie O'Hagan
Date
8/13/2026
vehicle.TurnOnMotors();

◆ TurnRight()

void RumPi::Vehicle::TurnRight ( )

Steers the vehicle right: left-aligned motors drive forward and right-aligned motors reverse.

Author
Eddie O'Hagan
Date
8/13/2026
vehicle.TurnRight();

Member Data Documentation

◆ myMotors

std::vector<Motor*> RumPi::Vehicle::myMotors
private

The motors this vehicle owns and drives.


The documentation for this class was generated from the following files: