Learning objectives
- Apply Python fundamentals - variables, data types, arithmetic, conditional statements and loops - to write working programs
- Operate and control the ROSPug quadruped robot using the WonderROS app and a remote desktop connection to its on-board Jetson Nano board
- Understand quadruped locomotion and ROS concepts, and write rospy scripts that publish pose, gait and velocity messages to make the robot walk, turn and patrol
- Build a complete computer vision workflow, from data capture and labelling through training and testing to GPU-accelerated deployment on the robot
Lesson plan
Python taster: Mastermind | Describe the logic of a number-guessing game and complete the program in Visual Studio Code | Hands-on: i) Generate four non-repeating digits ii) Read and validate player input for type and length iii) Compare the guess against the answer and output O / ? / X iv) Repeat until the player wins
What is Python? | Describe how Python executes code line by line, and the concepts of variables, functions, operators, keywords and data types | Hands-on: i) Write a self-introduction using variables of different data types ii) Convert values with str(), int() and float() to join them iii) Write code to swap the values of two variables
Arithmetic in Python | Understand arithmetic operators, the PEMDAS order of operations, and comparison operators returning Boolean values | Hands-on: i) Write code to implement given formulas ii) Solve a sweet-packing problem with floor division and modulus iii) Run and modify comparison operators to observe True and False results
Conditional statements | Understand how to control program flow with if, elif and else, indentation scope, and the and / or / not logical operators | Hands-on: i) Write code for a grade rating system ii) Write a rock paper scissors game against a randomly generated computer choice
Loop statements | Understand how to repeat code with for and while loops, and when to use each | Hands-on: i) Write code to calculate a summation and a product over a series of numbers ii) Count how many times a number can be divided iii) Generate a Fibonacci sequence up to an input value iv) Write a number-range guessing game
Image classification | Understand the four-step model training workflow, the split between training and test data, and the limitations and bias of AI models | Hands-on: i) Train a Google Teachable Machine model to classify red-crowned cranes and other animals ii) Test the model with unseen images iii) Improve a low-accuracy model by removing misleading images and adding more training data iv) Add a third class and retrain
ROSPug first run | Identify the parts of the ROSPug quadruped robot, the safe start-up pose and procedure, and the difference between AP and STA Wi-Fi modes | Hands-on: i) Power up the Jetson Nano board and check the battery status screen ii) Connect a phone to the robot with the WonderROS app iii) Drive the robot in Robot Control iv) Run preset motions in Robot Performance v) Pick a colour and run Target Tracking
Controlling ROSPug from a computer | Understand how to connect to the robot desktop over NoMachine, record custom action files, and use basic Linux commands and the Vim editor | Hands-on: i) Centre the servos and pose the robot by hand to record handshake and sit action files ii) Replay a saved action from the WonderROS app iii) Practise mkdir, ls, cd and ifconfig in the terminal iv) Create and run a Python file in Vim v) Install OpenCV, capture a photo from the robot camera, and run a pretrained YOLOv8 detection model
Walking and turning | Understand leg degrees of freedom, inverse kinematics, the robot coordinate system and default foot coordinates, and the walk, trot, amble and pace gaits | Hands-on: i) Write a rospy script that publishes pose, gait and velocity messages to walk in a trot gait ii) Change the speed and duration and compare the distance travelled iii) Turn on the spot using math.radians iv) Complete a there-and-back patrol and a loop patrol
Advanced ROSPug: ROS and computer vision | Understand ROS nodes, topics and publishers, the common computer vision tasks, and the data preparation, labelling, training and evaluation workflow | Hands-on: i) Write a buzzer node and sound it three times with a for loop ii) Change the walking pose and turn in repeated small steps iii) Capture a dataset with the capture tool and label it in LabelImg in YOLO format iv) Split the data into training and validation sets, write classes.txt and data.yaml, and train YOLOv5 v) Test the trained weights with detect.py vi) Convert the weights to a TensorRT engine and run detection from a ROS node
Prerequisites
Hardware
- ROSPug quadruped robot (Hiwonder) with Jetson Nano expansion board and on-board camera
- Smartphone or tablet for the WonderROS app
- Notebook/desktop connected to the same Wi-Fi network as the robot
- Wi-Fi router (needed for STA mode; one for the whole class)
Software
- WonderROS app
- NoMachine remote desktop
- Visual Studio Code
- Python 3
- ROS / rospy
- Linux terminal and Vim
- OpenCV
- Ultralytics YOLOv8 and YOLOv5
- LabelImg
- TensorRT
- Google Teachable Machine
- Programiz online Python compiler
Other requirements