Legacy Forum: Preserving Nearly 20 Years of Community History - A Time Capsule of Discussions, Memories, and Shared Experiences.

BASIC intepreter for Robobuilder

Korean company maker of Robot kits and servos designed for of articulated robots. Re-incarnation of Megarobotics.
36 postsPage 1 of 31, 2, 3
36 postsPage 1 of 31, 2, 3

BASIC intepreter for Robobuilder

Post by l3v3rz » Sun Jun 20, 2010 10:49 pm

Post by l3v3rz
Sun Jun 20, 2010 10:49 pm

Basic Announcement (!)

I have written a functional BASIC interpreter running on the Robobuilder RBC unit. So for all those who would like to try programming - but are daunted by the complexity of writing in C - and yet want more than Action builder - please go here , download and try it out !!

Main page - http://code.google.com/p/robobuilderlib/

Wiki - http://code.google.com/p/robobuilderlib/wiki/Basic

Writing your first program couldn't be easier, after downloading the firmware and uploading on to the robot using the RBC upgrade tool, connect a terminal program such as hyper terminal or putty and reset the power.

Please note: Basic programs are stored in flash - it will overwrite any action or motion scripts you have created. If / when you revert to standard firmware you will need to reload them.

It is possible (hopefully unlikely) that if the firmware goes wildly wrong it could overwrite your serial number and/or zero positions - these are recoverable but with some effort ! (The software even allows you to view and modify these settings)

The firmware has 19 built-in motions to try out, including football kicks. Full access to all sensor such as PSD, accelerometer and IR port. Its fast enough to program in continuous walking and auto balance - both demo program I will be sharing in the future. The wiki has loads of demo / test program I have written and tried out.

Here's an example session:

Code: Select all
Basic v=$Revision: 408 $
Commands: i r l c z q
: i
Enter Program '.' to Finish
> print "hello world"
hello world
> 10 print "hello world"
> .
1 lines entered, [25/3072] Bytes
: l
List Program
10 PRINT "hello world"
: i
Enter Program '.' to Finish
> 20 goto 10
> .
1 lines entered, [28/3072] Bytes
: l
List Program
10 PRINT "hello"
20 GOTO 10
: c
Clear Program
: l
List Program


If you find bugs - please report them on the Google site.

There is also a Basic client program that make handling larger programs easier and simply to download to the Bot. Again see wiki for details.

Finally - this is not commercial software and you use at your own risk :)
Basic Announcement (!)

I have written a functional BASIC interpreter running on the Robobuilder RBC unit. So for all those who would like to try programming - but are daunted by the complexity of writing in C - and yet want more than Action builder - please go here , download and try it out !!

Main page - http://code.google.com/p/robobuilderlib/

Wiki - http://code.google.com/p/robobuilderlib/wiki/Basic

Writing your first program couldn't be easier, after downloading the firmware and uploading on to the robot using the RBC upgrade tool, connect a terminal program such as hyper terminal or putty and reset the power.

Please note: Basic programs are stored in flash - it will overwrite any action or motion scripts you have created. If / when you revert to standard firmware you will need to reload them.

It is possible (hopefully unlikely) that if the firmware goes wildly wrong it could overwrite your serial number and/or zero positions - these are recoverable but with some effort ! (The software even allows you to view and modify these settings)

The firmware has 19 built-in motions to try out, including football kicks. Full access to all sensor such as PSD, accelerometer and IR port. Its fast enough to program in continuous walking and auto balance - both demo program I will be sharing in the future. The wiki has loads of demo / test program I have written and tried out.

Here's an example session:

Code: Select all
Basic v=$Revision: 408 $
Commands: i r l c z q
: i
Enter Program '.' to Finish
> print "hello world"
hello world
> 10 print "hello world"
> .
1 lines entered, [25/3072] Bytes
: l
List Program
10 PRINT "hello world"
: i
Enter Program '.' to Finish
> 20 goto 10
> .
1 lines entered, [28/3072] Bytes
: l
List Program
10 PRINT "hello"
20 GOTO 10
: c
Clear Program
: l
List Program


If you find bugs - please report them on the Google site.

There is also a Basic client program that make handling larger programs easier and simply to download to the Bot. Again see wiki for details.

