Shop OBEX P1 Docs P2 Docs Learn Events
Replacement rules for computing the shortest distance of a maze with the boe-bot — Parallax Forums

Replacement rules for computing the shortest distance of a maze with the boe-bot

kingbpkingbp Posts: 22
edited 2011-12-05 22:23 in BASIC Stamp
Hello I have a project with the Boe-bot where i want to make it drive through an entire line following maze with dead ends and continue until it reaches the end of the maze on the first run. Then It will make a 2nd run this time memorizing the entire maze and taking the shortest route to the end of the maze avoiding dead ends. I am using parallax's QTI sensors . I'm working on computing the shortest distance and storing the paths in memory but my code isn't working, I want to represent Left turn as L, Right turn as R, etc. but I get errors. Also I'm trying to use push and pop methods for replace path directions but there not working can you guys take a look at my code and give me some advice thanks.

' {$STAMP BS2}
' {$PBASIC 2.5}

myarray VAR Byte

GOSUB Turn_Right
GOSUB U_Turn
GOSUB Turn_Left
GOSUB Straight


L = GOSUB Turn_Left
R = GOSUB Turn_Right
S = GOSUB Straight
U = GOSUB U_Turn


IF (myarray = LUL)
THEN
POP LUL
PUSH S

IF (myarray = LUR)
THEN
POP LUR
PUSH U

IF (myarray = RUL)
THEN
POP RUL
PUSH U

IF (myarray = RUR)
THEN
POP RUL
PUSH S

IF (myarray = RUS)
THEN
POP RUL
PUSH L

IF (myarray = SUL)
THEN
POP SUL
PUSH R

IF (myarray = SUR)
THEN
POP SUR
PUSH L

IF (myarray = SUS)
THEN
POP SUS
PUSH U

Comments

  • SRLMSRLM Posts: 5,045
    edited 2011-12-05 21:35
    Starting with the obvious, but your "array" (called 'my array') is actually just a single byte. Next, IIRC the BS2 does not have PUSH and POP commands. As a side note about stacks, when you POP you don't give any parameters.

    Next, I'm not completely sure (you can do some weird things in PBASIC...) but I don't think you can assign a GOSUB to a variable. You'd have to use an IF block to test instead.

    Finally, I don't think you've posted your full code. Please remember to always do so in the future.
  • Mike4421Mike4421 Posts: 131
    edited 2011-12-05 22:23
    @ kingbp, your code looks a bit odd, Try looking at the "Stamps In Class Mini-Projects" book for a refference on storing navigation data on the Basic Stamp2 EEPROM memory for navigation. pg90 section " Ramping In Navigation " :nerd:

    The book is a free pdf download, from the book section. You will need to add your PBasic code for the logic you want to implement..... Have Fun out there. :smile:
Sign In or Register to comment.