RL Robotics LabSearch ↗
Lesson / authored

Week 5 · Build: Data that preserves what happened

Session 2 of 4 · Measure motion · Phase 2

Plan about 15 minutes for explanation, 30 minutes for practical work and 10–15 minutes for documentation. A longer build may continue into the next session: stop safely, commit the current state and record the next check. Desktop simulations count as software evidence; label them clearly and record physical validation separately.

Engineering challenge

Can your reported speed withstand scrutiny of the timing and distance measurements? This session focuses on data that preserves what happened.

Before you start

The previous week’s recorded baseline and Week 4, Improve. For later sessions this week, retain the preceding session’s files and predictions.

Equipment: Desktop Python, editor, paper and ruler; for physical work, the configured 3pi+ 2040, clear floor mat and hardware checklist. Week 3 additionally uses the separate low-voltage LED circuit described in its procedure.

For any motion, verify the stop button, short time limit and clear floor area first. Keep the wheels raised for a new device program until its commands and stop behaviour are checked. A hazard or uncertain input is a reason to stop and document, not to force the trial to finish.

Theory and mathematics

Data that preserves what happened

A CSV is a plain-text table: one row per trial and one column per quantity. Include a trial identifier and units in column names. Keep the measured time separate from commanded duration; they answer different questions. A missing reading is not zero. Use a blank with a note explaining the missing value. Save a raw file unchanged, then create a separate analysis script. This preserves evidence if you later find a calculation mistake. Code-generated values must be labelled simulated or fictional rather than mixed with real trials.

Worked example — illustrative values

At d = 0.60 ± 0.01 m and t = 3.0 ± 0.2 s, v = 0.20 m/s. The conservative relative bound is 0.01/0.60 + 0.2/3.0 ≈ 0.083, giving roughly ±0.017 m/s. Report about 0.20 ±0.02 m/s, and say these are estimated bounds rather than a confidence interval.

Write the calculation in your notebook before running code. State which values you measured, which you assumed and which the program calculates. A correct numerical calculation cannot rescue an incorrect physical assumption.

Run and explain the model

The following is desktop Python, not a ready-to-run motor program. Download this week’s example, save it in your student repository and run python3 code/w05.py from the repository root. The same small model is reused across the week so you can learn it, build with it, test it and revise it.

# Desktop Python teaching example. Numerical inputs are illustrative.
from statistics import mean, stdev
rows = [(0.59, 3.0), (0.61, 3.1), (0.60, 2.9)]  # fictional
speeds = [distance / elapsed for distance, elapsed in rows]
print("mean_m_s", mean(speeds))
print("sample_sd_m_s", stdev(speeds))

Run the example on desktop Python before adapting it. Change one valid input and check the result; keep device-only calls in a separate adapter. If an exception appears, read its final line, identify the input or assumption that caused it and make the smallest explained correction. Do not delete validation merely to obtain output.

Understanding the model and its limits

Each tuple stores distance and elapsed time for one trial. The list comprehension divides within each trial before calculating the mean. Averaging all distances and all times first produces a different estimator when times vary; state which question you want to answer. Sample standard deviation uses n−1 because the mean was estimated from the same observations. The example has only three fictional trials. Replace them with your complete measured batch, keep the units and reject invalid times explicitly. A spread smaller than your timing uncertainty should not be interpreted as extraordinarily precise motion.

Practical instructions

  1. Create data/w05-trials.csv with trial,distance_m,time_s,command,notes columns.
  2. Use the previously checked bounded pulse to collect five trials in the same lane.
  3. Measure from the same robot reference point and retain all rows.
  4. Write a script that reads CSV, rejects nonpositive times and calculates a new speed column without overwriting raw data.

Experiment

Collect five baseline trials and independently recalculate one row. Compare measured elapsed time with commanded time without silently substituting one for the other.

Before testing, record your prediction, changed factor, measured response, fixed conditions and stopping rule. Save every attempted run, including failures, with a condition and source version. If hardware is unavailable, use an explicitly labelled synthetic/replay dataset and list the physical question it cannot answer. Do not invent completed trials.

Deliverable

Five raw rows and a separate reproducible analysis script with nonpositive-time validation.

Save notebook/w05-s2.md, the relevant code revision, raw CSV or test-case records, and one labelled diagram/plot/table. Link the files relatively from your notebook. Use the entry template and report guide.

Completion criteria

A documented failed prediction can meet the learning criteria. A missing physical trial must remain marked untested; software success alone does not validate the robot.

Reading and video

Reflection and next step

Which assumption most affected your result? Point to one observation that supports your explanation and one alternative explanation the evidence has not ruled out. Write a specific next test with a changed factor and measurable outcome, then proceed through the week’s Learn → Build → Experiment → Improve cycle.

← Previous sessionCourse roadmapNext session →