Implementation:Google deepmind Mujoco Platform Interaction Header
| Knowledge Sources | |
|---|---|
| Domains | User Interaction, API Declaration |
| Last Updated | 2026-02-15 04:00 GMT |
Overview
Declares the API for mouse-driven camera motions, scene picking, object perturbation, and camera selection in MuJoCo's platform layer.
Description
interaction.h defines the interaction interface for MuJoCo's experimental platform. It declares the PickResult struct containing world coordinates, distance, and indices for body, geom, flex, and skin hits. The CameraMotion enum provides a comprehensive camera motion vocabulary: ZOOM, ORBIT, TRUCK_PEDESTAL, TRUCK_DOLLY, PAN_TILT, PLANAR_MOVE_H, PLANAR_MOVE_V, with documented definitions for each motion type. Constants for special camera indices (tumble, free, tracking) are defined. Key functions include Pick for scene picking, SetCamera for camera switching, MoveCamera for camera motion, and InitPerturb/MovePerturb for object manipulation.
Usage
Included by app.cc and other interactive MuJoCo applications that need to handle mouse-based scene interaction. The header provides the complete interface for translating user input into camera and perturbation state changes.
Code Reference
Source Location
- Repository: Google_deepmind_Mujoco
- File: src/experimental/platform/interaction.h
- Lines: 1-85
Key Functions
struct PickResult { mjtNum point[3]; mjtNum dist; int body, geom, flex, skin; };
PickResult Pick(const mjModel* m, const mjData* d, const mjvCamera* camera, float x, float y, float aspect_ratio, const mjvOption* vis_options);
int SetCamera(const mjModel* m, mjvCamera* camera, int request_idx);
enum class CameraMotion { ZOOM, ORBIT, TRUCK_PEDESTAL, TRUCK_DOLLY, PAN_TILT, PLANAR_MOVE_H, PLANAR_MOVE_V };
void MoveCamera(const mjModel* m, const mjData* d, mjvCamera* cam, CameraMotion motion, mjtNum dx, mjtNum dy);
void InitPerturb(const mjModel* m, const mjData* d, const mjvCamera* cam, mjvPerturb* pert, mjtPertBit active);
void MovePerturb(const mjModel* m, const mjData* d, const mjvCamera* cam, mjvPerturb* pert, mjtMouse action, mjtNum reldx, mjtNum reldy);
Import
#include "experimental/platform/interaction.h"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| m | const mjModel* | Yes | MuJoCo model |
| d | const mjData* | Yes | Current simulation data |
| camera | mjvCamera* | Yes | Camera for picking or motion |
| x, y | float | Yes | Normalized mouse coordinates for picking |
Outputs
| Name | Type | Description |
|---|---|---|
| PickResult | PickResult | Hit information from scene picking (body, geom, world point, distance) |
| camera index | int | Validated camera index from SetCamera |