Skip to content

Repository files navigation

FlightSim

This repository contains programs and scripts to simulate the 3D flight of a helicopter with an attached Apache Strapdown Pilotage camera system mounted on it.

Files and directories

  • Apocalyptic Building 3 - Contains the 3D model of a building used in the simulation.
  • RenderCrate-Small_Rocky_Landscape_Feature - Contains the 3D model of a rocky landscape used in the simulation.
  • buildings_v05.blend - Blender file containing the 3D model of the scene along with a script to generate the output.
  • calibration_v1.blend - Blender file containing the 3D model of the calibration scene.
  • Cameras.py - Python script to generate the camera positions for both Blender simulations.
  • tif_to_pgm.bash - Bash script to convert .tif files to .pgm files in the Blender output tree.
  • SimToStreams.cpp - Contains the source code for program to convert from Blender + .pgm output to streams.
  • SimToCalibration.cpp - Contains the source code for program to convert from Blender + .pgm output to calibration images.
  • config.json - Configuration file for the simulation, read by both Blender and SimToStreams.
  • poses.csv -- Contains the camera poses for the calibration_v1 simulation.
  • targets.json -- Contains the target positions and pointing tolerances for the calibration_v1 simulation.
  • CMakeLists.txt - CMake file to build the SimToStreams program.

Building

Download, build and install the ASDP_API_Core library.

Either clone this FlightSim repository withe the --recursive option, or run git submodule update --init --recursive to download the required submodules.

Run CMake to generate the build files for the SimToStreams program.

Using

Flight Simulation

Edit a copy of the config.json file to set the parameters for the helicopter-flight simulation. Alternatively, you can run the Make_Camera_Config_File.py script from the ASDP_Core_API repository to generate a new config.json file based on the parameters you set in that script.

Open Blender 4.0 and load the buildings_v05.blend file. Edit the script in the text editor to point at the edited config.json file and to set the renderPath where it will store its output. Open the System Console window if you want to see the progress as the program runs. Run the script in the text editor (alt-P in that frame) to generate the output. By editing the start and end frame, you can produce part of the simulation at a time, perhaps running in parallel on multiple machines.

Run the tif_to_pgm.bash script to convert the .tif files to .pgm files, with the renderPath as a command-line option.

Run the SimToStreams program to convert the Blender output to streams. Use the --help command-line option for more info.

Calibration Simulation

Edit a copy of the config.json file to set the parameters for the calibration simulation.

Edit a copy of the targets.json file to set the target positions and pointing tolerances for the calibration simulation.

Edit a copy of the poses.csv file to set the camera poses for the calibration simulation.

Open Blender 4.0 and load the calibration_v4.blend file. Edit the script in the text editor to point at the edited copies of the configuration files and to set the renderPath where it will store its output. Open the System Console window if you want to see the progress as the program runs. Run the script in the text editor (alt-P in that frame) to generate the output.

Run the tif_to_pgm.bash script to convert the .tif files to .pgm files, with the renderPath as a command-line option.

Run the SimToCalibration program to convert the Blender output images to distorted images with noise, perhaps multiple images per camera per frame. Use the --help command-line option for more info.

Scripting flight simulation under Linux:

Note: The specific Blender version we want is 4.0.2. For example, 4.2.0 renders much more slowly (about a minute per frame rather than about a second per frame).

Note: For whatever reason, the render grinds to a halt after about ten cameras on the first frame when blender is run in an ssh window or on the system console (non X-window), under Linux. This means that it must be run on a window that is open in X to run quickly to completion, which basically requires running it on a Render Server.

  • sudo snap install blender --classic --channel=4.0/stable
  • Edit the render_v11.py file to set the output directory.
  • blender -b buildings_v11.blend -P render_v11.py

Render partial: The values 1 and 5 for start (-s) and end (-e) should be modified to match the range you want. To render all of the frames in the video, leave out both of the -s and -e arguments and their values. To run multiple jobs in parallel, run two or more instances with non-overlapping start and end values (note that Blender rendering is multi-threaded, so at some point this becomes counterproductive).

  • blender -b buildings_v11.blend -s 1 -e 5 -P render_v11.py

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages