import { ServerRPC } from '@vuer-ai/vuer'; export interface KeyFrame { /** * Name of this keyframe. */ name?: string; /** * Simulation time, copied into mjData. */ time?: number; /** joint positions */ qpos?: number[]; /** joint velocities */ qvel?: number[]; /** actuator activations */ act?: number[]; /** control vector */ ctrl?: number[]; /** mocap body positions */ mocap_pos?: number[]; /** mocap body quaternions */ mocap_quat?: number[]; /** mocap body velocities */ site_xpos?: number[]; /** mocap body angular velocities */ site_xmat?: number[]; /** geom positions */ geom_xpos?: number[]; /** geom quaternions */ geom_xmat?: number[]; /** sensordata */ sensordata?: number[]; /** * Generalized forces applied directly to degrees of freedom (DoFs). * Shape: [nv] where nv is the number of velocity DoFs. * * Each element corresponds to a force/torque on a specific DoF: * - Hinge joint: 1 value (torque in Nm) * - Slide joint: 1 value (force in N) * - Ball joint: 3 values (torques around 3 axes) * - Free joint: 6 values (3 forces + 3 torques) * * Example: For joint i, use model.jnt_dofadr[i] to get the DoF index, * then set qfrc_applied[dof_index] = force_value */ qfrc_applied?: number[]; /** * External wrenches (force + torque) applied at each body's center of mass. * Shape: [nbody * 6] - flat array where nbody is the number of bodies. * * Each body occupies 6 consecutive values in world coordinates: * - [i*6 + 0:3]: Force vector [fx, fy, fz] in Newtons * - [i*6 + 3:6]: Torque vector [tx, ty, tz] in Newton-meters * * Example: To apply 10N force in X and 5Nm torque around Z to body i: * xfrc_applied[i*6 + 0] = 10; // fx * xfrc_applied[i*6 + 1] = 0; // fy * xfrc_applied[i*6 + 2] = 0; // fz * xfrc_applied[i*6 + 3] = 0; // tx * xfrc_applied[i*6 + 4] = 0; // ty * xfrc_applied[i*6 + 5] = 5; // tz * * Note: These forces are cleared after each simulation step unless reapplied. */ xfrc_applied?: number[]; } export declare const ALL_KEYFRAME_KEYS: string; export type KeyFrameKeys = 'name' | 'time' | 'qpos' | 'qvel' | 'act' | 'ctrl' | 'mocap_pos' | 'mocap_quat' | 'site_xpos' | 'site_xmat' | 'geom_xpos' | 'geom_xmat' | 'sensordata' | 'qfrc_applied' | 'xfrc_applied'; export type WrenchTuple = [number, number, number, number, number, number]; export type MjStepEvent = ServerRPC & { key?: string; data: { /** * External force/torque to apply via sim.applyForce(), outside the * xfrc_applied array. * * Contains 9 values: [fx, fy, fz, tx, ty, tz, px, py, pz] * - [0:3]: Force vector in world coordinates (Newtons) * - [3:6]: Torque vector in world coordinates (Newton-meters) * - [6:9]: Application point in world coordinates (meters) * * These values are passed to sim.applyForce() along with xfrc_bodyId. */ xfrc: number[] | WrenchTuple; /** * Body ID that the force in xfrc should be applied to. * This is a single body ID, not an array. * * Example: If xfrc contains 9 values [fx, fy, fz, tx, ty, tz, px, py, pz] * and xfrc_bodyId = 2, the force will be applied to body 2. * * Note: For applying multiple forces to different bodies, use multiple * MjStepEvent messages or use the xfrc_applied array instead. */ xfrc_bodyId: number; /** * Number of simulation steps to execute in this update. * If not specified, defaults to 1 step. */ sim_steps?: number; } & KeyFrame; };