{
 "原理:PID 三項各自在做什麼#1": {
  "type": "cards",
  "reveal": [
   0,
   3,
   3
  ],
  "cards": [
   {
    "title": "P 比例",
    "points": [
     "現在偏多遠,就打多少"
    ]
   },
   {
    "title": "I 積分",
    "points": [
     "長期偏右,慢慢加一點反向的力"
    ]
   },
   {
    "title": "D 微分",
    "points": [
     "快速回中,先回正,免得過頭"
    ]
   }
  ]
 },
 "原理:PID 三項各自在做什麼#3": {
  "type": "table",
  "head": [
   "項",
   "意義",
   "對應"
  ],
  "rows": [
   [
    "P",
    "比例常數 × 誤差",
    "現在"
   ],
   [
    "I",
    "積分(累加:誤差 × dt)",
    "過去的累積"
   ],
   [
    "D",
    "微分(差分:除以 dt)",
    "未來的趨勢"
   ]
  ],
  "reveal": [
   0,
   3,
   3,
   3
  ],
  "widths": [
   1,
   3,
   2
  ]
 },
 "原理:PID 三項各自在做什麼#4": {
  "type": "flow",
  "layout": "row",
  "reveal": [
   0,
   3
  ],
  "nodes": [
   {
    "label": "連續誤差曲線"
   },
   {
    "label": "切成寬 dt 的長方形"
   },
   {
    "label": "積分:面積累加",
    "sub": "微分:相鄰差分"
   }
  ]
 },
 "原理:PID 三項各自在做什麼#5": {
  "type": "table",
  "head": [
   "步驟",
   "誤差",
   "積分",
   "微分",
   "輸出"
  ],
  "rows": [
   [
    "第一步",
    "1.0",
    "0.1",
    "0",
    "2.1"
   ],
   [
    "第二步",
    "0.6",
    "0.16",
    "-4",
    "-0.64"
   ],
   [
    "第三步",
    "0.3",
    "0.19",
    "-3",
    "-0.71"
   ]
  ],
  "reveal": [
   0,
   0,
   1,
   2,
   3,
   3
  ]
 },
 "原理:PID 三項各自在做什麼#6": {
  "type": "cards",
  "reveal": [
   0,
   1,
   2
  ],
  "cards": [
   {
    "title": "第一步",
    "points": [
     "積分 0.1",
     "D 0"
    ],
    "value": "輸出 2.1"
   },
   {
    "title": "第二步",
    "points": [
     "積分 0.16",
     "D -4"
    ],
    "value": "輸出 -0.64"
   }
  ]
 },
 "原理:PID 三項各自在做什麼#7": {
  "type": "flow",
  "layout": "row",
  "reveal": [
   0,
   4
  ],
  "nodes": [
   {
    "label": "誤差 0.3"
   },
   {
    "label": "積分 0.19"
   },
   {
    "label": "D = (0.3-0.6)/0.1",
    "sub": "-3"
   },
   {
    "label": "輸出",
    "sub": "-0.71"
   }
  ]
 },
 "PID 的概念與離散化實作#1": {
  "type": "cards",
  "reveal": [
   0,
   0,
   1,
   2,
   3
  ],
  "cards": [
   {
    "title": "P 比例",
    "points": [
     "輸出正比於目前誤差",
     "反應快",
     "Kp 太大會震盪"
    ]
   },
   {
    "title": "I 積分",
    "points": [
     "輸出正比於誤差累積",
     "消除長期偏差",
     "太大會過衝和飽和"
    ]
   },
   {
    "title": "D 微分",
    "points": [
     "輸出正比於誤差變化率",
     "抑制過衝,像阻尼",
     "會放大雜訊"
    ]
   }
  ]
 },
 "PID 的概念與離散化實作#2": {
  "type": "flow",
  "layout": "cycle",
  "reveal": [
   0,
   5
  ],
  "nodes": [
   {
    "label": "目標值"
   },
   {
    "label": "誤差",
    "sub": "目標 - 測量"
   },
   {
    "label": "P + I + D",
    "sub": "三項相加"
   },
   {
    "label": "馬達與車體"
   },
   {
    "label": "感測器",
    "sub": "回授"
   }
  ]
 },
 "PID 的概念與離散化實作#3": {
  "type": "table",
  "head": [
   "項目",
   "數值"
  ],
  "rows": [
   [
    "dt",
    "0.02 秒"
   ],
   [
    "Kp",
    "30"
   ],
   [
    "Ki",
    "2"
   ],
   [
    "Kd",
    "5"
   ],
   [
    "這步誤差",
    "0.5"
   ],
   [
    "上一步誤差",
    "1.0"
   ],
   [
    "積分累積值",
    "0.3"
   ]
  ],
  "reveal": [
   0,
   0,
   1,
   7,
   7
  ],
  "widths": [
   2,
   2
  ]
 },
 "PID 的概念與離散化實作#4": {
  "type": "table",
  "head": [
   "項",
   "算式",
   "結果"
  ],
  "rows": [
   [
    "積分",
    "0.3 + 0.5 × 0.02",
    "0.31"
   ],
   [
    "微分",
    "(0.5 - 1.0) / 0.02",
    "-25"
   ]
  ],
  "reveal": [
   0,
   0,
   0,
   1,
   2
  ],
  "widths": [
   1,
   3,
   1
  ]
 },
 "PID 的概念與離散化實作#5": {
  "type": "waterfall",
  "unit": "",
  "reveal": [
   0,
   4
  ],
  "items": [
   {
    "label": "P 項",
    "value": 15
   },
   {
    "label": "I 項",
    "value": 0.62
   },
   {
    "label": "D 項",
    "value": -125
   },
   {
    "label": "輸出",
    "value": -109.38,
    "kind": "total"
   }
  ]
 },
 "PID 的概念與離散化實作#6": {
  "type": "flow",
  "layout": "row",
  "reveal": [
   0,
   4,
   4
  ],
  "nodes": [
   {
    "label": "取得現在時間",
    "sub": "算出 dt"
   },
   {
    "label": "dt 不大於 0",
    "sub": "回傳 0"
   },
   {
    "label": "積分加 誤差 × dt",
    "sub": "算出微分"
   },
   {
    "label": "回傳三項加總"
   }
  ]
 },
 "積分飽和、微分雜訊與調參流程#1": {
  "type": "flow",
  "layout": "row",
  "reveal": [
   0,
   2,
   4
  ],
  "nodes": [
   {
    "label": "誤差長時間無法消除",
    "sub": "例:車子被卡住"
   },
   {
    "label": "積分一直累加",
    "sub": "變得非常大"
   },
   {
    "label": "誤差終於消失",
    "sub": "積分仍很大"
   },
   {
    "label": "衝過頭",
    "sub": "積分飽和"
   }
  ]
 },
 "積分飽和、微分雜訊與調參流程#2": {
  "type": "table",
  "head": [
   "增益",
   "結果"
  ],
  "rows": [
   [
    "太小",
    "響應慢"
   ],
   [
    "太大",
    "過衝、震盪"
   ],
   [
    "適中 + 微分",
    "快速穩定下來"
   ]
  ],
  "reveal": [
   0,
   3
  ]
 },
 "積分飽和、微分雜訊與調參流程#3": {
  "type": "flow",
  "layout": "row",
  "reveal": [
   0,
   1,
   2,
   3,
   4
  ],
  "nodes": [
   {
    "label": "限制積分範圍"
   },
   {
    "label": "輸出飽和時停止累積",
    "sub": "條件式積分"
   },
   {
    "label": "誤差變號或脫線",
    "sub": "清除積分"
   },
   {
    "label": "馬達停止或 STOP",
    "sub": "重設積分與上次誤差"
   }
  ]
 },
 "積分飽和、微分雜訊與調參流程#5": {
  "type": "table",
  "head": [
   "解法",
   "做法"
  ],
  "rows": [
   [
    "低通濾波",
    "新值 = 0.7 × 舊 + 0.3 × 新讀值"
   ],
   [
    "減小 Kd",
    ""
   ],
   [
    "較長控制週期",
    ""
   ],
   [
    "微分作用在測量值",
    "避免目標突變衝擊"
   ]
  ],
  "reveal": [
   0,
   1,
   2,
   3,
   4
  ],
  "widths": [
   2,
   3
  ]
 },
 "積分飽和、微分雜訊與調參流程#6": {
  "type": "flow",
  "layout": "row",
  "reveal": [
   0,
   5,
   5
  ],
  "nodes": [
   {
    "label": "pidStep",
    "sub": "算出修正量"
   },
   {
    "label": "左輪",
    "sub": "基本速度 + 修正量"
   },
   {
    "label": "右輪",
    "sub": "基本速度 - 修正量"
   },
   {
    "label": "限幅 -100 到 100"
   },
   {
    "label": "setMotors",
    "sub": "送出左右輪速度"
   }
  ]
 },
 "把 PID 用在循線與直行#1": {
  "type": "flow",
  "layout": "snake",
  "reveal": [
   0,
   2,
   2,
   2,
   5,
   5
  ],
  "nodes": [
   {
    "label": "讀三顆感測器",
    "sub": "左 -1 中 0 右 +1"
   },
   {
    "label": "加權平均得位置",
    "sub": "例:左1 中1 右0 = -0.5"
   },
   {
    "label": "位置當誤差",
    "sub": "目標 0 = 線在中央"
   },
   {
    "label": "PID 算修正量"
   },
   {
    "label": "左右輪速度",
    "sub": "每 20 毫秒一圈"
   }
  ]
 },
 "把 PID 用在循線與直行#2": {
  "type": "cards",
  "reveal": [
   0,
   1,
   2
  ],
  "cards": [
   {
    "title": "位置公式",
    "points": [
     "(右 - 左) / (左 + 中 + 右)",
     "回傳 -1 到 +1"
    ]
   },
   {
    "title": "三顆都是 0",
    "points": [
     "式子沒有定義",
     "回傳最後一次方向的極值"
    ]
   }
  ]
 },
 "把 PID 用在循線與直行#4": {
  "type": "flow",
  "layout": "row",
  "reveal": [
   0,
   4
  ],
  "nodes": [
   {
    "label": "三顆都沒看到線"
   },
   {
    "label": "最後方向極值",
    "sub": "當誤差轉回去找"
   },
   {
    "label": "超過 1~2 秒",
    "sub": "還是找不到"
   },
   {
    "label": "進入 STOP",
    "sub": "重設積分"
   }
  ]
 },
 "把 PID 用在循線與直行#5": {
  "type": "flow",
  "layout": "snake",
  "reveal": [
   0,
   2,
   3,
   3,
   5
  ],
  "nodes": [
   {
    "label": "目標偏航角",
    "sub": "出發時的角度"
   },
   {
    "label": "誤差",
    "sub": "目標 - 目前"
   },
   {
    "label": "角度環繞",
    "sub": "限制在 ±180 度"
   },
   {
    "label": "PID 修正量"
   },
   {
    "label": "差速",
    "sub": "左 基本 - 修正 右 基本 + 修正"
   }
  ]
 },
 "把 PID 用在循線與直行#6": {
  "type": "table",
  "head": [
   "情況",
   "處理"
  ],
  "rows": [
   [
    "角度 > 180",
    "減 360"
   ],
   [
    "角度 < -180",
    "加 360"
   ],
   [
    "目標 5 度、現在 355 度",
    "直接相減 -350,環繞後 +10"
   ]
  ],
  "reveal": [
   0,
   2,
   2,
   3
  ],
  "widths": [
   2,
   3
  ]
 }
}