Contact us

Programming for Robotics

Core 3 takes learners from the Linux terminal to a ROS 2 node driving a simulated rover. Every learner finishes with one GitHub repository of code they wrote themselves.

See the eight weeksView the capstone
Duration
8 weeks
Sessions
2 per week
Each session
2 hours

How the course runs

Core 3 teaches learners to write, organise and run the code that sits under a robot. It runs for eight weeks with two sessions a week, which makes 16 sessions of two hours each.

Each two-hour session

  • 15 min Review of the last session and questions on the task
  • 45 min Live teaching, with learners typing along
  • 50 min Practical work, with the instructor moving around the room
  • 10 min Wrap-up and next task

Who it is for

No prior programming experience is needed. Learners need a laptop that can run Ubuntu 24.04 (native install, dual boot, WSL2 or a virtual machine) and secondary school mathematics for the kinematics in Week 7.

Ground rules

  • Code is typed, not pasted.
  • From Week 4 onward every task is submitted through Git.
  • Questions are asked early, because a small gap in Week 2 becomes a large one in Week 5.
  • Every week opens with Fix My Code, a short exercise that gives learners a headstart on the errors to expect that week.

By the end of Week 8 a learner can

  • Move around a Linux system, search it, and automate work with Bash scripts
  • Write Python programs using functions, collections, classes and modules
  • Use Git and GitHub with branches, pull requests and merge conflict resolution
  • Read and write CSV, JSON and YAML files, and handle errors in the process
  • Simulate a differential-drive robot, plot its data, and test the code with pytest
  • Publish and subscribe to topics in ROS 2 with rclpy, and view the data in RViz2
  • Combine all of this in one working Python package at the Week 8 capstone

The eight weeks

Each week lists what is taught, what happens in the two sessions, and what learners hand in.

Week 1

The Linux Terminal

Work comfortably in a Linux terminal, find your way around the file system, and process text with pipes and basic tools.

Session activities

Session 1

Build the workspace ~/aurora/core3/week1 with folders for notes, data, scripts and logs, using only the terminal.

Session 2

Analyse a 2,000-line robot log supplied by the instructor: count errors per hour, list every motor controller warning, and extract the timestamp of each battery reading below 20%.

Key concepts

  • Why robotics runs on Linux: ROS, hardware drivers, boards such as the Raspberry Pi and Jetson
  • Setup clinic: native Ubuntu, dual boot, WSL2, virtual machine
  • File system layout: /, /home, /etc, /usr, /dev; absolute and relative paths
  • Navigation and file commands: pwd, ls, cd, mkdir, touch, cp, mv, rm, cat, less, man
  • Tab completion and command history
  • Users, groups and file permissions: chmod, sudo
  • Redirection and pipes: >, >>, |
  • Text tools: grep, find, head, tail, wc, sort, cut
  • Environment variables, PATH, installing software with apt

Homework

Rebuild the workspace on your own machine and run the Session 2 log analysis again on a second log file.

Deliverable

A text file with the commands used and a one-paragraph explanation of what each pipeline does.

Week 2

Python Basics

Write short Python programs that make decisions and repeat actions.

Session activities

Session 1

Write a unit converter for degrees and radians, metres and feet, and rpm to rad/s. Then write a classifier that labels a motor speed as idle, cruising or overspeed.

Session 2

Write a battery drain simulator where the charge falls faster under load and the loop stops at 10%. Then print a formatted speed table for a motor from 0 to 100% in steps of 10.

Key concepts

  • Running Python: installing Python, the REPL, script files, virtual environments with venv
  • Variables and types: numbers, strings, booleans, type conversion
  • Output formatting: f-strings and format specifiers such as :.2f and :08.3f
  • Decisions: comparison operators, if, elif, else, input()
  • Loops: for with range, while, break, continue, nested loops
  • Common faults: infinite loops, off-by-one errors, changing a list while looping over it

Homework

Finish the obstacle alarm. The program reads distances typed by the user until they enter q, prints a status for each reading (clear, caution or stop), and prints a summary showing the closest reading and how many stops were triggered.

Deliverable

A .py file that runs without errors, with commented code.

Week 3

Data Structures and Functions

