---
title: AVALON Pt. 2
description:
robots: index, follow
lang: en
dir: ltr
breaks: true
---
# AVALON Pt. 2
{%hackmd theme-dark %}
###### tags: `metaverse lab`
A project log for [Metaverse Lab](https://hackaday.io/project/5077) by [alusion](https://hackaday.io/hacker/46747-alusion)
*Experiments with Decentralized VR/AR Infrastructure, Neural Networks, and 3D Internet.*
Originally published 05/03/2015 at 05:11
https://hackaday.io/project/5077-metaverse-lab/log/17307-avalon-pt-2
---
<p>Successful progress on getting AVALON [Anonymous Virtual/Augmented LOcal Networks] to work plug in play with some boot time scripts and new hardware upgrades. I shopped around and got a couple new raspberry pi 2 model B and ABS plastic cases. Here's some pics of the upgraded devices:</p>
<p><img class="lazy" src="https://cdn.hackaday.io/images/1127291430626778655.png"></p>
<p>The one on the far left is the basic Raspberry Pi 1 model B that is running the Janus multiserver and Piratebox via the Raspberry Pi build (Arch Linux). The middle one is the same device but PirateBox mounted on top, while the pi is running a webcam server and Janus multiserver inside. On the far right is the current prototype:</p>
<p><img class="lazy" src="https://cdn.hackaday.io/images/6717981430627093413.png"></p>
<p>Everything is now self contained with the <a href="http://www.microcenter.com/product/443781/Raspberry_Pi_2_Model_B">Raspberry Pi 2 model B</a> + <a href="http://www.amazon.com/gp/product/B002SZEOLG/">TL-WN722N</a> WiFi adapter, <a href="http://www.amazon.com/KMAX-806-Flashlight-Generation-SGH-T959V-BlackBerry/dp/B00BN42G5Y/">USB battery pack</a>, and a <a href="http://www.amazon.com/Logitech-Webcam-Widescreen-Calling-Recording/dp/B004FHO5Y6/">Logitech webcam</a>. It's capable of offline filesharing and communication that is Oculus Rift enabled for realtime 3D Virtual/Augmented reality interaction. This device automatically starts a WiFi hotspot that users can connect to and streams the Webcam video over the web browser which can be viewed inside Janus. </p>
<p><img class="lazy" src="https://cdn.hackaday.io/images/6301381430630484008.gif"></p>
<p> Can now have a window into the outside world inside my private VR/AR network. Quite meta with the camera looking at the device that we are currently inside of.</p>
<p>I've tested the Video Streaming into Janus with both Logitech c270 and Playstation Eye camera. They both work but I would recommend using the Logitech since the PS Eye only has 640x480 resolution. I'm going to write up a how-to on building your own AVALON for the Raspberry Pi 2 next!</p>
<hr>
<p>First <a href="https://www.raspberrypi.org/documentation/installation/installing-images/">install Raspbian</a> onto a MicroSD card. The Raspberry Pi 2 now uses the tiny SDHC cards for loading its operating system. We need to install the PirateBox utilities. If you're comfortable on the command line you can choose to do this in a chroot environment:</p>
<pre class="hljs http">mount -o <span class="hljs-keyword">bind</span> /dev /mnt/dev
mount -t proc none /mnt/proc
sudo <span class="hljs-keyword">chroot</span> /mnt/ <span class="hljs-regexp">/bin/bash</span></pre>
<p>Otherwise, download Raspbian from the official Raspberry Pi downloads page and aftering following the <a href="https://www.raspberrypi.org/documentation/installation/installing-images/">install guide</a> then you can plug it in to your raspberry pi and either SSH in or attach monitor/keyboard/networking devices to interact and <a href="https://github.com/LibraryBox-Dev/LibraryBox-core/tree/master/piratebox_origin/BuildScripts/RaspberryPi">install the things</a>. Expand<br></p><p> the FS, change root passwd, and enable SSH for now.</p>
<p>As root:<br></p><pre class="hljs sql">apt-get update
apt-get upgrade
apt-get install git tmux
apt-get -y <span class="hljs-operator"><span class="hljs-keyword">install</span> lighttpd
/etc/init.d/lighttpd <span class="hljs-keyword">stop</span>
<span class="hljs-keyword">update</span>-rc.d lighttpd remove
apt-<span class="hljs-keyword">get</span> -y <span class="hljs-keyword">install</span> dnsmasq
/etc/init.d/dnsmasq <span class="hljs-keyword">stop</span>
<span class="hljs-keyword">update</span>-rc.d dnsmasq remove
apt-<span class="hljs-keyword">get</span> -y <span class="hljs-keyword">install</span> hostapd
/etc/init.d/hostapd <span class="hljs-keyword">stop</span>
<span class="hljs-keyword">update</span>-rc.d hostapd remove
apt-<span class="hljs-keyword">get</span> -y <span class="hljs-keyword">install</span> iw
rm /<span class="hljs-keyword">bin</span>/sh
<span class="hljs-keyword">ln</span> /<span class="hljs-keyword">bin</span>/bash /<span class="hljs-keyword">bin</span>/sh
chmod a+rw /<span class="hljs-keyword">bin</span>/sh</span></pre>
<p>Then edit your network config file /etc/network/interfaces<br></p><pre class="hljs cpp"><span class="hljs-keyword">auto</span> lo
iface lo inet loopback
iface eth0 inet dhcp
iface wlan0 inet manual</pre>
<p>Save and exit. Then browse to your home directory and finish installing the rest of the packages:<br></p><pre class="hljs bash">wget <a href="http://downloads.piratebox.de/piratebox-ws_current.tar.gz" target="_blank">http://downloads.piratebox.de/piratebox-ws_current.tar.gz</a>
tar xzf piratebox-ws_current.tar.gz
<span class="hljs-built_in">cd</span> piratebox
mkdir -p /opt
cp -rv piratebox /opt
<span class="hljs-built_in">cd</span> /opt/piratebox
sed <span class="hljs-string">'s:DROOPY_USE_USER="no":DROOPY_USE_USER="yes":'</span> -i /opt/piratebox/conf/piratebox.conf
sed <span class="hljs-string">'s:PROBE_INTERFACE="no":PROBE_INTERFACE="yes":'</span> -i /opt/piratebox/conf/piratebox.conf
ln /opt/piratebox/init.d/piratebox /etc/init.d/piratebox
<span class="hljs-built_in">cd</span> ../../
rm -rv piratebox/ piratebox-ws_current.tar.gz</pre>
<p>You will want to run the PirateBox server by default on startup as well:<br></p><pre class="hljs vbscript">sudo <span class="hljs-operator"><span class="hljs-keyword">update</span>-rc.d piratebox defaults
sudo /etc/init.d/piratebox <span class="hljs-keyword">start</span>
sudo touch /opt/piratebox/conf/init_done
</span></pre>
<p>When I first tested this, I was frustrated with the reason why PirateBox software was crashing whenever I ran the stream / Janus server. The reason was because of a port conflict over 8080. So you'll need to edit the <strong>DROOPY_PORT</strong> in the <strong>/opt/piratebox/conf/piratebox.conf</strong> file and set it to 8085. Then edit the html <strong>/opt/piratebox/www/index.html</strong> and adjust to 8085. Will fix in pi image.<br></p>
<p>Now it's time to install the Webcam streamer that allows us to seamlessly pull visual information from the real world into the virtual reality environment as websurface content that you can put anywhere as you want inside your firebox room in Janus.</p>
<p>* The software is extremely versatile and has been successfully tested on <a href="http://www.madox.net/blog/2013/02/23/tl-wr703n-example-project-4-webcam-streaming/">openWRT devices</a> as well!</p>
<p>Follow these instructions to compile and start mjpg-streamer working on your raspberry pi with an HD webcam:</p>
<pre class="hljs bash"><span class="hljs-built_in">cd</span> /usr/src/
sudo mkdir mjpg-streamer
sudo chown `whoami`:users mjpg-streamer
<span class="hljs-built_in">cd</span> mjpg-streamer/
git <span class="hljs-built_in">clone</span> <a href="https://github.com/jacksonliam/mjpg-streamer.git" target="_blank">https://github.com/jacksonliam/mjpg-streamer.git</a> .
sudo apt-get install libv4l-dev libjpeg8-dev imagemagick build-essential cmake subversion
<span class="hljs-built_in">cd</span> mjpg-streamer-experimental
make
<span class="hljs-built_in">export</span> LD_LIBRARY_PATH=.
/usr/src/mjpg-streamer/mjpg-streamer-experimental
./mjpg_streamer -i <span class="hljs-string">"./input_uvc.so -r 1280x720"</span> -o <span class="hljs-string">"./output_http.so -w ./www -p 8090"</span></pre>
<p>The streaming video will be resized to 1280x720 over port 8090. Port 8090 won't conflict with the other services the Raspberry Pi is running. Your IP address will be set to 192.168.77.1 when running PirateBox so type into your browser url:<br></p><pre>
<a href="http://192.168.77.1:8090" target="_blank">http://192.168.77.1:8090</a></pre>
<p>Test if it works. If it doesn't, don't worry I'm working on an AVALON Pi image you can just flash. If it does, cool lets move on.<br></p><p>Lets create a script start_mjpg that will initiate the service on boot time. SSH into your pi and create new text file <strong>start_mjpg</strong></p>
<pre class="hljs bash"><span class="hljs-shebang">#!/bin/bash</span>
<span class="hljs-built_in">cd</span> /usr/src/mjpg-streamer/mjpg-streamer-experimental
./mjpg_streamer -i <span class="hljs-string">"./input_uvc.so -r 1280x720"</span> -o <span class="hljs-string">"./output_http.so -w ./www -p 8090"</span></pre>
<p>Lets repeat that last step to autostart our Janus multiserver as well. Create a new file <strong>start_janus</strong> and put this inside. Remember to <em>replace <strong>user</strong> with your <strong>username</strong></em>! **<br></p>
<pre class="hljs bash"><span class="hljs-shebang">#!/bin/bash</span>
<span class="hljs-built_in">cd</span> /home/user/janus-server
/usr/<span class="hljs-built_in">local</span>/bin/node /home/user/janus-server/server.js</pre>
<p>Save and exit. Now make the scripts executable:</p>
<pre>
chmod 755 start_mjpg
chmod 755 start_janus</pre>
<p>Stick the script into /usr/local/bin to run the scripts from wherever you are when logged into your Raspberry Pi. <strong>chown </strong>stands for change ownership.<br></p>
<pre class="hljs perl">sudo cp save_mjpg start_janus /usr/local/bin/
sudo chown 'whoami' /usr/local/bin/start_mjpg /usr/local/bin/start_janus</pre>
<p>Now to configure your script to autorun at boot time, edit the <strong>/etc/rc.local</strong> file and append the following below the comments and above exit 0. </p>
<p>** Do not forget to change <strong>user</strong> in the below script to your username! <br><span></span></p>
<pre class="hljs bash"><span class="hljs-comment">## Print the IP address</span>
_IP=$(hostname -I) || <span class="hljs-literal">true</span>
<span class="hljs-keyword">if</span> [ <span class="hljs-string">"<span class="hljs-variable">$_IP</span>"</span> ]; <span class="hljs-keyword">then</span>
<span class="hljs-built_in">printf</span> <span class="hljs-string">"My IP address is %s\n"</span> <span class="hljs-string">"<span class="hljs-variable">$_IP</span>"</span>
<span class="hljs-keyword">fi</span>
<span class="hljs-comment">## /etc/rc.local will run as root by default</span>
<span class="hljs-comment">## you must change user in your script!</span>
<span class="hljs-comment">## Start mjpg-streamer </span>
(sleep <span class="hljs-number">5</span>; su - user -c <span class="hljs-string">"/usr/local/bin/start_mjpg; echo 'Browse to <span class="hljs-variable">$_IP</span>:8090/javascript_simple.html'"</span>)&
<span class="hljs-comment">## Autostart Janus-Server</span>
(sleep <span class="hljs-number">2</span>; su - user -c <span class="hljs-string">"sh /usr/local/bin/start_janus"</span>)&
<span class="hljs-built_in">exit</span> <span class="hljs-number">0</span></pre>
<p>Reboot and check if everything is working. Make sure that the access point from Piratebox scripts is available and you can connect to it, that upload and download works, that you can browse to <a href="http://192.168.77.1:8090/javascript_simple.html" target="_blank">http://192.168.77.1:8090/javascript_simple.html</a> and view the webcam livestream. I will upload some default rooms and avatars for AVALON soon so that you can test the janus multi-server easily. Just remember that all the filepaths for your <a href="http://www.dgp.toronto.edu/~mccrae/projects/firebox/notes.html">firebox room</a> must correspond to the path hosted from PirateBox! <br></p><p>To do:</p>
<p>Customize defaults and UI then create a Raspberry Pi image for AVALON<br></p>
<p>Create a Github repo for default rooms and avatars that can be downloadable to a user's pi</p>
<p>Testing of CCTV functionality</p>
<p>Take some cool screen-shots / Video and also find a cool lunchbox to stick all the things inside. <br></p>
<p>Mount AVALON system onto a <a href="https://vimeo.com/36267881">drone</a> when given the opportunity.<br></p>