Help needed with difficult Boe-Bot project
Hello all,
I have a project where I need my robot to navigate to a maze, navigate through the maze and acquire and dispose bombs (lights) at a disposal site. Referring to the picture, I would start in front of one maze and must cross the middle area, which will be covered white with random black tape, to get to my enemy's maze and then navigate that maze. Upon exiting the maze, I must then pick up a bomb and get to the disposal site. There is one disposal site on each side of the middle area denoted by a rectangular area of black tape. The long piece of tape on the sides of each maze lead straight down to the disposal site. There are 3 bombs that need to be disposed of. I am using IR LEDs and photoresistors.
I am stuck on how to develop a good piece of code to do this project as accurate as possible. Please help me and thanks in advance for any help given.
I have a project where I need my robot to navigate to a maze, navigate through the maze and acquire and dispose bombs (lights) at a disposal site. Referring to the picture, I would start in front of one maze and must cross the middle area, which will be covered white with random black tape, to get to my enemy's maze and then navigate that maze. Upon exiting the maze, I must then pick up a bomb and get to the disposal site. There is one disposal site on each side of the middle area denoted by a rectangular area of black tape. The long piece of tape on the sides of each maze lead straight down to the disposal site. There are 3 bombs that need to be disposed of. I am using IR LEDs and photoresistors.
I am stuck on how to develop a good piece of code to do this project as accurate as possible. Please help me and thanks in advance for any help given.


