MrHague
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 18
Joined: Tue Apr 22, 2014 11:55 am

Re: Simple robot for RPi

Wed Jul 30, 2014 8:06 pm

These are the photos of my current set up.
I am genuinely lost now. I can't see what is wrong. I can't even stop the motors running by using AllOff, Pin11Off, MotorAOff, Set MotorA to Stop etc.

Strange the motors start running as soon as scratch enables external outputs etc as it starts.

http://s26.postimg.org/v6swjx72h/photo_1.jpg
http://s26.postimg.org/viacwonih/photo_2.jpg
http://s26.postimg.org/e8yhbtn2h/photo_3.jpg
http://s26.postimg.org/n2pdsxa15/photo_4.jpg

Any help would be great. I want to write it all up from start to finish for anyone else trying to go down this road.

paulwatford
Posts: 8
Joined: Mon Dec 22, 2014 8:37 pm

Re: Simple robot for RPi

Sun Jan 04, 2015 8:18 pm

Hi!

I was a complete novice 3 weeks ago. Well... I did a computer science degree but I honestly mostly just copied guides on the net.

I built a robot with a video streaming camera four powered wheels with a simple GUI for control.

Components:

Raspberry B+

Camera £16: http://www.amazon.co.uk/gp/product/B00E ... ge_o03_s00
WIFI dongle £5: http://www.amazon.co.uk/gp/product/B00E ... ge_o03_s00

Chassis and motors: £23 http://www.amazon.co.uk/gp/product/B00G ... ge_o00_s00

I used two power supplies. £12.99 each. (you can use one but when all four wheels are used sometimes the B+ can crash
http://www.amazon.com/Merkury-2200mAh-P ... ry+battery

And a pibrella £10.99: http://www.amazon.co.uk/Pibrella-perfec ... s=pibrella

Tutorial site I used to get the robot moving:
https://github.com/lesp/Pibrella_Robot/ ... r/robot.py

Site I used to get the camera working: (follow as far as getting the camera enabled)
http://www.maketecheasier.com/raspberry ... ce-camera/

Sites I used to get the camera streaming: (similar steps for both)
http://blog.miguelgrinberg.com/post/how ... spberry-pi
http://www.raspberrypi.org/forums/viewt ... 7&p=473109

Site for Gui (used easy gui)
http://www.ferg.org/easygui/tutorial.html

The robot runs well however there is no reverse using the Pibrella. I need a L298 for that which may be added soon. However you can get around just fine if you are careful and use small turns to get into the right positions. I had the Pibrella already in hand so thought I would see what I could do with it. If you want code I can email it to you. Just message me, I cannot upload here due to file types being not allowed.

paulwatford
Posts: 8
Joined: Mon Dec 22, 2014 8:37 pm

Re: Simple robot for RPi

Sun Jan 04, 2015 8:31 pm

#Code for Pibrella robot. Adapted from various sites and edited by Paul Watford. Demo using Pibrella button crashes at the moment if used.

import pibrella
import time
import signal
import datetime
import os
import easygui as eg
fwd = 3
trn = 1.2
sml = 0.5
tiny =0.2

def nothing():
pibrella.output.e.off()
pibrella.output.f.off()
pibrella.output.g.off()
pibrella.output.h.off()

def inchforward():
pibrella.output.e.on()
pibrella.output.f.on()
pibrella.output.g.on()
pibrella.output.h.on()
time.sleep(sml)
pibrella.output.e.off()
pibrella.output.f.off()
pibrella.output.g.off()
pibrella.output.h.off()
time.sleep(sml)



#g and h are back wheels

def forward():
pibrella.output.e.on()
pibrella.output.f.on()
pibrella.output.g.on()
pibrella.output.h.on()
time.sleep(fwd)
pibrella.output.e.off()
pibrella.output.f.off()
pibrella.output.g.off()
pibrella.output.h.off()
time.sleep(sml)


#e and g are left
def left():
pibrella.output.f.on()
pibrella.output.h.on()
time.sleep(trn)
pibrella.output.f.off()
pibrella.output.h.off()

def inchleft():
pibrella.output.f.on()
pibrella.output.h.on()
time.sleep(tiny)
pibrella.output.f.off()
pibrella.output.h.off()




# f and h are right
def right():
pibrella.output.e.on()
pibrella.output.g.on()
time.sleep(trn)
pibrella.output.e.off()
pibrella.output.g.off()

def inchright():
pibrella.output.e.on()
pibrella.output.g.on()
time.sleep(tiny)
pibrella.output.e.off()
pibrella.output.g.off()



def demo(pin):
time.sleep(sml)
forward()
left()
left()
time.sleep(sml)
forward()
# forward()
# right()
# smallforward()
# left()
# forward()
# left()
# smallforward()




pibrella.button.changed(demo)
while True:
direction = eg.buttonbox(msg="which direction?", choices=('left','forward','right','inchforward', 'inchleft', 'inchright','exit'))
if direction == 'forward':
forward()
if direction == 'left':
left()
if direction == 'right':
right()
if direction == 'exit':
exit()
if direction == 'inchforward':
inchforward()
if direction == 'inchright':
inchright()
if direction == 'inchleft':
inchleft()

else:
nothing()

B.Goode
Posts: 6462
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Simple robot for RPi

Sun Jan 04, 2015 9:17 pm

Python code needs to be wrapped in [ code ] and [ /code ] markers (using the [[ Code ]] button on the top row of the message editing screen.) Without this indentation is lost, and indentation is a critical part of python syntax.

paulwatford
Posts: 8
Joined: Mon Dec 22, 2014 8:37 pm

Re: Simple robot for RPi

Sat Jan 24, 2015 4:45 pm

Thank you for the tip. Sorry novice to the forums!

Return to “Picademy”

Who is online

Users browsing this forum: No registered users and 1 guest