Stage 03 · Lesson 14/14

Linux & Dev Environment · Lesson 14

Capstone: Build Your Robotics Workspace

Est. 60–90 min

Why

Why a ready workspace is your real Stage 3 certificate

In this capstone you will run one setup script that builds the whole workspace, prove each piece works with a self-check, and record it all in Git. It pulls together all 13 lessons of Stage 3.

Concept

The big idea: one script, one checklist, one clean repo

The Stage 3 checklist — every item has a command that proves it
LessonYou can…Proof command
1–2Use the terminal confidentlypwd && ls -a ~/robot_ws
3Keep a clean project treefind ~/robot_ws -maxdepth 1 | sort
4Read and fix permissionsstat -c '%A %n' scripts/bringup.sh and groups (has dialout?)
5See and stop processes safelypgrep -a python and a graceful-stop loop
6Install system toolsbash check_tools.sh
7Configure with environment variablesecho $SERIAL_PORT and read_env.py
8Automate with bash./scripts/bringup.sh sim; echo $?
9Version everythinggit log --oneline | head -n 5
10Edit in a configured VS Code.vscode/settings.json committed, venv interpreter selected
11Isolate Pythonpython which_env.py → in venv: True
12Understand the LANip -brief addr and your network sketch
13Reach the robot securelyssh jetson hostname (if you have hardware)

How it works

How it actually works: the setup script, piece by piece

  1. Choose the folder

    WS="${1:-$HOME/robot_ws}" — default ~/robot_ws, or any folder you pass (Lesson 8 defaults).

  2. Build the tree

    mkdir -p "$WS"/{src,config,scripts,logs} — brace expansion makes four folders in one go (Lesson 3).

  3. Never overwrite precious files

    [ -f config/robot.yaml ] || … writes the config only if it does not exist yet.

  4. Scripts and permissions

    Writes scripts/bringup.sh and gives it the x bit (Lesson 4).

  5. Environment and history

    Creates .venv (Lesson 11) and git init (Lesson 9) — only if missing, so rerunning is safe.

  6. Self-check

    Prints PASS / FAIL per item and runs bring-up in sim mode. A script that checks itself is a script you can trust.

Visual

Visualise it: leave a clean commit trail

Practise your capstone commit: stage the right files (not logs or .venv), write a clear message and commit. Your commit trail is your portfolio.

Interactive · Git workflow simulator

Working tree

  • M robot_controller.py
  • ?? camera_driver.py
  • M README.md
  • ?? config/robot.yaml

Staging area

  • (empty)

Recent commits

  • (none yet)
# git workflow simulator — working → add → commit
# no remote / network / credentials

Code lab

Code lab: build the whole workspace in one go

Save as setup_workspace.sh, chmod +x it, and try it first on a scratch folder: ./setup_workspace.sh /tmp/aihub-lab/robot_ws. When happy, run it with no argument to create ~/robot_ws.

setup_workspace.sh · Shell
#!/usr/bin/env bash
# setup_workspace.sh — Stage 3 capstone: build a complete robot workspace in one go
# Usage: ./setup_workspace.sh [folder]     (default: ~/robot_ws)
set -euo pipefail
WS="${1:-$HOME/robot_ws}"

mkdir -p "$WS"/{src,config,scripts,logs}
cd "$WS"
[ -f config/robot.yaml ] || printf 'robot_name: desk-arm\nserial_port: /dev/ttyUSB0\nstop_distance_cm: 20\n' > config/robot.yaml
printf '.venv/\nlogs/\n__pycache__/\n*.log\n' > .gitignore
cat > scripts/bringup.sh <<'SH'
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
echo "[bringup] mode=${1:-sim} port=${SERIAL_PORT:-/dev/ttyUSB0}"
SH
chmod +x scripts/bringup.sh
[ -d .venv ] || python3 -m venv .venv
[ -d .git ] || git init -q -b main

# --- self-check ---
for item in src config scripts logs .venv .git .gitignore; do
  if [ -e "$item" ]; then echo "PASS  $item"; else echo "FAIL  $item"; fi
done
[ -x scripts/bringup.sh ] && echo "PASS  scripts/bringup.sh is executable"
./scripts/bringup.sh sim

Output of ./setup_workspace.sh /tmp/aihub-lab/robot_ws

PASS  src
PASS  config
PASS  scripts
PASS  logs
PASS  .venv
PASS  .git
PASS  .gitignore
PASS  scripts/bringup.sh is executable
[bringup] mode=sim port=/dev/ttyUSB0
Then make the first commit · Shell
cd ~/robot_ws
git add .gitignore config scripts
git commit -m "chore: robotics workspace skeleton (Stage 3 capstone)"
git status --short     # should print nothing: clean

Rubric

Self-assessment rubric

AreaGetting thereReady for the next stage
TreeFiles mixed in one foldersrc / config / scripts / logs, logs ignored
ScriptsManual commands from memorybringup.sh with checks, exit codes, sim mode
PythonSystem pip, unknown versions.venv + requirements.txt, interpreter selected in VS Code
GitOne huge commit called “update”Small commits with clear messages, clean git status
Safetysudo for everythingdialout group, 755 scripts, 600 keys, graceful stop
RemoteMonitor and keyboard on the robotSSH key login, ~/.ssh/config alias, rsync

Real world

