Shop OBEX P1 Docs P2 Docs Learn Events
Boe Bot Escapes a maze Questions from school! — Parallax Forums

Boe Bot Escapes a maze Questions from school!

zhuhr96zhuhr96 Posts: 2
edited 2013-05-20 06:27 in Robotics
Hi,
Our tech teacher can't really teach us anything about robot, so i came here to ask some questions.
The program looks like this:
' {$STAMP BS2}
' {$PBASIC 2.5}
' 5.2
' Henry Zhu
' May 16
counter VAR Byte
FREQOUT 4, 2000, 3000
main:
DO
IF (IN5=0)AND(IN7=0) THEN ' Both whiskers detect obstacle
GOSUB Back_Up ' Back up & U-turn
GOSUB Turn_Left
GOSUB Turn_Left
ELSEIF (IN5=0) THEN ' Left whisker contacts
GOSUB Back_Up ' Back up & turn right
GOSUB Turn_Right
ELSEIF (IN7=0) THEN ' Right whisker contacts
GOSUB Back_Up ' Back up & turn left
GOSUB Turn_Left
ELSE ' Both whiskers 1, no contacts
GOSUB Forward_pulse ' Apply a forward pulse
ENDIF ' and check again
LOOP
' Functions
Forward_pulse:
PULSOUT 13, 850 ' Go Forward
PULSOUT 12, 650
PAUSE 20
RETURN
Turn_Left:
FOR counter = 0 TO 20 ' Left turn 90 degrees
PULSOUT 13, 650
PULSOUT 12, 650
PAUSE 20
NEXT
RETURN
Turn_Right: ' Right turn 90 degrees
FOR counter = 0 TO 20
PULSOUT 13, 850
PULSOUT 12, 850
PAUSE 20
NEXT
RETURN
Back_Up: ' Go Backward
FOR counter = 0 TO 40
PULSOUT 13, 650
PULSOUT 12, 850
PAUSE 20
NEXT
RETURN
END

Now the problems arise :
1.how to make the robot to turn around when it get struck in a corner? I know you have to do a nest if-then statement but how?

2. What are the values (ex.24?) to make the robot turn 30, 45 degrees? My strategy is to program the robot intelligently so it can escape the maze byitself rather the hard-coded way of doing it, which is also more time-consumpting.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-05-19 20:42
    1) Don't worry about nested IF / THEN statements. Think about what movements the BoeBot needs to make to turn around when it might be in a corner. You already have code to make the BoeBot go forward, backwards, and turn right or left by about 90 degrees. Truthfully, the only things the BoeBot can do is turn one wheel forward or backward and turn the other wheel forward or backward. How far the BoeBot moves or how much it turns depends on how long the wheels turn and their speed. How do you think that's determined?

    2) You should be able to approximate how to make the robot turn 30 or 45 degrees. You may have to experiment with exact values since servo motors are not exact things. They're sensitive to power supply voltage and there's some variation in manufacture in terms of friction mostly.
  • zhuhr96zhuhr96 Posts: 2
    edited 2013-05-20 06:27
    Thank for the reply,
    I don't have the boebot now to experiment, but...
    1)Time lteration and pulsewidth, but how do you determine the time in seconds using a for loop?

    2)Approximately 24 for 45 degrees turn?
Sign In or Register to comment.