Boe-bot for The Chair Challenge II
Find out my new project here.
Hope it respect all parameters in the challenge:
"The Chair Challenge!"
Requirements:
- Robot can be placed in any position and place operator prefers before start
- Robot must then spin around it´s own center at least 10 times before step 3. (so we know it is actually navigating on it´s own)
- Now the robot should try to drive around each of the 4 legs of a chair, like the orange arrow
- Result:
- Robot was placed at the chair left side, in it direction.
- The robot spins 10 times over itself before start the task.
- The robot drives around each of the 4 legs, like the orange arrow.
- Picts:
- Code:
"The Chair Challenge!"
Requirements:
- Robot can be placed in any position and place operator prefers before start
- Robot must then spin around it´s own center at least 10 times before step 3. (so we know it is actually navigating on it´s own)
- Now the robot should try to drive around each of the 4 legs of a chair, like the orange arrow
- Result:
- Robot was placed at the chair left side, in it direction.
- The robot spins 10 times over itself before start the task.
- The robot drives around each of the 4 legs, like the orange arrow.
- Code:
'(I know it is not that cute.. it may be simplified, but i was afraid of gaping time to finish the task, since I'm with school projects in hands.. maybe I tune it up later)
' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM6}
'---------- VARS ----------'
pulseCount VAR Byte
irdetectleft VAR Bit
irdetectrigth VAR Bit
fase VAR Byte
'---------- TEST ----------'
'---------- START ----------'
GOSUB Spin '5 Spins on it own center
GOSUB Spin '5 Spins on it own center
fase = 0
'--------- MAIN CODE ---------'
DO
FREQOUT 8,1,39500 'activate IR
irdetectleft=IN9
FREQOUT 2,1,39500 'activate IR
irdetectrigth = IN0
'-- states machine --'
SELECT fase 'find beguin position
CASE 0
IF (irdetectleft=0) AND (irdetectrigth=0) THEN
fase = fase + 1
LOW 1
ELSEIF (irdetectrigth=0)THEN
GOSUB Slow_Spin
HIGH 1
ELSE
GOSUB Soft_Spin
ENDIF
CASE 1 'turn around the first chair leg
GOSUB Slow_Around_Leg
HIGH 1
GOSUB Forward
GOSUB Around_Leg_Large
GOSUB Forward
GOSUB Slow_Around_Leg
GOSUB Slow_Around_Leg
GOSUB Slow_Around_Leg
LOW 1
fase = fase + 1
CASE 2 'find and sping on the 2nd leg
IF (irdetectleft=0) AND (irdetectrigth=0) THEN
GOSUB Slow_Around_Leg
HIGH 1
GOSUB Forward
GOSUB Around_Leg
'GOSUB Forward
LOW 1
fase = fase + 1
ELSEIF (irdetectrigth=0)THEN
HIGH 1
GOSUB Slow_Forward
ELSE
HIGH 1
GOSUB Slow_Forward
ENDIF
CASE 3 'find and sping on the 3rd leg
IF (irdetectleft=0) AND (irdetectrigth=0) THEN
GOSUB Slow_Around_Leg
HIGH 1
GOSUB Forward
GOSUB Around_Leg
GOSUB Forward
GOSUB Slow_Around_Leg
LOW 1
fase = fase + 1
ELSEIF (irdetectrigth=0)THEN
GOSUB Slow_Forward
ELSE
GOSUB Slow_Forward
ENDIF
CASE 4 'find and sping on the 4th leg
IF (irdetectleft=0) AND (irdetectrigth=0) THEN
GOSUB Slow_Around_Leg
HIGH 1
GOSUB Forward
GOSUB Around_Leg_Large
GOSUB Slow_Around_Leg
GOSUB Slow_Around_Leg
GOSUB Slow_Around_Leg
GOSUB Forward
LOW 1
fase = fase + 1
ELSEIF (irdetectrigth=0)THEN
HIGH 1
GOSUB Slow_Forward
ELSE
HIGH 1
GOSUB Slow_Forward
ENDIF
CASE ELSE 'stop at end of task
DO
GOSUB Stay
LOOP
ENDSELECT
LOOP
'---------- SPIN ----------'
Spin:
FOR pulseCount = 0 TO 255
PULSOUT 13,850
PULSOUT 12,850
PAUSE 45
NEXT
RETURN
Soft_Spin:
FOR pulseCount = 0 TO 10
PULSOUT 13,770
PULSOUT 12, 770
PAUSE 45
NEXT
RETURN
Slow_Spin:
FOR pulseCount = 0 TO 5
PULSOUT 13,755
PULSOUT 12,755
PAUSE 45
NEXT
RETURN
'---------- BASIC ----------'
Stay:
FOR pulseCount = 0 TO 255
PULSOUT 13,750
PULSOUT 12,750
PAUSE 45
NEXT
RETURN
Forward:
FOR pulseCount = 0 TO 40
PULSOUT 13, 650
PULSOUT 12, 850
PAUSE 20
NEXT
RETURN
Slow_Forward:
FOR pulseCount = 0 TO 50
PULSOUT 13, 740
PULSOUT 12, 760
PAUSE 20
NEXT
RETURN
'---------- LEGS ----------'
Around_Leg:
FOR pulseCount = 0 TO 110
PULSOUT 13,735
PULSOUT 12, 850
PAUSE 40
NEXT
RETURN
Around_Leg_Large:
FOR pulseCount = 0 TO 150
PULSOUT 13,735
PULSOUT 12, 850
PAUSE 40
NEXT
RETURN
Slow_Around_Leg:
FOR pulseCount = 0 TO 10
PULSOUT 13,735
PULSOUT 12, 850
PAUSE 40
NEXT
RETURN
It complete the requirementes asked in "The Chair Challenge II"
- Actuators / output devices: 2 servos, led's
- Control method: autonomous
- CPU: Basic Stamp 2
- Power source: 4 AA batteries
- Programming language: Basic
- Sensors / input devices: IR
- Target environment: indoor