Where this workspace takes you next

  • Stage 4 (Electronics & Embedded Systems) will talk to Arduino boards over the serial ports you can now open safely.
  • Stage 6 (the 6DOF arm) goes much more smoothly when you can run scripts, open the serial port and keep calibration in Git.
  • ROS 2 (Stage 10) is used from the terminal, configured with environment variables and organised in workspaces — all things you practised here.
  • A clean public repo with good commits is something you can show in an internship interview.

Mistakes

Common mistakes and debugging

Hardware & safety

Hardware lab and safety notes

If you have a robot computer, finish the capstone by reaching it from your new workspace — SSH in, sync code, run a sim-mode check.

  • Laptop: robot_ws repo, .venv, VS Code settings, setup_workspace.sh all PASS.
  • Robot (optional): SSH config entry, rsync of src/, bringup.sh sim run remotely.
  • Arduino (optional): hello_serial.ino uploaded and read through the venv’s pyserial without sudo.
Electronics workbench with tools and boards
Your finished workspace: laptop, robot computer and microcontroller working together.Photo: James Bastow · CC BY-SA 2.0 · Source: Wikimedia Commons · resized, converted to WebP

Debugging

Debugging: when it doesn’t work

Symptom → likely cause → fix
SymptomLikely causeFix
setup_workspace.sh shows FAILA tool is missingInstall it (Lesson 6) and re-run
Git push asks for a passwordHTTPS remoteUse an SSH remote with your key (Lesson 13)
Code works on laptop, fails on robotDifferent venv / missing packageRebuild the venv from requirements.txt on the robot
Arduino denied on the robotRobot user not in dialoutsudo usermod -aG dialout $USER on the robot, log out and in
NoteRead the last line of an error first — it usually names the problem. Change one thing at a time and re-run.

Think

Think about it

Think

Which checklist item protects people first, not just code?

Experiment

Try it in the lab: the capstone pass

Do this honestly — the checklist is for you, not for the app.

Experiment

The capstone pass

You will need

  • Git workflow simulator
  • Ubuntu laptop (or WSL2 / a Raspberry Pi)
  • Your notes from Lessons 1–13

Steps

  1. In the simulator, stage only the code and config files and commit with `docs: robotics workspace checklist`.
  2. On a real machine, run `setup_workspace.sh /tmp/aihub-lab/robot_ws` and check every line says PASS.
  3. Run it again to prove it is safe to rerun.
  4. Create your real `~/robot_ws`, make the first commit and push it to your own remote repository.
  5. Go down the checklist table and run every proof command. Tick each one.
  6. Write a 5-line reflection: what was hardest, and what you will automate next.

Interactive · Git workflow simulator

Working tree

  • M robot_controller.py
  • ?? camera_driver.py
  • M README.md
  • ?? config/robot.yaml

Staging area

  • (empty)

Recent commits

  • (none yet)
# git workflow simulator — working → add → commit
# no remote / network / credentials

Every line PASS, git status clean, bring-up prints mode=sim. Then mark Stage 3 complete in the app.

Knowledge check

Check your understanding

Knowledge check

1. The Stage 3 capstone is mainly about…

2. Why should setup_workspace.sh be safe to run twice?

3. Which should NOT be committed?

4. `mkdir -p "$WS"/{src,config,scripts,logs}` creates…

5. Which stage after this one will use your serial-port permission skills first?

Mini assignment

Capstone deliverables

Mini assignment

DevBox portfolio

Submit your finished robotics workspace as a small portfolio.

Deliverables

  • Link or screenshot of your `robot_ws` repository with at least 3 good commits
  • Terminal output of `setup_workspace.sh` (all PASS)
  • The completed checklist table with proof outputs
  • Your network sketch and SSH config (if you have robot hardware)
  • A 5-line reflection on Stage 3

Do this, step by step

  1. Run setup_workspace.sh on your own path and get every line PASS.
  2. Push robot_ws to a private GitHub repo with at least 3 good commits.
  3. Fill the checklist table with proof outputs.
  4. Write the 5-line reflection.

Stuck? Hints, one at a time

NoteTry the task first. Read one hint, try again, and only then read the next one.
  1. Hint 1: Run the script on a fresh folder like /tmp/aihub-lab/robot_ws first so nothing real is overwritten.
  2. Hint 2: A private repo is fine — share a screenshot if you cannot share the link.
  3. Hint 3: Reflection idea: one thing that broke, how you found it, and what you will do differently.

Challenges (pick by level)

  • 🟢 Easy: Add a README with “how to rebuild this workspace in 10 minutes”.
  • 🟡 Medium: Make setup_workspace.sh also create the .venv and install requirements.txt.
  • 🟠 Hard: Rebuild the whole workspace on a second machine (or Pi) from the repo alone.

Next step

Look back: Lesson 13: SSH & Remote Robotics Development. You have finished Stage 3! Next stage: Stage 4 — Electronics & Embedded Systems. Related: Stage 10 — ROS 2 and Stage 12 — Simulation & Digital Twin.

Sources

Self-attested for now — keep artifacts in your lab notebook.

Complete

Today's goal

0 of 1 done today

0-day streak
Daily goal:lessons, quizzes or assignments a day

Mark this lesson complete when you have worked the experiment, knowledge check, and assignment (even roughly).

Stuck somewhere?

Ask a doubt about this lesson

Saved with this lesson's id and your email so we can reply. Privacy · or email contact@aihubstation.in