Loading the 3D robot…

PRONTO student project · IMT Atlantique

A team of five: Valentin Lachaise · Marin de Vanssay · Xhanet Lekaj · Kellian Bailleul · Malo Guillard

The rolling base that follows the line and carries ten times its mass.

20 kg
maximum load
< 2 kg
on the scale
10×
its own mass, and more

01 · Assembled

A compact robot, sturdy, light.

Four printed modules make up the chassis, a 5 mm plywood plate takes the load. Under 2 kg to carry 20 kg.

1 / 4 · keep scrolling

Design

Choices, and the reasons behind them.

The robot has to carry 20 kg while weighing under 2 kg. Every decision about shape or material answers that constraint.

Dimensions

34 × 24.5 × 11.2 cm

Length, width and height measured on the 3D model, wheels included. The plywood plate itself measures 32 × 22 cm.

34 cm24.5 cm11.2 cm

top view · side view

Four wheels

Four contact points, a stable load.

Two driven wheels at the front, two free castors at the back. The four contacts draw a wide quadrilateral under the plate: the load stays above that surface, even when turning or braking, and the robot does not tip with 20 kg. The two driven wheels also let it pivot on the spot.

  • driven wheel
  • free castor

view from below · front on the right

Material

Printed PLA, shapes made to measure.

The chassis is printed in PLA. Solid, PLA is denser than plywood; but a printed part is not solid: with a partial infill it becomes lighter than the same part in wood. Above all, printing lets each module take the exact shape of the components it holds: the inside is fitted as tightly as possible, which cuts wasted space, so material, so mass. Plywood is kept for flat panels (plate, sides), laser-cut.

  • Birch plywood≈ 0.65 g/cm³
  • Solid PLA≈ 1.24 g/cm³
  • Printed PLA, 20 % infill≈ 0.25 g/cm³

Typical values, as an order of magnitude; the printed walls come on top of the infill.

Camera

Tilted at 45°, inside the useful volume.

The camera looks at the floor ahead of the robot, tilted at 45°. That way it sits inside the volume the chassis already uses instead of sticking out: less structure around it, so less mass. Its oblique image is then put back into the robot's frame by the program.

See the image processing
45°
tilt
40 × 30
pixels read
OV7670
module

Line following

A black line. One heading.

Keep scrolling: the floor runs under the robot, which steers to stay on it. The red trace is what its camera detects; the dashboard replays, with the same calculation, what the Pico sees and decides.

Step 1 / 3

See

The OV7670 camera films the floor at 40 × 30 pixels. Each row is thresholded with its own level: the black line stands out even when the lighting changes.

Step 2 / 3

Decide

The Pico runs a linear regression on the black pixels: it gets a straight line whose slope a says whether the line turns, and whose offset b says whether the robot is off to the side.

Step 3 / 3

Act

correction = 1.5 × b + 4 × a, added to one wheel and subtracted from the other: the robot straightens itself out. The coefficients 1.5 and 4 were found empirically, by successive trials on the course.

Finish. Hands-free.

Pico's view

Line detected

Left motor23 %
Right motor23 %

Code

From the image to wheel speed.

The program runs on the Pico, in CircuitPython. For every image the camera gives two numbers, a (the slope of the line) and b (how far off the robot is), and the code turns them into the speed of each wheel. Set a and b yourself and watch what each wheel does.

The control law
correction
= 1.5 × b + 4 × a
= 1.5 × (+0.0) + 4 × (+0.0) = +0.0
left wheel
= 23 + correction = 23 %
right wheel
= 23 − correction = 23 %
Left wheel23 %

PWM 24 % for 96 ms, then stopped for 4 ms

Right wheel23 %

PWM 24 % for 96 ms, then stopped for 4 ms

Why the wheels “pulse”

Below 24 % PWM the motors do not move the robot on the floor: that is the dead zone. To go slower, the code keeps a 24 % PWM but only powers the motor for a fraction of each 100 ms period, then cuts it. On average the speed is the one asked for. Even on a straight line, with 23 instead of 24, each wheel stops for 4 ms every period.

What about PID?

A proportional correction, not a full PID.

A PID adds to the proportional correction (P) a term that accumulates the error (I) and a term that follows how fast it changes (D). The final code only uses P: the offset measured by the camera, multiplied by a coefficient, directly gives the speed difference between the two wheels.

  • P
    Proportionalin the code

    Corrects harder the larger the error is: it is the line “correction = 1.5 × b + 4 × a”.

  • I
    Integralnot used

    Would accumulate the error over time to wipe out an offset that stays, for example one motor slightly weaker than the other.

  • D
    Derivativenot used

    Would ease the correction off when the error shrinks quickly, so the robot stops weaving around the line.

