Re: [pygame] Pygame, cwiid and ode - movement

2008-08-08 Thread flx
2008/8/7 Nathan Whitehead <[EMAIL PROTECTED]>:
> On Thu, Aug 7, 2008 at 2:39 AM, flx <[EMAIL PROTECTED]> wrote:
>> I'm trying to make a foosball [1] game wth pygame, using the wiimote
>> to control the bars.
>>
>> I've managed to control the rotation using the accelerometers, but i
>> can't get the sliding part right. I've been asked to use the ir
>> sensors for the sliding movement, but I just can't get it right.
>
> I think you have two separate questions here:
> * how to get IR working on the wiimote and get IR data
> * once IR is working, how to interpret the data to make the paddle
> slide around correctly
>
> For the first part: which Wiimote library are you using?  Does it
> support IR?  Is it buggy with your particular Wiimote/bluetooth
> combination?  What operating system are you using?
I'm using the libcwiid python moudule (so it's under linux) wich works
well with my hardware, i've written some documentation covering the
basics of interfacing using python-cwiid here [1]

>
> For the second part: I recommend making a simple program that just
> displays squares at the reported IR positions, setting the screen to
> 1024x768.  Then try moving the Wiimote around and take notes about
> where the squares go.  Where do they go when you slide left?  What
> about when you point downwards?  Rotate clockwise?  Then use those
> notes to write code to control the paddle directly.  You might need
> some calculations here (argh, math!).

Doing exactly this i realized that my problems were the reflections
and the points going out of sight, right as you say below

>
> Once you've got this down you will have control of the paddle but it
> will be jerky and flickery.  Also when you move too far to the edge of
> the screen the paddle will stop moving (one IR dot goes off screen).
>
> To fix the jerkiness, a first step is averaging several values over
> time.  A better but harder approach is a Kalman filter.
Didn't kow about Kalman filter (i'm rushing to wikipedia now :) ) but
definetly some kind of estimation will help

>
> To fix the flickery problem: if there are 0 dots reported, use the
> most recent positions.  That stops the input from disappearing for a
> frame.  If there are too many dots (3 or more), then you want to pick
> the 2 dots closest to the last reported IR positions.
>
> To fix the edge-of-the-screen problem, a good approach I've used is to
> guess where the missing IR dot should be.  I assume that the dot off
> the edge of the screen moves just like the one that remains on the
> screen.  This won't be strictly true if the wiimote is rotating or
> changing distance to the sensor bar, but it will keep the paddle
> responding to input rather than stopping abruptly at the edge of the
> screen.
I was thinking of working with the accelerometers when not enough ir
data is avaliable, it definetly won't be nearly as accurate, but could
work
>
> FYI: I'm working on a pygame library that supports the wiimote on all
> platforms, it will be done Real Soon Now.
> --
> Nathan Whitehead
>

Thanks, you've given me some very useful insight


[1] - http://flx.proyectoanonimo.com/proyectos/cwiid/

-- 
.__.·º(foolhu!)
(oO)
/ | | \


Re: [pygame] Pygame, cwiid and ode - movement

2008-08-07 Thread flx
2008/8/7 Luke Paireepinart <[EMAIL PROTECTED]>:
>
>
> On Thu, Aug 7, 2008 at 4:53 AM, Hugo Arts <[EMAIL PROTECTED]> wrote:
>>
>> you might want to post this on a wiimote development oriented mailing
>> list/forum.
>> This is not really a pygame-related question. At least include some
>> additional
>> details. Your question is really vague.
>>
>> Perhaps you will also benefit from reading this:
>> http://www.catb.org/~esr/faqs/smart-questions.html#intro
>>
>> Hugo
>>
>> On Thu, Aug 7, 2008 at 11:39 AM, flx <[EMAIL PROTECTED]> wrote:
>> > Hi all
>> >
>> > I'm trying to make a foosball [1] game wth pygame, using the wiimote
>> > to control the bars.
>> >
>> > I've managed to control the rotation using the accelerometers, but i
>> > can't get the sliding part right. I've been asked to use the ir
>> > sensors for the sliding movement, but I just can't get it right.
>> >
>> > Have someone done this before? is there anywhere i can look for a
>> > similar usage of the wiimote or ask for help?
>
> Just keep track of the 2 biggest IR points, and use trigonometry to
> calculate the distance to the edge between the IR based on their spacing.
> Then use the default IR spacing of the Wii hardware (and a camera field of
> view of 45 degrees) to calculate how far you are from it.
> It's pretty simple math.
that's more or less what i was doing, but it didnt gave me the
expected result, mostly because reflections and sources going out of
sight.

