Demo for WiTilt V3.3

I came up with demo python program to play with WiTilt v3.3 module. It definitely needs improvement and I’m planning to post it to some OpenSource project, but before I’d like to hear/read some comments.

I’m not sure how could I post the project here, it seems to be impossible, but upon any request I can email it to you. Again, this post is the first shot towards distributing the project and finding somebody who’d like to improve it.

If none will reply – I will move the topic to some OpenSource project forum.

Brief description:

  1. Allows to configure the module through built-in menu

  2. Displays raw sample data (XYZR), as well as integral values: velocity, position, angle (upon integration of acceleration and angular velocity).

  3. Uses preconfigured sampling rate (I usually play with 100Hz) and binary mode of data exchange

  4. Interprets the incoming data, process them (averaging), integrate them and displays with 30 fps.

  5. Has calibration feature which employs averaging instead of instant samples as in built-in feature.

  6. The program written in python + pygame + pyserial

  7. Tried on Ubuntu (9.04) and Windows(XP) machines

In purpose of accessing source files, the SourceForge.net project has been established:

http://sourceforge.net/projects/witiltdemo/

You might need to go directly to SVN repository:

http://witiltdemo.svn.sourceforge.net/v … emo/trunk/

to access project files

If you are interested in contributing to the project – let me know and I’ll add you up to the list of developers.

Below you can find some instractions of running the demo:

  • 1. The main file to run is witilt.py
    1. You need python, pygame, pyserial

    2. You need bluetooth connection ready to be used. By default the demo

    uses /dev/rfcomm0 as port number for connection. You can either

    hardcode another port or use command line option ‘-p ’.

    There is an issue with pyserial in Windows if you are using port

    numbers higher than 9, say com12. The way to handle it is to specify

    it in special way… (I don’t remember details, but I know where to

    look at). So if your BT dongle’s SPP sits on such a port, either

    reassign it to lower one or let me know and I’ll figure it out.

    1. There could be issue with true type fonts that I use to display

    text (I work in Ubuntu, which does have different fonts than Windows).

    It seems that some default font will be used in the case of error, so

    let me know if interface looks ugly…

    1. You can access original WiTilt V3.3 menu as selecting item 2 in the

    main menu. Its functionality is limited, so only the following actions

    seem to work well: selecting output mode, gravity range, content of

    binary pack. Don’t use it for calibration – there is dedicated

    procedure in the code (more reliable that built-in)

    1. Calibration data. There is the file ‘calib.dat’ in the source

    directory. It is used by default to read calibration data. If such a

    file is not found – the calibration data are retrived from the

    module. Filename is hardcoded, but easily can be changed.

    1. Calibration procedure. When you are running the process (1 from

    main menu), press ‘c’ to activate calibration. Then you’ll need to

    follow instructions, which are in selecting calibration axes by means

    of placing the module on the surface in certain orientation. The

    orientation will be determined automatically and the corresponding

    data will be gathered. Upon completing calibration for all 6 axis,

    (you will see 1 at all placeholders instead of 0) press ‘c’ again

    1. Monitoring process. Either acceleration or velocity or position can

    be used to affect position of the markers at the monitor screen. You

    need to look at DSP.getData() (3 last tuples responsible to the data

    passed for drawing. You might need to change the one after self.alpha

    to self.a for acceleration, self.v for velocity, self.p for position.

    Now it is set that acceleration is used to control position of the

    markers withing the monitor screen).

    And probably the last comment. I’m using tab size of 3 characters

    (instead of default 4) and do not expand tabs by spaces, so if you

    will face indentation problem after changing something, restore the

    source files from the archive and make adjustment in the IDE of your

    choice before editing.


  • Forgot to mention the mode of operation to be set up in WiTilt V3:

    binary + XYZ-R + 1.5g

    the last one (1.5g) is not required but existing calibration data are adjusted to it. If you use another range – the calibration is needed.

    Can you confirm which bluetooth device you are using? I cannot seem to get the WiTilt connected using RocketFish USB Bluetooth adapters. I have tried terminal programs (Putty) and your demo python program, but both cause the bluetooth system to ask for a passkey which obviously fails.

    The passcode for WiTiltV3 device is 1234 and you need to make the serial profile of your BT device ready by the time of program execution.

    Let’s go step by step. OS? If windows, what BT drivers do you use (Bitcomm, Bluesoleil, etc)? If linux – you need to install bluez.

    My setup:

    1. BT dongle: Omega (under windows works with standard windows drivers), under linux works with bluez (my case)

    2. I have configuration for rfcomm (linux) which allows me to bind certain device /dev/rfcomm0 to the dongle’s serial profile. Another config file ‘pincodes’ contains pins for all my known BT devices, including WiTiltV3

    3. When I’m running the application it tries to connect to /dev/rfcomm0 by default. If another port is specified via -p command line option it uses that port.

    Hello,

    I recently found your demo program for witilt accelerometer. I am interested to use it to find position estimate based on the accelerometer reading.

    However, when i run the program through windows, it always shut down on itself. I am using python v2.6.4 and pygame 1.9.1 and pyserial 2.5 rc2. I have set the witilt to be running at binary XYZ-R at 1.5g. Does the sampling rate matter?

    I am using Bluesoleil bluetooth driver and the device is set at COM4 serial port. I am not sure how to change the port for the program and i am new to python.

    If the error cannot be resolve, could you share with me how you arrive at the position estimate for your program as that will help my project a lot.

    Regards,

    Hao Xiang