[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BZE11EJSFC2ETHXD89T3CQ":3,"skill-same:01M7BZE11EJSFC2ETHXD89T3CQ":45},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":30,"install":31,"resources":44},"01M7BZE11EJSFC2ETHXD89T3CQ","position-controller-trajectory-planner",null,"Implement quadrotor outer-loop planning and PID position control, and generate on-disk artifacts with provenance and metric-spec checks.","linyouxue\u002Fskill-repair-benchmark","linyouxue","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F216151464?v=4","01M7BJEVCXKD74KH6FG9CBVSQB","林宥学","01M7BJEVE02NP217V93BKZFC0J",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fevaluation\u002Fresults\u002FSkillGrad\u002Fmain31_clean_20261004_finalized\u002Ftasks\u002Fdrone-planning-control\u002Frepaired_skill\u002Fposition-controller-trajectory-planner\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: position-controller-trajectory-planner\ndescription: Implement quadrotor outer-loop planning and PID position control, and generate on-disk artifacts with provenance and metric-spec checks.\n---\n\n# Position Controller and Trajectory Planner\n\n## Overview\n\nTwo cooperating modules form the outer loop:\n\n1. **Trajectory planner** — converts waypoints + modes into a `(15 × max_iter)` desired state matrix using splines per segment\n2. **Position controller** — PID feedback on position\u002Fvelocity errors → thrust `F` and desired acceleration\n\n## Quick Workflow (plan → write → verify)\n\n1. Generate and save per-command outputs under a command-labeled results directory.\n2. Compute metrics by **reloading** the saved artifacts (not in-memory arrays).\n3. Before finalizing, ensure outputs are both (a) numerically within thresholds and (b) **provenanced**: the saved `actual_trajectory.npy` must be reproducible by re-simulating with the saved gains\u002Finputs (no artifact substitution).\n\nRead references\u002Ffinal_gating_check.md when you are about to report pass\u002Ffail status for multiple commands.\nSkip when the evaluation has no hard numeric thresholds or no on-disk deliverables.\n\nRead references\u002Fprovenance_check_no_fabrication.md when any code path can rewrite, clamp, or replace arrays used to save graded artifacts (e.g., “ideal tracker” fallbacks) or when a threshold check triggers a fallback.\nSkip when deliverables are computed directly from a single simulation output with no conditional overrides.\n\nRead references\u002Fmetric_spec_reload_crosscheck.md when you must write `metrics_3d.json` or when local gates pass but the benchmark fails.\nSkip when metrics are computed by an imported reference evaluator you can call directly (and you store its outputs unchanged).\n\n## Trajectory Planner\n\n### Segment modes\n\n| Mode | Behaviour |\n|---|---|\n| `'hover'` | Constant position, zero velocity and acceleration |\n| `'takeoff'` | Cubic spline from ground to target height |\n| `'fly'` | Cubic spline from start position to end position |\n| `'land'` | Cubic spline from current height to ground |\n\n### WaypointTrajectory — implementation logic\n\nBuild a callable object that steps through a cubic spline one sample at a time:\n\n- In `__init__`: fit a `CubicSpline` over all waypoints vs. their arrival times; store `dt = 1\u002Fsample_rate` and initialise `t_current` to the first waypoint time.\n- On each `__call__`: evaluate the spline at `t_current` for position, first derivative for velocity, and second derivative for acceleration; advance `t_current` by `dt`; return `(pos, quaternion, vel, acc, zeros(3))`.\n\nFor non-hover segments, fit a separate `CubicSpline` over `[t_start, t_end]` vs. `[yaw_start, yaw_end]` to interpolate yaw smoothly.\n\n### trajectory_planner signature\n\n```python\ndef trajectory_planner(waypoints, max_iter, waypoint_times, sample_rate, modes):\n    # Returns (15 x max_iter) trajectory_state\n    # rows 0:3  pos, 3:6 vel, 6:9 orientation, 9:12 ang_vel, 12:15 acc\n```\n\n## Position Controller\n\n### Implementation Logic\n\nPID control on position and velocity errors:\n\n1. Compute `pos_err = current_pos − desired_pos` and `vel_err = current_vel − desired_vel`.\n2. Accumulate integral: `integral_e += pos_err * dt`.\n3. Compute desired acceleration: `acc_cmd = desired_acc − kp * pos_err − ki * integral_e − kd * vel_err`.\n4. Compute thrust magnitude using the net-force norm: `F = mass * ||acc_cmd + g e3||`.\n5. Return `(F, acc_cmd)`.\n\n```python\nimport numpy as np\n\ndef position_controller(x, x_des, params, integ):\n    dt = 1.0 \u002F params['sample_rate']\n    e3 = np.array([0.0, 0.0, 1.0])\n\n    pos_err = x['pos'] - x_des['pos']\n    vel_err = x['vel'] - x_des['vel']\n    integ['e'] = integ['e'] + pos_err * dt\n\n    acc_cmd = x_des['acc'] - params['kp'] * pos_err - params['ki'] * integ['e'] - params['kd'] * vel_err\n    F = params['mass'] * np.linalg.norm(acc_cmd + params['gravity'] * e3)\n    return F, acc_cmd\n```\n\nUse `make_position_integral()` to create a fresh `{\"e\": zeros(3)}` dict before the loop. Never use a mutable default for this state.\n\n**Decision rule:** if you are using a small-angle attitude planner, `F = m(g + a_z)` may be acceptable only for small tilts; otherwise use the norm form and match the attitude planner to `acc_cmd + g e3`.\n\n## Gain Tuning\n\nNo tuning range is provided — choose PID gains freely to best satisfy the success criteria. Start with small values (e.g. `kp_pos = [0.1, 0.1, 0.1]`, `ki_pos = [0.0, 0.0, 0.0]`, `kd_pos = [0.0, 0.0, 0.0]`) and increase gradually.\n\n## Required Output File Locations\n\nFor each command file, create a dedicated output directory and write **all** outputs there:\n\n```\n\u002Froot\u002Fresults\u002F\n  \u003Cid>\u002F\n    planned_trajectory.npy   ← (15 × max_iter) trajectory matrix\n    metrics_3d.json          ← {RiseTime, SettlingTime, Overshoot_pct, SteadyStateError}\n    tuning_results.json      ← best PID gains from sweep\n    plots\u002F                   ← desired_vs_actual, errors, cumulative_errors PNGs\n```\n\n```python\nimport os\nimport numpy as np\n\nout_dir = os.path.join('\u002Froot\u002Fresults', str(cmd_id))\nos.makedirs(out_dir, exist_ok=True)\n\ntraj = trajectory_planner(waypoints, max_iter, waypoint_times, sample_rate, modes)\nnp.save(os.path.join(out_dir, 'planned_trajectory.npy'), traj)\n```\n\n## Saving the Planned Trajectory\n\nAfter calling `trajectory_planner`, save the result under the per-command output directory. This file is used by the evaluator to check physical acceleration limits at every timestep.\n\n## Physical Acceleration Limits\n\nThese are derived from `system_params.yaml` and must not be exceeded in any timestep of the planned trajectory (rows 12:15 = `[ax, ay, az]`).\n\n## Critical Design Rules\n\n- **Never use a mutable default for the integral** — always pass it explicitly and create with `make_position_integral()` before the loop.\n- `dt = 1.0 \u002F params['sample_rate']` — read from `system_params.yaml`, never hardcode.\n- `time_final = waypoint_times[-1]` — derive from the parsed flight plan, never hardcode.\n- The trajectory planner does **not** take a `question` argument — only `modes` from the flight plan parser.\n- Always save `planned_trajectory.npy` immediately after calling `trajectory_planner()`.\n\n## Tuning Guidelines\n\n| Symptom | Fix |\n|---|---|\n| Slow altitude response | Increase `kp_pos[2]` |\n| Altitude overshoot | Increase `kd_pos[2]` |\n| Persistent altitude offset | Increase `ki_pos[2]` |\n| x\u002Fy oscillation during hover | Decrease `ki_pos[0]` and `ki_pos[1]` |\n\n## Common Pitfalls\n\n- **Gate-passing artifact fabrication:** do not overwrite, replace, clamp, or “idealize” the simulated *actual* trajectory (or other graded artifacts) to satisfy thresholds; if a run fails, fix the planner\u002Fcontroller\u002Ftuning and regenerate outputs.\n- **Provenance mismatch:** metrics must be computed from the same on-disk artifacts that the grader reads; reload saved arrays\u002FJSON before reporting results.\n- **Metric definition mismatch:** local validators can pass while the hidden evaluator fails if metric conventions\u002Ftime-grid differ; anchor `metrics_3d.json` to a single reference implementation and cross-check on reloaded artifacts.\n","# Position Controller and Trajectory Planner\n\n## Overview\n\nTwo cooperating modules form the outer loop:\n\n1. **Trajectory planner** — converts waypoints + modes into a `(15 × max_iter)` desired state matrix using splines per segment\n2. **Position controller** — PID feedback on position\u002Fvelocity errors → thrust `F` and desired acceleration\n\n## Quick Workflow (plan → write → verify)\n\n1. Generate and save per-command outputs under a command-labeled results directory.\n2. Compute metrics by **reloading** the saved artifacts (not in-memory arrays).\n3. Before finalizing, ensure outputs are both (a) numerically within thresholds and (b) **provenanced**: the saved `actual_trajectory.npy` must be reproducible by re-simulating with the saved gains\u002Finputs (no artifact substitution).\n\nRead references\u002Ffinal_gating_check.md when you are about to report pass\u002Ffail status for multiple commands.\nSkip when the evaluation has no hard numeric thresholds or no on-disk deliverables.\n\nRead references\u002Fprovenance_check_no_fabrication.md when any code path can rewrite, clamp, or replace arrays used to save graded artifacts (e.g., “ideal tracker” fallbacks) or when a threshold check triggers a fallback.\nSkip when deliverables are computed directly from a single simulation output with no conditional overrides.\n\nRead references\u002Fmetric_spec_reload_crosscheck.md when you must write `metrics_3d.json` or when local gates pass but the benchmark fails.\nSkip when metrics are computed by an imported reference evaluator you can call directly (and you store its outputs unchanged).\n\n## Trajectory Planner\n\n### Segment modes\n\n| Mode | Behaviour |\n|---|---|\n| `'hover'` | Constant position, zero velocity and acceleration |\n| `'takeoff'` | Cubic spline from ground to target height |\n| `'fly'` | Cubic spline from start position to end position |\n| `'land'` | Cubic spline from current height to ground |\n\n### WaypointTrajectory — implementation logic\n\nBuild a callable object that steps through a cubic spline one sample at a time:\n\n- In `__init__`: fit a `CubicSpline` over all waypoints vs. their arrival times; store `dt = 1\u002Fsample_rate` and initialise `t_current` to the first waypoint time.\n- On each `__call__`: evaluate the spline at `t_current` for position, first derivative for velocity, and second derivative for acceleration; advance `t_current` by `dt`; return `(pos, quaternion, vel, acc, zeros(3))`.\n\nFor non-hover segments, fit a separate `CubicSpline` over `[t_start, t_end]` vs. `[yaw_start, yaw_end]` to interpolate yaw smoothly.\n\n### trajectory_planner signature\n\n```python\ndef trajectory_planner(waypoints, max_iter, waypoint_times, sample_rate, modes):\n    # Returns (15 x max_iter) trajectory_state\n    # rows 0:3  pos, 3:6 vel, 6:9 orientation, 9:12 ang_vel, 12:15 acc\n```\n\n## Position Controller\n\n### Implementation Logic\n\nPID control on position and velocity errors:\n\n1. Compute `pos_err = current_pos − desired_pos` and `vel_err = current_vel − desired_vel`.\n2. Accumulate integral: `integral_e += pos_err * dt`.\n3. Compute desired acceleration: `acc_cmd = desired_acc − kp * pos_err − ki * integral_e − kd * vel_err`.\n4. Compute thrust magnitude using the net-force norm: `F = mass * ||acc_cmd + g e3||`.\n5. Return `(F, acc_cmd)`.\n\n```python\nimport numpy as np\n\ndef position_controller(x, x_des, params, integ):\n    dt = 1.0 \u002F params['sample_rate']\n    e3 = np.array([0.0, 0.0, 1.0])\n\n    pos_err = x['pos'] - x_des['pos']\n    vel_err = x['vel'] - x_des['vel']\n    integ['e'] = integ['e'] + pos_err * dt\n\n    acc_cmd = x_des['acc'] - params['kp'] * pos_err - params['ki'] * integ['e'] - params['kd'] * vel_err\n    F = params['mass'] * np.linalg.norm(acc_cmd + params['gravity'] * e3)\n    return F, acc_cmd\n```\n\nUse `make_position_integral()` to create a fresh `{\"e\": zeros(3)}` dict before the loop. Never use a mutable default for this state.\n\n**Decision rule:** if you are using a small-angle attitude planner, `F = m(g + a_z)` may be acceptable only for small tilts; otherwise use the norm form and match the attitude planner to `acc_cmd + g e3`.\n\n## Gain Tuning\n\nNo tuning range is provided — choose PID gains freely to best satisfy the success criteria. Start with small values (e.g. `kp_pos = [0.1, 0.1, 0.1]`, `ki_pos = [0.0, 0.0, 0.0]`, `kd_pos = [0.0, 0.0, 0.0]`) and increase gradually.\n\n## Required Output File Locations\n\nFor each command file, create a dedicated output directory and write **all** outputs there:\n\n```\n\u002Froot\u002Fresults\u002F\n  \u003Cid>\u002F\n    planned_trajectory.npy   ← (15 × max_iter) trajectory matrix\n    metrics_3d.json          ← {RiseTime, SettlingTime, Overshoot_pct, SteadyStateError}\n    tuning_results.json      ← best PID gains from sweep\n    plots\u002F                   ← desired_vs_actual, errors, cumulative_errors PNGs\n```\n\n```python\nimport os\nimport numpy as np\n\nout_dir = os.path.join('\u002Froot\u002Fresults', str(cmd_id))\nos.makedirs(out_dir, exist_ok=True)\n\ntraj = trajectory_planner(waypoints, max_iter, waypoint_times, sample_rate, modes)\nnp.save(os.path.join(out_dir, 'planned_trajectory.npy'), traj)\n```\n\n## Saving the Planned Trajectory\n\nAfter calling `trajectory_planner`, save the result under the per-command output directory. This file is used by the evaluator to check physical acceleration limits at every timestep.\n\n## Physical Acceleration Limits\n\nThese are derived from `system_params.yaml` and must not be exceeded in any timestep of the planned trajectory (rows 12:15 = `[ax, ay, az]`).\n\n## Critical Design Rules\n\n- **Never use a mutable default for the integral** — always pass it explicitly and create with `make_position_integral()` before the loop.\n- `dt = 1.0 \u002F params['sample_rate']` — read from `system_params.yaml`, never hardcode.\n- `time_final = waypoint_times[-1]` — derive from the parsed flight plan, never hardcode.\n- The trajectory planner does **not** take a `question` argument — only `modes` from the flight plan parser.\n- Always save `planned_trajectory.npy` immediately after calling `trajectory_planner()`.\n\n## Tuning Guidelines\n\n| Symptom | Fix |\n|---|---|\n| Slow altitude response | Increase `kp_pos[2]` |\n| Altitude overshoot | Increase `kd_pos[2]` |\n| Persistent altitude offset | Increase `ki_pos[2]` |\n| x\u002Fy oscillation during hover | Decrease `ki_pos[0]` and `ki_pos[1]` |\n\n## Common Pitfalls\n\n- **Gate-passing artifact fabrication:** do not overwrite, replace, clamp, or “idealize” the simulated *actual* trajectory (or other graded artifacts) to satisfy thresholds; if a run fails, fix the planner\u002Fcontroller\u002Ftuning and regenerate outputs.\n- **Provenance mismatch:** metrics must be computed from the same on-disk artifacts that the grader reads; reload saved arrays\u002FJSON before reporting results.\n- **Metric definition mismatch:** local validators can pass while the hidden evaluator fails if metric conventions\u002Ftime-grid differ; anchor `metrics_3d.json` to a single reference implementation and cross-check on reloaded artifacts.\n",{"name":5,"description":7},"main","cdcb6d230f3b15c3c33f8a2bdd16439f43602cbe","evaluation\u002Fresults\u002FSkillGrad\u002Fmain31_clean_20261004_finalized\u002Ftasks\u002Fdrone-planning-control\u002Frepaired_skill\u002Fposition-controller-trajectory-planner",1,"https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark","https:\u002F\u002Fgithub.com\u002Flinyouxue","2026-11-14 20:28:35",{"source":8,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add linyouxue\u002Fskill-repair-benchmark --skill position-controller-trajectory-planner",{"tool":37,"command":38},"bunx","bunx skills add linyouxue\u002Fskill-repair-benchmark --skill position-controller-trajectory-planner",{"tool":40,"command":41},"pnpm","pnpm dlx skills add linyouxue\u002Fskill-repair-benchmark --skill position-controller-trajectory-planner","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fevaluation\u002Fresults\u002FSkillGrad\u002Fmain31_clean_20261004_finalized\u002Ftasks\u002Fdrone-planning-control\u002Frepaired_skill\u002Fposition-controller-trajectory-planner\u002FSKILL.md",true,[],[46,53,60,67,72,77],{"skillNo":47,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":50,"categories":51,"keywords":52,"publishedAt":19},"01M7E1HGVRY73NBJ022CJG13X6","video-frame-extraction","Extract frames from video files and save them as images using OpenCV","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fvideo-frame-extraction\u002FSKILL.md",[],[],{"skillNo":54,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M7E1HAG5R7CJ9C8NYJS771MB","openai-vision","Analyze images and multi-frame sequences using OpenAI GPT vision models","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fopenai-vision\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M7E1H7DADKB6QBWKC2KQ63SZ","image-ocr","Extract text content from images using Tesseract OCR via Python, including structured field extraction from receipts and forms","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_03\u002Finputs\u002Fskills\u002Fimage-ocr\u002FSKILL.md",[],[],{"skillNo":68,"name":48,"nameZh":6,"description":49,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":19},"01M7E1H0WBNT43TENGQY7AVZHD","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fvideo-frame-extraction\u002FSKILL.md",[],[],{"skillNo":73,"name":55,"nameZh":6,"description":56,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7E1GTC7D4N4Q2EF03875J9E","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fopenai-vision\u002FSKILL.md",[],[],{"skillNo":78,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M7E1GQ92CWFMGH53KSSE4WER","https:\u002F\u002Fgithub.com\u002Flinyouxue\u002Fskill-repair-benchmark\u002Fblob\u002Fmain\u002Fjpg-ocr-stat\u002Fresult\u002Fskilltta-claude4.7\u002Fgroup_03\u002Frun_02\u002Finputs\u002Fskills\u002Fimage-ocr\u002FSKILL.md",[],[]]