Skip to content

skulumani/asteroid_dumbbell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dumbbell about and asteroid

Simulation to test the motion of a dumbbell spacecraft around an asteroid

Testing Coverage
Build Status Coverage Status

Development Environment setup

This code is written in Python and uses:

To set it all up properly you must first install Anaconda and clone the asteroid environment:

conda env create --file asteroid.yml

The follow the instructions in each section below.

Repository setup

Clone and run chmod +x setup_repo.sh then ./setup_repo.sh to automatically create the correct remote repositories. This will ensure that pushes are sent to both:

Blender Setup links

To build and install Blender as a Python module:

  • Ensure you're using the asteroid conda enviornment and Python 3.5
  • Run utilities/build_blender.sh and hope for the best
  • Run py.test and make sure all the tests pass

Building OpenCV

There is a bash script, utilities/build_opencv.sh which will build OpenCV for Python

  • Make sure you install the asteroid env - conda env create -n asteroid -f asteroid.yml or update conda env update -n asteroid -f asteroid.yml
  • Run build_opencv.sh
  • Check and make sure cv2.so is located in $HOME/anaconda3/envs/asteroid/lib/python3.5/site-packages

Some other helpful links:

Building PCL

There's another bash script, utilities/build_pcl.sh which will build Point Cloud Library.

  • Make sure you install the asteroid env - conda env create -n asteroid -f asteroid.yml
  • bash utilities/build_pcl.sh
  • Run the tests

Usage guide

You can run the simulation for both the inertial and relative equations of motion. There are driver modules for each, which are called: * inertial_driver.py - Driver functions to simulate the inertial equations of motion * relative_driver.py - Driver functions to simulate the relative equations of motion * dumbbell_driver.py - More driver functions which were used during testing/debuggin * eom_comparison.py - Functions to allow the comparision between the different EOMS

To profile the Python code you can use cProfile or line-profiler

pip install line-profiler snakeviz
  • Use cProfile to find which function call is taking the most time out of a bigger script
import cProfile
cProfile.run('script to execute as a string')
* You can also do this from within iPython as
~~~
%prun -D output.prof function()
~~~
  • Next use snakeviz to visualize it
%load_ext snakeviz
%snakeviz function()
  • Once you have an idea of the slow function you can find specific lines within the function using line-profiler
%load_ext line_profiler
%lprun -T output.txt -f ast.function() script()

SPICE in Python

There seems to be several attemps to get SPICE working in Python. Use one of the following

Creating a movie from a bunch of images

Use this command to create a movie with ffmpeg

ffmpeg -framerate 60 -i test%06d.png -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" output.mp4 

Some additional information:

TODO

  1. Create a setup script that setups up the development environment

    • Can setup Anaconda
    • Downloads shape models from github release (ensure the tar.gz file includes everythign)
    • Runs the build scripts
    • Runs pytest
  2. Figure out how to get TOX/Create a seperate build script for travis

Doxygen

Install

sudo apt-get install -y doxygen graphviz