Real-Time memory management

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: 99jonathan, roger, imaqine

Real-Time memory management

Postby Helfawi » Sun Apr 06, 2014 7:13 pm

hello everybody,
I'm sorry if this is not the correct place for my question
I want to ask : is lejos support low level memory management like RTJS ?
and how far may I go into critical real time application using NXT and Lejos ?
Thanks in advance :)
Helfawi
New User
 
Posts: 7
Joined: Sun Apr 06, 2014 7:08 pm

Re: Real-Time memory management

Postby gloomyandy » Sun Apr 06, 2014 8:48 pm

It is probably better if you describe what it is you are trying to do and why you think memory management may be a problem. In general leJOS does not implement RTJS but the pause times for gc used in the NXT version of leJOS are very small (approx 3mS).
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4085
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Real-Time memory management

Postby Helfawi » Mon Apr 07, 2014 1:51 pm

Thanks gloomyandy ,
I'm trying to make segawy self balancing but I have problem with calculating the time interval (sampling time) I want it to be 10msec and I want to use this interval to calculate angular speed from a given tow angles (theta2-theta1)/dt
so I'm afraid that when the gc will work it will take another 3msec so the result will be not correct
and until now the segawy can not balance so I want to be sure that my problem is with the PID parameters or it is latency from the system
Helfawi
New User
 
Posts: 7
Joined: Sun Apr 06, 2014 7:08 pm

Re: Real-Time memory management

Postby gloomyandy » Mon Apr 07, 2014 2:46 pm

Well first off there are many, many segways already using leJOS (we even provide the code for one as part of the leJOS class library), so you know that it is possible. Secondly it is always best to actually time the interval and use that value. Thirdly although in theory the gc can run any time, if your control loop is not generating garbage then it is very unlikely that that gc will run. Finally, do you have any evidence that your loop times are actually varying and that it is the gc that is causing the issue? It is always best to collect the evidence first rather than trying to fix problems that may not exist. Oh and one other thing. What gyro are you using? On the NXT if you use the HiTechnics cyro then it may very well have a sample jitter of around 3ms due to the way that analogue sensors are handled by the hardware. For this reason you may need to smooth the results to some degree.

Good luck

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 4085
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Real-Time memory management

Postby Helfawi » Mon Apr 07, 2014 5:35 pm

many thanks gloomyandy you have made it easier for me :)
now my problem is one of two :
the PID parameters need to be corrected OR the sensor is the problem becuase I do not have Gyro I'm using accelerometer and extracting the tilt from the Ax,Ay,Az after filtering it using low-pass filter
Helfawi
New User
 
Posts: 7
Joined: Sun Apr 06, 2014 7:08 pm

Re: Real-Time memory management

Postby Aswin » Mon Apr 07, 2014 7:04 pm

Hi,

There is a fine PID controller class shipped with LeJOS that takes care of timing. It takes care of other things as well, like dead bands etc. You could use this class. I think it is in the utility package.

However, you cannot use an accelerometer for balancing robots. This is because you cannot distinguish tilt com acceleration and both determine he output of he sensor. I have seen balancing robots using a light sensor. You could try his.

Aswin
My NXT blog: http://nxttime.wordpress.com/
Aswin
leJOS Team Member
 
Posts: 203
Joined: Tue Apr 26, 2011 9:18 pm
Location: Netherlands

Re: Real-Time memory management

Postby Helfawi » Mon Apr 07, 2014 7:53 pm

hi Aswin ,
Could you please explain more about "you cannot distinguish tilt com acceleration and both determine he output of he sensor" ?
because I have tried to read the tilt value from the accelometro sensor and it was pretty good but with some noise which I have filtered it later
the "light sensor" is my backup plan until now
Thanks
Helfawi
New User
 
Posts: 7
Joined: Sun Apr 06, 2014 7:08 pm

Re: Real-Time memory management

Postby Aswin » Mon Apr 07, 2014 8:45 pm

Well you tried tilt when there was no acceleration I guess. That works fine. But your balancing robot will go forth and back. This gives acceleration that is noticed by the sensor. You cannot seperate acceleration coming from this motion from the one that is coming from gravity. Therefore you can no longer calculate tilt.

I think this has been discussed before. So there might be a better explanation somewhere in previous threads.

Aswin
My NXT blog: http://nxttime.wordpress.com/
Aswin
leJOS Team Member
 
Posts: 203
Joined: Tue Apr 26, 2011 9:18 pm
Location: Netherlands

Re: Real-Time memory management

Postby Helfawi » Tue Apr 08, 2014 1:28 pm

mmmm I got it... thank you very much Aswin
Helfawi
New User
 
Posts: 7
Joined: Sun Apr 06, 2014 7:08 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 1 guest

more stuff