Controlling a NavQPlus with an HTML WebServer
This is an example of how to use a Webserver running locally on the NavQPlus. Note that this is one of several methods available. In this example the idea is to control the robot (or anything), using low level commands written with shell scripts commanded from an HTML page. By not using a higher level language such as Python it helps make the robot responsive and quick to act.
A WebServer is used to control the NavQPlus using low level commands written with shell scripts commanded straight from a HTML page. This page will explain how to set-up a WebServer and control your NAVQ+.
The webserver we will use is called Lighttpd
, for more information on the Lighttpd read the following link:
First step is to install Lighttpd WebServer and components. Use the following code in your NAVQ+ serial console application:
This is the output you should receive after running all three codes above:
Lighttpd is looking for an index.html page at /var/www/html. We will change it, so the index.html will be placed under /var/www. For that, we must edit the Lighttpd config file using nano (if you do not have nano see this chapter):
In this file you should change:
To:
I personally did not have to change the file location. Not sure why
It should look something like this:
Then exit the file and save. For the changes we made just now to take effect, we must reboot the web server. To do that enter both commands in order:
At this point the web server is running and if a page index.html is located at /var/www, we can access it from any browser, typing the NAVQ+ address you can see the default web page by lighttpd. Get the NavQ+ IP address and input it into your browser search bar.
Now let's try and place an example template webpage and access it.
Stop the server for the next few steps.
Clone the following repository to somewhere where you will remember in your home file.
After cloning the repository, you will copy some of the files to /var/www. This can be done with these commands:
Now access the page again using the IP address of your NavQPlus, you should get this:
You have managed to make a simple webserver. This webpage can be quite useful to use as a GUI for robot controls as displayed in the example page above.