BRAT JR. Walking Program

Does anyone have a BRAT JR. walking program? I’m doing a science fair project and I need just a simple walk program that I can compile onto the Basic Atom. I don’t have the SSC-32 scequencer, so I need something that will work for just the atom. Thanks! :smiley:

When you go under the tutorial for the SSC-32 sequencer, it has a zip file in it with a walking project. Is there any way this can be transferred into the basic language for programming?? :confused:

Where is the ZIP? What files are in the ZIP? If it is a sequence that can be loaded into SEQ, then when SEQ runs, you can capture the output (made to be sent to an SSC32) with a terminal emulator, and then copy paste into a BASIC program. You’ll have to add a few characters to make it a proper BASIC serial command. Take a look at the “canned” moves for the hexapod 'bot, like “attack”.

The BASIC program just outputs the strings (again to the SSC32).

With a simple sequence for a gait cycle, you can send it repeatedly, and you’ve got a walk! I did this for my biped Loki (but in C, not BASIC).

But I haven’t found the ZIP you’re talking about!

Alan KM6VV

Here’s the tutorial where the zip file’s located:

lynxmotion.com/images/html/build106.htm

Go to step 14 and it will say to download the zip file. It has projects for the BRAT, which I need in BASIC.

P.S.- I don’t currently have the sequencer or SSC-32, so maybe if someone else is looking else to modify these programs, they can post there code for others to use. :wink:

Sorry, I have the BRAT not the Brat JR. If you had the Atom Pro, it would probably be not difficult to modify the walking code to make it work on JR. However you might try converting the TV brat code up under the BIPED forum to run on JR. Probably not the whole thing, but simply the movement function and cooresponding calls and the like. The problem is that it relies on HSERVO and I don’t know how well this would work on the ATOM with just the servo command. But you might give it a try.

Good Luck

OK, got the ZIP.

I “captured” these 6 steps with SEQ from “biped6-turn”:

#0P1500#1P1112#2P842#16P1501#18P1627T1000
#1P1889#2P1577#17P1112#18P732T1000
#0P1344#1P1890#2P1578#16P1722#17P1112#18P731T1000
#0P1356#1P1890#2P1578#16P1723#17P1919#18P1577T1000
#0P1722#16P1367#17P1889#18P1577T1000
#0P1767#1P1113#2P732#16P1358#17P1889T1000

You might be able to get it directly from the CSV file, but that has not proved to be as easy.

This line from the Basic Atom Pro sample for 3DOF-C 'bot:

serout
p15,i38400,"#",MRHH,MRHH2,“P1800#”,MRHV,MRHV2,“P1700#”,MRK,MRK2,“P1700#”,
MLHH,MLHH2,“P1200#”,MLHV,MLHV2,“P1300#”,MLK,MLK2,“P1300T288”,13]

Make up the first string something like this (not using con, but can be directly copied from the stuff we copy paste):

serout p15, i38400, “#0P1500#1P1112#2P842#16P1501#18P1627T1000”,13]

then pause, and send the next string.

Your serout command might be a little different.

HTH

Alan KM6VV

isn’t the whole point of a science fair project to DIY? I can’t image why you would want source code for a BRAT jr walking gate, there are only 4 servos to control (3 at once). Sorry, not to haggle at you, but you would impress your judges and learn more by DIY.

I must say Joe is partially right. Better to “make it up” yourself.

SEQ would be a good tool to get your sequences figured out. I used SEQ at first, then added code to my 'bot (in C) to allow me to move the servos and save the locations (4 at a time) in EEPROM. The “walk” (a complete gait cycle) above can be repeated to get your 'bot to walk.

You might write code for your 'bot to receive commands from the com port. Then you can move each servo, as I have done, and save them as I did.

Alan KM6VV

Well I do speak from experience being involved in regional science fairs for the past four years and national for the past two years (hopefully this year). I highly reccommend DIY, the judges will be 2X more impressed even if its less proffessional or perfect.

I agree with Alan and Mike that for a science fair it would be much better to be DIY.

If I understand correctly his Brat Jr does not have an SSC-32 on it, but instead has the servos connected directly to the bot board and he needs to control them directly with the Atom basic. That is why I mentioned the TV brat code, that is up in the BIPED forum. The problem is that it relies on HSERVO. For example: here is an extract of the code that I did to help debug some problem of the recent beta IDEs. This code simply tried to take one step forward. It precalculated all of the math and simply called through to hservo:

[code]debug con 1
; Try TV Remote Brat taking one step forward with HSERVO. Nothing else in the program

