To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.pbforthOpen lugnet.robotics.rcx.pbforth in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / pbFORTH / 161
160  |  162
Subject: 
FW: belated question from Mindfest
Newsgroups: 
lugnet.robotics.rcx.pbforth
Date: 
Tue, 2 Nov 1999 19:02:00 GMT
Viewed: 
1440 times
  
-----Original Message-----
From: munafo@gcctech.com [mailto:munafo@gcctech.com]
Sent: Monday, November 01, 1999 5:24 PM
To: rhempel@bmts.com; Robert Munafo
Subject: belated question from Mindfest


Ralph,

It was good talking to you at Mindfest. As you saw, I threw in my
comments about the numeric library debate on LUGNET about 2 weeks after
it was current, and I came in on the side of the applications programmer
(rather than systems programmer) viewpoint.

Nevertheless, at Mindfest I heard you emphasize the virtues of
programming without variables and without any numerics beyond a basic
16-bit integer, and wanted to ask about doing my current project in
pbFORTH. I almost had a chance to ask you on Sunday while you were
setting up the maze robot but someone else started asking questions
about the maze and I decided to save it for later.

My current project has a "data collection mode" and "behavior playback
mode". In collection mode, it is accumulating statistics on five inputs
(3 sensors and two motors) and their correlation to each other and to
certain derived functions, using a total of about 15 variables. In
playback mode, it continually reads the 3 inputs and regenerates the
motor speed values as outputs using a model that treats the statistics
as parameters in a set of equations.

Although this could be done entirely with the stack, I can't really see
the point because every word in my program would end up looking
something like this:

: ACCUM_M1 ( f0 r0 f4 r4 f1 r1 f5 r5 f3 r3 f7 r7 l0 l9 lv lm t1 t2 t3 t4
t5 t6 -- f0 r0 f4 r4 f1 r1 f5 r5 f3 r3 f7 r7 l0 l9 lv lm t1 t2 t3 t4 t5
t6 ) // accumulates current reading into M1 totals
  INPUT_1 EX_MOTOR 4 NDUP + 4 NEXCH DROP
  22 NDUP + 22 NEXCH DROP
  // more of the same to accumulate rotation and weighted correlations
  // (I forget how to write comments in FORTH)
;

As you can see I'm keeping all th "variables" on the stack, and using
hypothetical words NDUP (that takes a parameter such as 22 and copies
the 22nd cell on the stack) and NEXCH (that exchanges the top cell with
the Nth cell). Such code would have hundreds of constants (like 22) that
correspond to the precise location of each of the variables on the stack
at that point in the code, and whenever you need to add more variables
or temp storage space you would have to carefully recompute the proper
values of all these constants.

So it seems a more standard implementation with variables is in order.
But you seem to have quite a bit of experience avoiding the use of
non-stack storage so I wanted to hear what you had to say.

- Robert



1 Message in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR