Posted in Uncategorized

A Web Server-Controlled Mobile Robot

This post is about getting into robotics.  I discovered building robots uses some of the same skills for building CNC machines.  Basically you are coupling motors to move to an object to move that object. I increased my knowledge in web development.  Software is a significant part of the robot, because it controls everything. A friend and I built robots which are controlled from a web server and wifi. No wires are connected to the robots. My friend did most of the heavy lifting on the software.

Mobile Robot and Test Fixture

About the robots

Currently our robots are prototypes.  At this point, in the project, we are only proving a concept.  Of course, with any project, the budget is limited. The objective is to keep the cost down by using Off-the-shelf parts that are available most places such as Lowes, Home Depot or online.  I am amazed with the availability and low cost of the technology.

Robot parts purchased Locally

This section of the blog is about the parts that were purchased locally.  The frame, wheels, and the battery were purchased from Lowes Hardware.

The webcam was purchased from Best Buy.

The ½” thick plastic was purchased from Tap Plastics in Bellevue Washington which was repurposed from another project.

The most expensive part of the robot is the battery and charger.  The battery is a Dewalt 12 volt 3 Amp Hour Lithium Ion battery used in their power drills.  This works pretty well for pro-typing. You will need a larger battery for production.



Robot parts purchased online

This section of the blog covers the parts that were purchased online.  These parts can be purchased from Amazon or Ebay. If you buy the parts from Ebay you might be able to save more money.  Don’t forget that the Amazon prices are pretty good, when you factor in Prime’s free shipping.

The Raspberry Pi, Arduino, Stepper Motors and Drivers, Battery Emulation Circuit were purchased off Amazon.

Web server and Clients

The software is composed of a web server and a 2 or more clients.  

  • Client 1 is running on the Raspberry Pi.
  • Client 2 is running on the desktop/laptop and sending messages between a game engine.

The game engine is connected to an XBox controller which sends messages to the server commanding it to move the robot.   The server passes the message to the Raspberry Pi. Then the Pi executes the commands sent over.

I will cover this is more detail in the next post if there is a demand.

Live Streaming Video V4L2RTSPServer

Currently, I am working on the live stream video.  I am running v4l2rtspserver on the Raspberry Pi to stream live video from the webcam.  

The software needed on your host pc;

  • Install Visual Studio Code.
  • Install Vlc- use this tool to view the streaming video.  No programming is required.
  • Install Python
  • Install Opencv-python- Pip install opencv-python

You need to install v4l2rtspserver on your Raspberry Pi;

All the information needed is at https://github.com/mpromonet/v4l2rtspserver

After you install the software on the Raspberry Pi, run the following command from the terminal.

V4l2rtspserver -c -v -H480 -W640 /dev/video0

After running the command.  The program outputs the url it is streaming from to the termainal.  You will see a url.

rtsp://<url>:8554/unicast.

View Live Streaming Video from VLC

Run the VLC and “Open Network Stream” from the Media menu.  Enter the rtsp://<url>:8554/unicast. You should see the video from the webcam.

Open the Network Stream and PLAY
Live Video in VLC

View Live Streaming Video from Opencv-python

The VLC is a good way to verify your video is working, but you cannot use it for many applications.  It would take a lot of work to integrate it into an application like unity or any other application. You can use Opencv-python.

I am not going to show you how to install it, because there are many tutorials out there.   But, here is one that I used;

Open Visual Studio Code and copy/past the following snippet

“”” Quick script to test an RTSP server. “””

import cv2 as cv

vcap = cv.VideoCapture(“rtsp://XX.0.0.XX:8554/unicast”)

while(1):

     ret, frame = vcap.read()

     cv.imshow(‘VIDEO’, frame)

     cv.waitKey(1)

Before you run the code enter your url.

You should see video as shown in the photo below.

Live Video from the Webcam

Summary

We can move the robots. But more work needs to be done;

We plan to implement the following

Stream the video in Unity or GoDot.

Control the robot from a browser

Develop an easier way to get the url from robot without using Putty

Make it autonomous.