Remote Control Vehicle


9 posts
by ibanezmatt13 » Mon Feb 18, 2013 7:59 pm
Hi,

I really want to be able to create a remote control vehicle with my Pi! For a project, I would love to be able to press the up arrow on my keyboard to make an RC car go forward. The problem is, I don't know where to start.

Would I use infrared or PWM to control my RC vehicle? What would I need and where would I begin?

Thanks in advance
Matt
Posts: 128
Joined: Fri Dec 28, 2012 9:49 am
by badook » Tue Feb 19, 2013 11:41 am
To control an rc car with a raspberry pi you need:
  • a raspberry (eheh)
  • a base car/robot (3-wheeled robots are the best to start with)
  • an H Bridge
  • jumper cables
  • a battery pack for the motors
to make it portable you might also need:
  • a wifi dongle
  • a battery pack to power the raspberry

How do you put it all together?
Well, your car will likely have 2 motors, they must be connected to an H Bridge, which has two functions. First of all an H Bridge makes it possible to "run" each motor in both directions, and it also takes power from an external battery pack and feeds it to the motors. The raspberry pi cannot generally power the motors directly (depending on their size) because it can't supply enough current.
Once the H Bridge is connected to the motors and to the raspberry pi you can already start experimenting moving the motors.

One example of Motor Driver Controller (with the h-bridge) is this one: http://www.ebay.co.uk/itm/L298N-DC-Step ... 0973372764
There are several posts in this forum about this motor driver.
Posts: 42
Joined: Sun Dec 16, 2012 7:44 pm
by bantammenace2012 » Tue Feb 19, 2013 2:54 pm
The way I'm trying to do it is a tracked vehicle using a Wii remote/nunchuk which communicates via Bluetooth. There is no need for a wireless/internet connection (see option below)
Headless operation requires autologin to the RPi and autolaunch of LXDE and Scratch to start automatically using the 'ControllingTwoMotorsForRasPi' image by Kahuziro Abee and a simple scratch project.
Lego WeDo USB hub and 2 Lego WeDo motors
Nintendo Wii controller/nunchuk and Bluetooth dongle Martin Bateman http://www.star.uclan.ac.uk/~mb/rpjam3sept2012.html
Matt Hawkins,
RaspberryPi-Spy, http://www.raspberrypi-spy.co.uk/2013/0 ... pberry-pi/
Raspi.tv, http://www.raspberrypi.org/archives/3298
Battery: Anker for example

Options:
WiFi dongle, (tight ?)VNC Server at boot, smartphone operating as a WiFi hotspot. This way if things do go wrong at least you can log in to the RPi to try to resolve them. Possibly need to look at security issues here

Bluetooth speaker for sound effects.

replace WeDo motors with motors driven via GPUO/add-on boards
Posts: 55
Joined: Mon May 28, 2012 12:18 pm
by petethefeet » Sun Feb 24, 2013 7:32 am
Hey there,

Like yourself I have dived in at the deep end and looking to learn Python with a motorised project! Like the MagPi project I am using a Big Trak base, but as a skid drive it is the same controls as your tracked vehicle.

Hardware includes:
RPi :D
PiFace interface board
4 relay board
IOGEAR high capacity USB battery pack

Instead of the H-Bridge I have opted to use a 4 relay board, each relay has two positions, Normally Open (NO) and Normally Closed(NC). The relays can handle over 240V so they give me opportunity to migrate all this into something with bigger motors :twisted:

The NO position has the positive voltage, the NC has the negative and the contact is attached to a motor terminal.


If relay A is energised motor terminal A has 5v, relay B has 0v the motor turns in direction 1, if relay B is energised the motor terminal B has 5v, relay A has 0v motor turns in direction 2. Here we have the basics for a skid drive!

Now to make a program that relates a Key press to a relay. In order to go forward the left motor needs to go anti clockwise, while the one on the right needs to go clockwise.

Code: Select all
import piface.pfio as pfio
import pygame
from pygame.locals import *

pfio.init()
pygame.init()

screen = pygame.display.set_mode((640, 480))
pygame.display.set_caption('pygame Caption')
pygame.mouse.set_visible(0)

