Active Topics

 


Reply
Thread Tools
Posts: 13 | Thanked: 12 times | Joined on Oct 2011
#1
I am not perfectly sure I am writing this on the right forum, so apologies if the forum is not correct.

So, I decided to try and give a look on the data the sensors deliver in my N9, but hit a wall.

I thought that it would be relatively easy to just create a python script that prints out accelerometer and/or compass data. So, I installed python and some bindings as instructed in

http://wiki.meego.com/Python/Harmattan/Getting_started

(Note: python-modules-all was not found)

Then, found some example codes:

http://qt.gitorious.org/pyside/pysid...bility/sensors

and

http://wiki.meego.com/User:Mdengler

Both get stuck somewhere before getting to the output generating part. Typical output, after which the process must be killed manually:

Code:
~/python $ python ac.py 
Using the meego graphics system
loaded the Generic plugin 
loaded the grue plugin 
Loaded the MeeGo sensor plugin 
Setting data rate 0 Hz (interval 0 ms) for "meego.accelerometer" 
Setting data rate 0 Hz (interval 0 ms) for "meego.magnetometer"
Finally, I tried to generate as simple script as I could:

Code:
import sys
from PySide.QtCore import *
from QtMobility.Sensors import *
                                
app = QCoreApplication(sys.argv)
sensor = QAccelerometer()       
sensor.start()                  
reading = sensor.reading()      
print reading.x(), reading.y(), reading.z()
Which gives following output:

Code:
~/python $ python acc.py  
loaded the Generic plugin 
loaded the grue plugin 
Loaded the MeeGo sensor plugin 
Setting data rate 0 Hz (interval 0 ms) for "meego.accelerometer" 
0.0 0.0 0.0
~/python $
Now, I would expect one of those to be slightly below 10 if the phone is lying still. I tried similar script for the compass sensor, and I got a bearing of 0 regardless which direction the phone was turned.

So, what have I missed?

Thanks,

Gybe
 
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#2
 

The Following User Says Thank You to nicolai For This Useful Post:
Posts: 13 | Thanked: 12 times | Joined on Oct 2011
#3
Originally Posted by nicolai View Post
Here is an example that works for me:
http://qt.gitorious.org/pyside/pysid...cceleration.py

nicolai
Thanks nicolai, that is one of the example scripts I tried, with following output:

Code:
~/python $ python show_acceleration.py 
loaded the Generic plugin 
loaded the grue plugin 
Loaded the MeeGo sensor plugin 
Setting data rate 0 Hz (interval 0 ms) for "meego.accelerometer" 
^C^Z[1]+  Stopped                    python show_acceleration.py
~/python $ python ./show_acceleration.py 
loaded the Generic plugin 
loaded the grue plugin 
Loaded the MeeGo sensor plugin 
Setting data rate 0 Hz (interval 0 ms) for "meego.accelerometer" 
^Z[2]+  Stopped                    python ./show_acceleration.py
~/python $ python ./show_acceleration.py -r 100

loaded the Generic plugin 
loaded the grue plugin 
Loaded the MeeGo sensor plugin 
Setting data rate 100 Hz (interval 10 ms) for "meego.accelerometer" 
^Z[3]+  Stopped                    python ./show_acceleration.py -r 100
It simply does not produce any output after it tells me that it has set the data rate, which forces me to kill the process manually.

So basically I have copied the script file to my n9 and run it as user. Is this how you do it as well?

Is there something I need to enable if I want my scripts to use the data from sensors?

Gybe
 
nicolai's Avatar
Posts: 1,637 | Thanked: 4,424 times | Joined on Apr 2009 @ Germany
#4
Yes, I started this script from xterm application on my N950
and over ssh. On both ways it produces an output like:
Acceleration: -4.42 x 0.18 y 13.42 z m/s^2 11.00 ms since last, 87.85 Hz
Acceleration: -2.12 x 1.59 y 6.71 z m/s^2 110.00 ms since last, 9.05 Hz
Acceleration: -2.12 x 1.59 y 6.71 z m/s^2 32.00 ms since last, 31.03 Hz

It only produces an output while the screen is unlocked.
 

The Following User Says Thank You to nicolai For This Useful Post:
Posts: 13 | Thanked: 12 times | Joined on Oct 2011
#5
Originally Posted by nicolai View Post

It only produces an output while the screen is unlocked.
That was it. Thanks very much.
 

The Following User Says Thank You to Gybe For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 11:21.