A modular MATLAB/Simulink control stack for a differential-drive robot, covering the path from motor identification and low-level control to odometry, autonomous path following, and reactive obstacle avoidance. The same control architecture can switch between an identified plant model and an Arduino Mega 2560 hardware target.
This project was developed during a 2023 Mobile Robotics Laboratory course and later extended with a scanning ultrasonic sonar.
| Area | Implementation |
|---|---|
| Embedded robotics | Arduino I/O, PWM motor actuation, encoder acquisition, and fixed-step execution |
| System identification | Discrete motor transfer functions derived from measured encoder responses |
| Feedback control | Per-wheel closed-loop speed control and robot orientation control |
| Robot modelling | Direct/inverse differential-drive kinematics and odometry |
| Autonomous navigation | Pure Pursuit waypoint tracking and a custom MATLAB Function alternative |
| Reactive behaviour | Stateflow-based obstacle avoidance using infrared distance sensors |
| Model-Based Design | Reusable subsystem references and a hardware/simulation variant architecture |
| Experimental extension | Servo-driven ultrasonic scanning, obstacle localisation, and serial polar visualisation |
flowchart LR
WP[Waypoints] --> PP[Pure Pursuit]
IR[Infrared sensors] --> OA[Stateflow obstacle avoidance]
SONAR[Optional scanning sonar] -.-> OA
PP --> ARB[Command arbitration]
OA --> ARB
ARB --> MCI[Inverse kinematics]
MCI --> CTRL[Wheel-speed control]
CTRL --> VAR{Plant variant}
VAR -->|Simulation| TF[Identified motor models]
VAR -->|Hardware| HW[Arduino + motors]
HW --> ENC[Wheel encoders]
TF --> MCD[Direct kinematics]
ENC --> MCD
MCD --> ODO[Odometry]
ODO --> PP
The separation between navigation, kinematics, control, plant, and sensing makes it possible to test algorithms in simulation before deploying the same model structure to the robot. See the model and architecture guide for the complete inventory.
The final model combines waypoint tracking, odometry, speed control, infrared sensing, a Stateflow avoidance supervisor, and a simulation/hardware plant variant.
The optional extension mounts an ultrasonic sensor on a servo and visualises angle–distance measurements as a polar scan:
The models were authored in MATLAB/Simulink R2023b. Use R2023b or a newer compatible release with:
- MATLAB and Simulink
- Robotics System Toolbox for the Pure Pursuit block
- Simulink Support Package for Arduino Hardware for deployment and Arduino blocks
- Stateflow for the behaviour supervisors
System Identification Toolbox is useful for repeating the motor-identification workflow, but the identified motor models are already included.
- Clone or download the repository.
- Open MATLAB in the repository root.
- Open
AngelPieroProject.prj. - Start with
Modelos/PieroFinalProject.slxfor the integrated baseline. - Select the simulated or hardware plant variant in the model before running it.
From the MATLAB Command Window:
openProject("AngelPieroProject.prj");
open_system("Modelos/PieroFinalProject.slx");To check that every committed model can be loaded:
addpath("scripts");
results = validateProject;
assert(all(results.Loaded));Hardware deployment additionally requires the PIERO platform (or equivalent differential-drive hardware), an Arduino Mega 2560, motors with encoders, motor drivers, and compatible distance sensors.
| Path | Contents |
|---|---|
Modelos/ |
Top-level experiments and integrated navigation models |
Subsistemas/ |
Reusable control, plant, sensing, kinematics, and odometry components |
Data/ |
Encoder S-function source, wrapper, TLC file, and Windows MEX binary |
Funciones/ |
MATLAB sonar visualisation utility |
Tareas/ |
Eight illustrated engineering notes in Spanish |
docs/ |
Architecture guide and the original weekly development journal |
scripts/ |
Non-destructive model-load validation |
- Model and architecture guide
- Engineering tasks / prácticas (Spanish)
- Optional sonar project (Spanish)
- Original development journal (Spanish)
This repository is Ángel Muñoz Rocha's personal project record from a collaborative university laboratory. It includes his development notes, model integration work, Arduino/Simulink investigation, sensor work, and the individual sonar extension. The journal preserves the original team context and contributions.