Store sensor data in the right structure and package logic into functions.

Session activities

Session 1

Store a robot's waypoints as a list of tuples, keep sensor readings in a dictionary keyed by sensor name, and remove duplicate sensor IDs with a set.

Session 2

Refactor the Week 2 obstacle alarm into functions. Write moving_average(), clamp() and distance_between().

Key concepts

  • Collections: lists, tuples, dictionaries, sets, and choosing between them
  • Indexing, slicing, common methods, sorting with a key
  • Nested structures and looping over dictionaries
  • Comprehensions: list and dictionary
  • Functions: def, parameters, return values, default and keyword arguments, *args and **kwargs
  • Scope, docstrings, type hints
  • lambda, map and filter
  • Reading CSV files with the csv module

Homework

LiDAR scan analysis. Read the supplied CSV of range readings, drop invalid values such as inf and 0, then report the minimum, maximum and mean range and the angle of the closest object.

Deliverable

A .py script built from functions, with commented code, run against the supplied CSV.

Week 4

Git, GitHub and Modules

Keep work under version control and split code across files.

Session activities

Session 1

Create the repository core3-programming-robotics. Move Weeks 1 to 3 into it and commit them in logical pieces.

Session 2

Create a merge conflict on purpose with a partner and resolve it. Then split the Week 3 LiDAR script into a module and a main script.

Midpoint check

A 20-minute written quiz on Weeks 1 to 4, followed by a live inspection of each repository for commit history, folder structure and whether the code runs from a fresh clone.

Key concepts

  • The version control model: working directory, staging area, repository history
  • Core commands: init, status, add, commit, log, diff
  • .gitignore and commit messages someone else can follow
  • GitHub: remotes, push, pull, clone, SSH keys
  • Branches, merging and merge conflicts
  • Pull requests and reviewing a classmate's work
  • Python modules and imports: if __name__ == '__main__', project layout
  • File handling: open and with; exceptions with try and except

Homework

Open a pull request that moves the LiDAR analysis into a module with a separate main script, and fix anything the midpoint check flagged.

Deliverable

A GitHub repository link with Weeks 1 to 3 committed in logical pieces, plus the pull request.

Week 5

Object-Oriented Programming

Model sensors and actuators as classes. This week starts the capstone.

Session activities

Session 1

Write a Sensor class with a name, unit, valid range and a read() method that adds simulated noise.

Session 2

Build DistanceSensor, BatterySensor, TemperatureSensor and ImuSensor from the Sensor base. Build Motor and Servo from an Actuator base. Write a Robot class that holds lists of each.

Key concepts

  • Classes and objects: __init__, attributes, methods, __repr__
  • Encapsulation: properties and input validation
  • Inheritance: super(), abstract base classes with abc
  • Polymorphism
  • Composition: a Robot has sensors and actuators
  • Simulated sensor noise

Homework

Capstone milestone 1. Build the rover package skeleton with the Sensor, Actuator and Robot classes and a robot.step() method that reads every sensor once. Keep the classes tidy, because the AI in Robotics track reuses them.

Deliverable

A pull request against main containing the rover skeleton, with commented code.

Week 6

Scripting and Automation

Automate runs of the program from the shell and from Python.

Session activities

Session 1

Write run_experiments.sh, which runs the rover at five different speeds and saves each log to its own file.

Session 2

Add a command line to the rover, for example: python -m rover --config robot.yaml --steps 200 --log out.csv

Key concepts

  • Bash scripting: shebang lines, variables, arguments, if, for, functions
  • Exit codes and stopping a script when a command fails
  • Scheduled jobs: cron basics
  • Command-line options with argparse
  • Logging: the logging module and its levels
  • Configuration files: JSON and YAML
  • Writing CSV, pathlib, subprocess basics

Homework

Capstone milestone 2. Add the command line, a YAML config describing the robot's sensors, and a CSV log written by the logging module.

Deliverable

A pull request where the full project runs from a fresh terminal with one command and no edits to the source.

Week 7

Simulation, Plotting and Testing

Simulate motion, view the results, and prove the code works.

Session activities

Session 1

Plot the Week 3 LiDAR scan in polar and Cartesian form. Plot a noisy signal against its moving-average version.