Finally - this is not commercial software and you use at your own risk :)
Last edited by l3v3rz on Tue Jan 24, 2012 8:44 pm, edited 5 times in total.
l3v3rz
Savvy Roboteer
Savvy Roboteer
Posts: 473
Joined: Fri Jul 18, 2008 2:34 pm

Post by AlexanderHWUK » Tue Jun 22, 2010 2:18 pm

Post by AlexanderHWUK
Tue Jun 22, 2010 2:18 pm

Man that is awesome! I remember when I used to program with GWBasic (I still love it!).

L3v3rz, you're the man :wink:

Alex
Man that is awesome! I remember when I used to program with GWBasic (I still love it!).

L3v3rz, you're the man :wink:

Alex
AlexanderHWUK
Savvy Roboteer
Savvy Roboteer
Posts: 27
Joined: Tue Mar 02, 2010 4:54 pm

Post by l3v3rz » Tue Jun 22, 2010 7:17 pm

Post by l3v3rz
Tue Jun 22, 2010 7:17 pm

Thanks Alex.

Here's an example of how to program a continuous forward walking:

Code: Select all
5 STAND 16
10 PRINT "press any key start"
15 LET K=$kbd
20 LET A=25
30 PRINT "R";
35 MOVE @{16,123,156,212,80,108,126,73,40,150,141,68,44,40,138,208,195},1,A
40 MOVE @{16,130,165,201,81,115,134,81,31,147,149,72,44,40,145,209,201},1,A
45 MOVE @{16,132,171,197,83,117,137,86,28,148,152,78,43,41,154,209,206},1,A
50 MOVE @{16,132,175,195,87,117,139,91,27,152,154,87,43,43,164,209,211},1,A
55 MOVE @{16,132,178,197,91,117,137,95,28,157,152,97,43,48,172,209,213},1,A
60 MOVE @{16,130,179,201,95,115,134,96,31,161,149,105,43,53,179,210,214},1,A
65 MOVE @{16,127,178,206,98,112,130,95,35,166,145,111,42,57,182,210,214},1,A
70 MOVE @{16,124,175,212,100,109,127,92,40,170,142,113,42,59,183,210,214},1,A
75 PRINT "L";
80 MOVE @{16,124,175,212,100,109,127,92,40,170,142,113,42,59,183,210,214},1,A
85 MOVE @{16,120,172,217,102,105,123,88,46,170,138,111,42,57,182,210,214},1,A
90 MOVE @{16,116,167,221,103,101,120,83,51,169,135,106,43,53,179,210,214},1,A
95 MOVE @{16,113,162,224,102,98,118,77,55,167,133,97,43,48,173,209,213},1,A
100 MOVE @{16,111,157,225,98,96,118,73,57,163,133,87,43,43,164,209,211},1,A
105 MOVE @{16,113,153,224,93,98,118,70,55,159,133,79,43,41,154,209,206},1,A
110 MOVE @{16,116,152,221,89,101,120,69,51,155,135,72,44,40,146,209,201},1,A
115 MOVE @{16,120,153,217,84,105,123,70,46,152,138,69,44,40,140,208,197},1,A
120 MOVE @{16,123,156,212,80,108,126,73,40,150,141,68,44,40,138,208,195},1,A
125 GOTO 30


Line 5 STAND - instructs the robot to take up basic posture. line 15 causes the program to wait for a key press - you could alternatively make it wait for IR remote by switch $KBD for $IR.

Line 35 move @{...},1,A moves servos from their current position to the new position, as specified in the list @{...}. First number is length of list i.e. 16. There are two other parameters, the '1' is the number of increments to take and the 'A' is a variable containing 25, the total length of time i.e. 25ms. You can vary A or switch for a constant etc...

Line 125 GOTO will cause the program to loop for ever (or until 'Esc' is pressed on keyboard). Line 25 and 70 produce 'RLRL... etc on the serial port.

