Shop OBEX P1 Docs P2 Docs Learn Events
Boe-Bot path planning — Parallax Forums

Boe-Bot path planning

kingbpkingbp Posts: 22
edited 2012-06-07 08:54 in Robotics
Hello I have a project where the boe-bot navigates through a maze twice the first time inspecting every path, the second run taking the shortest path to the end of the maze.

for the paths i identified the paths as Left turn , Right turn , Straight, U-turn . Each path has a case because i'm using qti sensors but im not going to paste the cases on here because i can complete the first pass through the maze im having trouble on the second path.The boe-bot doesn't do anything when i try to navigate through the maze a second time. Here is a fragment of my code can you guys help me fix the code?


If (Sensor = CASE for Right Turn) THEN 'Pseudo code to store string in eeprom for right turn
DATA "R" 'Write string R into eeprom
ELSE


If (Sensor = CASE for UTurn) THEN 'Pseudo code to store string in eeprom for right turn
DATA "U" 'Write string U into eeprom
ELSE

If (Sensor = CASE for Straight) THEN 'Pseudo code to store string in eeprom for right turn
DATA "S" 'Write string R into eeprom
ELSE

If (Sensor = CASE for Left turn) THEN 'Pseudo code to store string in eeprom for right turn
DATA "R" 'Write string R into eeprom

ENDIF
ENDIF
ENDIF
ENDIF

READ 0,Sensors ' puts "R" into Sensors
READ 1, Sensors 'puts "U" Sensors
READ 2, Sensors 'puts "S" into Sensors
READ 3, Sensors ' puts "L" into Sensors



Sensors = 0 'This points to next available position in array
Sensors = Sensors + 1 'Add one to the pointer so the next letter goes in the next position in the array.

IF (Sensors < 3)THEN 'Array will not work unless it has three chracters in array

IF (Sensors - 1 <> "U")Then 'Exit IF the NEXT-TO-last turn is NOT a U-Turn
RETURN
ENDIF
ENDIF


IF Sensors = 313 THEN '3 represents left turn which is stored in eeprom address 3, 1 represents Uturn in eepromaddress 1 in memory
Sensors = Sensors - 3 'shorten the array by 3 characters. We'll "chop off" the LUL and replace with S
Sensors = 2 'The turn we should have taken (AND will take NEXT time. 2 respresents straight in eepromAddress 2
Sensors = Sensors + 1 'set up the pointer TO point TO the NEXT character in the array.

...

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-04-19 19:34
    The WRITE statement is used to write a byte into EEPROM. DATA is used to place fixed data into EEPROM when the program is compiled and downloaded to the Stamp. Look up both these statements in the Basic Stamp Syntax and Reference Manual which can be downloaded from Parallax or should be in the Stamp Editor's help files.

    Look up the SELECT statement format in the Manual. That's what you would use in place of the IF / ELSE / ENDIFs.
  • ercoerco Posts: 20,255
    edited 2012-04-19 19:48
    Do you have encoders on your BoeBot? Lots more programming, but they would make your second run easier, plus allow accurate straight-line navigation & turning. A Servopal would also help out to reduce processor overhead (servo pulsouts) to focus on navigation. What you seek is possible with a BoeBot, but it's not easy.

    Has anyone actually done this yet? Good challenge.

    Great challenge. This should have been a contest at Expo, using a BoeBot or Scribbler 1. I would have entered!
  • kingbpkingbp Posts: 22
    edited 2012-04-19 19:54
    what if i wanted to write a WORD in eepromAddress is the Write Command ok to use or is there another command.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-04-19 20:06
    Yes, the WRITE statement can write a sequence of bytes, words, or a combination of both starting at a specified EEPROM location. Similarly, the READ statement can handle bytes and words. Look at the documentation for the syntax and examples.
  • RahulRahul Posts: 2
    edited 2012-06-07 01:58
    Hi Mike,

    Once the shortest path learned from the first pass is stored in the memory, how to execute only the newly stored shortest path for the second pass? wont the BOT execute everything from the beginning, ie start executing the first pass again?
    Sorry I am new to Robotics.
    Thanks
  • agfaagfa Posts: 295
    edited 2012-06-07 04:25
    I've done this. I didn't use a BOE BOT, but I did use a BOE. The maze was a line maze so basic navigation was accomplished by following a line. I had a set of rules defining the maze, such as only 90 deg. turns and intersections, each turn or intersection fell on a 1" grid, and the end of the maze was a solid block. I did use a single wheel encoder. On the first pass, I followed the left wall and stored the complete path in eeprom as X,Y coordinates. The complete path being each intersection's coordinate. To navigate the second time I had a separate program follow the path looking for redundant points and ignore the moves between them.

    Hope this helps!

    agfa
  • RahulRahul Posts: 2
    edited 2012-06-07 08:04
    How to do that in the same program like in this link
    http://www.youtube.com/watch?v=TcywiIAdI44&feature=youtube_gdata_player
  • agfaagfa Posts: 295
    edited 2012-06-07 08:46
    The 2 programs can easlily be combined to run consecutively into one.
  • ercoerco Posts: 20,255
    edited 2012-06-07 08:54
Sign In or Register to comment.