Repository navigation
Additions
- Added
NeuroMechFlyWithSeparateTrochanterFemur, a NeuroMechFly variant in which each leg's trochanter and femur are separate bodies (with separate meshes) rather than a single fused trochanterfemur body. This enables valid segmentation maps for these segments. We tentatively plan to make this the only supported NeuroMechFly body in FlyGym v3 (#313). - Added
GPUSimulation.set_state(),get_base_linear_velocity(), andget_base_angular_velocity()(#305). - Added
forward()to bothSimulationandGPUSimulationto recompute derived quantities (e.g. body positions) without stepping physics. - Lazy getters in
GPUSimulationnow accept an optionaldstarray to write into an existing buffer instead of allocating a new one (#301). - Added
World.flyandSimulation.flyshorthands for single-fly setups,Simulation.fly_lookup, andBaseFly.n_bodysegs,n_jointdofs, andget_n_actuated_jointdofs()(#301). - Added
Retina.fisheye_image_to_hex_pxls(), which fuses fisheye correction and ommatidia pooling into a single pass. CPU vision now uses it, making this step about 2× faster (#308, #315; thanks @Cr0me1ve). - Added
scripts/export_model_for_flexik.pyto export the fly body plan for FlexIK. - Added trajectory recording, which decouples the number of simulated worlds from the number of rendered ones.
Simulation.set_trajectory_recorder()andGPUSimulation.set_trajectory_recorder()attach a recorder that stores only the kinematic state (qposand mocap poses) at the video frame rate. The resultingRecordedTrajectoryobjects can be saved, sub-selected, and rendered to video afterwards withflygym.recording.render_trajectories()(CPU) orflygym.warp.recording.render_trajectories_gpu()(GPU batch rendering). A recorder can be used together with a renderer, and rendering a recorded trajectory gives exactly the same frames as rendering live. See the new tutorial 8. Recording and rendering trajectories (#296, #319).
Changes
- Renderers now draw a private copy of the simulation state in which body, camera, light, and tendon positions are recomputed from the current
qpos. Previously, they drew the positions computed at the start of the last physics step, so frames lagged by one timestep. The simulation state itself is not modified (#319). WarpGPUBatchRenderernow renders only the selectedworldsinstead of all simulated worlds, so rendering a few out of many worlds is much faster and uses less GPU memory (#319).GPUSimulation.reset()now resetsmjw_datain place using MuJoCo Warp'sreset_data_keyframe(), instead of reallocating the GPU-side model and data on every reset (#302). Note that, as withSimulation.reset(), derived kinematic quantities (xpos,xquat, …) are not recomputed on reset; callforward()if you need them.- Remote assets are now stored as tarballs with SHA-256 checksums. FlyGym verifies the checksum after download and moves the extracted files into the cache atomically, which also makes concurrent downloads safe (#303).
GPUSimulationnow uses a constraint solver tolerance of 1e-5 by default, configurable via the newsolver_toleranceargument. Since MuJoCo Warp 3.10, which fixed a float32 precision issue in its convergence check, MuJoCo Warp's default tolerance (1e-6) causes a small fraction of worlds to stall until they hit the solver iteration limit, printing "solver iterations limit reached" warnings. Because all worlds wait for the slowest one, this slowed down GPU simulation by ~25% with 1000 worlds. With 1e-5, these stalls are essentially gone, while joint-angle tracking is unchanged within GPU run-to-run variability.GPUSimulationnow disables MuJoCo Warp's solver and line search iteration limit warnings, which are printed once per world per step and could flood the output. This follows MuJoCo Playground. Warnings about contact and constraint buffer overflows are still shown.- The WASM NeuroMechFly Live game is easier to play: stronger leg adhesion, faster turning, gamepad leg buttons matching the physical left/right layout, and correct colors for split trochanter/femur geoms (#314).
Bug fixes
- Fixed body-segment position/orientation getters returning wrong values when MuJoCo's
fusestaticcompiler option merges bodies and invalidates body IDs (#312). - Fixed the ground texture not showing in GPU batch rendering after the MuJoCo Warp 3.16 upgrade. MuJoCo Warp now maps textures on finite planes like the CPU renderer does, so FlyGym's workaround of scaling
texrepeatdown by 1000× was removed. - Fixed
GPUSimulationdropping thetimestepoverride when GPU batch rendering is enabled, which recompiles the model. - Fixed GPU benchmark and tutorial timings, which stopped the timer before queued GPU work finished and therefore overstated throughput by up to ~50% (#311; thanks @AdeliyaLeleytner).
Housekeeping
- Support documentation site with multiple release versions #299.
- Automated release workflow #321.
- Bumped MuJoCo and MuJoCo Warp versions to 3.16.
- FlyGym now supports Python 3.12 – 3.15. The
rlextra is not yet installable on Python 3.15 because PyTorch does not ship wheels for it. - Updated Warp kernel type hints to the PEP 484-compliant
wp.array[dtype]syntax and replaced string array dimensions withTypeVars defined inflygym.utils.typing(#304). - Unit tests can now run in parallel via
pytest-xdist(pytest -n auto).
Contributors
@sibocw, @stimpfli, @AdeliyaLeleytner, @Cr0me1ve
What's Changed
- Buffering optimization by @sibocw in #301
- Reset mjw_data in place instead of rebuilding GPU structs by @sibocw in #302
- Improve lazy asset loading: use tarred files and checksums by @sibocw in #303
- Update type hints to be PEP 484 compliant by @sibocw in #304
- Fix bug where some body IDs become invalid after compilation when fusestatic=true by @sibocw in #312
- Split trochanters and femurs as separate bodies, not just geoms by @sibocw in #313
- Features added for the
flycontrolproject by @sibocw in #305 - Improve WASM game playability; fix femur colors and gamepad sides by @sibocw in #314
- Fix GPU benchmark timing boundaries by @AdeliyaLeleytner in #311
- PR308 trimmed to just fusing fisheye correction with batched stepping and retina pooling by @sibocw in #315
- Add Adelya Leleytner to contributors by @AdeliyaLeleytner in #317
- use mjw.reset_data_keyframe instead of our local implementation by @sibocw in #318
- Add kinematic trajectory recording with post-hoc rendering (#296) by @sibocw in #319
- Add versioned docs via separate flygym-docs repo by @sibocw in #300
- Pre-release review fixes for v2.1.1 by @sibocw in #320
- Automate release workflow by @sibocw in #321
- Version v2.1.1 by @sibocw in #295
New Contributors
- @Cr0me1ve made their first contribution in #308
- @AdeliyaLeleytner made their first contribution in #311
Full Changelog: v2.1.0...v2.1.1