{
 "原理:PID 三項各自在做什麼#3": {
  "type": "cards",
  "reveal": [
   0,
   1,
   2,
   3
  ],
  "cards": [
   {
    "title": "P 比例",
    "points": [
     "看現在的誤差",
     "誤差大就大力修正"
    ]
   },
   {
    "title": "I 積分",
    "points": [
     "看過去累積的誤差",
     "持續存在就不斷變大"
    ]
   },
   {
    "title": "D 微分",
    "points": [
     "看未來的趨勢",
     "下降越快越早減輸出"
    ]
   }
  ]
 },
 "原理:PID 三項各自在做什麼#4": {
  "type": "flow",
  "layout": "snake",
  "reveal": [
   1,
   5
  ],
  "nodes": [
   {
    "label": "誤差 e",
    "sub": "目標 − 實際",
    "color": 1
   },
   {
    "label": "P 項",
    "sub": "Kp × e",
    "color": 0
   },
   {
    "label": "I 項",
    "sub": "Ki × 誤差積分",
    "color": 2
   },
   {
    "label": "D 項",
    "sub": "Kd × 誤差變化率",
    "color": 3
   },
   {
    "label": "輸出 u",
    "sub": "三項的和",
    "color": 4,
    "kind": "end"
   }
  ]
 },
 "原理:PID 三項各自在做什麼#6": {
  "type": "flow",
  "layout": "snake",
  "reveal": [
   0,
   3,
   4,
   6
  ],
  "nodes": [
   {
    "label": "需要輸出",
    "sub": "5 單位",
    "color": 1
   },
   {
    "label": "純 P",
    "sub": "Kp = 2",
    "color": 0
   },
   {
    "label": "所需誤差",
    "sub": "5 ÷ 2 = 2.5",
    "color": 3
   },
   {
    "label": "殘留誤差",
    "sub": "固定 2.5",
    "color": 4
   },
   {
    "label": "加入 I 項",
    "sub": "累積殘留",
    "color": 2
   },
   {
    "label": "誤差趨近零",
    "sub": "輸出剛好 5",
    "color": 1,
    "kind": "end"
   }
  ]
 },
 "原理:PID 三項各自在做什麼#7": {
  "type": "flow",
  "layout": "snake",
  "reveal": [
   1,
   4,
   5
  ],
  "nodes": [
   {
    "label": "Kp 太大",
    "sub": "猛推",
    "color": 4
   },
   {
    "label": "指令延遲",
    "sub": "約 0.1 秒才反映",
    "color": 3
   },
   {
    "label": "結果過頭",
    "sub": "反向修正又過頭",
    "color": 0
   },
   {
    "label": "來回震盪",
    "sub": "甚至越震越大",
    "color": 4
   },
   {
    "label": "D 項預測趨勢",
    "sub": "減少過頭",
    "color": 2,
    "kind": "end"
   }
  ]
 },
 "開迴路與閉迴路:為什麼需要回授#2": {
  "type": "flow",
  "layout": "row",
  "reveal": [
   0,
   2,
   4,
   4
  ],
  "nodes": [
   {
    "label": "量測",
    "sub": "IMU yaw 5°",
    "color": 1
   },
   {
    "label": "比較",
    "sub": "目標 0°",
    "color": 0
   },
   {
    "label": "誤差",
    "sub": "0 − 5 = −5°",
    "color": 3
   },
   {
    "label": "修正",
    "sub": "右輪慢、左輪快",
    "color": 2,
    "kind": "end"
   }
  ]
 },
 "開迴路與閉迴路:為什麼需要回授#3": {
  "type": "flow",
  "layout": "cycle",
  "reveal": [
   2,
   6
  ],
  "nodes": [
   {
    "label": "目標值",
    "color": 1
   },
   {
    "label": "誤差 e",
    "sub": "目標 − 回授",
    "color": 3
   },
   {
    "label": "P / I / D",
    "sub": "三項相加",
    "color": 0
   },
   {
    "label": "輸出 u",
    "sub": "送到馬達",
    "color": 2
   },
   {
    "label": "馬達與車體",
    "color": 4
   },
   {
    "label": "感測器",
    "sub": "回授到最前面",
    "color": 1
   }
  ]
 },
 "開迴路與閉迴路:為什麼需要回授#4": {
  "type": "cards",
  "reveal": [
   0,
   1,
   2,
   3,
   4,
   4
  ],
  "cards": [
   {
    "title": "Kp 太小",
    "points": [
     "反應慢",
     "誤差拖很久才消失"
    ]
   },
   {
    "title": "Kp 剛好",
    "points": [
     "快速接近目標"
    ]
   },
   {
    "title": "Kp 太大",
    "points": [
     "修正過頭",
     "左右擺盪、越擺越大"
    ]
   },
   {
    "title": "範例",
    "points": [
     "Kp 2.0、誤差 15°",
     "右輪加 u、左輪減 u"
    ],
    "value": "u = 30"
   }
  ]
 },
 "開迴路與閉迴路:為什麼需要回授#6": {
  "type": "bar",
  "labels": [
   "IMU 讀取+計算",
   "控制迴圈",
   "太慢的迴圈"
  ],
  "values": [
   5,
   20,
   200
  ],
  "unit": "ms",
  "reveal": [
   0,
   2,
   2,
   3
  ],
  "highlight": 2
 },
 "PID 三項與離散實作#1": {
  "type": "table",
  "head": [
   "項",
   "看什麼",
   "作用"
  ],
  "rows": [
   [
    "P 比例",
    "現在的誤差",
    "誤差越大推越用力"
   ],
   [
    "I 積分",
    "過去累積的誤差",
    "消除穩態誤差"
   ],
   [
    "D 微分",
    "未來的趨勢",
    "抑制超調與震盪"
   ]
  ],
  "reveal": [
   0,
   1,
   2,
   3,
   3
  ],
  "widths": [
   1,
   1.3,
   2
  ]
 },
 "PID 三項與離散實作#4": {
  "type": "waterfall",
  "unit": "",
  "reveal": [
   0,
   0,
   0,
   3,
   3,
   3,
   4
  ],
  "items": [
   {
    "label": "P 項 Kp×e",
    "value": 12
   },
   {
    "label": "I 項 Ki×∫",
    "value": 0.8
   },
   {
    "label": "D 項 Kd×微分",
    "value": -4
   },
   {
    "label": "輸出 u",
    "value": 8.8,
    "kind": "total"
   }
  ]
 },
 "PID 三項與離散實作#6": {
  "type": "cards",
  "reveal": [
   0,
   1,
   2,
   3,
   4
  ],
  "cards": [
   {
    "title": "抗積分飽和",
    "points": [
     "限制積分範圍",
     "或飽和時暫停累加"
    ]
   },
   {
    "title": "微分雜訊",
    "points": [
     "差分會放大雜訊",
     "低通濾波、Kd 先設 0"
    ]
   },
   {
    "title": "微分衝擊",
    "points": [
     "目標突變尖峰",
     "對測量值微分"
    ]
   },
   {
    "title": "角度環繞",
    "points": [
     "誤差正規化到",
     "−180° ~ 180°"
    ]
   }
  ]
 },
 "PID 三項與離散實作#7": {
  "type": "flow",
  "layout": "row",
  "reveal": [
   1,
   4
  ],
  "nodes": [
   {
    "label": "目標 10°",
    "sub": "yaw 350°",
    "color": 1
   },
   {
    "label": "直接相減",
    "sub": "−340°,轉大圈",
    "color": 4
   },
   {
    "label": "正規化",
    "sub": "加 180、取餘 360、減 180",
    "color": 0
   },
   {
    "label": "結果",
    "sub": "+20°,轉一點點",
    "color": 2,
    "kind": "end"
   }
  ]
 },
 "直線行駛與循線的 PID 應用#1": {
  "type": "flow",
  "layout": "cycle",
  "reveal": [
   0,
   0,
   1,
   5,
   5,
   5
  ],
  "nodes": [
   {
    "label": "讀 yaw",
    "sub": "度,逆時針為正",
    "color": 1
   },
   {
    "label": "算航向誤差",
    "color": 0
   },
   {
    "label": "PID 求 u",
    "color": 2
   },
   {
    "label": "左 45−u",
    "sub": "右 45+u",
    "color": 3
   },
   {
    "label": "睡眠 0.02 秒",
    "color": 4
   }
  ]
 },
 "直線行駛與循線的 PID 應用#2": {
  "type": "table",
  "head": [
   "感測器看到線",
   "位置"
  ],
  "rows": [
   [
    "只有左邊",
    "−1"
   ],
   [
    "左和中間",
    "−0.5"
   ],
   [
    "只有中間",
    "0"
   ],
   [
    "中間和右邊",
    "+0.5"
   ]
  ],
  "reveal": [
   0,
   0,
   4,
   4,
   4
  ]
 },
 "直線行駛與循線的 PID 應用#5": {
  "type": "cards",
  "reveal": [
   0,
   1,
   2,
   3,
   4
  ],
  "cards": [
   {
    "title": "完成時間",
    "points": [
     "跑完一圈幾秒"
    ]
   },
   {
    "title": "出軌次數",
    "points": [
     "需人工扶回",
     "或進入搜尋狀態"
    ]
   },
   {
    "title": "黑線上時間比例",
    "points": [
     "感測器看到黑線的比例"
    ]
   },
   {
    "title": "直線行駛偏移",
    "points": [
     "走兩公尺",
     "終點的橫向距離"
    ]
   }
  ]
 },
 "直線行駛與循線的 PID 應用#6": {
  "type": "table",
  "head": [
   "已知量",
   "數值"
  ],
  "rows": [
   [
    "基本速度",
    "45"
   ],
   [
    "Kp",
    "1.5"
   ],
   [
    "目標 yaw",
    "0°"
   ],
   [
    "量到 yaw",
    "8°(偏左)"
   ]
  ],
  "reveal": [
   0,
   4,
   4
  ]
 },
 "直線行駛與循線的 PID 應用#7": {
  "type": "flow",
  "layout": "row",
  "reveal": [
   0,
   1,
   2,
   3,
   4
  ],
  "nodes": [
   {
    "label": "航向誤差",
    "sub": "0−8+180 取餘 360 −180 = −8",
    "color": 1
   },
   {
    "label": "u(只看 P)",
    "sub": "1.5 × (−8) = −12",
    "color": 3
   },
   {
    "label": "左輪",
    "sub": "45 − (−12) = 57",
    "color": 0
   },
   {
    "label": "右輪",
    "sub": "45 + (−12) = 33",
    "color": 2,
    "kind": "end"
   }
  ]
 }
}