davidbuckley.net |
home >  Ambler >  | 7 September 2017 |
'---------------- main user routine names ---------- ' F Forward ' B Backward ' Br back with right foot ' Bl back with left foot ' R RightTurn ' L LeftTurn ' H Halt, stand to attention ' V Voice, beep 1KHz for 0.1sec ' U do Ultrasonic test react using UawareAt, UtooNear from AUawareAt, AUtooNear ' T if no parameter do Tf ' Tf Foot Turn - if Left forward turn right, if Right forward turn left ' Tm memory Turn - same way as last time ' To Other Turn - opposite way to last time ' G ask Cmndr if Step - read Sharp-IR - sets fB_SgOn=1 ' g - sets fB_SgOn=0 '' g foot sensors - no room so use fB_StOn '' g0 foot sensors off => fB_SgOn =0 - no room '' g1 foot sensors on => fB_SgOn =1 - no room ' A ask Cmndr for default Act ' Q Quit and wait for cmnds ' w Wait 1/10 secs in next cmnd, if next cmnd is not number then wait 0 secs ' m set rollby and stepby; actualrollby =15+rollby, actualstepby =stepby*3; resolution roll 10us, stepby 30us ' <bytevalue> => $XX => rollbyNibble stepbyNibble ' $hh => rollbyNibble stepbyNibble ' a<Act> jump to Act in next byte ' r<Act> do Act in next byte as reaction ' ' comment start, ignore all until next ' ' s<num> set speed, maxed to potspeed 1-15, turn off program auto speed adj ' sc => turn on potspeed (1-15) ' su => increase speed, maxed to potspeed 1-15 ' sd => decrease speed MIN 1 ' sp => set pace-speed, 0 - 15 10us resolution 0 ignored ' sr => set roll-speed, 0 - 15 10us resolution 0 ignored ' s$ => set RollSpeedNibble and PaceSpeedNibble in next byte, $hh, 10us resolution ' f foot sensors ' f0 foot sensors off => fB_StOn =0 ' f1 foot sensors on => fB_StOn =1 ' d<Act> set defaultAct in next byte '' um<Do> if Urange<Umemory '' u+<num> set UawareAt '' u-<num> set UtooNear '' ur<num><Do> if Urange<num> 'AabCEeGghIiJjKklMNnOoPpQqStUuvWXxYyZz available as primary cmnd '!¬`|\/<>@~#:;,[]{}()*&^£ available ''/jump to Act in next byte ''\act as reaction Act in next byte '' "blm",LeftFootMaskbyte '' "brm",RightFootMaskbyte '' "ble",LeftFootExpectedbyte '' "bre",RightFootExpectedbyte ' '---------------- system names ----------- 'PoseData 'pRollR DATA rollC +roll,0 'pRollL DATA rollC -roll ,0 'pRollC DATA rollC,0 'ppaceC DATA paceC,0 '================ Mind ===================================================== zz CON 16 'selected on [KEY_POWER] ' Act 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ' A B C D E F ' DoIndex DATA A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,Azz 'A0 init Act done after poweron or reset, defaultAct got from Cmndr A0 DATA "'A0'" DATA "m$3D"'"m$7A" 'rollby=7, stepby=10 DATA "s$66" 'rollspeed=6, pacespeed=6 DATA "Vw5Hw5V" 'wait 1 sec - easier to see initial position, then get Act DATA "f1A." 'BumpSensorsOn, get default Act '---------------- Acts -- if ended with '.' are Activities ----------------- ' if not ended with '.' continue with next Act 'end lists with "." otherwise starts doing next Act! 'Acts can have any legal variable name. 'Any repeat parameter for FBRLV etc will be ignored - code removed after 6-1-1 ** A1 DATA "FFRRH w2 LLBBBH." 'roughly F & B about same spot A2 DATA "'A2'suFUa2" A3 DATA "'A3'Ga2" 'HWFFH W1 BB." A4 DATA "Vw V w5." 'w missing param so does w0 A5 DATA "H" ',"W1FW1F." A6 DATA " " 'scRRRRRLLLLL." A7 DATA "LLRR." A8 DATA "FRV." A9 DATA "RRRLLL." A10 DATA " " 'FFFFFFFBBBBBBB." A11 DATA "sdFsua3" A12 DATA "." 's$36,FFFm$7A FFFs$22,m$44,BBBBBB." A13 DATA "." 'suFFFBBB." A14 DATA "BGf0GF 2R2 5 7junk g 'test'V." 'test repeat param' 2 5 7=257=2 **ignored 'Az DATA A15 DATA "d13g." Azz DATA "f0." 'selected on [KEY_POWER] 'A15 DATA "suF." '---------------- frustration reactions ------- 'have to turn off the Toe sensors until moved away from obstacle otherwise loops rf1R DATA "f0VVVBf1RR." 'if (hurtsR+hurtsL) >= hurtedRL1 rf2L DATA "f0VVVVVBf1LLLL." 'if (hurtsR+hurtsL) >= hurtedRL2 '---------------- bump reactions -------------- 'if toeX bumped then hurtsX +=hurted rbR DATA "f0VsdBrBf1L." 'if hurtsR >= hurted rbL DATA "f0VVsdBlBf1R." 'if hurtsL >= hurted '---------------- US reactions ---------------- rUawareAt DATA "VTf." rUtooNear DATA "VVBTmTm." '---------------------------------------------- Bend DATA "." 'end marker to avoid doing the program!
'---------------- user commands ---------- 'Action cmnds Z CON 0 'end of list, null move F CON 1 'Forward B CON 2 'Back R CON 3 'Right turn L CON 4 'Left turn H CON 5 'Halt, stand to attention V CON 6 'Voice, beep 1KHz for 0.1sec Br CON 7 'Back with right foot, for toe bump Bl CON 8 'Back with left foot, for toe bump fT CON 9 'footTurn, turn away from leading Foot mT CON 10 'memoryTurn, turn same way as last time, use f_TurnedR oT CON 11 'otherTurn, turn other way and toggle f_TurnedR Vt CON 12 'Voice Tune Vb CON 13 'Voice Beep 'Behavioural cmnds Su CON 20 'increase speed(+1) MAX potspeed Sd CON 21 'reduce speed(/2) MIN minpacespeed tbOn CON 22 'SensorToeBump on tbOff CON 23 'SensorToeBump off bk CON 24 'set fb_Fdir to 0 so StepandTurn is stepback 'frustUp CON 25 'frustration, inc Nibble frust - not used Wlight CON 25 'walk towards light Wdark CON 26 'walk towards dark Ewoff CON 27 'Eye Walk off ttyOn CON 28 'debug text On ttyOff CON 29 'debug text Off Ew CON 30 'Eye walk, test and set paceTurn h0 CON 31 'reduce hurts to zero, otherwise frustration behaviour gets subsumed after next move usOn CON 32 usOff CON 33 'Parameter cmnds 'could use '(ASC 39) for tty comments ,"'comment'" instead of tty,"comment¬" w CON 40 'Wait 1/10 secs in next byte a CON 41 'jump to Act in next byte s CON 42 'set speeds to next byte, $rp '$55 is max for servos to follow pulse 'from Pot(^15) works best with pacerollspeedratio =1 m CON 43 'set Roll and Step to next byte $rollby,stepby 'S03 max speed is 45.5us/frame @20ms/frame, max potspeed is 15 'rollby <$0-$F> delta roll from rollmin 'actualrollby =rollby +rollmin ie rollby=0 => rollC +-rollmin 'if rollby 7 '=>+-(7+15)*10us=*-220us '@ speed 5(10us)=50us '=>440/50*20ms=176ms/STEP & 9 frames 'stepby <$0-$F> '(in 30us units, 15=>450us so pace is 2*450=900us) 'pacepulse =+-(3*stepby)+paceC 'ie 150+-45 => 105 - 195 (10us) => 1050 - 1950us 'if stepby 10 ($A) '=>+-300us '@ speed 5(10us)=50us '=>600/50*20ms=240ms/step & 12 frames 'so at speed=5 rollby=7 stepby=10 one step takes 240+176=416ms 'rolltime/steptime =176/240 =0.73 d CON 44 'set default Act to next byte usa CON 45 'set USaware range(<=) to next low.nib resolution 2"=>5cm, max 15=>30" IfusOn CON 46 IfusL CON 47 'US if Less <param> <Do>; if USRange<USActionRange jump to Act in next byte IfusLm CON 48 'US if Less mem <Do>; if USRange<USlast jump to Act in next byte tty CON 49 'debug text starting in next byte and ending with ¬ 'Hurt rule cmnds IfHLR CON 50 'test ToesRL eg IfHLR,hurtingalot,Af2 IfHR CON 51 'test Toe R IfHL CON 52 'test Toe L '---------------- Acts -- if ended with 'z' are Activities ----------------- ' if not ended with 'z' continue with next Act 'end lists with Z otherwise starts doing next Act! 'Acts can have any legal variable name. defaultAct DATA A1 'default Act name done after 'Z', overwritten at init: Ainit DATA Vt,Vb,V,m,$58,ttyOn,H,Z 'initialisation Act done after PowerOn or Reset if no PicAxe 'ABack DATA B,Z A15 DATA V,Z 'just so we know the switch is on -1 not 0 !!! 'A14 shows asymetric nature of servos, set speed to 1 and walking very even ' set spped above and Rroll is faster than Lroll and completes roll whereas Left doesn't A14 DATA 'F,w,10,F,w,10,F,V,w,10,B,w,10,B,w,10,B,w,10,Z A13 DATA 'H,w,2,F,F,H,w,1,B,B,Z A12 DATA 'F,F,R,R,H,w,2,L,L,B,B,B,H,Z 'roughly F & B about same spot A11 DATA 'F,F,R,L,L,Z 'A10 DATA s,$66,F,Su,a,A3,Z A10 DATA 'F,F,F,F,F,F,F,B,B,B,B,B,B,B,Z A9 DATA 'L,L,R,R,a,A4,Z 'A8 DATA R,R,R,R,R,L,L,L,L,L,Z A8 DATA A7 DATA Wdark,a,A5 'US dark walk, jump to A5 A6 DATA Wlight 'US light walk, drop to A5 A5 DATA Vb,tty,"A4¬",usOn,a,A2 'US walk, jump to A2 A4 DATA Wdark,a,A2 'dark walk, jump to A2 A3 DATA Wlight 'light walk, drop to A2 A2 DATA tbOn 'SensorT Walk, toe bump on A1 DATA m,$58 'set Roll and Step Walk DATA Ew,F,Su,IfusOn,USwalk,a,Walk ''a' preserves behaviours USwalk DATA IfusL,4,USavoid,a,Walk A0 DATA w,1,Z 'just wait '---------------- frustration behavioural Acts ------- 'inhibit sensors until Toe moved back a bit, otherwise just loops to here Af1 DATA tty,"Af1R¬",h0,tbOff,V,V,V,B,tbOn,mT,mT,Z 'if (hurtsR+hurtsL)>hurting Af2 DATA tty,"Af2L¬",h0,tbOff,V,V,V,V,V,B,tbOn,B,mT,mT,mT,Z 'if (hurtsR+hurtsL)>hurtalot '---------------- bump behavioural Acts ------------- 'if toeX bumped then hurtsX += ahurt 'inhibit sensors until Toe moved back a bit, otherwise just loops to here AbR DATA tty,"AbR¬",tbOff,V,Sd,Br,B,tbOn,L,Z 'if hurtsR>hurtalittle AbL DATA tty,"AbL¬",tbOff,V,V,Sd,Bl,B,tbOn,R,Z 'if hurtsL>hurtalittle '---------------- US behavioural Acts ------------- USTfScan DATA tty,"`USTfScan¬" DATA V,fT,IfusLm,USoTscan,IfusL,4,USmT,Z 'TurnScan, using Tf means centre doesn't move (much) USoTscan DATA tty,"`USoTscan¬" DATA V,V,oT,bk,mT,mT,IfusL,4,USmT,Z 'OtherTurnScan bk so so stepturn doesn't move closer USmT DATA tty,"`USmT¬" DATA V,V,V,bk,mT,mT,IfusL,4,USmT,Z 'MemoryTurn bk so so stepturn doesn't move closer 'USslow DATA Sd,Z USback DATA B,fT 'and test again '---------------- US behavioural Rules ------------- 'Behaviour variable thresholds and BehaviouralAction 'US: ActionRange,Act USavoid DATA V,tty,"USavoid¬" ' DATA frustUp 'UScaution DATA tty,"caut¬",usIFL,3,USslow UStooclose DATA tty,"close¬",IfusL,2,USback 'Joe 3 USinway DATA tty,"way¬",IfusL,4,USTfScan DATA Z '---------------- Tactile behavioural rules --- HurtRules DATA tty,"Hrules¬" frus2 DATA IfHLR,hurtingalot,Af2 'L+R >hurtingalot frus1 DATA IfHLR,hurting,Af1 'L+R >hurting hurtR DATA IfHR,hurtalittle,AbR 'R >ahurt hurtL DATA IfHL,hurtalittle,AbL,Z 'L >ahurt '---------------------------------------------- Bend DATA Z 'end marker to avoid doing the program! '----------------------------------------------
'Action cmnds Z CON 0 'end of list, null move F CON 1 'Forward B CON 2 'Back R CON 3 'Right turn L CON 4 'Left turn H CON 5 'Halt, stand to attention V CON 6 'Voice, beep 1KHz for 0.1sec Br CON 7 'Back with right foot, for toe bump Bl CON 8 'Back with left foot, for toe bump fT CON 9 'footTurn, turn away from leading Foot mT CON 10 'memoryTurn, turn same way as last time, use f_TurnedR oT CON 11 'otherTurn, turn other way and toggle f_TurnedR Vt CON 12 'Voice Tune Vb CON 13 'Voice Beep 'Behavioural cmnds Su CON 20 'increase speed(+1) MAX potspeed Sd CON 21 'reduce speed(/2) MIN minpacespeed tbOn CON 22 'SensorToeBump on tbOff CON 23 'SensorToeBump off bk CON 24 'set fb_Fdir to 0 so StepandTurn is stepback 'frustUp CON 25 'frustration, inc Nibble frust Wlight CON 25 'walk towards light Wdark CON 26 'walk towards dark Ewoff CON 27 'Eye Walk off ttyOn CON 28 'debug text On ttyOff CON 29 'debug text Off Ew CON 30 'Eye walk, test and set paceTurn h0 CON 31 'reduce hurts to zero, otherwise frustration behaviour gets subsumed after next move usOn CON 32 usOff CON 33 'Parameter cmnds 'could use '(ASC 39) for tty comments ,"'comment'" instead of tty,"comment¬" w CON 40 'Wait 1/10 secs in next byte a CON 41 'jump to Act in next byte s CON 42 'set speeds to next byte, $rp '$55 is max for servos to follow pulse 'from Pot(^15) works best with pacerollspeedratio =1 m CON 43 'set Roll and Step to next byte $rollby,stepby 'S03 max speed is 45.5us/frame @20ms/frame, max potspeed is 15 'rollby <$0-$F> delta roll from rollmin 'actualrollby =rollby +rollmin ie rollby=0 => rollC +-rollmin 'if rollby 7 '=>+-(7+15)*10us=*-220us '@ speed 5(10us)=50us '=>440/50*20ms=176ms/STEP & 9 frames 'stepby <$0-$F> '(in 30us units, 15=>450us so pace is 2*450=900us) 'pacepulse =+-(3*stepby)+paceC 'ie 150+-45 => 105 - 195 (10us) => 1050 - 1950us 'if stepby 10 ($A) '=>+-300us '@ speed 5(10us)=50us '=>600/50*20ms=240ms/step & 12 frames 'so at speed=5 rollby=7 stepby=10 one step takes 240+176=416ms 'rolltime/steptime =176/240 =0.73 d CON 44 'set default Act to next byte usa CON 45 'set USaware range(<=) to next low.nib resolution 2"=>5cm, max 15=>30" IfusOn CON 46 IfusL CON 47 'US if Less <param> <Do>; if USRange<USActionRange jump to Act in next byte IfusLm CON 48 'US if Less mem <Do>; if USRange<USlast jump to Act in next byte tty CON 49 'debug text starting in next byte and ending with ¬ 'Hurt rule cmnds IfHLR CON 50 'test ToesRL eg IfHLR,hurtingalot,Af2 IfHR CON 51 'test Toe R IfHL CON 52 'test Toe L '---------------- Acts -- if ended with 'z' are Activities ----------------- ' if not ended with 'z' continue with next Act 'end lists with Z otherwise starts doing next Act! 'Acts can have any legal variable name. defaultAct DATA A1 'default Act name done after 'Z', overwritten at init: Ainit DATA Vt,Vb,V,m,$58,ttyOn,H,Z 'initialisation Act done after PowerOn or Reset if no PicAxe 'ABack DATA B,Z A15 DATA V,Z 'Mom - just so we know the switch is on -1 not 0 !!! 'A14 shows asymetric nature of servos, set speed to 1 and walking very even ' set spped above and Rroll is faster than Lroll and completes roll whereas Left doesn't A14 DATA 'F,w,10,F,w,10,F,V,w,10,B,w,10,B,w,10,B,w,10,Z A13 DATA 'H,w,2,F,F,H,w,1,B,B,Z A12 DATA 'F,F,R,R,H,w,2,L,L,B,B,B,H,Z 'roughly F & B about same spot A11 DATA 'F,F,R,L,L,Z 'A10 DATA s,$66,F,Su,a,A3,Z A10 DATA 'F,F,F,F,F,F,F,B,B,B,B,B,B,B,Z A9 DATA 'L,L,R,R,a,A4,Z 'A8 DATA R,R,R,R,R,L,L,L,L,L,Z A8 DATA A7 DATA Wdark,a,A5 'US dark walk, jump to A5 A6 DATA Wlight 'US light walk, drop to A5 A5 DATA tty,"A5¬",Vb,usOn,a,A2 'US walk, jump to A2 A4 DATA Wdark,a,A2 'dark walk, jump to A2 A3 DATA Wlight 'light walk, drop to A2 A2 DATA tty,"A2¬",tbOn 'SensorT Walk, toe bump on A1 DATA m,$58 'set Roll and Step Walk DATA Ew,F,Su,IfusOn,USwalk,a,Walk ''a' preserves behaviours USwalk DATA IfusL,4,USavoid,a,Walk '2" resolution =>8" A0 DATA w,1,Z 'just wait '---------------- frustration behavioural Acts ------- 'inhibit sensors until Toe moved back a bit, otherwise just loops to here Af1 DATA tty,"Af1R¬",h0,tbOff,V,V,V,B,tbOn,mT,mT,Z 'if (hurtsR+hurtsL)>hurting Af2 DATA tty,"Af2L¬",h0,tbOff,V,V,V,V,V,B,tbOn,B,mT,mT,mT,Z 'if (hurtsR+hurtsL)>hurtalot '---------------- bump behavioural Acts ------------- 'if toeX bumped then hurtsX += ahurt 'inhibit sensors until Toe moved back a bit, otherwise just loops to here AbR DATA tty,"AbR¬",tbOff,V,Sd,Br,B,tbOn,L,Z 'if hurtsR>hurtalittle AbL DATA tty,"AbL¬",tbOff,V,V,Sd,Bl,B,tbOn,R,Z 'if hurtsL>hurtalittle '---------------- US behavioural Acts ------------- USTfScan DATA tty,"`USTfScan¬" DATA V,fT,IfusLm,USoTscan,IfusL,4,USmT,Z 'TurnScan, using Tf means centre doesn't move (much) USoTscan DATA tty,"`USoTscan¬" DATA V,V,oT,bk,mT,mT,IfusL,4,USmT,Z 'OtherTurnScan bk so so stepturn doesn't move closer USmT DATA tty,"`USmT¬" DATA V,V,V,bk,mT,mT,IfusL,4,USmT,Z 'MemoryTurn bk so so stepturn doesn't move closer 'USslow DATA Sd,Z USback DATA B,fT 'and test again '---------------- US behavioural Rules ------------- 'Behaviour variable thresholds and BehaviouralAction 'US: ActionRange,Act USavoid DATA V,tty,"USavoid¬" ' DATA frustUp 'UScaution DATA tty,"caut¬",usIFL,3,USslow UStooclose DATA tty,"close¬",IfusL,2,USback 'Joe 3 USinway DATA tty,"way¬",IfusL,4,USTfScan DATA Z '---------------- Tactile behavioural rules --- HurtRules DATA tty,"Hrules¬" frus2 DATA IfHLR,hurtingalot,Af2 'L+R >hurtingalot frus1 DATA IfHLR,hurting,Af1 'L+R >hurting hurtR DATA IfHR,hurtalittle,AbR 'R >ahurt hurtL DATA IfHL,hurtalittle,AbL,Z 'L >ahurt '---------------------------------------------- Bend DATA Z 'end marker to avoid doing the program! '----------------------------------------------
'---------------- user commands ---------- 'Action cmnds Z CON 0 'end of list, null move F CON 1 'Forward B CON 2 'Back R CON 3 'Right turn L CON 4 'Left turn H CON 5 'Halt, stand to attention V CON 6 'Voice, beep 1KHz for 0.1sec Br CON 7 'Back with right foot, for toe bump Bl CON 8 'Back with left foot, for toe bump fT CON 9 'footTurn, turn away from leading Foot mT CON 10 'memoryTurn, turn same way as last time, use f_TurnedR oT CON 11 'otherTurn, turn other way and toggle f_TurnedR Vt CON 12 'Voice Tune Vb CON 13 'Voice Beep 'Behavioural cmnds Su CON 20 'increase speed(+1) MAX potspeed Sd CON 21 'reduce speed(/2) MIN minpacespeed StbOn CON 22 'SensorToeBump on StbOff CON 23 'SensorToeBump off 'frustUp CON 25 'frustration, inc Nibble frust Wlight CON 24 'walk towards light Wdark CON 25 'walk towards light Ewoff CON 26 'Eye Walk off ttyOn CON 27 'debug text On ttyOff CON 28 'debug text Off Ew CON 29 'Eye walk, test and set paceTurn h0 CON 30 'reduce hurts to zero, otherwise frustration behaviour gets subsumed after next move 'Parameter cmnds w CON 40 'Wait 1/10 secs in next byte a CON 41 'jump to Act in next byte s CON 42 'set speeds to next byte, $rp '$55 is max for servos to follow pulse 'from Pot(^15) works best with pacerollspeedratio =1 m CON 43 'set Roll and Step to next byte $rollby,stepby 'S03 max speed is 45.5us/frame @20ms/frame, max potspeed is 15 'rollby <$0-$F> delta roll from rollmin 'actualrollby =rollby +rollmin ie rollby=0 => rollC +-rollmin 'if rollby 7 '=>+-(7+15)*10us=*-220us '@ speed 5(10us)=50us '=>440/50*20ms=176ms/STEP & 9 frames 'stepby <$0-$F> '(in 30us units, 15=>450us so pace is 2*450=900us) 'pacepulse =+-(3*stepby)+paceC 'ie 150+-45 => 105 - 195 (10us) => 1050 - 1950us 'if stepby 10 ($A) '=>+-300us '@ speed 5(10us)=50us '=>600/50*20ms=240ms/step & 12 frames 'so at speed=5 rollby=7 stepby=10 one step takes 240+176=416ms 'rolltime/steptime =176/240 =0.73 d CON 44 'set default Act to next byte usa CON 45 'set USaware range(<=) to next low.nib resolution 2"=>5cm, max 15=>30" usIFL CON 46 'US if Less <param> <Do>; if USRange<USActionRange jump to Act in next byte usIFLm CON 47 'US if Less mem <Do>; if USRange<USlast jump to Act in next byte tty CON 48 'debug text starting in next byte and ending with ¬ T CON 49 'Talk #msg in next byte St CON "t" 'Test Sname CON "n" Sforward CON "f" Sback CON "b" Sright CON "r" Sleft CON "l" Sobstacle CON "o" '"s" - Hello I am the BASIC Stamp 'Hurt rule cmnds IFhLR CON 50 'test ToesRL IFhR CON 51 'test Toe R IFhL CON 52 'test Toe L '---------------- Acts -- if ended with 'z' are Activities ----------------- ' if not ended with 'z' continue with next Act 'end lists with Z otherwise starts doing next Act! 'Acts can have any legal variable name. defaultAct DATA A1 'default Act name done after 'Z', overwritten at init: 'first Act DATA must be @>0 since Z=> pD=0 means nothing to do Ainit DATA Vt,Vb,V,m,$A6,ttyOn,H,T,Sname,V,V,Z 'initialisation Act done after PowerOn or Reset 'ABack DATA B,Z A15 DATA V,Z 'just so we know the switch is on -1 not 0 !!! 'A14 shows asymetric nature of servos, set speed to 1 and walking very even ' set spped above and Rroll is faster than Lroll and completes roll whereas Left doesn't A14 DATA F,w,10,F,w,10,F,V,w,10,B,w,10,B,w,10,B,w,10,Z A13 DATA 'H,w,2,F,F,H,w,1,B,B,Z A12 DATA 'F,F,R,R,H,w,2,L,L,B,B,B,H,Z 'roughly F & B about same spot A11 DATA StbOn,F,F,F,R,R,R,B,B,B,L,L,L,Su,Z 'A10 DATA s,$66,F,Su,a,A3,Z A10 DATA 'F,F,F,F,F,F,F,B,B,B,B,B,B,B,Z A9 DATA 'L,L,R,R,a,A4,Z 'A8 DATA R,R,R,R,R,L,L,L,L,L,Z A8 DATA A7 DATA A6 DATA Wdark,a,A4 'US dark walk, jump to A4 A5 DATA Wlight 'US light walk, drop to A4 A4 DATA Vb,tty,"A4¬",StbOn,m,$58 'US walk, setup USwalk DATA Ew,F,Su,usIFL,4,USavoid,a,USwalk A3 DATA Wdark,a,A1 'dark walk, jump to A1 A2 DATA Wlight 'light walk, drop to A1 A1 DATA StbOn '(70)SensorT Walk, toe bump on A0 DATA m,$58 'set Roll and Step 'Walk DATA Ew,F,Su,a,Walk '(73)'a' preserves behaviours Walk DATA F,Su,a,Walk ''a' preserves behaviours DATA @256 DATA "B" 'first Act DATA must be @>0 since Z=> pD=0 means nothing to do '---------------- frustration behavioural Acts ------- 'inhibit sensors until Toe moved back a bit, otherwise just loops to here Af1 DATA tty,"Af1R¬",h0,StbOff,V,V,V,B,StbOn,mT,mT,Z 'if (hurtsR+hurtsL)>hurting Af2 DATA tty,"Af2L¬",h0,StbOff,V,V,V,V,V,B,StbOn,B,mT,mT,mT,Z 'if (hurtsR+hurtsL)>hurtalot '---------------- bump behavioural Acts ------------- 'if toeX bumped then hurtsX += ahurt 'inhibit sensors until Toe moved back a bit, otherwise just loops to here AbR DATA tty,"AbR¬",StbOff,V,Sd,Br,StbOn,L,L,Z 'if hurtsR>hurtalittle AbL DATA tty,"AbL¬",StbOff,V,V,Sd,Bl,StbOn,R,R,Z 'if hurtsL>hurtalittle '---------------- US behavioural Acts ------------- USTfScan DATA tty,"`USTfScan¬" DATA V,fT,usIFLm,USoTscan,usIFL,4,USmT,Z 'TurnScan, using Tf means centre doesn't move (much) USoTscan DATA tty,"`USoTscan¬" 'DATA V,V,oT,bk,mT,mT,usIFL,4,USmT,Z 'OtherTurnScan bk only used for skid turns DATA V,V,oT,mT,mT,usIFL,4,USmT,Z 'OtherTurnScan USmT DATA tty,"`USmT¬" 'DATA V,V,V,bk,mT,mT,usIFL,4,USmT,Z bk only used for skid turns DATA V,V,V,mT,mT,usIFL,4,USmT,Z 'USslow DATA Sd,Z USback DATA B,fT 'and test again '---------------- US behavioural Rules ------------- 'Behaviour variable thresholds and BehaviouralAction 'US: ActionRange,Act USavoid DATA V,tty,"USavoid¬" ' DATA frustUp 'UScaution DATA tty,"caut¬",usIFL,3,USslow UStooclose DATA tty,"close¬",usIFL,2,USback 'Joe 3 USinway DATA tty,"way¬",usIFL,4,USTfScan DATA Z '---------------- Tactile behavioural rules --- HurtRules DATA tty,"Hrules¬" frus2 DATA IFhLR,hurtingalot,Af2 'L+R >hurtingalot frus1 DATA IFhLR,hurting,Af1 'L+R >hurting hurtR DATA IFhR,hurtalittle,AbR 'R >ahurt hurtL DATA IFhL,hurtalittle,AbL,Z 'L >ahurt '---------------------------------------------- Bend DATA Z 'end marker to avoid doing the program! '----------------------------------------------
'---------------- user commands ---------- 'Action cmnds Z CON 0 'end of list, null move F CON 1 'Forward B CON 2 'Back R CON 3 'Right turn L CON 4 'Left turn H CON 5 'Halt, stand to attention V CON 6 'Voice, beep 1KHz for 0.1sec Br CON 7 'Back with right foot, for toe bump Bl CON 8 'Back with left foot, for toe bump fT CON 9 'footTurn, turn away from leading Foot mT CON 10 'memoryTurn, turn same way as last time, use f_TurnedR oT CON 11 'otherTurn, turn other way and toggle f_TurnedR Vt CON 12 'Voice Tune Vb CON 13 'Voice Beep 'Behavioural cmnds Su CON 20 'increase speed(+1) MAX potspeed Sd CON 21 'reduce speed(/2) MIN minpacespeed StbOn CON 22 'SensorToeBump on StbOff CON 23 'SensorToeBump off 'frustUp CON 25 'frustration, inc Nibble frust Wlight CON 24 'walk towards light Wdark CON 25 'walk towards light Ewoff CON 26 'Eye Walk off ttyOn CON 27 'debug text On ttyOff CON 28 'debug text Off Ew CON 29 'Eye walk, test and set paceTurn h0 CON 30 'reduce hurts to zero, otherwise frustration behaviour gets subsumed after next move 'Parameter cmnds - note no US sensor on Tom w CON 40 'Wait 1/10 secs in next byte a CON 41 'jump to Act in next byte s CON 42 'set speeds to next byte, $rp '$55 is max for servos to follow pulse 'from Pot(^15) works best with pacerollspeedratio =1 m CON 43 'set Roll and Step to next byte $rollby,stepby 'S03 max speed is 45.5us/frame @20ms/frame, max potspeed is 15 'rollby <$0-$F> delta roll from rollmin 'actualrollby =rollby +rollmin ie rollby=0 => rollC +-rollmin 'if rollby 7 '=>+-(7+15)*10us=*-220us '@ speed 5(10us)=50us '=>440/50*20ms=176ms/STEP & 9 frames 'stepby <$0-$F> '(in 30us units, 15=>450us so pace is 2*450=900us) 'pacepulse =+-(3*stepby)+paceC 'ie 150+-45 => 105 - 195 (10us) => 1050 - 1950us 'if stepby 10 ($A) '=>+-300us '@ speed 5(10us)=50us '=>600/50*20ms=240ms/step & 12 frames 'so at speed=5 rollby=7 stepby=10 one step takes 240+176=416ms 'rolltime/steptime =176/240 =0.73 d CON 44 'set default Act to next byte 'usa CON 45 'set USaware range(<=) to next low.nib resolution 2"=>5cm, max 15=>30" 'usIFL CON 46 'US if Less <param> <Do> if USRange<USActionRange jump to Act in next byte 'usIFLm CON 47 'US if Less mem <D>>; if USRange<USlast jump to Act in next byte tty CON 48 'debug text starting in next byte and ending with ¬ T CON 49 'Talk #msg in next byte S_test CON "t" Sname CON "n" Sforward CON "f" Sback CON "b" Sright CON "r" Sleft CON "l" Sobstacle CON "o" '"s" - Hello I am the BASIC Stamp 'Hurt rule cmnds IFhLR CON 50 'test ToesRL IFhR CON 51 'test Toe R IFhL CON 52 'test Toe L '---------------- Acts -- if ended with 'z' are Activities ----------------- ' if not ended with 'z' continue with next Act 'end lists with Z otherwise starts doing next Act! 'Acts can have any legal variable name. defaultAct DATA A1 'default Act name done after 'Z', overwritten at init: 'first Act DATA must be @>0 since Z=> pD=0 means nothing to do Ainit DATA Vt,Vb,V,m,$A6,ttyOn,H,T,Sname,V,V,Z 'initialisation Act done after PowerOn or Reset 'ABack DATA B,Z A15 DATA V,Z 'just so we know the switch is on -1 not 0 !!! 'A14 shows asymetric nature of servos, set speed to 1 and walking very even ' set spped above and Rroll is faster than Lroll and completes roll whereas Left doesn't A14 DATA F,w,10,F,w,10,F,V,w,10,B,w,10,B,w,10,B,w,10,Z A13 DATA 'H,w,2,F,F,H,w,1,B,B,Z A12 DATA 'F,F,R,R,H,w,2,L,L,B,B,B,H,Z 'roughly F & B about same spot A11 DATA StbOn,F,F,F,R,R,R,B,B,B,L,L,L,Su,Z 'A10 DATA s,$66,F,Su,a,A3,Z A10 DATA 'F,F,F,F,F,F,F,B,B,B,B,B,B,B,Z A9 DATA 'L,L,R,R,a,A4,Z 'A8 DATA R,R,R,R,R,L,L,L,L,L,Z A8 DATA A7 DATA A6 DATA Wdark,a,A4 'US dark walk, jump to A4 A5 DATA Wlight 'US light walk, drop to A4 A4 DATA Vb,tty,"A4¬",z 'StbOn,m,$58 'US walk, setup no US on Tom ' USwalk DATA Ew,F,Su,usIFL,4,USavoid,a,USwalk A3 DATA Wdark,a,A1 'dark walk, jump to A1 A2 DATA Wlight 'light walk, drop to A1 A1 DATA StbOn 'SensorT Walk, toe bump on A0 DATA m,$A6 'set Roll and Step 'Walk DATA Ew,F,Su,a,Walk 'a' preserves behaviours Walk DATA F,Su,a,Walk ''a' preserves behaviours DATA @256 DATA "B" 'first Act DATA must be @>0 since Z=> pD=0 means nothing to do '---------------- frustration behavioural Acts ------- 'inhibit sensors until Toe moved back a bit, otherwise just loops to here Af1 DATA tty,"Af1R¬",h0,StbOff,V,V,V,B,StbOn,mT,mT,Z 'if (hurtsR+hurtsL)>hurting Af2 DATA tty,"Af2L¬",h0,StbOff,V,V,V,V,V,B,StbOn,B,mT,mT,mT,Z 'if (hurtsR+hurtsL)>hurtalot '---------------- bump behavioural Acts ------------- 'if toeX bumped then hurtsX += ahurt 'inhibit sensors until Toe moved back a bit, otherwise just loops to here AbR DATA tty,"AbR¬",StbOff,V,Sd,Br,StbOn,L,L,Z 'if hurtsR>hurtalittle AbL DATA tty,"AbL¬",StbOff,V,V,Sd,Bl,StbOn,R,R,Z 'if hurtsL>hurtalittle '---------------- US behavioural Acts ------------- 'USTfScan DATA tty,"`USTfScan¬" ' DATA V,fT,usIFLm,USoTscan,usIFL,4,USmT,Z 'TurnScan, using Tf means centre doesn't move (much) 'USoTscan DATA tty,"`USoTscan¬" ' 'DATA V,V,oT,bk,mT,mT,usIFL,4,USmT,Z 'OtherTurnScan bk only used for skid turns ' DATA V,V,oT,mT,mT,usIFL,4,USmT,Z 'OtherTurnScan 'USmT DATA tty,"`USmT¬" ' 'DATA V,V,V,bk,mT,mT,usIFL,4,USmT,Z bk only used for skid turns ' DATA V,V,V,mT,mT,usIFL,4,USmT,Z 'USslow DATA Sd,Z 'USback DATA B,fT 'and test again '---------------- US behavioural Rules ------------- 'Behaviour variable thresholds and BehaviouralAction 'US: ActionRange,Act 'USavoid DATA V,tty,"USavoid¬" ' DATA frustUp 'UScaution DATA tty,"caut¬",usIFL,3,USslow 'UStooclose DATA tty,"close¬",usIFL,2,USback 'Joe 3 'USinway DATA tty,"way¬",usIFL,4,USTfScan ' DATA Z '---------------- Tactile behavioural rules --- HurtRules DATA tty,"Hrules¬" frus2 DATA IFhLR,hurtingalot,Af2 'L+R >hurtingalot frus1 DATA IFhLR,hurting,Af1 'L+R >hurting hurtR DATA IFhR,hurtalittle,AbR 'R >ahurt hurtL DATA IFhL,hurtalittle,AbL,Z 'L >ahurt '---------------------------------------------- Bend DATA Z 'end marker to avoid doing the program! '----------------------------------------------