1 Step 1: Copy the passive skeleton
Suppose the runner to be created is named demo_runner
- Copy the Runner directory:
src/runner/passive->src/runner/demo - Copy the parameter class directory:
src/data/_param/passive_param->src/data/_param/demo_param - Copy the parameter configuration:
assets/config/<robot>/passive/default.yaml->assets/config/<robot>/demo/default.yaml - Quick reference table for key replacement parts:
| Replacement Item | passive template | demo example | Description |
|---|---|---|---|
| Parameter class name and default tag | PassiveParam("passive") | DemoParam("demo") | Must be aligned with mode.yaml/param_tag |
| Parameter type in Runner | std::shared_ptr<data::PassiveParam> | std::shared_ptr<data::DemoParam> | Includes the constructor and create<...>() in Enter() |
| Registration macro string | REGISTER_RUNNER(PassiveRunner, "passive_runner", kMotion) | REGISTER_RUNNER(DemoRunner, "demo_runner", kMotion) | Must be exactly identical to runner[].name in task_motion |
| Parameter configuration path | assets/config/<robot>/passive/default.yaml | assets/config/<robot>/demo/default.yaml | Referenced later in mode.yaml via scope |
2 Step 2: Add a Runner in the Task
- Add the new
tag -> scopein bothassets/config/<robot>/mode.yaml(simandrobot)
YAML |
- Add a task entry in
task_motion/*.yamlortask_resident/*.yamland mount it:- Assume the added demo_runner is a motion task
YAML |
3 Step 3: Extend the Parameter Class
- Add
LOAD_PARAM(...)fields as needed, and complete the read logic inUpdate(). - When constraints are needed, you can add
Check()(range, dimension, non-empty, etc.).
Example: if your Runner needs to load a model file (such as a policy network)
- Add a new field in the parameter YAML (e.g.
policy_path):
YAML |
- Add a new read field in the parameter class:
C++ |
- Load the model in the Runner
Enter():
C++ |
- Add a member in the Runner header file:
std::unique_ptr<math::MNNModel> model_;
This forms the complete chain: YAML configuration -> Param LOAD_PARAM -> Runner Enter() takes effect
4 Step 4: Extend the Runner Logic
motion runneradditionally maintainsSetupContext()/TeardownContext()to manage global parameters- Continuously write output in
Run()(GetMutableOutput().SetCommand(...)) - Put the time-consuming reset logic in
TryExit, and one-time cleanup/reset inExit
