Conventions Crazyflow

VérifiéSûr

Pièges et conventions non évidents pour travailler dans le simulateur de drones Crazyflow, incluant l'ajout de modèles, les tests et l'utilisation de JAX.

Spar Skills Guide Bot
DeveloppementAvancé
14/08/2026
Claude CodeCursorCodex
#jax#simulation#drone-dynamics#array-api#testing

Recommandé pour

Synthèse automatique

Documente les conventions et les pièges non évidents du simulateur de drones crazyflow, notamment l'API array, l'usage de JAX, l'enregistrement de modèles de dynamique et l'organisation des tests avec pixi.

Points forts

  • Explique les règles précises de l'API array : récupérer le namespace via array_namespace, coercer les paramètres avec to_xp et ne jamais importer numpy dans un chemin de calcul
  • Donne une procédure fiable pour ajouter un modèle de dynamique ou un drone, avec les emplacements d'enregistrement et l'astuce du grep qui échoue à cause de build_control_fns
  • Signale des pièges de test concrets : les tests de rendu désélectionnés par addopts, le fichier de visualisation ignoré en headless, et les docstrings exécutables dont la sortie n'est pas comparée
  • Précise les subtilités d'utilisation hors Sim : ordre d'import de scipy, les trois load_params distincts, le partial partagé de parametrize et les conventions de dimensions de batch

Limites

  • Contenu très spécifique au dépôt crazyflow : inutilisable comme guide général sur JAX ou sur la simulation de drones
  • Le document s'interrompt au milieu d'une phrase sur symbolic_dynamics, laissant cette section incomplète
  • Suppose une familiarité avec pixi, jax.jit/grad/vmap et le framework de test du projet
Quand l'utiliser

À charger dès qu'une tâche touche le code de crazyflow : ajout d'un drone ou d'un modèle de dynamique, réutilisation de contrôleurs hors Sim, ou débogage de tests et d'exemples exécutables.

Quand l'éviter

Pour apprendre JAX, l'API array standard ou la simulation de drones en général, ou pour travailler sur un autre simulateur que crazyflow.

Analyse de sécurité

Sûr
Score qualité92/100

The skill is a codebase-specific guide with no dangerous instructions, credential handling, network exfiltration, obfuscated payloads, or destructive commands. It suggests deleting a shared JAX cache to resolve confusing failures, which is mildly operational but not a meaningful security risk.

Aucun point d'attention détecté

Comment cette analyse est faite

Exemples

Add a new drone platform
Add a new quadrotor platform called 'x500' to crazyflow: register it in the available drones, add the matching section to every crazyflow/dynamics/*/params.toml, and make sure the ~40 parametrized registration tests pass.
Use dynamics outside Sim
Write a batched MPC-style loop that calls crazyflow's dynamics and Mellinger controller outside Sim, with array_namespace handling, zeros-initialized integral state under jit, and a ctrl_freq that matches my real 100 Hz loop.
Debug tests and doctests
My crazyflow tests pass in CI but a docstring example prints the wrong value — convert the output check to a pycon fence with >>> prompts and tell me why the markdown runner never caught it.

name: crazyflow description: Non-obvious traps and conventions in the crazyflow drone simulator. Use when working in the crazyflow codebase, adding a dynamics model or drone platform, reusing the dynamics or controllers outside Sim for estimation or MPC, or writing code under jax.jit, grad or vmap.

Crazyflow

Settings are in pyproject.toml, layout in the tree, API reference in docs/.

Conventions

  • Ruff settings live in pyproject.toml and must pass before committing.
  • Dynamics and controllers follow the array API standard. Take the namespace from the inputs with array_namespace(...), do all math through it, coerce bound parameters with to_xp, and never import numpy into a computation path.
  • crazyflow/control/mellinger/params.toml deliberately holds values that differ from the true physical constants in crazyflow/drones/params.toml, reproducing the real firmware. Do not unify them.

Testing

pixi run -e tests tests        # what CI runs
pixi run -e tests test-docs    # every example in docstrings and docs

Use pixi, not uv. pixi run <cmd> resolves task names only, so arbitrary commands need -e tests.

  • addopts = "-m 'not render'" deselects every render test, and tests/unit/test_visualizations.py is @skip_if_headless without the marker, so it is skipped silently without DISPLAY. Rendering regressions pass CI green. Run -m render locally with a display.
  • Docs and docstrings are executable. The markdown runner catches exceptions but never compares output, so a print with the result in a trailing comment proves nothing. Output that must be checked goes in a pycon fence with >>> prompts, which doctest picks up.
  • tests/integration/test_examples.py runs every script under examples/, so a new example is a new test.
  • tests/conftest.py forces JAX's persistent cache on at /tmp/jax_cache, shared across branches. Delete it when failures make no sense.
  • Request the device fixture rather than a GPU marker. It falls back to CPU silently, so gpu-tests asserts nothing about placement on a machine without CUDA.

Adding a dynamics model or drone

Grepping the name of an existing model or drone finds every registration site, except when matching against all models in the simulation's build_control_fns.

Define the function in dynamics.py and never in the package __init__.py, because load_params derives the model name from fn.__module__.split(".")[-2]. parametrize binds exactly the keyword-only parameters after the bare *, so anything before it is never bound. Every drone in available_drones needs a section in every crazyflow/dynamics/*/params.toml, even an empty one.

