How teamaguarai/pampas works
Project type and purpose
• pampas is a C++ embedded-control library for Raspberry Pi that drives an RC car (motor + steering) and reads sensors (wheel pulse, IMU).
• It provides a hardware abstraction layer (HAL), control algorithms (PID, filters), and an API for user code.
File structure
• / & src/
• Public headers and implementations for each module:
– Drive (overall motion), PID (controller), Steer, Motor, PulseWidth, Velocimeter, MPU9250 (IMU), I2Cdev, gpio, Conversion, LowPass, operations, Writer, Exception.
• scripts/ & install
• Installation and wiringPi setup scripts for Raspberry Pi.
• testing/
• Unit tests for each module, verifying control loops, sensor reads, error handling, etc.
README
• Describes system: Raspberry Pi ↔ sensors (pulse, IMU via I2C) ↔ actuators (motor, steering servo).
• Shows example usage: configure Drive (PID + transfer function + motor pins + velocimeter), then run control loop.
• Points out compilation flags and dependencies: –lpampas –lwiringPi.
Components
a. Application Layer (user code)
– main.cpp (or external client), calls pampas::Drive, pampas::Velocimeter, etc.
b. Control Layer
– Drive module: orchestrates control loop
– PID module: computes control output
– Transfer functions & operations: polynomial regression, conversions
c. Sensor Abstraction Layer
– Velocimeter: reads pulse pin via gpio → measures wheel speed
– MPU9250 + I2Cdev: reads IMU over I²C bus
– LowPass: filters sensor noise
d. Actuator Abstraction Layer
– Motor + PulseWidth: generates PWM via gpio to motor driver
– Steer: generates PWM to steering servo
e. HAL & Platform Interfaces
– gpio: wrapper around wiringPi for pin I/O
– wiringPi (external) & I2C bus driver
f. External Hardware
– Raspberry Pi 3 (SOC, CPU, I/O headers)
– ESC / servo / motor assembly
– Hall-effect or IR sensor for wheel speed
– MPU9250 IMU sensor
Relationships & Data Flow
• Application Layer → invokes Control Layer (Drive.run())
• Control Layer ↔ Sensor Abstraction:
• starts velocimeter, waits for update → gets speed feedback
• reads IMU data continuously via I2Cdev → feeds into filters
• Control Layer → computes outputs via PID & transfer functions → passes commands to Actuator Layer
• Actuator Layer → uses gpio/PulseWidth to emit PWM signals → drives physical actuators
• Hardware sends back sensor signals → loop continues
Architectural patterns & design principles
• Layered architecture: clear separation between user code, control logic, HAL, and hardware
• Hardware Abstraction Layer (gpio, I2Cdev) to isolate platform details
• Single Responsibility: each class (Motor, Velocimeter, PID) has one focus
• Feedback control loop: real-time sensing → compute → actuate → sense