View unanswered posts | View active topics It is currently Mon Sep 15, 2014 12:06 am






Reply to topic  [ 39 posts ]  Go to page 1, 2, 3  Next
File read and write functions 
Author Message
Rookie
User avatar

Joined: Wed Apr 30, 2008 7:05 am
Posts: 18
Location: Brisbane, QLD
Post File read and write functions
As i have hit the wall in terms of variable memory, i am forced to find other ways to hold the data for my lego nxt ratSLAM implementation :shock: . So my query involves the file read and write functions. Once you have called the openwrite() function, and have written data to the file is it possible to call the openread function without closing the file? Calling the Openwrite command again causes an error as the file already exists. In otherwords is it possible to both read and write to the file so that i can write some data to the file, read it back, write some more data to the same file, read that back and so forth. - This would be great as it would ease the pain of the 15kb variable memory limit - and let me finish my thesis :P

_________________
experiencing slow death by thesis


Thu Aug 21, 2008 9:08 pm
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 615
Post Re: File read and write functions
No. Sorry.

ROBOTC on the NXT uses the file system developed by LEGO for the NXT. The feature set is fixed.

If you are out of memory for variables have you used the most "economical" storage technique. I.E. used "byte" or "char" variables to store small numbers? etc.

How much "extra" memory do you want / need?


Thu Sep 18, 2008 7:05 am
Profile
Rookie
User avatar

Joined: Wed Apr 30, 2008 7:05 am
Posts: 18
Location: Brisbane, QLD
Post Re: File read and write functions
yes im already using the most efficient storage methods but all my neural networks for my SLAM implementation are still a little heavy on the data. If it would be possible to get say 18Kb i would be able to produce a very nice SLAM robot. Any more space would be greatly appreciated

_________________
experiencing slow death by thesis


Thu Sep 18, 2008 6:59 pm
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: File read and write functions
hi,
have you got a simply readable overview with some mathmatical background information about this ratSLAM topic?

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Fri Sep 19, 2008 1:43 am
Profile
Rookie
User avatar

Joined: Wed Apr 30, 2008 7:05 am
Posts: 18
Location: Brisbane, QLD
Post Re: File read and write functions
http://www.itee.uq.edu.au/~wyeth/RatSLAM/
Gordo is the mastermind. Im just taking ratSLAM from running on a pioneer robot linked wirelessly to a desktop PC to running it fully onboard a lego NXT - a big difference let me tell you

_________________
experiencing slow death by thesis


Fri Sep 19, 2008 2:26 am
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: File read and write functions
hi,
a nice project - for a mainframe computer I guess, not to be run in download mode on nxt.
But what I actually don't understand: what exactly does the hippocampus model ?
How is the neural net working exactly, which is it's architecture?
My English unfortunately is too bad to understand this point.


BTW: An artificial neural net is strongly limited by the nxt variable RAM - with 15k you won't get a powerful NN working ever.
As you may have noticed, my own neural net allows about 40 artificial neurons, not more - then the memory reaches the 15 kB limit.
You need 1 input neuron for every switch (bumper) and every analog sensor range (0-15cm, 16-25cm, 26-80cm) plus 20% calculating reserve,
and you actually need at least 3 output neurons for each motor (for direction and speed control).
8 analog sensors * 3 ranges = 24 + 20% = 29 hidden/input neurons
+ 2 motors *3 outputs= 6 output neurons
= 35 neurons over all for a simple backpropagation net
plus rest of your actual main program that does anything useful = 15 kB memory reached!

And above this you need memory for the navigation map. My own navigation robot uses a maximum 40x40 square map and then also the 15k limit already has been reached.

Together it's 30 k - for a verry very simple NN and a very very simple navigation map - twice as much as you may have available!

Yet only nxtOSEK gives you a variable memory amount like this (and even a big chunk more).

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Fri Sep 19, 2008 3:07 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3218
Location: Rotterdam, The Netherlands
Post Re: File read and write functions
Ford,

Maybe you should use something like the Olimex Linux board: [LINK]. A friend of mine has it and it's very, very nice. A bit on the pricey side, but you can do a lot with it! They cost about 140 euro a piece.

