Welcome to the RERO Robotics Hackathon — Round 0 (Online Round)!
This round is completely virtual. You will design and tune a PID controller to control a simulated Mass–Spring–Damper system. Your goal: make the system reach its target quickly, smoothly, and efficiently.
🚨 ONLY EDIT ONE FILE:
submission_template/pid_controller.py
❌ Do NOT modify or move any other files. ❌ Do NOT rename folders or edit the grader scripts. ✅ Your task is only to implement your PID parameters in
pid_controller.py.
If you edit anything else, your submission will fail the autograder and earn zero.
You’ll tune a PID controller that drives a simulated mass–spring–damper system to a target position. Your controller will be tested automatically using multiple simulations. Each test evaluates how fast, accurate, and smooth your control is. The better your tuning, the higher your score (out of 1000).
You only need to implement one function:
def get_pid(seed):
Kp = ...
Ki = ...
Kd = ...
return Kp, Ki, KdThe system you’re controlling is a mass–spring–damper:
Where:
-
$m$ : mass -
$c$ : damping coefficient -
$k$ : spring stiffness -
$y$ : output position -
$u$ : control force (PID output)
This setup models many real systems — like suspension, robotic joints, or drones.
| Parameter | Symbol | Value | Unit |
|---|---|---|---|
| Mass | m | 15.0 | kg |
| Damping | c | 10.5 | N·s/m |
| Spring constant | k | 25.0 | N/m |
| Max actuator force | uₘₐₓ | 75.0 | N |
| Sampling time | Ts | 0.01 | s |
Random noise and small disturbances are added automatically. Your PID must handle these variations gracefully.
| File/Folder | Purpose | Can you edit it? |
|---|---|---|
submission_template/pid_controller.py |
Your file. Implement get_pid(seed) here. |
✅ YES |
grader/evaluator.py |
Runs the simulation and evaluates your PID. | ❌ NO |
grader/plant.py |
The simulated mass–spring–damper system. | ❌ NO |
grader/scoring.py |
Measures metrics like rise time, overshoot, etc. | ❌ NO |
.github/workflows/classroom.yml |
GitHub Actions autograder workflow. | ❌ NO |
You can test everything on your own computer before submitting.
You need Python 3.9 or later. Check your version:
python --versionIn your project folder, run:
pip install numpy matplotlib(If a requirements.txt is provided, you can run pip install -r requirements.txt.)
Run the evaluator script:
python -m grader.evaluator submission_template/pid_controller.pyIt will:
-
Load your PID gains
-
Simulate the system
-
Save the results as:
score.json— detailed numeric resultsresult.png— graph of your system response
You’ll see output like:
[INFO] Master RNG seed = 1234567
Mean score: 782.4
Results saved to score.json and result.png
Open result.png to see how your controller performed.
Open score.json to view metrics like overshoot, rise time, settling time, IAE, and energy.
If your score is low, tweak Kp, Ki, and Kd in pid_controller.py and run again.
The system measures several performance metrics:
| Metric | Description | Ideal Value |
|---|---|---|
| Overshoot | How far you exceed the target | Low |
| Undershoot | How far you dip below target | Low |
| Rise Time | Time to reach 90% of target | Short |
| Settling Time | Time to remain within ±7.5% | Short |
| ESS | Steady-state error | Near 0 |
| Smoothness | How stable the response is | High |
| IAE | Integrated absolute error | Small |
| Energy | Actuator effort used | Low |
Your total score starts at 1000 points. Points are subtracted based on these metrics. Higher is better.
Click the GitHub Classroom link provided by the organizers.
This creates your private repo (e.g., pid-tuning-yourname).
submission_template/pid_controller.py
Example:
def get_pid(seed):
Kp = 12.0
Ki = 5.0
Kd = 1.2
return Kp, Ki, KdRun:
python -m grader.evaluator submission_template/pid_controller.pyOnce satisfied with your results:
git add submission_template/pid_controller.py
git commit -m "Updated PID tuning"
git push origin mainGitHub Actions will automatically:
- Run the evaluator,
- Generate your score,
- Upload
score.jsonandresult.pngas artifacts, - Update the leaderboard.
You can view results in the Actions tab on your repo.
Imagine:
- A block (mass) connected to a spring and a damper.
- When you push the block, it moves.
- The spring tries to pull it back.
- The damper tries to slow it down.
That’s your system. Your job is to control it so it reaches the target position and stays there quickly and smoothly.
| Type | Damping Ratio | Description |
|---|---|---|
| Underdamped | < 0.5 | Oscillatory |
| Critically damped | ≈ 0.7 | Fast and smooth |
| Overdamped | > 1.0 | Slow but stable |
Your system has moderate damping (≈ 0.68) — a balanced test case for PID control.
A PID Controller combines three simple ideas:
Where
| Term | Role | Effect |
|---|---|---|
| P (Proportional) | Reacts to present error | Faster response; may overshoot |
| I (Integral) | Reacts to accumulated error | Removes steady-state offset |
| D (Derivative) | Reacts to error rate | Dampens oscillations |
You tune (Kp, Ki, Kd) to balance speed, accuracy, and stability.
- Set
Ki = 0andKd = 0. - Increase
Kpuntil you observe small oscillations. - Add
Kdto reduce oscillations and overshoot. - Add
Kito eliminate steady-state error. - Iterate: small changes → re-test → evaluate.
- Set
Ki = 0,Kd = 0. - Increase
Kpuntil the system oscillates continuously — this is Ku (ultimate gain). - Measure the oscillation period Pu.
- Apply:
| Controller | Kp | Ti | Td |
|---|---|---|---|
| P | 0.5·Ku | — | — |
| PI | 0.45·Ku | Pu / 1.2 | — |
| PID | 0.6·Ku | Pu / 2 | Pu / 8 |
This gives a starting point; fine-tune manually afterwards.
Try this to get going:
def get_pid(seed):
Kp = 12.0
Ki = 5.0
Kd = 1.2
return Kp, Ki, KdThen adjust values based on your result.png and score.json.
Good PID response:
- Smooth rise
- Little or no overshoot
- Settles quickly near setpoint
Bad PID response:
- Large oscillations
- Excessive overshoot/undershoot
- Very slow to settle or never reaches setpoint
Aim for a clean, fast rise and stable steady-state.
| Metric | Ideal |
|---|---|
| Overshoot | Low |
| Settling time | Short |
| ESS (steady-state error) | Near 0 |
| Smoothness | High |
| IAE (integrated abs error) | Small |
| Energy | Low |
Higher score indicates better control performance.
- ✅ Edited only
submission_template/pid_controller.py - ✅ Ran evaluator locally with no errors
- ✅ Committed and pushed changes to GitHub
- ✅ Verified the GitHub Action completed successfully
- ✅ Downloaded your
score.jsonandresult.pngfrom Actions → Artifacts
If you’re stuck or confused:
- Email:
ieee.ras.rr@pes.edu
We’ll help you get set up.
“If it overshoots, lower Kp. If it oscillates, increase Kd. If it never reaches the target, increase Ki.”
Good luck, engineers — and remember: Do not edit any file except submission_template/pid_controller.py.