I'm trying to dealt with reflections tracking only points with, more
or less, the same distance between them that they had the last time I
registered them, but if you loose sight of one the ir source it acts
weird.

I'm thinking in a hybrid, acc + ir, way of achieving this.

> Check wiibrew.net/com/org (whichever it is) and wiili.org, specifically the
> Wii Remote articles.  They have some details about IR.
> Let me know if you have more specific questions about the Wii Remote (you
> can ask me off-list if you want.)
> -Luke

Thank you very much, I didn't know wiibrew.org and it looks promising


-- 
.__.·º(foolhu!)
(oO)
/ | | \


Re: [pygame] Pygame, cwiid and ode - movement

2008-08-07 Thread Luke Paireepinart
On Thu, Aug 7, 2008 at 2:12 PM, Nathan Whitehead <[EMAIL PROTECTED]> wrote:
Hey nathan, good to see you still talkin' about the Wii Remote :)
Are you using pywiiuse for the data input, or some other library?
>
>
>
> To fix the jerkiness, a first step is averaging several values over
> time.  A better but harder approach is a Kalman filter.


Speaking of Kalman filters, is there an already-implemented filter in Python
that can be used, or
does everybody roll their own?  If there isn't, maybe that's something to
work on (not that I know a lot about kalman filters,
but I wouldn't mind starting a project.)  I'm at work so I can't do
extensive research into it right now.


> To fix the flickery problem: if there are 0 dots reported, use the
> most recent positions.  That stops the input from disappearing for a
> frame.  If there are too many dots (3 or more), then you want to pick
> the 2 dots closest to the last reported IR positions.
>
> To fix the edge-of-the-screen problem, a good approach I've used is to
> guess where the missing IR dot should be.  I assume that the dot off
> the edge of the screen moves just like the one that remains on the
> screen.  This won't be strictly true if the wiimote is rotating or
> changing distance to the sensor bar, but it will keep the paddle
> responding to input rather than stopping abruptly at the edge of the
> screen.

Sounds like good advice.

>
>
> FYI: I'm working on a pygame library that supports the wiimote on all
> platforms, it will be done Real Soon Now.


Awesome!  I think that we talked about this before, but I'm not sure.
Are you going to make the event engine sufficiently robust so that it can
support Pyglet with little changes?
Do you have source available?  I'd love to take a look at what you're doing!
Thanks,
-Luke


Re: [pygame] Pygame, cwiid and ode - movement

2008-08-07 Thread Nathan Whitehead
On Thu, Aug 7, 2008 at 2:39 AM, flx <[EMAIL PROTECTED]> wrote:
> I'm trying to make a foosball [1] game wth pygame, using the wiimote
> to control the bars.
>
> I've managed to control the rotation using the accelerometers, but i
> can't get the sliding part right. I've been asked to use the ir
> sensors for the sliding movement, but I just can't get it right.

I think you have two separate questions here:
* how to get IR working on the wiimote and get IR data
* once IR is working, how to interpret the data to make the paddle
slide around correctly

For the first part: which Wiimote library are you using?  Does it
support IR?  Is it buggy with your particular Wiimote/bluetooth
combination?  What operating system are you using?

For the second part: I recommend making a simple program that just
displays squares at the reported IR positions, setting the screen to
1024x768.  Then try moving the Wiimote around and take notes about
where the squares go.  Where do they go when you slide left?  What
about when you point downwards?  Rotate clockwise?  Then use those
notes to write code to control the paddle directly.  You might need
some calculations here (argh, math!).

Once you've got this down you will have control of the paddle but it
will be jerky and flickery.  Also when you move too far to the edge of
the screen the paddle will stop moving (one IR dot goes off screen).

To fix the jerkiness, a first step is averaging several values over
time.  A better but harder approach is a Kalman filter.

To fix the flickery problem: if there are 0 dots reported, use the
most recent positions.  That stops the input from disappearing for a
frame.  If there are too many dots (3 or more), then you want to pick
the 2 dots closest to the last reported IR positions.

To fix the edge-of-the-screen problem, a good approach I've used is to
guess where the missing IR dot should be.  I assume that the dot off
the edge of the screen moves just like the one that remains on the
screen.  This won't be strictly true if the wiimote is rotating or
changing distance to the sensor bar, but it will keep the paddle
responding to input rather than stopping abruptly at the edge of the
screen.

FYI: I'm working on a pygame library that supports the wiimote on all
platforms, it will be done Real Soon Now.
--
Nathan Whitehead


Re: [pygame] Pygame, cwiid and ode - movement

2008-08-07 Thread Luke Paireepinart
And you'd probably want to use a kalman filter to prevent a bunch of jumping
around as extra IR points are detected (there's a lot of random IR in a lot
of people's rooms.)
Sorry for the noise, I didn't think of that until after I submitted the
original reply.

On Thu, Aug 7, 2008 at 10:41 AM, Luke Paireepinart
<[EMAIL PROTECTED]>wrote:

> Oh and the resolution of the IR camera is 1024x768, so use that when you're
> translating the pixel space coordinates into real world units. (Your IR data
> will be the brightness/largeness of the point as one unit, and the X and Y
> values as the other units.)
>
>
> On Thu, Aug 7, 2008 at 10:00 AM, Dan Krol <[EMAIL PROTECTED]> wrote:
>
>> Hmm, I bet it be useful to have a library function that calculates that
>> for you.
>>
>> On Thu, Aug 7, 2008 at 9:33 AM, Luke Paireepinart
>> <[EMAIL PROTECTED]> wrote:
>> >
>> >
>> > On Thu, Aug 7, 2008 at 4:53 AM, Hugo Arts <[EMAIL PROTECTED]> wrote:
>> >>
>> >> you might want to post this on a wiimote development oriented mailing
>> >> list/forum.
>> >> This is not really a pygame-related question. At least include some
>> >> additional
>> >> details. Your question is really vague.
>> >>
>> >> Perhaps you will also benefit from reading this:
>> >> http://www.catb.org/~esr/faqs/smart-questions.html#intro
>> >>
>> >> Hugo
>> >>
>> >> On Thu, Aug 7, 2008 at 11:39 AM, flx <[EMAIL PROTECTED]> wrote:
>> >> > Hi all
>> >> >
>> >> > I'm trying to make a foosball [1] game wth pygame, using the wiimote
>> >> > to control the bars.
>> >> >
>> >> > I've managed to control the rotation using the accelerometers, but i
>> >> > can't get the sliding part right. I've been asked to use the ir
>> >> > sensors for the sliding movement, but I just can't get it right.
>> >> >
>> >> > Have someone done this before? is there anywhere i can look for a
>> >> > similar usage of the wiimote or ask for help?
>> >
>> > Just keep track of the 2 biggest IR points, and use trigonometry to
>> > calculate the distance to the edge between the IR based on their
>> spacing.
>> > Then use the default IR spacing of the Wii hardware (and a camera field
>> of
>> > view of 45 degrees) to calculate how far you are from it.
>> > It's pretty simple math.
>> > Check wiibrew.net/com/org (whichever it is) and wiili.org, specifically
>> the
>> > Wii Remote articles.  They have some details about IR.
>> > Let me know if you have more specific questions about the Wii Remote
>> (you
>> > can ask me off-list if you want.)
>> > -Luke
>> >>
>> >> >
>> >> >
>> >> > [1] - http://en.wikipedia.org/wiki/Table_football
>> >> >
>> >> > --
>> >> > .__.·º(foolhu!)
>> >> > (oO)
>> >> > / | | \
>> >> >
>> >
>> >
>>
>
>


Re: [pygame] Pygame, cwiid and ode - movement

2008-08-07 Thread Luke Paireepinart
Oh and the resolution of the IR camera is 1024x768, so use that when you're
translating the pixel space coordinates into real world units. (Your IR data
will be the brightness/largeness of the point as one unit, and the X and Y
values as the other units.)

On Thu, Aug 7, 2008 at 10:00 AM, Dan Krol <[EMAIL PROTECTED]> wrote:

> Hmm, I bet it be useful to have a library function that calculates that for
> you.
>
> On Thu, Aug 7, 2008 at 9:33 AM, Luke Paireepinart
> <[EMAIL PROTECTED]> wrote:
> >
> >
> > On Thu, Aug 7, 2008 at 4:53 AM, Hugo Arts <[EMAIL PROTECTED]> wrote:
> >>
> >> you might want to post this on a wiimote development oriented mailing
> >> list/forum.
> >> This is not really a pygame-related question. At least include some
> >> additional
> >> details. Your question is really vague.
> >>
> >> Perhaps you will also benefit from reading this:
> >> http://www.catb.org/~esr/faqs/smart-questions.html#intro
> >>
> >> Hugo
> >>
> >> On Thu, Aug 7, 2008 at 11:39 AM, flx <[EMAIL PROTECTED]> wrote:
> >> > Hi all
> >> >
> >> > I'm trying to make a foosball [1] game wth pygame, using the wiimote
> >> > to control the bars.
> >> >
> >> > I've managed to control the rotation using the accelerometers, but i
> >> > can't get the sliding part right. I've been asked to use the ir
> >> > sensors for the sliding movement, but I just can't get it right.
> >> >
> >> > Have someone done this before? is there anywhere i can look for a
> >> > similar usage of the wiimote or ask for help?
> >
> > Just keep track of the 2 biggest IR points, and use trigonometry to
> > calculate the distance to the edge between the IR based on their spacing.
> > Then use the default IR spacing of the Wii hardware (and a camera field
> of
> > view of 45 degrees) to calculate how far you are from it.
> > It's pretty simple math.
> > Check wiibrew.net/com/org (whichever it is) and wiili.org, specifically
> the
> > Wii Remote articles.  They have some details about IR.
> > Let me know if you have more specific questions about the Wii Remote (you
> > can ask me off-list if you want.)
> > -Luke
> >>
> >> >
> >> >
> >> > [1] - http://en.wikipedia.org/wiki/Table_football
> >> >
> >> > --
> >> > .__.·º(foolhu!)
> >> > (oO)
> >> > / | | \
> >> >
> >
> >
>


Re: [pygame] Pygame, cwiid and ode - movement

2008-08-07 Thread Dan Krol
Hmm, I bet it be useful to have a library function that calculates that for you.

On Thu, Aug 7, 2008 at 9:33 AM, Luke Paireepinart
<[EMAIL PROTECTED]> wrote:
>
>
> On Thu, Aug 7, 2008 at 4:53 AM, Hugo Arts <[EMAIL PROTECTED]> wrote:
>>
>> you might want to post this on a wiimote development oriented mailing
>> list/forum.
>> This is not really a pygame-related question. At least include some
>> additional
>> details. Your question is really vague.
>>
>> Perhaps you will also benefit from reading this:
>> http://www.catb.org/~esr/faqs/smart-questions.html#intro
>>
>> Hugo
>>
>> On Thu, Aug 7, 2008 at 11:39 AM, flx <[EMAIL PROTECTED]> wrote:
>> > Hi all
>> >
>> > I'm trying to make a foosball [1] game wth pygame, using the wiimote
>> > to control the bars.
>> >
>> > I've managed to control the rotation using the accelerometers, but i
>> > can't get the sliding part right. I've been asked to use the ir
>> > sensors for the sliding movement, but I just can't get it right.
>> >
>> > Have someone done this before? is there anywhere i can look for a
>> > similar usage of the wiimote or ask for help?
>
> Just keep track of the 2 biggest IR points, and use trigonometry to
> calculate the distance to the edge between the IR based on their spacing.
> Then use the default IR spacing of the Wii hardware (and a camera field of
> view of 45 degrees) to calculate how far you are from it.
> It's pretty simple math.
> Check wiibrew.net/com/org (whichever it is) and wiili.org, specifically the
> Wii Remote articles.  They have some details about IR.
> Let me know if you have more specific questions about the Wii Remote (you
> can ask me off-list if you want.)
> -Luke
>>
>> >
>> >
>> > [1] - http://en.wikipedia.org/wiki/Table_football
>> >
>> > --
>> > .__.·º(foolhu!)
>> > (oO)
>> > / | | \
>> >
>
>


Re: [pygame] Pygame, cwiid and ode - movement

2008-08-07 Thread Luke Paireepinart
On Thu, Aug 7, 2008 at 4:53 AM, Hugo Arts <[EMAIL PROTECTED]> wrote:

> you might want to post this on a wiimote development oriented mailing
> list/forum.
> This is not really a pygame-related question. At least include some
> additional
> details. Your question is really vague.
>
> Perhaps you will also benefit from reading this:
> http://www.catb.org/~esr/faqs/smart-questions.html#intro
>
> Hugo
>
> On Thu, Aug 7, 2008 at 11:39 AM, flx <[EMAIL PROTECTED]> wrote:
> > Hi all
> >
> > I'm trying to make a foosball [1] game wth pygame, using the wiimote
> > to control the bars.
> >
> > I've managed to control the rotation using the accelerometers, but i
> > can't get the sliding part right. I've been asked to use the ir
> > sensors for the sliding movement, but I just can't get it right.
> >
> > Have someone done this before? is there anywhere i can look for a
> > similar usage of the wiimote or ask for help?
>

Just keep track of the 2 biggest IR points, and use trigonometry to
calculate the distance to the edge between the IR based on their spacing.
Then use the default IR spacing of the Wii hardware (and a camera field of
view of 45 degrees) to calculate how far you are from it.
It's pretty simple math.
Check wiibrew.net/com/org (whichever it is) and wiili.org, specifically the
Wii Remote articles.  They have some details about IR.
Let me know if you have more specific questions about the Wii Remote (you
can ask me off-list if you want.)
-Luke

>
> >
> >
> > [1] - http://en.wikipedia.org/wiki/Table_football
> >
> > --
> > .__.·º(foolhu!)
> > (oO)
> > / | | \
> >
>


Re: [pygame] Pygame, cwiid and ode - movement

2008-08-07 Thread Hugo Arts
you might want to post this on a wiimote development oriented mailing
list/forum.
This is not really a pygame-related question. At least include some additional
details. Your question is really vague.

Perhaps you will also benefit from reading this:
http://www.catb.org/~esr/faqs/smart-questions.html#intro

Hugo

On Thu, Aug 7, 2008 at 11:39 AM, flx <[EMAIL PROTECTED]> wrote:
> Hi all
>
> I'm trying to make a foosball [1] game wth pygame, using the wiimote
> to control the bars.
>
> I've managed to control the rotation using the accelerometers, but i
> can't get the sliding part right. I've been asked to use the ir
> sensors for the sliding movement, but I just can't get it right.
>
> Have someone done this before? is there anywhere i can look for a
> similar usage of the wiimote or ask for help?
>
>
> [1] - http://en.wikipedia.org/wiki/Table_football
>
> --
> .__.·º(foolhu!)
> (oO)
> / | | \
>


[pygame] Pygame, cwiid and ode - movement

2008-08-07 Thread flx
Hi all

I'm trying to make a foosball [1] game wth pygame, using the wiimote
to control the bars.

I've managed to control the rotation using the accelerometers, but i
can't get the sliding part right. I've been asked to use the ir
sensors for the sliding movement, but I just can't get it right.

Have someone done this before? is there anywhere i can look for a
similar usage of the wiimote or ask for help?


[1] - http://en.wikipedia.org/wiki/Table_football

-- 
.__.·º(foolhu!)
(oO)
/ | | \