Feature list:
* MCU: AT91SAM9260 16/32 bit ARM9™ 180MHz operation
* standard JTAG connector with ARM 2x10 pin layout for programming/debugging with ARM-JTAG
* 64 MB SDRAM
* 512MB NAND Flash (seen in Linux as silicon drive)
* Ethernet 100Mbit connector
* USB host and USB device connectors
* RS232 interface and drivers
* SD/MMC card connector
* one user button and one reset button
* one power and two status LEDs
* on board voltage regulator 3.3V with up to 800mA current
* single power supply: 5V DC required
* power supply filtering capacitor
* 18.432 Mhz crystal on socket
* extension header
* PCB: FR-4, 1.5 mm (0,062"), soldermask, silkscreen component print
* Dimensions: 100 x 80 mm (3.94 x 3.15")

Regards,
Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Fri Sep 19, 2008 4:39 am
Profile WWW
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: File read and write functions
no, I'll go ahead with my nxt's.

Maybe one can send some values via RS485 to store them or calculate on other nxt's?
With 4 of them you could build a scalar quad core "super nxt" sharing µC power, memory and I/O ports 8)

So a RS485 networking and transmission control protocol is urgently needed...!

And I really wonder how those neural networks for locky's SLAM implementation will look like.

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Fri Sep 19, 2008 5:05 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3218
Location: Rotterdam, The Netherlands
Post Re: File read and write functions
Well, you could also use external memory which you can access through I2C. A while back I requested a few 512 and 1024Kbit EEPROM chips samples but I have not had time to play with them. At top speed, you could probably get about 800 bytes per second in, if you requested large chunks at once, otherwise you're looking at about 500 bytes per second. This speed is limited by the internal workings of the I2C timers in the FW, if I understood Dick correctly.

Regards,
Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Fri Sep 19, 2008 5:21 am
Profile WWW
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: File read and write functions
as far as I understood Dick Swan, this memory may not be addressed for variables?

for example, you got a 100x100 sqare map of 8 bytes each, this will amount to 80 kbyte.
How do want to read a value (byte)map[10][99][3]?

or you have a neuron structure, and you use an array of 200 of them, they will need maybe 50 kByte of memory.
Code:
typedef struct{
   float in[ni];    // Einzel-Inputs (Dendriten)
   float w[ni];     // Einzel-Wichtungen (jedes Dendriten)
   float net;       // totaler Input
   float th;        // Schwellenwert (threshold)
   float d;         // delta=Fehlersignal
   float out;       // Output (Axon): z.B. 0 oder 1
} tNeuron;

tNeuron aNeuron[200];



how do you want to calculate their internal float values, e.g.
Code:
void netPropagThr(tNeuron &neur){   // Propagierungsfunktion 2
  int i=0;                          // kalkuliert den Gesamt-Input (net)
  float s=0;                        // und beruecksichtigt Schwellwert

  for(i=0;i<ni;i++){
     s+= (neur.in[i]*neur.w[i]);     // gewichtete Summe
  }
  neur.net=s-neur.th;               // abzueglich Schwellwert
}

for(n=0;n<200;n++){
  netPropagThr(aNeuron[n]);
}


if they are not present in the 15k RAM?

I think this is similar to the old MS-DOS computers (IBM XT):
you might have had 4 GByte of RAM, but DOS only handled 640k.

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Fri Sep 19, 2008 6:17 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3218
Location: Rotterdam, The Netherlands
Post Re: File read and write functions
You would need to access them differently and not through the standard method of variables. Functions could be written to retrieve or write the values for a neuron or a set of neurons to the eeprom.

Regards,
Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Fri Sep 19, 2008 7:27 am
Profile WWW
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: File read and write functions
oh - I have a read/write cycle to a neuron or to a map field every 10 msec, and I can't isolate the structure array into single structures.

So it won't work with the I2C memory unfortunately.
Only other (slave) nxt's can make the calculations by their own and share the results with the (master) nxt via RS485:

Main program with BUG2 on nxt master (electronic house butler) (8k)
navigation, mapping and a-star on nxt slave1 (15k)
grabber and cam control on nxt slave2 (10k)
neural net on nxt slave3 (15k)

Or really another BIOS would be a better way (the Lego BIOS to be exchanged like at nxtOSEK).

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Fri Sep 19, 2008 9:25 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3218
Location: Rotterdam, The Netherlands
Post Re: File read and write functions
Are you really accessing *all* of the data *all* of the time? Surely not? I very much doubt you couldn't somehow optimise the algorithm to allow for block-like operations when it comes to this stuff. If you can have another NXT do the calculations then I am sure there is a way to somehow store the bulk of this data in external memory and only pull out what you need.

Regards,
Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Fri Sep 19, 2008 9:34 am
Profile WWW
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: File read and write functions
yes, surely!
the NN is a background task which calculates it's outputs every 50msec depending on all sensor input values,
and the navigator is a background task which calculates the current position anew at every tick of the motor encounters as fast as they can be registered; above this, if obstacles are detected (or meanwhile have been removed), they are written to the map resp. the map has to be actualized, and the a-star and the bug2 calculate immediately the newest shortest way to the target anew.
Above this, additional navigation tasks are running to confirm the odometric data (compass, landmarks (POBeye cam), bearing of IR or ultrasonic buoys, maybe some time GPS)

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Last edited by Ford Prefect on Fri Sep 19, 2008 9:52 am, edited 1 time in total.



Fri Sep 19, 2008 9:44 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3218
Location: Rotterdam, The Netherlands
Post Re: File read and write functions
How about this? When I am done with your expansion board, I will have a go with the memory chips. The nice thing is, I have 3 1024Kbit and 3 512Kbit chips (not Mbit, sorry, I think I typed that in a previous post) and you can use up to 8 of them. We'll try working with just the one first, of course :) It would be kind of cool to make this work!

Regards,
Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Fri Sep 19, 2008 9:50 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 39 posts ]  Go to page 1, 2, 3  Next

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.