DEV Community

Daniel Ioni
Daniel Ioni

Posted on

๐Ÿ›ด Urban Lab: Building a Smart Scooter with AI and Reinforcement Learning"

๐Ÿ›ด Urban Lab: Building a Smart Scooter with AI and Reinforcement Learning

What happens when you combine 3D printing, open-source hardware, AI and reinforcement learning?

That's the idea behind Urban Lab, an experimental smart-mobility project developed in Rimini, Italy.

The project explores how accessible technologies can be combined to prototype a connected electric scooter platform.


๐ŸŽฏ The Vision

Urban Lab brings together:

  • ๐Ÿ–จ๏ธ 3D printing
  • โšก Electric mobility
  • ๐Ÿง  Artificial intelligence
  • ๐Ÿค– Reinforcement learning
  • ๐Ÿ“ก IoT sensors
  • ๐Ÿ”ง ESP32 hardware
  • ๐Ÿ“ฑ Mobile applications
  • ๐ŸŒ Open-source software

The goal isn't simply to build a scooter.

The goal is to create an open platform for experimentation.


๐Ÿง  Why Reinforcement Learning?

One of the most interesting areas we're exploring is Reinforcement Learning (RL).

Instead of explicitly programming every possible situation, an RL agent can learn a policy through interaction with a simulated environment.

For a smart mobility platform, interesting research areas include:

Challenge RL Research Direction
Dynamic control Policy optimization
Energy efficiency Reward optimization
Terrain adaptation Robust control
Braking Control optimization
Navigation Policy-based decision making

These are experimental research directions. Any deployment on a real vehicle requires extensive simulation, testing and safety validation.


๐Ÿ—๏ธ RL Architecture

The proposed architecture looks like this:


text
             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
             โ”‚   Scooter Sensors   โ”‚
             โ”‚ IMU / GPS / Battery โ”‚
             โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ”‚
                        โ–ผ
             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
             โ”‚  Simulation / RL    โ”‚
             โ”‚      Training       โ”‚
             โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ”‚
                        โ–ผ
             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
             โ”‚   Trained Policy    โ”‚
             โ”‚   ONNX / Runtime    โ”‚
             โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ”‚
                        โ–ผ
             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
             โ”‚   Edge Controller   โ”‚
             โ”‚       ESP32         โ”‚
             โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ”‚
                        โ–ผ
             โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
             โ”‚ Motor / Brake / I/O โ”‚
             โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
The important principle is to keep the training environment separated from the physical vehicle.

๐Ÿ“ฆ Technology Stack

The experimental software stack includes:

Python
Gymnasium
PyTorch
ONNX
ONNX Runtime
ESP32
C/C++
React Native

Where appropriate, RL libraries can be evaluated and integrated during development.

๐Ÿงช Simulation Environment

A simplified Gymnasium environment could represent the scooter using observations such as:

class ScooterEnv(gym.Env):
    """
    Example observation space:

    - speed
    - inclination
    - battery level
    - obstacle distance
    - motor RPM
    - motor temperature

    Example actions:

    - acceleration
    - braking
    - steering
    """

    def __init__(self):
        super().__init__()

    def reset(self, seed=None, options=None):
        pass

    def step(self, action):
        pass

The simulation environment is important because it allows us to test policies before considering physical deployment.

๐Ÿš€ PPO Training

One possible algorithm for experimentation is Proximal Policy Optimization (PPO).

Example configuration:

algorithm:
  name: PPO
  learning_rate: 0.0003
  n_steps: 2048
  batch_size: 64
  n_epochs: 10
  gamma: 0.99
  gae_lambda: 0.95
  clip_range: 0.2

network:
  architecture: mlp
  hidden_layers:
    - 256
    - 256
    - 128
  activation: tanh

training:
  total_timesteps: 1000000

These values are starting points for experimentation rather than guaranteed optimal parameters.

๐Ÿ–จ๏ธ 3D Printing

3D printing is another important part of Urban Lab.

Potential printed components include:

Component   Material
Electronics enclosure   PETG
ESP32 mount PLA/PETG
Battery enclosure prototype PETG
Cable management    TPU
Mudguards   TPU
Mechanical prototypes   PETG/ABS

Structural components must be properly engineered and validated before being used in a vehicle.