Registration alone produces roughly 40 parametrized tests. These do not include derivatives tests.

Using dynamics and controllers outside Sim

Pure, batched, array-API functions with no dependency on Sim.

  • Import crazyflow before scipy. crazyflow/__init__.py sets SCIPY_ARRAY_API=1 and imports scipy immediately, and scipy cannot be reconfigured once loaded. Transitive imports through acados or sklearn trigger this too.
  • Three different load_params exist. The two in .core filter to the target signature and silently drop the rest, so hardware constants like thrust_max need crazyflow.drones.load_params.
  • parametrize returns a functools.partial whose keywords dict is shared by every reference to it. Call parametrize again for an independent copy.
  • Leading batch dimensions, trailing feature axis. quat is scalar-last xyzw, force is (..., 1) rather than a scalar, ang_vel is body frame.
  • ctrl_freq scales only the integral and derivative terms, so it must match your real loop rate. Under jit, initialize integral states to zeros rather than None, since the pytree structure change forces a recompile.
  • symbolic_dynamics monkey-patches module-global symbols while building, so it is not reentrant. Do not build two concurrently.

The functional API and jit

Sim rebinds sim.data as a Python side effect that JAX cannot trace, so anything inside jit, grad, vmap or scan must use crazyflow.sim.functional with Sim only as the builder. See functional-api.md.

  • After editing a pipeline, call build_step_fn() or build_reset_fn() again. The builders snapshot the stages, so a later edit is silently ignored and the stage never runs.
  • n_steps is static, so each distinct value compiles separately. Build once and reuse.
  • states.force and states.torque are inputs, not outputs, and nothing clears them, so writing them applies a persistent disturbance.
  • Mutating state does not invalidate core.mjx_synced, so contacts() can query stale geometry. Set the flag false yourself.
  • Gradients vanish at clip_floor_pos (jnp.where on floor contact) and at any saturation bound.

Splats

attach_splats performs no calibration. Both .ply files must already sit in the simulator's frames, the scene in the MuJoCo world frame at metric scale and the drone in its body frame. An uncalibrated splat looks correct alone but does not match the simulated geometry. See splats.md.

Du fichier au premier essai

Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.

Consulter la source et ses fichiers annexes

Ce téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.

1. Télécharger le fichier

Télécharger SKILL.md

Depuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/crazyflow-conventions-msshyweq/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.

Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.

mkdir -p '.skill-downloads/crazyflow-conventions-msshyweq' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/crazyflow-conventions-msshyweq/download' --output '.skill-downloads/crazyflow-conventions-msshyweq/SKILL.md.part' && mv '.skill-downloads/crazyflow-conventions-msshyweq/SKILL.md.part' '.skill-downloads/crazyflow-conventions-msshyweq/SKILL.md'

2. Vérifier les prérequis

Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.

Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.

Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.

3. Charger la skill

Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.

Claude Code
test -f '.skill-downloads/crazyflow-conventions-msshyweq/SKILL.md' && test -s '.skill-downloads/crazyflow-conventions-msshyweq/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/crazyflow' && cp -R '.skill-downloads/crazyflow-conventions-msshyweq' '.claude/skills/crazyflow'

Cursor
test -f '.skill-downloads/crazyflow-conventions-msshyweq/SKILL.md' && test -s '.skill-downloads/crazyflow-conventions-msshyweq/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/crazyflow' && cp -R '.skill-downloads/crazyflow-conventions-msshyweq' '.cursor/skills/crazyflow'

Codex
test -f '.skill-downloads/crazyflow-conventions-msshyweq/SKILL.md' && test -s '.skill-downloads/crazyflow-conventions-msshyweq/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/crazyflow' && cp -R '.skill-downloads/crazyflow-conventions-msshyweq' '.agents/skills/crazyflow'

OpenSkills

OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.

Installation officielle d’OpenSkills
openskills install './.skill-downloads/crazyflow-conventions-msshyweq'

openskills read 'crazyflow-conventions-msshyweq'

La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.

Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.

openskills sync

Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.

4. Faire un premier essai

Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :

Lis .skill-downloads/crazyflow-conventions-msshyweq/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.

Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.

Skills similaires