Boe-Bot path planning
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.
...
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
Look up the SELECT statement format in the Manual. That's what you would use in place of the IF / ELSE / ENDIFs.
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!
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
Hope this helps!
agfa
http://www.youtube.com/watch?v=TcywiIAdI44&feature=youtube_gdata_player