Comments
1 - go straight ahead if the line continues ahead.
2 - go left if there is a line to the left.
3 - go right if there is a line to the right.
4 - look for the bomb if the line stops.
' __BoeBotProject.bs2 ' {$STAMP BS2} ' {$PBASIC 2.5} DEBUG "Program Running!" ' ----- [ Variables ] ------------------------------------------------------------------ PIN_SPEAKER VAR Nib PIN_LEFT_WHEEL VAR Nib PIN_RIGHT_WHEEL VAR Nib PIN_LED_LEFT VAR Nib PIN_LED_RIGHT VAR Nib PIN_LED_CENTER VAR Nib STATUS_MAZE_END VAR Bit STATUS_LED_LEFT VAR Bit STATUS_LED_CENTER VAR Bit STATUS_LED_RIGHT VAR Bit STATUS_BOMB_ACQUIRED VAR Bit SPEAKER_FREQUENCY VAR Byte SPEAKER_DURATION VAR Byte PULSE_COUNT VAR Byte SLOW_SPEED_LEFT_WHEEL VAR Byte SLOW_SPEED_RIGHT_WHEEL VAR Byte FULL_SPEED_LEFT_WHEEL VAR Byte FULL_SPEED_RIGHT_WHEEL VAR Byte ' ----- [ Initialization ] ------------------------------------------------------------- PIN_SPEAKER = 4 PIN_LEFT_WHEEL = 13 PIN_RIGHT_WHEEL = 12 PIN_LED_LEFT = PIN_LED_RIGHT = PIN_LED_CENTER = STATUS_MAZE = 0 STATUS_BOMB_ACQUIRED = 0 SPEAKER_DURATION = 1000 SPEAKER_FREQUENCY = 3000 SLOW_SPEED_LEFT_WHEEL = 730 SLOW_SPEED_RIGHT_WHEEL = 770 FULL_SPEED_LEFT_WHEEL = 650 FULL_SPEED_RIGHT_WHEEL = 850 FREQOUT PIN_SPEAKER, SPEAKER_DURATION, SPEAKER_FREQUENCY ' ----- [ Main Routine ] --------------------------------------------------------------- ' Go straight to the entrance of the maze FOR PULSE_COUNT = 1 TO 122 PULSOUT PIN_LEFT_WHEEL, FULL_SPEED_LEFT_WHEEL PULSOUT PIN_RIGHT_WHEEL, FULL_SPEED_RIGHT_WHEEL PAUSE 20 NEXT ' Navigation DO GOSUB GetLedStatus GOSUB MakeDecision LOOP ' ----- [ Subroutine: GetLedStatus ] --------------------------------------------------- ' Get the status of the LEDs. GetLedStatus: RETURN ' ----- [ Subroutine: MakeDecision ] --------------------------------------------------- ' Make decisions based on LED status. MakeDecision: IF (STATUS_LED_LEFT = 1) AND (STATUS_LED_CENTER = 0) AND (STATUS_LED_RIGHT = 0) THEN ' Basic left turn. GOSUB Turn_Left ELSEIF (STATUS_LED_LEFT = 0) AND (STATUS_LED_CENTER = 0) AND (STATUS_LED_RIGHT = 1) THEN ' Basic right turn. GOSUB Turn_Right ELSEIF (STATUS_LED_LEFT = 0) AND (STATUS_LED_CENTER = 0) AND (STATUS_LED_RIGHT = 0) THEN ' Dead end GOSUB Turn_Back ELSEIF (STATUS_LED_LEFT = 1) AND (STATUS_LED_CENTER = 1) AND (STATUS_LED_RIGHT = 0) THEN ' Choose left over straight. GOSUB Turn_Left ELSEIF (STATUS_LED_LEFT = 1) AND (STATUS_LED_CENTER = 0) AND (STATUS_LED_RIGHT = 1) THEN ' Choose right over left. GOSUB Turn_Right ELSE GOSUB Foward ENDIF GOSUB CheckMaze IF (STATUS_MAZE_END = 1) THEN GOSUB AcquireBomb GOSUB DisposeBomb ENDIF RETURN ' ----- [ Subroutine: Foward ] --------------------------------------------------------- ' Go foward slowly. Foward: FOR PULSE_COUNT = 1 TO 41 PULSOUT PIN_LEFT_WHEEL, SLOW_SPEED_LEFT_WHEEL PULSOUT PIN_RIGHT_WHEEL, SLOW_SPEED_RIGHT_WHEEL PAUSE 20 NEXT RETURN ' ----- [ Subroutine: Right ] ---------------------------------------------------------- ' Turn right slowly. Turn_Right: FOR PULSE_COUNT = 1 TO 41 PULSOUT PIN_LEFT_WHEEL, SLOW_SPEED_RIGHT_WHEEL PULSOUT PIN_RIGHT_WHEEL, SLOW_SPEED_RIGHT_WHEEL PAUSE 20 NEXT RETURN ' ----- [ Subroutine: Left ] ----------------------------------------------------------- ' Turn left slowly. Turn_Left: FOR PULSE_COUNT = 1 TO 41 PULSOUT PIN_LEFT_WHEEL, SLOW_SPEED_LEFT_WHEEL PULSOUT PIN_RIGHT_WHEEL, SLOW_SPEED_LEFT_WHEEL PAUSE 20 NEXT RETURN ' ----- [ Subroutine: Back ] ----------------------------------------------------------- 'Reverse and turn right. Turn_Back: FOR PULSE_COUNT = 1 TO 122 PULSOUT PIN_LEFT_WHEEL, SLOW_SPEED_RIGHT_WHEEL PULSOUT PIN_RIGHT_WHEEL, SLOW_SPEED_LEFT_WHEEL PAUSE 20 NEXT GOSUB Turn_Right RETURN ' ----- [ Subroutine: CheckMaze ] ------------------------------------------------------ ' Look for light to signal end of maze. CheckMaze: IF THEN ' Signal end of maze. STATUS_MAZE_END = 1 ENDIF RETURN ' ----- [ Subroutine: AcquireBomb ] ---------------------------------------------------- ' After detecting light, get the bomb. AcquireBomb: IF THEN ' Bomb acquired. STATUS_BOMB_ACQUIRED = 1 ENDIF RETURN ' ----- [ Subroutine: DisposeBomb ] ---------------------------------------------------- ' Navigate to bomb disposal site. DisposeBomb: ' No longer have a bomb. STATUS_BOMB_ACQUIRED = 0 ' No longer in the maze. STATUS_MAZE_END = 0 RETURN