As for the wheel speed, it is not regulated: the motors carry a 12-counts-per-turn encoder, but the final program does not read it. The camera closes the loop, image after image: if a wheel is too slow, the line drifts in the image and the next correction catches it up.

Image processing

A camera at 45°, an image put back upright.

the robot made transparent · only the camera is in colour

Tilted at 45°, the camera fits inside the robot's useful volume instead of sticking out: less structure around it, so less mass. In return its image is oblique: the near floor fills the bottom of the image, the far floor, narrower, the top.

  1. 1

    Capture

    The OV7670 is read at 40 × 30 pixels. The code flips the image vertically (flip_y): the bottom row is the floor closest to the robot, the top row the farthest.

  2. 2

    Binarise

    Each row has its own threshold, halfway between its darkest and lightest pixel, if the contrast exceeds 30. The black line becomes 0, the rest 255.

  3. 3

    Back into the robot's frame

    Each black pixel gets two coordinates in the robot's frame: v, the distance ahead (v = height − 1 − row) and u, the side (u = centre − column).

  4. 4

    Fit a line

    A linear regression u = a·v + b gives the slope a and the offset b. Three columns on each side and two rows at the top and bottom are ignored.

  5. The program does not correct the perspective with a geometric transform: the coefficients 1.5 and 4, tuned by trial on the course, make up for the effect of the tilt.

Excerpt of the final program

Download the code
def guider(a, b):
    correction = COEFF_DECALAGE * b + COEFF_ANGLE * a

    vd = max(0, min(100, VITESSE_BASE - correction))
    vg = max(0, min(100, VITESSE_BASE + correction))

    ratio_d = min(1.0, vd / DEAD_ZONE) if vd > 0 else 0.0
    ratio_g = min(1.0, vg / DEAD_ZONE) if vg > 0 else 0.0

    pwm_d = vd if vd >= DEAD_ZONE else DEAD_ZONE
    pwm_g = vg if vg >= DEAD_ZONE else DEAD_ZONE

    t_on_d = PERIODE_MS * ratio_d / 1000.0
    t_on_g = PERIODE_MS * ratio_g / 1000.0
    ...

Interface

One button, one LED, one screen.

All the controls sit on the robot's right side. Plug in the battery, press the button, vary the charge: the LED and the screen react like on the robot.

Right side · 5 mm plywoodunpowered
The panel is on the right side, with the camera side up.

Power

Battery unplugged

86 %
Greenabove 20 %
Orange20 % or less
Red10 % or less

Course events

No battery: screen off, LED off. Plug it in to start the robot.

Program states

Waiting

Motors stopped. The robot waits for a press.

Running

The line is seen: the robot follows it.

Searching

Line lost: it backs up while turning to find it again.

Arrived

Black floor across the whole image: end of course, LED steady.

  • Waiting → Running (button)
  • Running → Searching (line lost)
  • Searching → Running (line found again)
  • Running → Arrived (black floor)
  • Arrived → Waiting (button)
Button · GP22
On / off
LED · GP28
Green · orange · red
Screen · GP26 · GP27
1.3″ OLED SH1106
Battery · ADC
Voltage read by the analog input

Line_following_macro_PWM.py · excerpt

def reg_lin_pico(buffer, width, height):
    # line u = a*v + b over the black pixels (v: distance, u: side)
    for j in range(2, height - 2):
        for i in range(3, width - 3):
            if buffer[i + width * j] == 0:
                v = height - 1 - j
                u = (width - 1) / 2.0 - i
                n += 1; sum_x += v; sum_y += u
                sum_xx += v * v; sum_xy += v * u
    a = (n * sum_xy - sum_x * sum_y) / (n * sum_xx - sum_x ** 2)
    b = (sum_y - a * sum_x) / n
    return a, b

def guider(a, b):
    correction = COEFF_DECALAGE * b + COEFF_ANGLE * a
    vd = max(0, min(100, VITESSE_BASE - correction))
    vg = max(0, min(100, VITESSE_BASE + correction))
VITESSE_BASE = 23 · COEFF_ANGLE = 4.0 · COEFF_DECALAGE = 1.5 · DEAD_ZONE = 24 % · period 100 ms

Battery → screen

From voltage to percentage.