Session 2

Implement DiffDriveRobot.update(dt). Plot the path for a square and a circle. Write at least 8 tests covering the sensors and the kinematics.

Install clinic

The last 20 minutes of Session 2 are for anyone stuck installing ROS 2 Jazzy.

Key concepts

  • NumPy: arrays, shapes, slicing, vectorised operations
  • matplotlib: line plots, scatter plots, subplots, saving figures
  • Differential-drive kinematics: wheel speeds to linear and angular velocity, pose update with dt
  • A 2D world: walls, collision check, obstacle behaviour
  • pytest: assertions, fixtures, parametrize

Homework

Capstone milestone 3. Add the 2D simulation with the obstacle behaviour (stop or turn when the distance sensor reads under 0.5 m). Install ROS 2 Jazzy before Week 8.

Deliverable

A saved path plot, a green pytest run, and the updated pull request.

Week 8

ROS 2 and Capstone Demos

Connect the Python code to ROS 2 and present the finished project.

Session activities

Session 1

Wrap the rover in a node that publishes the distance sensor as sensor_msgs/Range and subscribes to cmd_vel to drive the simulation.

Session 2, first hour

Final build time and code review in pairs, each learner reading a partner's repository against the capstone requirements.

Session 2, second hour

Demos of five minutes each with two minutes of questions. Cohorts above 15 submit a short recorded video instead.

Key concepts

  • ROS 2 basics: nodes, topics, messages, the ROS graph
  • Workspaces and colcon
  • Command-line tools: ros2 run, ros2 topic list, ros2 topic echo
  • turtlesim, then an rclpy publisher and subscriber
  • Viewing data in RViz2
  • Capstone review: pair code review against the requirements

Homework

Finish the capstone and push the final version to GitHub.

Deliverable

The capstone repository link, a README and a demo. The instructor clones the repository fresh and runs it from the README alone.

Capstone project: the rover package

The capstone is built in pieces from Week 5 to Week 8. Each learner produces a Python package called rover in their own repository, and the instructor clones it fresh and runs it from the README alone.

The package must include

  • Sensor and Actuator base classes with at least two subclasses of each
  • A Robot class that holds its sensors and actuators and advances one time step at a time
  • A 2D differential-drive simulation with walls and obstacles
  • An obstacle behaviour: the robot stops or turns when the distance sensor reads under 0.5 m
  • A command-line interface, a config file and CSV logging
  • At least 8 passing pytest tests
  • A README that tells a stranger how to install and run it
  • A commit history of at least 15 meaningful commits and one merged pull request
  • A ROS 2 node that publishes the rover's distance readings and subscribes to velocity commands

Milestones

  1. Week 5: the package skeleton with Sensor, Actuator and Robot
  2. Week 6: command line, YAML config and CSV logging
  3. Week 7: 2D simulation, obstacle behaviour, path plot and tests
  4. Week 8: ROS 2 node, pair review and a five-minute demo

Tools and platforms

Everything is free to install and runs on a standard laptop.

  • Ubuntu 24.04Linux environment for the whole course: native, dual boot, WSL2 or virtual machine (Weeks 1 to 8)
  • BashTerminal commands, pipes, text tools and shell scripting (Weeks 1, 6)
  • Python 3.12Core language for all programming work (Weeks 2 to 8)
  • Python standard librarycsv, argparse, logging, json, pathlib and subprocess (Weeks 3 to 6)
  • PyYAMLReading robot configuration files (Week 6)
  • Git and GitHubVersion control, branches, pull requests and task submission (Week 4 onward)
  • VS CodeCode editor and integrated terminal (Weeks 2 to 8)
  • NumPy and matplotlibArray maths and plotting of sensor and path data (Week 7)
  • pytestAutomated testing of sensors and kinematics (Week 7)
  • ROS 2 Jazzy and RViz2Nodes, topics, rclpy and data visualisation (Week 8)

Assessment

How learners are graded

Weekly tasks40%
Midpoint check, end of Week 410%
Capstone repository and demo40%
Participation and code reviews10%

A weekly task is marked complete, partial or missing. Partial work gets written feedback within a week.