| \input{header} |
| \definecolor{mygray}{gray}{.95} |
| |
| \begin{document} |
| \title{\rule{\textwidth}{1pt}\textbf{ Rover Documentation} \\ Browser-based Camera Stream \& Drive Control \rule{\textwidth}{1pt}\vspace{-20pt}} |
| \date{} |
| \maketitle |
| \setlength{\headsep}{20pt} |
| \vspace{-20pt} |
| \begin{tabularx}{\textwidth}{Xlll} |
| & \textit{Version} & \textit{\today }&\\ |
| &\textit{Implementation} &\textit{Mustafa Özcelikörs} & \textit{mozcelikors@gmail.com}\\ |
| &\textit{Supervision \& revision} &\textit{Robert Höttger} &\textit{robert.hoettger@fh-dortmund.de}\\ \\ |
| &&\multicolumn{2}{l}{University of Applied Sciences and Arts Dortmund}\\ |
| &&\multicolumn{2}{l}{IDiAL Institute, Project AMALTHEA4public}\\ |
| &&\multicolumn{2}{l}{BMBF Fund.Nb. 01|S14029K} |
| \end{tabularx} |
| \vspace{15pt}\\ |
| \begin{tabularx}{\textwidth}{cXc} |
| \includegraphics[width=0.4\textwidth]{../images/rover.png}&& |
| \includegraphics[width=0.4\textwidth]{../images/page.png} |
| \end{tabularx} |
| \section{General structure} |
| \begin{figure}[h!] |
| \centering |
| \includegraphics[width=0.75\textwidth]{../images/webstructure.png} |
| \caption{General structure of this documentation's rover control} |
| \label{fig:struct} |
| \end{figure} |
| |
| \section{Introduction} |
| If you want to skip the manual installation process described in this document, access the pre-installed RPI3 images at \url{https://www.pimes.fh-dortmund.de/owncloud/index.php/s/qhWRjatfTQkaeEW} and apply them to your SD card. |
| |
| If you do not want to use the provided images, this documentation describes how to setup a Raspberry PI (RPI) in order to view its camera stream via a browser and further take control of the motors connected to the RPI in form of the Rover. Please note that your RPI requires internet connection for some provided commands and that some of those take some time to execute. |
| |
| If you work with a plain Jessie (lite) distribution, please remember to add an empty file named `ssh` to the SD card in order to gain ssh access. |
| \section{Apache2, cmake, and PHP5 Installation and Configuration} |
| In order to start driving the rover from a web page, one should install Apache2 and PHP5. To get the latest packages from the repository list go into shell and type (\textit{internet connectivity required}): |
| \begin{lstlisting} |
| sudo apt-get update |
| sudo apt-get upgrade |
| \end{lstlisting} |
| To install apache2 and cmake type: |
| \begin{lstlisting} |
| sudo apt-get install apache2 -y |
| sudo apt-get install php5 libapache2-mod-php5 -y |
| sudo apt-get install cmake |
| \end{lstlisting} |
| Afterwards, the webpage should be located at \texttt{/var/www/html} directory. In order to give certain permissions to the current user execute: |
| \begin{lstlisting} |
| sudo chgrp -R www-data /var/www/html |
| sudo find /var/www/html -type d -exec chmod g+rx {} + |
| sudo find /var/www/html -type f -exec chmod g+r {} + |
| \end{lstlisting} |
| In the following, replace pi with your user name, which is typically "pi" in Raspbian: |
| |
| \begin{lstlisting} |
| sudo chown -R pi /var/www/html/ |
| sudo find /var/www/html -type d -exec chmod u+rwx {} + |
| sudo find /var/www/html -type f -exec chmod u+rw {} + |
| \end{lstlisting} |
| Subsequently, enable access to the Linux file-system from the provided webpage via: |
| \begin{lstlisting} |
| sudo visudo |
| \end{lstlisting} |
| Within the editor, add the following to the end, save the file, and exit (depending on your default editor) |
| (Saving and exiting in Nano editor $Ctrl+O \rightarrow Y \rightarrow Enter$, saving and exiting in Emacs editor $Ctrl + X \rightarrow Ctrl + S \rightarrow Enter \rightarrow Ctrl + X \rightarrow K \rightarrow Enter$) |
| \begin{lstlisting} |
| www-data ALL=(ALL) NOPASSWD: ALL |
| \end{lstlisting} |
| \section{Setting up the webpage} |
| Before we begin, we need some building tools and git in order to continue. Execute the following to make this work:\textit{} |
| \begin{lstlisting} |
| sudo apt-get install build-essential |
| sudo apt-get install git |
| \end{lstlisting} |
| After the RPI setup is complete, download the provided files from our repository, and make the following changes in order to merge it with you current \texttt{/var/www/html/} folder. \textbf{If you copy\&paste the command, make sure there is not line break!} |
| \begin{lstlisting} |
| sudo git clone https://gitlab.pimes.fh-dortmund.de/RPublic/RoverWeb.git |
| sudo cp -r /var/www/RoverWeb*@/@** /var/www/ |
| sudo rm -rf RoverWeb/ |
| \end{lstlisting} |
| %cd /var/www/ |
| %sudo git init |
| %sudo git remote add -f origin https://git.eclipse.org/r/app4mc/org.eclipse.app4mc.examples |
| %git config core.sparseCheckout true |
| %echo "rover/web/" >> .git/info/sparse-checkout |
| %git pull origin master |
| \section{Installing psutil} |
| In order to monitor core utilization, a python pip package called 'psutil' needs to be installed. First, we need to get the essential building and packaging tools for python. \textbf{If you copy\&paste the command, make sure there is not line break!} |
| \begin{lstlisting} |
| sudo apt-get install build-essential python-dev python3-dev python-pkg-resources python3-pkg-resources python-pip |
| cd /var/www/html/ |
| sudo pip install psutil/ |
| \end{lstlisting} |
| \textbf{OPTIONAL:} The last command, in some Linux distributions (such as Jessie Lite) created error regarding the pip version. In case you get an error, try to fix your pip by the following: (Replace 1.5.6 with the version of pip it requires) |
| \begin{lstlisting} |
| sudo easy_install pip==1.5.6 |
| \end{lstlisting} |
| Now, we are ready to test if our script is running. To move forward check if the following command results in an error. If it does not, hit Ctrl+C to exit the program and move onto the next section. |
| \begin{lstlisting} |
| sudo python /var/www/html/record_core_usage_rpi.py |
| \end{lstlisting} |
| \section{Installing Raspberry Pi Camera and Streamer} |
| \textit{Note: The following parts are quite error prone. Please contact us if you have problems.} |
| Firstly, install the Raspberry Pi camera via: |
| \begin{lstlisting} |
| sudo raspi-config |
| \end{lstlisting} |
| Select Advanced $\rightarrow$ Enable Camera (or '5 Interfacing Options' $\rightarrow$ 'P1 Camera' $\rightarrow$ '$<$Yes$>$' $\rightarrow$ '$<$Ok$>$'), and then save and reboot your Pi.Installation of the Streamer requires a .so specific file input\_raspicam.so if you are using Raspicam instead of a webcam. This is provided with the files cloned from our git repository, but needs to be installed properly.\\ |
| Before this is done, we should make sure the required packages are installed and libraries are properly configured: |
| \begin{lstlisting} |
| sudo apt-get install libjpeg8-dev imagemagick libv4l-dev |
| sudo ln -s /usr/include/linux/videodev2.h /usr/include/linux/videodev.h |
| \end{lstlisting} |
| Afterwards, the \texttt{mjpg-streamer} has to be installed via (\textbf{again, make sure there is no line break!}): |
| \begin{lstlisting} |
| cd /var/www/html/camerastuff/newmjpg-streamer/mjpg-streamer/mjpg-streamer-experimental |
| sudo make clean |
| sudo cmake . |
| sudo make |
| sudo make install |
| \end{lstlisting} |
| Subsequently, copy the necessary libraries and executables in the respective folders: |
| \begin{lstlisting} |
| sudo cp mjpg_streamer /usr/local/bin |
| sudo cp output_http.so input_raspicam.so input_uvc.so /usr/local/lib/ |
| \end{lstlisting} |
| Before testing the camera, permissions to the executables and libraries have to be set: |
| \begin{lstlisting} |
| sudo chmod 777 /usr/local/lib*@/@**.so |
| sudo chmod 777 /usr/local/bin/mjpg_streamer |
| \end{lstlisting} |
| %sudo chmod 777 /usr/local/lib/*.so |
| Finally, the camera can be tested. With the following command (if there are no errors)the setup should be working. The following not only makes the executables know the location of the libraries but also sets up a reliable and fast input connection for raspberry pi camera: |
| \begin{lstlisting} |
| sudo bash /var/www/html/camerastuff/webcam_stream_start_from_rpi_camera.sh |
| \end{lstlisting} |
| The following provides the specific content of this file, that can be adjusted towards specific needs: |
| \begin{lstlisting} |
| #!/bin/bash |
| sudo bash /var/www/html/camerastuff/newmjpg-streamer/mjpg-streamer/mjpg-streamer-experimental |
| export LD_LIBRARY_PATH=/usr/local/lib |
| sudo /usr/local/bin/mjpg_streamer -i "/usr/local/lib/input_raspicam.so -x 640 -y 480 -fps 30" -o "/usr/local/lib/output_http.so -w /usr/local/www -p 8081" |
| \end{lstlisting} |
| After starting this .bash file, the webpage at \url{http://192.168.168.1/jqueryControl.php} should show the camera stream. |
| \section{Adjustments to the rover application} |
| %\subsection{AUTOMATIC WAY} |
| In order to update the Eclipse application that is written with pThreads, one could clone the files from the repository to their Eclipse workspace. To do that, download the files from the following Git repository and then import the sources located at \textbf{\underline{\texttt{rover/src/}}} to your workspace. |
| \begin{lstlisting} |
| https://git.eclipse.org/r/app4mc/org.eclipse.app4mc.examples |
| \end{lstlisting} |
| Basics about setting up Eclipse is given at \url{goo.gl/vT5PF8}. |
| \section{Completion} |
| In order to be able to use the web-page with its all functions, the following commands have to be executed on the rover before connecting to the webpage after a reboot. |
| \begin{lstlisting} |
| sudo python /var/www/html/initialize.py |
| sudo bash /var/www/html/camerastuff/webcam_stream_start_from_rpi_camera.sh & |
| sudo python /var/www/html/record_core_usage_rpi.py & |
| \end{lstlisting} |
| To make everything permanent, it is suggested to insert some commands into \texttt{/etc/rc.local} file. Therefore, type: |
| \begin{lstlisting} |
| cd /etc/ |
| sudo nano rc.local |
| \end{lstlisting} |
| And paste the following before the '\texttt{exit 0}' command line: |
| \begin{lstlisting} |
| cd /var/www/html/ |
| sudo python /var/www/html/initialize.py & |
| sudo python /var/www/html/record_core_usage_rpi.py & |
| sudo bash /var/www/html/camerastuff/webcam_stream_start_from_rpi_camera.sh & |
| \end{lstlisting} |
| Save and close via \textit{Ctrl}$\rightarrow$\textit{X, Y }$\rightarrow$ \textit{Enter}.\\ |
| To see the camera stream and to control the rover, use your browser and type in: |
| \begin{lstlisting}[label={lst:1}] |
| http:*@//@*<Your_IP_Address>/jqueryControl.php |
| \end{lstlisting} |
| If your rover provides the hotspot from PolarSys, use |
| \begin{lstlisting}[label={lst:partWrkflw}] |
| http:*@//@*192.168.168.1/jqueryControl.php |
| \end{lstlisting} |
| \section{Reporting} |
| If you have any problems, hints, bugs, or similar, please let the authors of this document know. |
| \end{document} |