▶ Try it its model runs in your browser, nothing to install

template · verified

arche/two-link-arm

Two-link arm

A two-link arm hanging from a fixed shoulder, a motor and an encoder at each joint, and a controller that cancels gravity and reaches its pose; its plant in MuJoCo (archec gen --target mujoco), its test cases run against it (archec sim --plant … --test).

plantmujocorobotarmcontrolgravity-compensation

archec add main.arche arche/two-link-arm@^0.1

Package

Kindtemplate
Version0.1.0
LicenseApache-2.0
Export controlnone
Works witharchec >=0.10
Edition0.12
Handlersthe action language (```arche), run as TypeScript from its code
Homehttps://github.com/arche-lang/arche-lang

Model

SystemsArm
ComponentsLink Motor Encoder Controller
Requirements2
Messages2

Code it brings

WhereLanguageLines
main.arche · Controller.on_shoulder.bodyarche4
main.arche · Controller.on_elbow.bodyarche11

Two-link arm

A two-link arm hanging from a fixed shoulder: two 0.5 m links of 1 kg, a motor (N·m) and an encoder at each joint. Its controller cancels gravity and adds a PD law on top, so it reaches its targets — a plain PD, as examples/arm has, stops short of them, held back by gravity.

| | | |---|---| | Plant | 2 hinges (y), 2 torque motors (±20 N·m), 2 encoders, 1 ms step | | Controller | τ = G(q) + KP·(target − q) − KD·q̇, 100 Hz; KP 40, KD 6 | | Requirements | REQ-ARM-REACH (within 0.02 rad in 2 s), REQ-ARM-HOLD | | Test plan | TP-ARM: reach the first pose, hold it, a second pose |

archec new my-arm --template two-link-arm     a project from it, yours to change
archec gen main.arche --target mujoco -o out
archec sim main.arche --plant out/mujoco/plant_bridge.py --test
python3 out/mujoco/plant_bridge.py --viewer

In MuJoCo (4.0), from 0, 0 to 0.6, 0.9 rad: within 0.02 rad at 0.78 s, and 2·10⁻⁶ rad off at 3 s. Change the targets (controller.target_shoulder, target_elbow) or the links' mass and length — G(q) uses LINK_MASS and LINK_LENGTH, so change them together.

Versions

VersionPublishedarchecState
0.1.02026-11-12>=0.10public

Signature

Signed by arche with key e660d0a8851875b9. Files: 3, fingerprint sha256-4b62d917af56341075e5…. archec add checks both before it writes anything.

Discussion

Loading…