Toyota Challenge Program

Discussions around autonomous, semi-automatic and intelligent robots and systems.

Moderators: petec, administrator, BeligerAnt

alasdair
Posts: 563
Joined: Sat Jan 03, 2009 3:52 pm
Location: Marlow, Bucks

Toyota Challenge Program

Postby alasdair » Wed Jan 11, 2012 10:36 am

Hi

As not many people will know, most of my christmas presents and time has been used to learn about programming in basic picaxe. This is because my school is entred into a competition run by toyota and rapid to build an obstacle avoiding robot. The PCB is supplied (but sadly i have no diagram which i will explain) and we essentially have to write a program and build it.
http://www.rapidonline.com/toyota/rulesandcriteria/PIC-vehicle.html Thats a link to the website

I just wanted any basic know it alls to give a simple check over of my program, as i am not really sure if it works :P

Just so you know, ~ means that there will be a pin number but since i dont know it yet as i dont have the pcb diagram it is substituted.

The basic jist of the robot is that it will move forwards, repeatedly pinging the sonar array and whenever it sees anything within a defined range (on this, for example 15 cm) it stops, moves the sonar array to see either side and where there is more space, and then moves into it. And just to make it that little bit more complicated our group has decided to make it omni directional. :) so instead of turning left and right it strafes using omni wheels.


'Toyota Challenge Program JHGS space invaders V2
'Alasdair Hutchinson

#picaxe 18m

symbol trig = ~ 'Define output pin for Trigger on sonar
symbol echo = ~ 'Define input pin for Echo on sonar
symbol range = w1 'range in cm defined from ping
symbol front_left = w2 'distance in cm to object to the front-left
symbol front_right = w3 'distance in cm to object to the front-right


main: 'main
servopos 2,150 'face sonar array forwards
gosub ping 'gosub ping
if range => 15 then 'if nothing ahead within 15
gosub nodanger 'gosub nodanger
else 'otherwise
gosub somethingthere 'gosub somethingthere
end if 'end if
goto main 'goto main


whichway: 'whichway subroutine
servopos 2,150 'face sonar array forwards
if front_left > front_right then 'if the space to the left is greater
gosub straferight 'go to the straferight sub
end if 'end if
if front_right > front_left then 'if the space to the right is greater
gosub strafeleft 'go to the strafeleft sub
end if 'end if
return 'return


ping: 'ping subroutine
pulsout trig,2 'produce 20uS trigger pulse
pulsin echo,1,range 'measures the range
pause 10 'pause 10 ms
let range = range * 10 / 58 'converts range to cm
return 'return


somethingthere: 'somthingthere subroutine
gosub ping 'gosub ping
if distance > 15 then return 'this is a range re-check
endif 'end if
gosub allstop 'gosub allstop
gosub look_left 'look left
pause (insert time for servo to move)'wait for the servo to be finished turning
gosub ping 'gosub ping
let front_left = range 'change front left variable to be range
gosub look_right 'look right
pause (insert time for servo to move)'wait for the servo to be finished turning
gosub ping 'gosub ping
let front_right = range 'change front right variable to be range
gosub whichway 'gosub whichway
return 'return


allstop: 'allstop subroutine
Halt A, Halt B 'stop the motors
servopos 2,150 'face sonar array forward
pause 600 'stop for a 600ms
return 'return


look_right: 'look_right subroutine
servopos 2, 215 'rotate servo far right
return 'return


look_left: 'look_left subroutine
servopos 2, 85 'rotate servo far left
return 'return


straferight: 'straferight subroutine
forward hmotor
forward B 'make the horizontal movement motor high
halt A 'make the vertical movement motor low
do until range > 15
gosub ping 'ping subroutine
exit do '
gosub allstop '
goto main 'goto main


strafeleft: 'strafeleft subroutine
backward B 'make the horizontal movement motor backward
halt A 'make the vertical movement motor low
do until range > 15
gosub ping 'ping subroutine
exit do ' '
gosub allstop '
goto main 'goto main


nodanger: 'nodanger subroutine
forward A 'make the vertical movement motor forward
halt B 'make the horizontal movement motor stop
return 'return


And the last thing, I need to make a subroutine and check for if it gets stuck in a u bend, so that it reverses then strafes a certain way, but that is not done yet. Any ideas?

alasdair
Posts: 563
Joined: Sat Jan 03, 2009 3:52 pm
Location: Marlow, Bucks

Re: Toyota Challenge Program

Postby alasdair » Wed Jan 11, 2012 12:06 pm

Another thing (will he ever stop? >_<) is that i have heard an 18m cant run the servo command. Is that true?

daliad100
Posts: 229
Joined: Thu Apr 08, 2010 8:18 pm
Location: Milton Keynes
Contact:

Re: Toyota Challenge Program

Postby daliad100 » Wed Jan 11, 2012 3:11 pm

I'm pretty certain that if you send a pulsout command every 20ms to a servo you can drive it. You'll have to figure out what value to give the pulsout as it depends on the clock speed of the chip.

Then chuck it in with something like this so you don't have to do as much maths on the chip, save an output or two and probably make coding a bit easier (mostly because of less maths.)
Team Imperial - What is that, metric?


Return to “Autonomous and Intelligent Systems”

Who is online

Users browsing this forum: No registered users and 1 guest