Code

Reproduce our work.

The source code necessary for evolving the KROs reported in our paper can be found at: github.com/skriegman/kinematically_replicating_organisms.

The instructions for actually building KROs are also entirely open-source in the form of our PNAS paper and its supplementary materials.

Source code and build instructions are licensed under CC BY-NC 4.0.

Start here:

We recommend starting with this Science Buddies tutorial for VoxCAD. The first step links to a Windows installation of VoxCAD. If you do not have Windows, you can instead download a GUI for Mac and Linux, and then continue with step 2 of the procedure.

The simulation.

The xenobot software has two parts:

     viz: draw and visualize simulated xenobots.

       sim: gpu-accelerated simulation.

viz

You can manually design xenobots by drawing them in our graphical user interface voxcraft-viz, which was originally forked from voxcad.

Star Fork Download

install on Windows

On Win10, you can download the software here.

install on linux

On linux you can install with snap

sudo snap install voxcraft-viz

Get it from the Snap Store

install on macOS

On macOS follow these steps to install viz (you’ll need Homebrew):

brew install cmake
brew install boost
brew install qt5
brew install glfw3
brew install xquartz
brew install freeglut
brew install mesa

This will take a while…

git clone https://github.com/voxcraft/voxcraft-viz.git

cd voxcraft-viz/
mkdir build
cd build/
  
cmake -DQt5_DIR=$(brew --prefix qt5)/lib/cmake/Qt5 -DCMAKE_BUILD_TYPE=Release ..
  
make -j 10

Copy the executable voxcraft-viz somewhere in your $PATH, for example /usr/local/bin.

cp voxcraft-viz /usr/local/bin

Done!

Type voxcraft-viz into your terminal to launch the viz.

drawing a robot in viz

You can draw a custom robot in voxcraft-viz using your mouse and then press play to watch its behavior.



playing a history file in viz

voxcraft-viz can also be used to replay the behavior of robots that have already been simulated elsewhere: their history.

You can download one of these prerecorded history files

m190.history    m805.history

and replay it in voxcraft-viz:


sim

voxcraft-sim simulates voxels in parallel on a gpu. The simulations are headless (without graphics) but a history file can be recorded that traces the behavior of each voxel within a simulation. This history can then be replayed in either voxcraft-viz or Unity.

Star Fork Download

run sim in Google Colab

Create a new notebook and go to Menu->Runtime->Change runtime type, select GPU.

Then, copy and run the script from this (readonly) example notebook.

It will produce a.history which can be played in voxcraft-viz to visualize the simulated behavior.

render a history file in Unity

History files can also be rendered in the Unity game engine.

You can download this Unity demo project here.

install sim from scratch

If you have access to Nvidia graphic cards you can compile voxcraft-sim from scratch. The most difficult part is installing CUDA 10.1.

Once you have CUDA 10.1, the rest is easy:

sudo apt-get update
sudo apt-get install -y git cmake libboost-all-dev

git clone https://github.com/voxcraft/voxcraft-sim.git
cd voxcraft-sim
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCUDA_DEBUG=OFF ..
make -j 10

Now you will have two executables: voxcraft-sim and vx3_node_worker.

Copy and paste them to a directory where you want to run the simulations.

Finally, try one of the demos:

./voxcraft-sim -i ../demos/basic/ > demo_basic.history

This will produce a demo_basic.history file that can be visualized in voxcraft-viz.

cite voxcraft-sim

If you use this code for academic purposes, please cite:

@MISC{liu_voxcraft_2020,
	title = {Voxcraft-sim, a GPU-accelerated voxel-based physics engine},
	howpublished = {\url{https://github.com/voxcraft/voxcraft-sim}},
	author = {Sida Liu and David Matthews and Sam Kriegman and Josh Bongard},
	year = {2020},
	doi = {10.5281/zenodo.3835152},
}

DOI

Thanks!