๐Ÿ“ก Sensors & Electronics

The experimental architecture includes:

Sensor  Example Purpose
GPS NEO-6M  Position
IMU MPU6050 Motion
Proximity   HC-SR04 Obstacle detection
NFC RC522   Authentication
Display OLED    Local status

The ESP32 provides a low-cost platform for connecting these components.

๐Ÿ’ป ESP32 Firmware

A simplified firmware architecture:

#include <Arduino.h>

struct ScooterState {
    float speed = 0;
    float battery = 100;
    float temperature = 25;

    bool isMoving = false;
    bool isLocked = false;
};

ScooterState scooterState;

void setup() {
    Serial.begin(115200);

    setupSensors();
    setupWiFi();
    setupBLE();
}

void loop() {
    readSensors();
    updateTelemetry();
    checkErrors();

    delay(100);
}

The firmware is designed around a simple pipeline:

Sensors โ†’ Processing โ†’ Telemetry โ†’ Decision Support

๐Ÿ“ฑ Mobile Application

A future mobile application can provide:

Battery monitoring
Vehicle status
Sensor information
BLE connectivity
GPS information
Maintenance notifications
AI-assisted diagnostics

Example:

const connectDevice = async (device) => {
    const connectedDevice = await device.connect();

    await connectedDevice
        .discoverAllServicesAndCharacteristics();

    const data = await readCharacteristic();

    setScooterData(parseData(data));
    setConnected(true);
};
๐Ÿ”ฌ Safety First

A smart vehicle is a safety-critical system.

For that reason, Urban Lab follows an important development principle:

Simulation first. Hardware testing second. Public-road operation only after appropriate safety and regulatory validation.

RL policies should never directly control a real vehicle without appropriate safeguards, limits, emergency controls and extensive validation.

๐Ÿ“ Project Structure
urban-lab-scooter/
โ”‚
โ”œโ”€โ”€ 3d-printing/
โ”‚   โ”œโ”€โ”€ stl-files/
โ”‚   โ””โ”€โ”€ slicer-profiles/
โ”‚
โ”œโ”€โ”€ rl/
โ”‚   โ”œโ”€โ”€ environments/
โ”‚   โ”œโ”€โ”€ configs/
โ”‚   โ””โ”€โ”€ scripts/
โ”‚
โ”œโ”€โ”€ firmware/
โ”‚
โ”œโ”€โ”€ app/
โ”‚
โ””โ”€โ”€ docs/
๐Ÿš€ Roadmap
Current
โœ… Project architecture
โœ… Hardware research
โœ… 3D-printing development
โœ… ESP32 development
๐Ÿ”„ RL experimentation
Next
โณ Simulation environment
โณ RL training
โณ Model evaluation
โณ Sensor integration
โณ Edge inference experiments
โณ Physical prototype testing
Future
๐ŸŒ Open datasets
๐Ÿค– Improved control policies
๐Ÿ“Š Telemetry dashboard
๐Ÿง  AI-assisted diagnostics
๐Ÿ›ด Advanced mobility experiments
๐Ÿค Contributing

Urban Lab is an open-source experiment.

You can contribute with:

๐Ÿง  AI / ML
๐Ÿค– Reinforcement Learning
๐Ÿ”ง Firmware
๐Ÿ“ก IoT
๐Ÿ–จ๏ธ 3D design
๐Ÿ“ฑ Mobile development
๐Ÿ“š Documentation
๐Ÿงช Testing

Issues and pull requests are welcome.

๐Ÿ”— Projects

Urban Lab

https://github.com/DanielIoni-creator/urban-lab

MyZubster

https://github.com/myzubster/myzubster

If you're interested in open-source AI, hardware and sustainable technology, follow the development and get involved.

๐Ÿ Final Thoughts

Urban Lab is an experiment at the intersection of:

Open Source ร— AI ร— Robotics ร— IoT ร— Sustainable Mobility

We're starting with a scooter, but the bigger objective is to build an open environment where hardware and software can evolve together.

Build. Simulate. Test. Improve. Share.

๐Ÿ›ด๐Ÿค–๐ŸŒฑ

Urban Lab โ€” Open-source mobility from Rimini.
Enter fullscreen mode Exit fullscreen mode

Top comments (0)