Missing getYTilt() in AccelHTSensor

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

Moderators: 99jonathan, roger, imaqine

Missing getYTilt() in AccelHTSensor

Postby ekinnear » Tue Jan 10, 2012 9:29 pm

The API has methods for get X,Y,Z tilts for the AccelHTSensor class.
However, when I try to use them, they are not there. The listing in Eclipse has the Mindsensors sensor having them, but not the HiTechnic sensor.
Eclipse says:
The method getYTilt() is undefined for the type AccelHTSensor

and it won't compile without it (it can't find the method I'm trying to call, so this is not a surprise).

Am I missing something or are they just not there? Have they been removed?
ekinnear
New User
 
Posts: 3
Joined: Mon Jan 09, 2012 10:26 pm

Re: Missing getYTilt() in AccelHTSensor

Postby skoehler » Wed Jan 11, 2012 12:46 am

Which version of leJOS are you using? Are you using a snapshot? Because the get*Tilt method have been removed from AccelHTSensor. This sensor does not provide any tilt data.
skoehler
leJOS Team Member
 
Posts: 1405
Joined: Thu Oct 30, 2008 4:54 pm

Re: Missing getYTilt() in AccelHTSensor

Postby ohma » Wed Mar 28, 2012 3:26 pm

I guees he is using 0.9.1, and I wonder why .getTilt have been removed? It worked perfekt. I used it for a "magic-wand" - which work quite good.
Can we maybe get it back?
ohma
New User
 
Posts: 3
Joined: Wed Mar 28, 2012 3:21 pm

Re: Missing getYTilt() in AccelHTSensor

Postby skoehler » Wed Mar 28, 2012 3:36 pm

ohma wrote:I guees he is using 0.9.1, and I wonder why .getTilt have been removed? It worked perfekt. I used it for a "magic-wand" - which work quite good.
Can we maybe get it back?


I checked revision 5101 of AccelHTSensor.java, which is the last one which contained getTiltX(), and the fact is that getTiltX() was returning the upper 8 bits of acceleration (not tilt!) value of the X axis while getAccelX() returned the lower two bits. Again: the sensor does NOT provide any tilt data, as you can see on the manufacturer's homepage: http://www.hitechnic.com/cgi-bin/commer ... ey=NAC1040
That the tilt methods even existed, and that they returned the wrong data, was a bug which originated in the mistake of copy/pasting AccelMindSensor.java to AccelHTSensor.java.

If your old code works nicely, then it will most likely still work. Since what used to be returned by getTiltX() is now returned by getAccelX(). In fact, your code only needs to adjust to the fact that getAccelX() now returns the whole 10 bit, instead of the upper 8 that used to be returned by getTiltX().
skoehler
leJOS Team Member
 
Posts: 1405
Joined: Thu Oct 30, 2008 4:54 pm

Re: Missing getYTilt() in AccelHTSensor

Postby Aswin » Wed Mar 28, 2012 5:03 pm

You can convert tilt to acceleration and back:
Cos(angle)=acceleration

Angle is in radians, acceleration in milliG.
My NXT blog: http://nxttime.wordpress.com/
Aswin
leJOS Team Member
 
Posts: 199
Joined: Tue Apr 26, 2011 9:18 pm
Location: Netherlands

Re: Missing getYTilt() in AccelHTSensor

Postby skoehler » Wed Mar 28, 2012 5:17 pm

Aswin wrote:You can convert tilt to acceleration and back:
Cos(angle)=acceleration

That's not quite correct. Here's the correct formula:
sin(angle_y) = accel_x / 1G
sin(angle_x) = accel_y / 1G
and they only hold, if the acceleration sensor is not accelerated in either X or Y direction.


Also, just to be clear, this formula was never implemented in AccelHTSensor. It really never returned any kind of tilt data. The getTiltXYZ methods returned acceleration data instead.
skoehler
leJOS Team Member
 
Posts: 1405
Joined: Thu Oct 30, 2008 4:54 pm

Re: Missing getYTilt() in AccelHTSensor

Postby ohma » Tue Apr 10, 2012 2:09 pm

Hallo
I have uploaded a short film showing how you could use the getXtilt() - and I will still claim that it works perfectly, though I'm not that into programming.
http://www.youtube.com/watch?v=CWedcoGH_ts

The are almost non conversion between the values from accel/tilt-sensor and input to the motors.
The 'boom' which control altitude:
Code: Select all
//Lejos 0.9.0
altitude= tilt.getXtilt()*2; //send it via Bluetooth
Boom.rotateTo(altitude,true);
ohma
New User
 
Posts: 3
Joined: Wed Mar 28, 2012 3:21 pm

Re: Missing getYTilt() in AccelHTSensor

Postby skoehler » Tue Apr 10, 2012 2:37 pm

You do realize, that the X acceleration value increases/decreases as you move the wand in the video? The acceleration on the x axis is zero if you holt the wand horizontally.
That's simply due to how gravity affects an acceleration sensor. It's similar, but not equal to a tilt value. Consider how "linear" the arcus sine looks:
http://en.wikipedia.org/wiki/Inverse_tr ... c_function
You probably didn't notice the difference between x (acceleration) and arcsin(x) (tilt).
skoehler
leJOS Team Member
 
Posts: 1405
Joined: Thu Oct 30, 2008 4:54 pm


Return to NXJ Software

Who is online

Users browsing this forum: Google [Bot] and 4 guests

more stuff