To run type 'r'. in command mode ':' prompt or the red square on IR. The program is in flash so its still there even after being turned off. Just turn back on and press the red button ! (you'll need to switch the KBD for IR first - or it after standing it will wait for keyboard input)

Lots of mods to expand this are possible. The program could check for $PSD value or check, or see if its fallen over, by testing the accelerometer $X / $Y or $Z. You can vary the speed by changing the value 'A' -etc ...



l3v3rz
Thanks Alex.

Here's an example of how to program a continuous forward walking:

Code: Select all
5 STAND 16
10 PRINT "press any key start"
15 LET K=$kbd
20 LET A=25
30 PRINT "R";
35 MOVE @{16,123,156,212,80,108,126,73,40,150,141,68,44,40,138,208,195},1,A
40 MOVE @{16,130,165,201,81,115,134,81,31,147,149,72,44,40,145,209,201},1,A
45 MOVE @{16,132,171,197,83,117,137,86,28,148,152,78,43,41,154,209,206},1,A
50 MOVE @{16,132,175,195,87,117,139,91,27,152,154,87,43,43,164,209,211},1,A
55 MOVE @{16,132,178,197,91,117,137,95,28,157,152,97,43,48,172,209,213},1,A
60 MOVE @{16,130,179,201,95,115,134,96,31,161,149,105,43,53,179,210,214},1,A
65 MOVE @{16,127,178,206,98,112,130,95,35,166,145,111,42,57,182,210,214},1,A
70 MOVE @{16,124,175,212,100,109,127,92,40,170,142,113,42,59,183,210,214},1,A
75 PRINT "L";
80 MOVE @{16,124,175,212,100,109,127,92,40,170,142,113,42,59,183,210,214},1,A
85 MOVE @{16,120,172,217,102,105,123,88,46,170,138,111,42,57,182,210,214},1,A
90 MOVE @{16,116,167,221,103,101,120,83,51,169,135,106,43,53,179,210,214},1,A
95 MOVE @{16,113,162,224,102,98,118,77,55,167,133,97,43,48,173,209,213},1,A
100 MOVE @{16,111,157,225,98,96,118,73,57,163,133,87,43,43,164,209,211},1,A
105 MOVE @{16,113,153,224,93,98,118,70,55,159,133,79,43,41,154,209,206},1,A
110 MOVE @{16,116,152,221,89,101,120,69,51,155,135,72,44,40,146,209,201},1,A
115 MOVE @{16,120,153,217,84,105,123,70,46,152,138,69,44,40,140,208,197},1,A
120 MOVE @{16,123,156,212,80,108,126,73,40,150,141,68,44,40,138,208,195},1,A
125 GOTO 30


Line 5 STAND - instructs the robot to take up basic posture. line 15 causes the program to wait for a key press - you could alternatively make it wait for IR remote by switch $KBD for $IR.

Line 35 move @{...},1,A moves servos from their current position to the new position, as specified in the list @{...}. First number is length of list i.e. 16. There are two other parameters, the '1' is the number of increments to take and the 'A' is a variable containing 25, the total length of time i.e. 25ms. You can vary A or switch for a constant etc...

Line 125 GOTO will cause the program to loop for ever (or until 'Esc' is pressed on keyboard). Line 25 and 70 produce 'RLRL... etc on the serial port.

To run type 'r'. in command mode ':' prompt or the red square on IR. The program is in flash so its still there even after being turned off. Just turn back on and press the red button ! (you'll need to switch the KBD for IR first - or it after standing it will wait for keyboard input)

Lots of mods to expand this are possible. The program could check for $PSD value or check, or see if its fallen over, by testing the accelerometer $X / $Y or $Z. You can vary the speed by changing the value 'A' -etc ...



l3v3rz
l3v3rz
Savvy Roboteer
Savvy Roboteer
Posts: 473
Joined: Fri Jul 18, 2008 2:34 pm

Post by limor » Tue Jun 22, 2010 8:38 pm

Post by limor
Tue Jun 22, 2010 8:38 pm

amazing
amazing
limor
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1845
Joined: Mon Oct 11, 2004 1:00 am
Location: London, UK

Post by l3v3rz » Wed Jun 23, 2010 6:38 pm

Post by l3v3rz
Wed Jun 23, 2010 6:38 pm

Thanks Limor.

Code is now at R216. I built a windows executable version basic.exe - so you can try it without even having a robot or RBC unit - see website for details.

Here's a new example of simple auto-balance:

Code: Select all
10 STAND 16
20 Print "Press any key"
30 if $kir<0 then 30
40 list m=7,-4,-2,-1,0,1,2,4
50 Let d=$find($z, @{7,-15,-10,-5,0,5,10,15}
60 let o=@m[d]
70 wait 10
80 print $z;"-";d;"-";o
90 servo 10=$servo(10)+o
100 servo 13=$servo(13)-o
110 wait 10
120 if $kir<0 then 40


Line 10 causes the robot takes up Basic pose. Line 30 make it wait until keyboard or IR input. Line 40 set up list of offset values. Lines 50 maps the output of the z axis of the accelerometer ($z) to a range using the $find function. Line 60 then translates that into a displacement to apply to the servo. In lines 90 and 100 it updates the current position of the servo $servo(x) with the offset o. Line 120 cause the program to loop until either keyboard or IR remote is pressed ($kir) is received. If -1 it means no input.
Thanks Limor.

Code is now at R216. I built a windows executable version basic.exe - so you can try it without even having a robot or RBC unit - see website for details.

Here's a new example of simple auto-balance:

Code: Select all
10 STAND 16
20 Print "Press any key"
30 if $kir<0 then 30
40 list m=7,-4,-2,-1,0,1,2,4
50 Let d=$find($z, @{7,-15,-10,-5,0,5,10,15}
60 let o=@m[d]
70 wait 10
80 print $z;"-";d;"-";o
90 servo 10=$servo(10)+o
100 servo 13=$servo(13)-o
110 wait 10
120 if $kir<0 then 40


Line 10 causes the robot takes up Basic pose. Line 30 make it wait until keyboard or IR input. Line 40 set up list of offset values. Lines 50 maps the output of the z axis of the accelerometer ($z) to a range using the $find function. Line 60 then translates that into a displacement to apply to the servo. In lines 90 and 100 it updates the current position of the servo $servo(x) with the offset o. Line 120 cause the program to loop until either keyboard or IR remote is pressed ($kir) is received. If -1 it means no input.
l3v3rz
Savvy Roboteer
Savvy Roboteer
Posts: 473
Joined: Fri Jul 18, 2008 2:34 pm

Post by l3v3rz » Tue Aug 31, 2010 7:25 pm

Post by l3v3rz
Tue Aug 31, 2010 7:25 pm

New version of Basic now available - it now supports audio sampling and FFT

Current version of Basic manual now V2.2

For details:
http://code.google.com/p/robobuilderlib/
New version of Basic now available - it now supports audio sampling and FFT

Current version of Basic manual now V2.2

For details:
http://code.google.com/p/robobuilderlib/
Last edited by l3v3rz on Sat Jan 14, 2012 1:35 pm, edited 1 time in total.
l3v3rz
Savvy Roboteer
Savvy Roboteer
Posts: 473
Joined: Fri Jul 18, 2008 2:34 pm

Post by l3v3rz » Sun Mar 06, 2011 4:44 pm

Post by l3v3rz
Sun Mar 06, 2011 4:44 pm

In one of the examples above I show continuous walking by sending out a sequence of predefined servo moves. But its possible to generate a walking gate mathematically using sine waves. The position of each servo can be defined as

Code: Select all
Position = Offset + Amplitude * SIN (angle + phase)


As the angle goes through 360 degrees the servo position will vary about the offset by +/- the amplitude during each walking cycle.

To program this in BASIC needs the function $SIN(angle) will returns a sine value between -32768 and +32768 for angle values between 0 and 255. So to use the I create the following code:

Code: Select all
FOR X=0 to 15
   LET P = B + (A*$SIN((X + C)*16)/32)/1024
NEXT X

    P = Position
    X = Angle (0->15)
    B = offset
    A = amplitude
    C = phase


To enable each servo to have a different value of A, B and C I put those values into three indexed lists as follows

Code: Select all
LIST A=16, 10, 13, 15,11, 10, 10,13,15, 11, 10,22, 1, 9, 22,  1,  9
LIST B=16,122,166,210,92,107,129,83,42,159,144,91,43,50,161,209,205
LIST C=16,  0,  2,  8, 5,  0, 15, 2, 8,  6, 15, 5,11, 5,  5,  5,  5


A contains a 16 element list containing the amplitudes of the sine waves. To access a list element use @A[Y] where Y is a value between 0 and 15. @A[0] will point to the value 10 (not 16 which is just the length and not stored).

So putting this all together the following code will generate a continuous walking motion,:

Code: Select all
5 LIST A=16, 10, 13, 15,11, 10, 10,13,15, 11, 10,22, 1, 9, 22,  1,  9
10 LIST B=16,122,166,210,92,107,129,83,42,159,144,91,43,50,161,209,205
15 LIST C=16,  0,  2,  8, 5,  0, 15, 2, 8,  6, 15, 5,11, 5,  5,  5,  5
20 FOR X=0 TO 15
25 FOR Y=0 TO 15
30 LET P=@B[Y]+@A[Y]*$SIN((X+@C[y])*16)/32768
50 PRINT P;":";
55 SERVO y=p
60 NEXT Y
65 PRINT ""
70 NEXT X
75 IF $KIR<0 THEN 20


The lines 30 performs calculation of sine wave. since Build 408 no longer necessary to break into into simpler steps. The calculation is sent to the servo in line 55. The program is fast enough to run a smooth walking gate. It will continue to run until it detects IR or keyboard press (or you turn it off!). The Speed can be improved by replacing LIST with DATA statements
In one of the examples above I show continuous walking by sending out a sequence of predefined servo moves. But its possible to generate a walking gate mathematically using sine waves. The position of each servo can be defined as

Code: Select all
Position = Offset + Amplitude * SIN (angle + phase)


As the angle goes through 360 degrees the servo position will vary about the offset by +/- the amplitude during each walking cycle.

To program this in BASIC needs the function $SIN(angle) will returns a sine value between -32768 and +32768 for angle values between 0 and 255. So to use the I create the following code:

Code: Select all
FOR X=0 to 15
   LET P = B + (A*$SIN((X + C)*16)/32)/1024
NEXT X

    P = Position
    X = Angle (0->15)
    B = offset
    A = amplitude
    C = phase


To enable each servo to have a different value of A, B and C I put those values into three indexed lists as follows

Code: Select all
LIST A=16, 10, 13, 15,11, 10, 10,13,15, 11, 10,22, 1, 9, 22,  1,  9
LIST B=16,122,166,210,92,107,129,83,42,159,144,91,43,50,161,209,205
LIST C=16,  0,  2,  8, 5,  0, 15, 2, 8,  6, 15, 5,11, 5,  5,  5,  5


A contains a 16 element list containing the amplitudes of the sine waves. To access a list element use @A[Y] where Y is a value between 0 and 15. @A[0] will point to the value 10 (not 16 which is just the length and not stored).

So putting this all together the following code will generate a continuous walking motion,:

Code: Select all
5 LIST A=16, 10, 13, 15,11, 10, 10,13,15, 11, 10,22, 1, 9, 22,  1,  9
10 LIST B=16,122,166,210,92,107,129,83,42,159,144,91,43,50,161,209,205
15 LIST C=16,  0,  2,  8, 5,  0, 15, 2, 8,  6, 15, 5,11, 5,  5,  5,  5
20 FOR X=0 TO 15
25 FOR Y=0 TO 15
30 LET P=@B[Y]+@A[Y]*$SIN((X+@C[y])*16)/32768
50 PRINT P;":";
55 SERVO y=p
60 NEXT Y
65 PRINT ""
70 NEXT X
75 IF $KIR<0 THEN 20


The lines 30 performs calculation of sine wave. since Build 408 no longer necessary to break into into simpler steps. The calculation is sent to the servo in line 55. The program is fast enough to run a smooth walking gate. It will continue to run until it detects IR or keyboard press (or you turn it off!). The Speed can be improved by replacing LIST with DATA statements
Last edited by l3v3rz on Tue Jan 24, 2012 8:47 pm, edited 1 time in total.
l3v3rz
Savvy Roboteer
Savvy Roboteer
Posts: 473
Joined: Fri Jul 18, 2008 2:34 pm

Post by l3v3rz » Sat Aug 13, 2011 9:08 pm

Post by l3v3rz
Sat Aug 13, 2011 9:08 pm

Here a demo of Basic running, on a standard Robobuilder, the "dynamic distance sensor" code - see http://code.google.com/p/robobuilderlib/wiki/BasicDemos This has also been modified to output/print the value of the PSD to a terminal (see example 10 for details).

The demo also shows my mobile phone running the RoboAndroid app in "Basic mode" which acts as a terminal so I can see the output being fed over bluetooth.

phpBB [media]


If you don't have a mobile phone then you can view the output by connecting the serial cable and using a terminal emulator like putty.

Goto to project page for more download ans other details
Here a demo of Basic running, on a standard Robobuilder, the "dynamic distance sensor" code - see http://code.google.com/p/robobuilderlib/wiki/BasicDemos This has also been modified to output/print the value of the PSD to a terminal (see example 10 for details).

The demo also shows my mobile phone running the RoboAndroid app in "Basic mode" which acts as a terminal so I can see the output being fed over bluetooth.

phpBB [media]


If you don't have a mobile phone then you can view the output by connecting the serial cable and using a terminal emulator like putty.

Goto to project page for more download ans other details
Last edited by l3v3rz on Sat Jan 14, 2012 1:36 pm, edited 1 time in total.
l3v3rz
Savvy Roboteer
Savvy Roboteer
Posts: 473
Joined: Fri Jul 18, 2008 2:34 pm

Post by l3v3rz » Wed Aug 24, 2011 8:58 am

Post by l3v3rz
Wed Aug 24, 2011 8:58 am

Hers a video showing a couple of demos. In the first part of the video it show "Mirror Moves" - any changes to the left arm are mirror on the right arm. It then shows using the remote to record a some positions and play them back. In the second half of the video is "Continuous walking". This is using sine waves to generate the gate. It also uses the distance sensor to switch to a reverse gate when it comes to close to an object (like a wall or my hand). In both demos the robot is entirely controlled by the BASIC running on the RBC Output of the program is displayed on the phone using roboandroid app in "Basic mode".

phpBB [media]
Hers a video showing a couple of demos. In the first part of the video it show "Mirror Moves" - any changes to the left arm are mirror on the right arm. It then shows using the remote to record a some positions and play them back. In the second half of the video is "Continuous walking". This is using sine waves to generate the gate. It also uses the distance sensor to switch to a reverse gate when it comes to close to an object (like a wall or my hand). In both demos the robot is entirely controlled by the BASIC running on the RBC Output of the program is displayed on the phone using roboandroid app in "Basic mode".

phpBB [media]
l3v3rz
Savvy Roboteer
Savvy Roboteer
Posts: 473
Joined: Fri Jul 18, 2008 2:34 pm

Post by Joe » Mon Oct 24, 2011 1:51 pm

Post by Joe
Mon Oct 24, 2011 1:51 pm

This looks really cool! I have to confess I was a bit skeptical about the utility of the BASIC stuff way back when. But then I got stuck under something heavy for a while, and I'm just now getting back into the hobby... and what you've done looks amazing!

I expect to start testing it out this week, and I'm sure I'll be peppering you with questions. I just have one to start with for now:

When the docs say "scans the keyboard"... what keyboard? Does this really mean the serial port? But a serial port doesn't really have a state; it only sends a byte at a time. So how would I actually use that to, say, walk forward continuously while the up-arrow key (on my laptop?) is pressed? Or are we talking about hooking up a real Bluetooth keyboard?

Confused but grateful,
- Joe
This looks really cool! I have to confess I was a bit skeptical about the utility of the BASIC stuff way back when. But then I got stuck under something heavy for a while, and I'm just now getting back into the hobby... and what you've done looks amazing!

I expect to start testing it out this week, and I'm sure I'll be peppering you with questions. I just have one to start with for now:

When the docs say "scans the keyboard"... what keyboard? Does this really mean the serial port? But a serial port doesn't really have a state; it only sends a byte at a time. So how would I actually use that to, say, walk forward continuously while the up-arrow key (on my laptop?) is pressed? Or are we talking about hooking up a real Bluetooth keyboard?

Confused but grateful,
- Joe
Joe
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 204
Joined: Tue Sep 05, 2006 1:00 am

Post by l3v3rz » Mon Oct 24, 2011 3:44 pm

Post by l3v3rz
Mon Oct 24, 2011 3:44 pm

Yes you're right "scans keyboard" is inaaccurate - it scan serial input for input character. since BT and wired connections both appear on same port it will see either (or both). In fact in the vids you can see I/O running of BT on to the android phone. When I develop I usually just use a lead from my desktop.

Once the byte is read subsequent reads return -1 and the byte is sent only when the key is released (I think) so it doesn't know that its pressed. To achieve similar to what you want I use one key to start walking and then a second key to stop walking. Incidentally IR input also appears as a byte (if using $KIR) so I check for either a 'q' or a 7 as my stop condition. Alternatively (see code in above example) you can walk until any key is pressed (IR or $KBD) by simply looping while $KIR<0 - see line 75

Whilst BASIC ain't the most powerful language I have recently been writing some genetic algorithms for balance and a simple 3 neuron neural network all in BASIC which I will share in the near future.

If you do find BASIC to basic - there's always octave - see my other post for a plugin module. Looking forward to next weeks mlclass on neural networks.

cheers
Yes you're right "scans keyboard" is inaaccurate - it scan serial input for input character. since BT and wired connections both appear on same port it will see either (or both). In fact in the vids you can see I/O running of BT on to the android phone. When I develop I usually just use a lead from my desktop.

Once the byte is read subsequent reads return -1 and the byte is sent only when the key is released (I think) so it doesn't know that its pressed. To achieve similar to what you want I use one key to start walking and then a second key to stop walking. Incidentally IR input also appears as a byte (if using $KIR) so I check for either a 'q' or a 7 as my stop condition. Alternatively (see code in above example) you can walk until any key is pressed (IR or $KBD) by simply looping while $KIR<0 - see line 75

Whilst BASIC ain't the most powerful language I have recently been writing some genetic algorithms for balance and a simple 3 neuron neural network all in BASIC which I will share in the near future.

If you do find BASIC to basic - there's always octave - see my other post for a plugin module. Looking forward to next weeks mlclass on neural networks.

cheers
l3v3rz
Savvy Roboteer
Savvy Roboteer
Posts: 473
Joined: Fri Jul 18, 2008 2:34 pm

Post by Joe » Mon Oct 24, 2011 7:11 pm

Post by Joe
Mon Oct 24, 2011 7:11 pm

OK, that makes sense. We should talk at some point about building in a more sophisticated control scheme; with that, I think this could be used for serious Robo-One style competitions. But that can wait a bit.

My biggest complaint so far: & and | for "and" and "or"? Really? :) This is BASIC, let's embrace it and spell out these keywords. (I assume all keywords get tokenized and only take up a byte or so of memory anyway... is that true?)

Speaking of memory: how big a program can you fit with this, before you start running out of room?

Thanks again,
- Joe
OK, that makes sense. We should talk at some point about building in a more sophisticated control scheme; with that, I think this could be used for serious Robo-One style competitions. But that can wait a bit.

My biggest complaint so far: & and | for "and" and "or"? Really? :) This is BASIC, let's embrace it and spell out these keywords. (I assume all keywords get tokenized and only take up a byte or so of memory anyway... is that true?)

Speaking of memory: how big a program can you fit with this, before you start running out of room?

Thanks again,
- Joe
Joe
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 204
Joined: Tue Sep 05, 2006 1:00 am

Post by l3v3rz » Mon Oct 24, 2011 8:08 pm

Post by l3v3rz
Mon Oct 24, 2011 8:08 pm

I assume all keywords get tokenized

Only LHS (FOR - NEXT etc) the problem is the input tokeniser is also in the firmware so its pretty simple. and has to provide edit. Having an external tokeniser only would make life easier, but I like having it for immediate mode. (if you type a line in without a line number it executes straight away.

Speaking of memory: how big a program can you fit with this, before you start running out of room?

An average line is around 16 bytes and I reserve 3072 bytes from flash for program so - approximately 190 lines of code.

The main problems I see are more stack overflows etc. as it runs of memory, so for instance expressions with >3 levels of nesting etc ... I'd treat it more as a prototyping environment and when you're happy then translate into C. In fact it might be possible to build a simple basic compiler based on the interpreter generating C which would then feed into AVR GCC.

If you interesting how it works - the entire basic interpreter code is in one file basic.c (except for line editing in edit.c) - look in the source tree.

Have fun.
I assume all keywords get tokenized

Only LHS (FOR - NEXT etc) the problem is the input tokeniser is also in the firmware so its pretty simple. and has to provide edit. Having an external tokeniser only would make life easier, but I like having it for immediate mode. (if you type a line in without a line number it executes straight away.

Speaking of memory: how big a program can you fit with this, before you start running out of room?

An average line is around 16 bytes and I reserve 3072 bytes from flash for program so - approximately 190 lines of code.

The main problems I see are more stack overflows etc. as it runs of memory, so for instance expressions with >3 levels of nesting etc ... I'd treat it more as a prototyping environment and when you're happy then translate into C. In fact it might be possible to build a simple basic compiler based on the interpreter generating C which would then feed into AVR GCC.

If you interesting how it works - the entire basic interpreter code is in one file basic.c (except for line editing in edit.c) - look in the source tree.

Have fun.
l3v3rz
Savvy Roboteer
Savvy Roboteer
Posts: 473
Joined: Fri Jul 18, 2008 2:34 pm

Post by l3v3rz » Wed Nov 02, 2011 2:40 pm

Post by l3v3rz
Wed Nov 02, 2011 2:40 pm

Latest version of firmware (v375) now uploaded. Also a linux version that works via DCMP also uploaded (same build).

This adds ability to have offsets applied to STAND command Also a lot of new stuff since v336. - check wiki for details.

Note this won't work with the old BasicClient.exe - a new Java based preprocessor is JBasic.jar under development to replace this
Latest version of firmware (v375) now uploaded. Also a linux version that works via DCMP also uploaded (same build).

This adds ability to have offsets applied to STAND command Also a lot of new stuff since v336. - check wiki for details.

Note this won't work with the old BasicClient.exe - a new Java based preprocessor is JBasic.jar under development to replace this
l3v3rz
Savvy Roboteer
Savvy Roboteer
Posts: 473
Joined: Fri Jul 18, 2008 2:34 pm

Post by ron » Wed Nov 30, 2011 5:45 am

Post by ron
Wed Nov 30, 2011 5:45 am

[quote="l3v3rz"]Thanks Limor.

Code is now at R216. I built a windows executable version basic.exe - so you can try it without even having a robot or RBC unit - see website for details.

Here's a new example of simple auto-balance:

Code: Select all
10 STAND 16
20 Print "Press any key"
30 if $kir<0 then 30
40 list m=7,-4,-2,-1,0,1,2,4
50 Let d=$find($z, @{7,-15,-10,-5,0,5,10,15}
60 let o=@m[d]
70 wait 10
80 print $z;"-";d;"-";o
90 servo 10=$servo(10)+o
100 servo 13=$servo(13)-o
110 wait 10
120 if $kir<0 then 40


quote]

I get runtime error 5 in line 30 when I try to run this, Most of the examples work, but I get runtime error 5 on this and a few other examples. Mirror for one, suggestions ?

Image
[quote="l3v3rz"]Thanks Limor.

Code is now at R216. I built a windows executable version basic.exe - so you can try it without even having a robot or RBC unit - see website for details.

Here's a new example of simple auto-balance:

Code: Select all
10 STAND 16
20 Print "Press any key"
30 if $kir<0 then 30
40 list m=7,-4,-2,-1,0,1,2,4
50 Let d=$find($z, @{7,-15,-10,-5,0,5,10,15}
60 let o=@m[d]
70 wait 10
80 print $z;"-";d;"-";o
90 servo 10=$servo(10)+o
100 servo 13=$servo(13)-o
110 wait 10
120 if $kir<0 then 40


quote]

I get runtime error 5 in line 30 when I try to run this, Most of the examples work, but I get runtime error 5 on this and a few other examples. Mirror for one, suggestions ?

Image
ron
Robot Builder
Robot Builder
Posts: 11
Joined: Fri Oct 14, 2011 5:39 am

Next
36 postsPage 1 of 31, 2, 3
36 postsPage 1 of 31, 2, 3