lmphysics
lmphysics is a self-contained Project Chrono rigid-body physics host for LMScript. It simulates 3D collisions, friction, restitution, joints, springs, motors, gears, and mechanisms in SI units and exports trajectories to CSV.
Quick reference
npm install -g @lmctl-ai/lmctl
lmphysics --version
lmphysics --lmcode-schema --json
lmctl autorun examples/pendulum.lms
| Object or method | Signature or syntax | Purpose |
|---|---|---|
| context phys: Phys | phys.system("nsc" | "smc"), phys.assert_close(a, b, tol) | Create a non-smooth complementarity (nsc) or penalty (smc) world and verify known answers. |
| System numerics | s.gravity(x,y,z), s.timestep(dt), s.integrator(name), s.solver(name, iters) | Configure gravity, time step, integrator (euler, trapezoidal, hht, newmark), and solver (psor, apgd). |
| System bodies | s.ground(name), s.floor(name, mat), s.box(...), s.sphere(...), s.cylinder(...) | Add fixed ground/floor anchors or rigid box, sphere, and cylinder bodies with material collisions. |
| System joints & motors | s.revolute(...), s.prismatic(...), s.universal(...), s.gear(...), s.spring_at(...), s.motor_speed(...) | Connect bodies with 3D kinematic joints, gears, springs, dampers, and expression-driven rotational or linear motors. |
| Recording & state | s.record(name, cols), s.record_every(n), s.run(t_end), s.energy(), s.save_csv(path) | Integrate forward in time, inspect mechanical energy and reactions, and save CSV trajectories and quaternions. |
p = _lmcode_ cli="lmphysics" install="github:lmctl-ai/lmphysics@latest";
let s = phys.system("nsc");
s.integrator("hht").timestep(0.0005);
let pin = s.ground("pin");
let bob = s.sphere("bob", 0.05, 2000.0).pos(0.866, 0.0, -0.5);
let hinge = s.revolute("hinge", pin, bob, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
s.record("bob", "x,z,vx,vz").record("hinge", "angle,fx,fz");
let e0 = s.energy();
s.run(5.0);
phys.assert_close(s.energy() / e0, 1.0, 0.0001);
s.save_csv("pendulum.csv");
end _lmcode_
r = run_lmcode(p);
require(r.ok, json_stringify(r));
Documentation pages
- Skill — authoring rules, CLI commands, inputs and outputs, safety rules, worked examples, and verification steps.
- Guide — NSC vs SMC contact, integrator and solver selection, collision margins, pose export, and the standard lmcode_std_v3 library.
- Reference — complete CLI flags, Phys/System/Body/Joint method signatures, standard library catalog, and exit codes.