Anth's Computer Cave

Stirling Robot software: CamBot

16th September, 2019


In this article we'll cover the RobotMoves remote navigation module, CamBot. To see the other RobotMoves modules available, click the Software Overview button above.

A Stirling robotic vacuum cleaner with added sensors and a new head. Picture: Anthony Hartup.
Our robot,Stirling, in its current form with its new head

CamBot allows you to remotely navigate your robot from a browser using the camera feed from an Android phone. An obvious use for this would be an inspection robot to explore areas too small for a human to traverse.

If you haven't already grabbed the RobotMoves software you can download the full suite of modules here. This was updated on the 19th of September, 2019.

Inside the robot_moves folder you'll find cambot.py, our remote navigation module, along with the cambot folder containing all the web files for the control GUI.


How it works

The CamBot interface runs in a web browser on your PC or laptop. In the left column there are basic controls for forward, backward, left and right movement. There are also readings for all proximity sensors on the robot. The right column holds the live feed from an IP web camera attached to your robot.

The browser-based control GUI for Cambot. Picture: Anthony Hartup.

We are using an old Android phone for a camera, running the IP Webcam app. With some modifications it should also work with other types of IP web cameras.

The Python program, cambot.py, runs on your Raspberry Pi, listening on a web socket for commands from your browser. Whenever you click the movement controls in your browser Cambot travels in your desired direction as you watch live.


Setup

Note: This tutorial assumes you have already configured your robot's motors in robot_moves.py and distance sensors in robot_sensors.py, as described in the earlier RobotMoves articles.

Web server

To communicate with your robot's Raspberry Pi from your PC's browser you'll need to install a web server on the Pi.

We have a tutorial for installing an Apache2 web server and PHP here. Follow the instructions in that tutorial, setting the robot_moves folder as the server's Document Root.

Camera IP address

Inside the robot_moves folder you'll see the cambot folder, which holds all the web files to run the CamBot system.

Most of these will work out of the box, but you will need to modify the IP details for your web camera.

On line 30 in cambot.html you'll see a commented-out iframe to hold the URL for your web camera.

The placeholder, "http://10.0.0.98:8080/jsfs.html", is a sample LAN URL for viewing the feed of an Android phone camera running the IP Webcam app.

If you are also using the IP Webcam app you can simply susbtitute your phone's LAN IP address for the "10.0.0.98" section of the line, then un-comment the iframe.

For example, if your phone's LAN IP is 192.168.1.4, your line would look like this:

If you are using a different camera or app you'll need to replace the entire url, "http://10.0.0.98:8080/jsfs.html", with the IP, port number and webpage you use to access the web camera from a browser.

Save and close the file.


Run CamBot

We can now take it for a spin.

Start the IP Webcam app running on the phone and mount the phone on your robot.

Connect to your Raspberry Pi via SSH and navigate into the robot_moves folder. Type:

sudo python cambot.py

Your robot will begin monitoring its distance sensors and listening for commands.

Now open a browser on your PC. Chrome, Firefox, and any of the other main browsers should work.

In the address bar type the URL for the cambot.html file on your Raspberry Pi. This will be the Pi IP address + /cambot/cambot.html. For instance, if your PI IP address is 10.0.0.112, the URL would be:

10.0.0.112/cambot/cambot.html

You should see the CamBot GUI, with the camera feed in the right column.

Cheers

Anth


Previous: RobotMoves Avoidance module

Next: Phone Wheel, coming soon...

_____________________________________________


Comments

Leave a comment on this article




Leave a comment on this article