done = False
while not done:
    for event in pygame.event.get():
        if event.type == KEYDOWN:
            if event.key == (K_UP):
                pfio.LED(4).turn_on()
                pfio.LED(7).turn_on()

            if event.key == (K_DOWN):
                pfio.LED(5).turn_on()
                pfio.LED(6).turn_on()

            if event.key == (K_LEFT):
                pfio.LED(5).turn_on()
                pfio.LED(7).turn_on()

            if event.key == (K_RIGHT):
                pfio.LED(4).turn_on()
                pfio.LED(6).turn_on()


        if event.type == KEYUP:
            if event.key == (K_UP):
                pfio.LED(4).turn_off()
                pfio.LED(7).turn_off()

            if event.key == (K_DOWN):
                pfio.LED(5).turn_off()
                pfio.LED(6).turn_off()

            if event.key == (K_LEFT):
                pfio.LED(5).turn_off()
                pfio.LED(7).turn_off()

            if event.key == (K_RIGHT):
                pfio.LED(4).turn_off()
                pfio.LED(6).turn_off()

           
       
            if (event.key == K_ESCAPE):
                done = True


This code lets the rover go forward, reverse, rotate left and right.

Its all about baby steps, once you get the basics working you can think about getting the controller working.

Good luck and keep us posted
New but willing to learn

Pete
Posts: 23
Joined: Wed Nov 21, 2012 10:01 am
by arcanon » Sun Feb 24, 2013 2:48 pm
Here was my effort to build something from the ground up:

http://subgroup-ash.blogspot.de/2013/02 ... mega8.html

Uses keyboard or voice control input + web cam and wifi.
Posts: 36
Joined: Wed Nov 14, 2012 9:18 am
by tcumming » Tue Aug 20, 2013 8:22 pm
Here's a simple BOM for a pi-remote controlled vehicle.

  • Raspberrypi with camera
  • Wifi usb dongle
  • Tamiya 70108 Tracked Vehicle Chassis
  • Batteries to power both pi and vehicle chassis
  • Cheap low-voltage motor bridge circuit.
  • Software to connect the pieces.

Wire the batteries (maybe some circuitry to get the voltage right) to power the 'pi.

Wire some 'pi gpio lines to the bridge circuit (two gpio lines per motor will get you off, backwards, forward, and smoke :). The same circuit will need power from the batteries.

To prototype it, start out running raspistill to read out the camera once per second to a file that's visible via a web browser. The same page that shows the camera image would also have a html form and four buttons (left, right, forward, backward). Pressing a button would run some cgi script that uses the gpio lines to control the motors.

Improvements would be to clean up the script described above to use video and maybe click on the video to change directions, etc. Add pwm to control motor speed.

Hardware improvements would be to make rpi pcb daughter board that would incorporate the motor driver, battery power clean up and charging. Maybe some more sensor inputs, servo outputs for aux stuff....

Just my $.02...

tom
Posts: 5
Joined: Mon Nov 14, 2011 1:24 am
by Shea » Thu Aug 22, 2013 4:35 am
If you use the L298 bridge, you may want to use one more GPIO pin to do softpwm - motor variable speed control.
Posts: 23
Joined: Fri Nov 25, 2011 7:16 pm
by BrendonShaw » Thu Aug 22, 2013 10:28 am
I created this RPi robot, we have started a web site and can send you link if you woud like more information?

viewtopic.php?t=42774&p=346773
Posts: 71
Joined: Sat Jun 30, 2012 7:53 am
by squire_root » Thu Aug 22, 2013 5:35 pm
if you want a more beginner way you might want to invest in a mindstorms nxt robot. This will provide you with sensors and multiple motor/servos as well as parts to build the robot with.
parts:
1. Mindstorms NXT
2. Raspberry Pi
3. Wifi dongle
4. Some sort of battery pack to power the pi

Step 1:
Format your sd card for Rasbian (hard float)

Step 2:
Install nxt-python http://code.google.com/p/nxt-python/

Step 3:
build a robot, and hook up the nxt to the Pi

Step 4:
ssh to your pi and write a program in python using the curses library (comes pre-installed with python) to control the robot over the internet

Success!
Posts: 3
Joined: Mon Jul 29, 2013 3:59 am