The robot does not “know” how much is left: it measures the battery voltage, then works out a percentage. The emptier the LiPo, the lower its voltage.

  1. 1

    Measure

    A 3S LiPo reaches 12.6 V, but the Pico's analogue input only accepts 3.3 V. A pair of resistors divides the voltage (here by 4, as an example).

  2. 2

    Read

    The analogue-to-digital converter gives a number from 0 to 65,535 for 0 to 3.3 V. The battery voltage is then worked back from it.

  3. 3

    Convert

    Between 9.9 V (empty, 3.3 V per cell) and 12.6 V (full, 4.2 V per cell), the percentage is a simple rule of three.

  4. 4

    Display

    The screen shows the battery and its percentage; the LED is green, orange under 20 % and red under 10 %.

Pico input
2.90 V
Value read
57,591
Percentage
63 %
LED
green

percentage = (voltage − 9.9) ÷ (12.6 − 9.9) × 100

Two precautions: the voltage sags when the motors draw current, so the reading is smoothed over several samples; and a LiPo's discharge is not a straight line, so the rule of three remains an approximation.

In the downloadable program (macro-PWM) the screen still shows “-- %”: the conversion above is the principle of the gauge, not a line of that file.

Battery life

A few hours, depending on the load.

The 3S LiPo battery stores 11.1 V × 3.7 Ah ≈ 41 Wh. Battery life is that energy divided by what the robot draws on average.

usable battery life

≈ 3.0 h

usable · 80 %reserve · 20 %

The same current would drain the battery in 3.7 h, but a LiPo is not taken down to zero: the 20 % reserve protects it.

This is a calculation, not a measurement: the average current depends on the load, the speed and the course, and has not been recorded on the robot. An ammeter in series with the battery would give the real value.

The battery's 35C allows about 130 A: far beyond what the robot asks for.

Manufacturing

From the file to the part.

The robot was not bought ready-made: almost everything that holds it together was drawn, printed or cut on site.

01SolidWorksBlender

Modelled

More than thirty parts drawn one by one, then brought together in a full assembly: motors, board, battery, fasteners. Blender produces the render.

02Bambu LabPLA 1.75 mm

Printed

Chassis in four modules, three generations of wheel, spacers and mounts: everything comes off the school's FabLab printers.

03Inkscape5 mm laser

Cut

Plate and side panels in 5 mm plywood, drawn in Inkscape and cut in the same FabLab, on a 350 × 350 mm sheet.

Every part, and its place in the robot.

3D model exported from the robot's Blender file.

Preparing the 3D viewer…
350 mm

Laser cutting

One sheet, a single pass.

The plate, the five side panels and the button disc come out of the same 5 mm plywood panel, with the LETHALBOT and IMT Atlantique engravings and the on / off symbol. Holes first, outlines after: the parts do not move until they are finished.

Sheet
350 × 350 mm
Material
5 mm plywood
Software
Inkscape
Engravings
3: name, school, button
The laser is cutting…
Cut Engraving

Build log

Eleven weeks, several versions.

Reconstructed from the dates of the CAD files: you can watch the parts mature, from the first wheel to the last touch-up. The first versions of the robot were made quickly, so the code could be tested for real; the adjustments came afterwards, and the code went through three versions.

  1. February 123D printing

    The first parts come out

    Wheel, lid screw, motor holder: the small parts are checked first, before the chassis. The first versions of the robot are made quickly, just enough to test the code on the real robot.

  2. February 27Iteration

    Wheel V2, final covers

    The wheel goes to its second version, the four covers reach their final shape.

  3. Late February · code V1CircuitPython

    First version: macro-PWM, coefficients to tune

    The camera is read at 40 × 30 pixels, a line is fitted to the track and corrects the two wheels with coefficients of 5 and 2. Below 24 % PWM the motors do not move the robot: the code pulses them over 150 ms periods. The arrival is confirmed after five images without a line.

  4. March 14 – 19SolidWorks

    Chassis in four modules

    The chassis is split into four parts that are easier to print. Two series, the second one is the right one.

  5. March 24Laser cutting

    The sheet goes to the laser

    Plate, side panels and button disc drawn in Inkscape, with the LETHALBOT and IMT Atlantique engravings, cut from 5 mm plywood.

  6. March 26Assembly

    The whole robot exists

    The complete assembly is built in SolidWorks with motors, board, battery and fasteners.

  7. March 30 · code V2CircuitPython

    Constant speed, searching for the line

    The motors run continuously at 21 %, without pulsing, and the coefficients become 4 and 1.5. Two additions: a search state (the robot backs up while turning to find the line) and an arrival detected by a completely black floor. The binarisation threshold becomes global over the image.

  8. April 3Blender

    Exploded view render

    The robot's explosion animated in Blender: the one you scroll through at the top of this page.

  9. April 25 · final codeCircuitPython

    Macro-PWM, per-row threshold: the robot's program

    Back to macro-PWM, at 23 % over a 100 ms period, with the per-row threshold of the first version and the two additions of the second. It is the program the robot runs, downloadable below.

  10. April 28 – 30Finishing

    Wheel V3, last touch-ups

    The wheel goes to its third version and gets its sandpaper strip: the robot is finished.