;System variables
righthip con p15
rightknee con p14
rightankle con p13 ; was p9 but that is speaker
lefthip con p12
leftknee con p11
leftankle con p10

;Interrupt init
USE_HSERVO con 1
;HSERVO_GROUPS con 4
ENABLEHSERVO

; We simply want to emulate the gosub movement command for one step forward
; we will precalculate all of the speeds and the like
; if(command = 1 or command = 116) then ;(Button 2 or joystick up) Walk Forwards
; RA RK RH LA LK LH SPEED
; gosub movement -7.0, 20.0, 20.0, 7.0,-20.0,-20.0, 500.0]
; gosub movement 7.0, 20.0, 20.0, -7.0,-20.0,-20.0, 500.0]
; gosub movement 7.0,-20.0,-20.0, -7.0, 20.0, 20.0, 500.0]
; gosub movement -7.0,-20.0,-20.0, 7.0, 20.0, 20.0, 500.0]

;Movement: 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000 0.0000000000
gosub movement [0,0, 0,0, 0,0, 0,0, 0,0, 0,0]
pause 2000

;Movement: -7.0000000000 20.0000000000 20.0000000000 7.0000000000 -20.0000000000 -20.0000000000 500.0000000000
gosub movement -1166,46, 3331,133, 3331,133, -1166,46, 3331,133, 3331,133]

;Movement: 7.0000000000 20.0000000000 20.0000000000 -7.0000000000 -20.0000000000 -20.0000000000 500.0000000000
gosub movement [1166,93, 3331,0, 3331,0, 1166,93, 3331,0, 3331,0]

;Movement: 7.0000000000 -20.0000000000 -20.0000000000 -7.0000000000 20.0000000000 20.0000000000 500.0000000000
gosub movement [1166,0, -3331,266, -3331,266, 1166,0, -3331,266, -3331,266]

;Movement: -7.0000000000 -20.0000000000 -20.0000000000 7.0000000000 20.0000000000 20.0000000000 500.0000000000
gosub movement -1166,93, -3331,0, -3331,0, -1166,93, -3331,0, -3331,0]


pause 2000
gosub movement [0,0, 0,0, 0,0, 0,0, 0,0, 0,0]

loop
goto loop

;Should never need to edit anything below this line. Add user subroutines above this and below main.
lefthippos var sword
leftkneepos var sword
leftanklepos var sword
righthippos var sword
rightkneepos var sword
rightanklepos var sword
lhspeed var word
lkspeed var word
laspeed var word
rhspeed var word
rkspeed var word
raspeed var word
movement [rightanklepos,raspeed, rightkneepos,rkspeed, righthippos,rhspeed, leftanklepos,laspeed, leftkneepos, lkspeed,lefthippos,lhspeed]

#ifdef DEBUG
serout S_OUT, i2400, |
sdec (rightanklepos), “(”, dec raspeed, ") ",|
sdec (rightkneepos), “(”, dec rkspeed, ") " , |
sdec (righthippos), “(”, dec rhspeed, ") ", |
sdec (-leftanklepos), “(”, dec laspeed, ") ", |
sdec (-leftkneepos), “(”, dec lkspeed, “) “, |
sdec (-lefthippos),”(”, dec lhspeed, “)”, 13, 10]
#endif
hservo [lefthip\lefthippos\lhspeed, |
righthip\righthippos\rhspeed, |
leftknee\leftkneepos\lkspeed, |
rightknee\rightkneepos\rkspeed, |
leftankle\leftanklepos\laspeed, |
rightankle\rightanklepos\raspeed]

hservowait [lefthip,righthip,leftknee,rightknee,leftankle,rightankle]

return
[/code]
But of course the BRAT has six servos and the JR only has 4. So the actual movement function would be different. Alan has extracted the movement information from them the SEG info for the 4 servos.

So you might start by looking at both sets of information, and maybe write your equivlent of the movement function. It would probably rely on using the SERVO command from basic, which only controls one servo at a time. So start off calling servo for the end point for each of the servos for each step. Note: you will need to make sure that you convert the values to the appropriate range for the servo command.

This will probably not give you a totally satisfying movement, as for each step each of the servos want to move a different amount and if you want a more fluid movement, you may want to break up the sequence into smaller sequences such that you can get each servo to the end point at the same time. This is what the SSC-32 does for you and likewise HSERVO does on the Atom Pro. .
You could either hand coding this and change the six steps into may 20 or 30 steps or you could setup your movement function to calculate the differences programatically for the 4 servos and choose to make the appropriate smaller increments for each servo to get to the desired location for each sequence in the step.

I hope this gives you a good starting point.

Good Luck

Kurt