# STDP Simulation Environment This package contains the four indoor scenes, drone model, camera capture plugin, and trajectory playback tools used by STDP. It targets **Gazebo Classic 11** and uses the Gazebo C++ API directly; ROS, PX4, and a flight controller are not required. Policy training, trajectory planning, and benchmark evaluation require the main project code and datasets and are outside the scope of this environment package. ## Contents | Path | Purpose | | --- | --- | | `world/home_room_v{1,2,3,4}.world` | Scene layouts, furniture, collision geometry, lighting, and drone references | | `models/simple_drone/` | Drone SDF and model metadata; front/down/left/right RGB cameras at 640 x 480 and 15 Hz | | `plugins/SimpleDronePlugin.cc` | Trajectory playback, command-file control, waypoint capture, image checks, and CSV updates | | `plugins/CMakeLists.txt` | C++14 build configuration for `libSimpleDronePlugin.so` | | `models/sun/`, `models/ground_plane/` | Referenced base models, bundled to avoid downloading models at runtime | | `media/materials/scripts/home.material` | Custom floor, wall, ceiling, and furniture materials | | `media/materials/textures/` | The four Gazebo textures referenced by the custom materials | | `gazebo_env.sh`, `build.sh` | Environment setup and plugin compilation | | `run.sh` | Single-trajectory playback with GUI or background Xorg/Xvfb rendering | | `datasets_construct.sh` | Batch capture, image validation, and retries | | `examples/smoke.csv`, `smoke.sh` | One-waypoint environment check; not a benchmark trajectory | | `SOURCE_FILES.json`, `SHA256SUMS` | Source provenance and release file checksums | | `ENVIRONMENT.txt`, `VALIDATION.md`, `validation/` | Reference versions, validation scope, and build/capture logs | Furniture is defined as geometry inside the world files; no additional STL/DAE meshes are required. Built-in `Gazebo/*` materials, OGRE, system plugins, and shared libraries are provided by the Gazebo installation. ## Requirements and Build The reference system is Ubuntu 20.04.6 LTS with Gazebo Classic 11.15.1 and CMake 3.16.3. The newer Gazebo simulator (`gz sim`) cannot load this Classic plugin directly. Exact recorded package versions are listed in `ENVIRONMENT.txt`. On Ubuntu 20.04 with a Gazebo 11 package source configured: ```bash sudo apt-get update sudo apt-get install gazebo11 libgazebo11-dev build-essential cmake pkg-config \ python3 python3-numpy python3-pil xvfb x11-utils mesa-utils pciutils ``` If `gazebo11` has no installation candidate, configure a Gazebo Classic package source appropriate for your system first. Package repositories and GPU drivers are not included in this release. From this directory, use a system Bash shell, preferably after leaving Conda: ```bash sha256sum -c SHA256SUMS chmod +x *.sh bash build.sh ``` The build produces `plugins/build/libSimpleDronePlugin.so`. Downloads of individual source files may not preserve executable permissions; the `chmod` command above restores them for the launch and capture scripts. Precompiled binaries and machine-specific CMake caches are excluded from the archive. `run.sh` also builds the plugin automatically when it is missing. Run `build.sh` again after changing CMake configuration. ## Smoke Check ```bash bash smoke.sh v1 # Explicit software rendering when no usable display is available: SIMPLE_DRONE_RENDER_BACKEND=xvfb bash smoke.sh v1 ``` Replace `v1` with `v2`, `v3`, or `v4` to select another scene. A successful check prints `PASS`, writes four PNG files under `datasets/smoke_world_v1/images/smoke/images_{front,down,left,right}/`, and records capture metadata in the smoke trajectory CSV. Re-running the check resets this smoke example's CSV and images. Camera sensors need an OpenGL/X rendering context even under `gzserver`. Xvfb software rendering can be slow; increase `SIMPLE_DRONE_RUN_TIMEOUT` if necessary. Check `.run_logs/` under the output dataset directory for display startup errors. Missing or rejected gray frames do not count as a successful check. The reference v1 smoke check passed using the plugin's existing single-camera sweep fallback after physical camera frames were rejected under Xvfb. See `VALIDATION.md` for the exact scope and limitations of this result. ## Replay a Trajectory Arrange input trajectories as follows: ```text datasets/world_v1/trajectory/my_trajectory.csv datasets/world_v2/trajectory/... datasets/world_v3/trajectory/... datasets/world_v4/trajectory/... ``` The CSV must have a header, and its first six columns must be ordered as `step,x,y,z,yaw_rad,yaw_deg`. Positions are in meters; `yaw_rad` is in radians. See `examples/smoke.csv` for a minimal input. ```bash SIMPLE_DRONE_QUIT_ON_FINISH=1 ./run.sh v1 my_trajectory.csv SIMPLE_DRONE_QUIT_ON_FINISH=1 ./run.sh gui v2 my_trajectory.csv ./datasets_construct.sh datasets/world_v1 ``` **Capture updates the input CSV in place**, adding frame indices, captured yaw, and image filenames. Use a working copy of your reference trajectory. Images are written to `datasets/world_vN/images//images_/`. By default, `run.sh` leaves the simulation running after playback; set `SIMPLE_DRONE_QUIT_ON_FINISH=1` to exit automatically. For an existing custom dataset directory: ```bash DATASET_ROOT=./datasets/world_v3 SIMPLE_DRONE_QUIT_ON_FINISH=1 \ ./run.sh v3 my_trajectory.csv ``` The batch script defaults to `datasets/world_v3` when called without arguments; explicitly pass the desired dataset directory. If its name is not `world_vN`, also set `WORLD_VERSION=vN`. The original batch script can skip timed-out trajectories, so review its final log and per-trajectory outputs for a full run. ## Manual Scene Launch and Command Control After compiling the plugin: ```bash source ./gazebo_env.sh gazebo --verbose world/home_room_v1.world ``` Without dataset playback or command-file settings, the plugin uses its built-in waypoints and writes to this package's `drone_images/` directory. For command control, set `SIMPLE_DRONE_COMMAND_FILE` to an absolute command-file path before launching. After launch, update the file with `x,y,z,yaw` (target position in meters, yaw in radians) to issue a new command. The existing plugin clamps targets to x in [-7, 6.5], y in [-4, 4], and z in [1.2, 1.8]. Do not enable dataset playback variables at the same time. Policy inference and closed-loop training/evaluation still require the main project's Python code, including `scripts/stage2_gazebo_common.py` and its dependencies. ## Packaging Notes and Third-Party Assets The four world files, plugin source, camera settings, and custom material script are unchanged from the source project. The drone model's personal absolute output path was replaced with a relative path and its author field was anonymized; `gazebo_env.sh` supplies a package-local output directory. Launch scripts use the bundled models and no longer explicitly add the original user's model cache. No source-project files were moved. The bundled base models and textures retain their original contents and author metadata where present. Their origins are recorded in `SOURCE_FILES.json`; they remain subject to their upstream licenses and are not relicensed by this package. Large datasets, captured images, model weights, training outputs, ROS bags, OpenVINS, plotting utilities, and old build caches are excluded. Local build and smoke outputs may exist after running checks, but are not part of the release archive.