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"
Very nice, I’m impressed. And with a Basic Stamp, too. Technically it only spun around 8 times, not 10, but personally I think it’s clear, especially with the posted code, that you’re actually navigating and not just following a pre-stored path.
I’m surprised and impressed that you were able to do it without wheel encoders or some other way to keep track of where you are. Maybe I should have tried harder with mine
Thanks for your coment, its really positive to hear feedback… specialy when its a good one… hehe
(bad ones are welcome too, i’m always ready to learn with my errors)
Yeah… now that u tell i notice that it does only finish the 9º spin but at detection mode already… well sory for that, because of basic stamp only alow me to play with number o cycles, and time per cycle, it depends a bit the speed of servos for the batterys state.
Anyway, i think everyone can see that it uses IR to detect when to to next stage, or stay in that stage trying to find the chair legs to procede
Code is a bit ugly, but BS doesn’t alow us to much more, since not even can use arguments in the sub-rutines calls.
But its true that can be made with the same algoritme in a easy code if i got time for that.
Anyway… i don’t wanna be specialized in BS, since i’m just migrating to Arduino, and the only reason i used Boe-bot for this is that Arduino structure was not ready for the job yeath. (hope have time to work on it soon =] )
I haven’t worked with it, I haven’t worked with it, but I have a databook on it somewhere and I have often thought of starting to work with it. After all, assembler is fun! What processor from the 8051 family are you using and what development board?
Good job TigPT, to me it looks like you totally aced the chair challange. Could you upload one more picture that shows where you mounted the sensors? I can’t see any on the pictures so far and neither on the video.
We don’t stop playing because we grow old, we grow old because we stop playing.
good work! i am still trying to do the challenge using picaxe… still struggling on the code. lol. I also have a bs2 and the book said that the servo needs a 20ms pause. why did you use pause 45 and 40 on other part?
Thanks. for the info. Have Thanks. for the info. Have you used picaxe. What do you think is better. Im using picaxe now and bs2 is starting to gather dust. How about the cost? Good work on the challenge!
Minimum? I’ve pulsed RC servos at 13 ms intervals and gotten better torque and seemingly quicker response out of them. I think I heard some RC speed controls will not operate well with a higher pulse rate though, but do not have specifics on which one had the problem.