Parts

Everything that is in the robot.

20 lines read off the final product model: what is in the animation, nothing more. Filter, search, open a card: a click on the reference copies it.

  • Computing & vision

    Raspberry Pi Pico W

    RP2040CircuitPython
  • Computing & vision

    OmniVision CMOS camera

    640 × 480 maxread at 40 × 3030 frames/s
  • Computing & vision

    Perfboard (breadboard)

    ≈ 170 × 55 mm
  • Power

    LiPo battery

    11.1 V3,700 mAh35C max138 × 26 × 44 mm
  • Power

    Digilent dual H-bridge

    2 DC motors12 V
  • ×2Power

    Digilent gear motor

    12 V1:19 reduction12-count/turn encoder
  • Interface

    JOY-IT OLED display

    1.3 inchI²CSH1106132 × 64
  • Interface

    Weltron push button

    Push button
  • Interface

    Green / red LED

    Ø 5 mmGP28
  • ×4Structure

    Chassis modules

    Black PLA4 parts
  • ×4Structure

    Chassis covers

    Black PLA
  • ×7Structure

    Plate and side panels

    5 mm1 plate + 5 panels + 1 disc
  • ×10Structure

    Printed mounting parts

    White / black / red PLA
  • ×2Wheels & drive

    Printed wheels

    Ø 60 mmWhite PLA
  • ×2Wheels & drive

    Sandpaper strip

    1 strip per wheelgrip
  • ×2Wheels & drive

    Caster wheels with mounting plate

    Ø 40 mmH 60 mm42 × 42 plate32 mm hole spacing
  • ×24Fasteners & material

    Hex-head screws

    24 screws3 diameters
  • ×24Fasteners & material

    Hex nuts

    24 nuts
  • ×16Fasteners & material

    Washers

    16 washers
  • Fasteners & material

    PLA filament, 1.75 mm

    1.75 mmblack · white · red

Electronics

Who talks to whom.

Simplified block diagram, with the real Pico pins from the final wiring. Red is energy; grey is signals. Hover a block: its links light up.

LiPo 3S11.1 V · 3,700 mAhRaspberry Pi Pico WCircuitPythonOV7670GP0 – GP131.3″ OLEDGP26 · GP27 · I²CButtonGP22 · on / offGreen / red LEDGP28PmodDHB1GP14 – GP172 × IG22001912 V · 1:19 · encoder
Energy SignalsClick a block to lock it
GP 0 – 13
OV7670 camera
GP 14 – 21
Motors (H-bridge)
GP 22
Start button
GP 26 – 27
OLED screen (I²C)
GP 28
Green / red LED
ADC
Battery voltage

CircuitPython

Raspberry Pi Pico W

Reads the camera (GP0 to GP13), computes the correction, drives the H-bridge (GP14 to GP17) and shows on the screen (GP26, GP27).

Figures

Light on the scale, tough under load.

20 kg

Maximum load

carried by the plywood plate

< 2 kg

Empty mass

battery and electronics included

11.1 V

LiPo 3S battery

3,700 mAh · 35C max

1:19

Motor reduction

with a 12-count-per-turn encoder

30 i/s

OV7670 camera

read at 40 × 30 pixels

5 mm

Plywood

plate and five side panels

8 kg

Load test

Put something on it.

8kg×4 its mass
020 · max26

Sources

The files, as I made them.

The complete assembled robot, then every part: the SolidWorks models, the Blender animation, the Inkscape drawings, the parts to print and the code can be downloaded, opened and modified. Part by part, the “Download the part” button is in the Manufacturing section.

32 files · 11.9 MB

SolidWorks

The 30 parts and the complete assembly.

1 file · 1.7 MB

Assembled robot

The 30 parts in a single STEP file.

2 files · 6.8 MB

Blender

The exploded-view animation.

2 files · 198 KB

Inkscape

Laser cutting, engravings, logo.

30 files · 3.5 MB

3D printing

One STL file per part.

3 files · 9 KB

Code

The 3 programs of the Pico W.

Reassembled

Everything fits. Ready to roll.

About a hundred parts, a robot that fits in your hands and carries twenty kilos.