Book Image

Raspberry Pi Robotic Blueprints

Book Image

Raspberry Pi Robotic Blueprints

Overview of this book

The Raspberry Pi is a series of credit card-sized single-board computers developed in the UK by the Raspberry Pi Foundation with the intention of promoting the teaching of basic computer science in schools. The Raspberry Pi is known as a tiny computer built on a single circuit board. It runs a Linux operating system, and has connection ports for various peripherals so that it can be hooked up to sensors, motors, cameras, and more. Raspberry Pi has been hugely popular among hardware hobbyists for various projects, including robotics. This book gives you an insight into implementing several creative projects using the peripherals provided by Raspberry Pi. To start, we’ll walk through the basic robotics concepts that the world of Raspberry Pi offers us, implementing wireless communication to control your robot from a distance. Next, we demonstrate how to build a sensible and a visionary robot, maximizing the use of sensors and step controllers. After that, we focus on building a wheeled robot that can draw and play hockey. To finish with a bang, we’ll build an autonomous hexcopter, that is, a flying robot controlled by Raspberry Pi. By the end of this book, you will be a maestro in applying an array of different technologies to create almost any imaginable robot.
Table of Contents (14 chapters)
Raspberry Pi Robotic Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Accessing the RC car remotely


You can now control your RC Car, but you certainly want to do this without any connected cables. This section will show you how to add a wireless LAN device so that you can control your car remotely. The first step in doing this is to install a Wireless LAN device. There are several possible ways to do this; however, the one that works well, with full documentation, is described at https://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point/overview.

You should now be able to connect to your Raspberry Pi via the Wireless Access Point. Once you've created the wireless access point, you can login via a VNC connection, this way you can add a USB webcam to your car to make it even easier to control. To do this, first download an application that can support a VNC connection. You can get this on your Raspberry Pi using an application called vncserver. You'll need to install a version of this on your Raspberry Pi by typing sudo apt-get install tightvncserver in a terminal window on your Raspberry Pi.

TightVNC Server is an application that will allow you to remotely view your complete graphical desktop. Once you have it installed, you can do the following:

  1. You need to start the server by typing vncserver in a terminal window on Raspberry Pi.

  2. You will be prompted for a password and then asked to verify it, then you will be asked if you'd like to have a view-only password. Remember the password that you have entered, you'll need it to remotely login via a VNC Viewer.

  3. You'll need a VNC Viewer application for your remote computer. One choice for Windows users is RealVNC, available at http://www.realvnc.com/download/viewer/. When you run it, you will see the following:

  4. Enter the VNC Server address, which is the IP address of your Raspberry Pi, and click on Connect. You will get a warning about an unencrypted connection, select Continue and you will get the following pop-up window:

  5. Type in the password that you entered while starting the vncserver, and you will then get a graphical view of your Raspberry Pi, which looks like the following screenshot:

You can now access all the capabilities of your system; however, they may be slower if you are doing a graphics-intense data transfer. To avoid having to type vncserver each time you boot your Raspberry Pi, use the instructions given at http://www.havetheknowhow.com/Configure-the-server/Run-VNC-on-boot.html.

Vncserver is also available via Linux. You can use an application called Remote Desktop Viewer to view the remote Raspberry Pi GUI system. If you have not installed this application, install it using the update software application based on the type of Linux system you have. Once you have the software, perform the following steps:

  1. Run the application and you will get the following result:

  2. Make sure vncserver is running on Raspberry Pi; the easiest way to do this is to log in using SSH and run vncserver at the prompt. Now click on Connect on Remote Desktop Viewer. Fill in the screen as follows, under the Protocol selection, choose VNC, and you will see the following screenshot:

  3. Now enter the host IP address, make sure you include a :1 at the end and then click on Connect. You'll need to enter the vncserver password that you created when you first ran vncserver on Raspberry Pi, like this:

You can see the graphical screen of Raspberry Pi. Now you are ready to observe the output of a USB webcam connected to your car. This is quite straightforward, simply plug in a USB webcam and download a video viewer. One such video viewer that works well is luvcview. To install this, type sudo apt-get install luvcview.

With all these tools installed, you can now run vncview, bring up a luvcview window so you can see what your RC Car is seeing and control it remotely by running the xcmodControl.py program that you wrote earlier. The screen will look similar to the following:

There are a lot of additions that you can make to your Raspberry Pi controlled car, such as adding the joystick control or more autonomy. However, let's move on to the next project.