I set up an original experience in my bedroom. It's designed to measure a length using a webcam. On this picture, you can see how things are laid out:

The principle is quite simple:

The next step is to locate the pendulum in this image. I wrote a modified Hough Transform to identify circles in order to do that. To convert the disc to a circle, I used a gradient filter, on the green channel to emphasize the edges:

Once and for all, I manually estimated the radius of the pendulum. Running an HT on this yields the following Hough-space (ie: parameter space):
Extracting the maximum intensity in the above image gives the cartesian coordinates of the pendulum position. I did this on a sequence of 3000 frames, captured at 25 FPS with a resolution of 320x240 pixels. I pinched the pendulum beforehand, not caring whether it was in the right alignment etc: it doesn't matter. Here is an excerpt of the data, for the horizontal position (vertical position doesn't vary enough to be relevant):
As expected, the observed "signal" is a decaying sinusoid. We wish to evaluate the frequency of the latter. IMHO, a Fourier analysis isn't the best choice here, since we know that the signal much ressembles a stable carrier amplitude modulated by a very low frequency decaying function. Simply counting zero-crossings is acceptable in this configuration. According to this formula:
l = g/w^2
where l is the pendulum length, g is 9.81 m/s^2 and w = 2*pi*f, where f is the oscillation frequency, the test yields the following results:
f = .958 Hz
l = 27.1 cm
It's funny that I unwillingly built a nearly 1 Hz pendulum ^_^.
Of course, the measured length covers the distance between the pivot point and about the center of the bob.
Currently, the Hough Transform is too slow, so the computations are done offline. To speed things up, one could use a model of the system to estimate the next position of the bob, and only look it up in a small area.
The initial project was to mount the pivot point on a horizontal axis. The position of the pivot would then be controlled by a motor, itself controlled by the Lego Mindstorms RCX brick. In order to do so, I made the necessary physics calculations and coded an RCX Matlab Toolbox (interesting to do actually), but the latter was way too slow to expect anything interesting to be feasible. Damn the infrared protocol ... The idea was to pinch the pendulum, and have the computer automatically move the pivot point in order to stabilize it as fast as possible. It's a nice project, because it involves a lot of math, a bit of physics and practical issues. Unfortunately, it's not realizable with the RCX. At least, not with my software.
If you're aware of any way to control the motors of the RCX brick live from a computer, with a reasonable delay, in whatever language, I would be glad to hear about it!
Kirua

The principle is quite simple:
- build a pendulum the same length as the object you want to measure,
- point a webcam in front of it,
- connect the webcam to your computer,
- set the pendulum in motion, and acquire a bunch of frames,
- find the pendulum position in each frame,
- knowing the physics of the situation, analyze the motion to determine the length of the pendulum.
- you only need to evaluate the oscillation frequency: it's no big deal if the camera is not set up perfectly parallel to the motion plane or if the resolution is poor,
- mass, initial conditions and amplitude (if tiny) are nothing to worry about,
- the webcam delay is not a problem, since only the time difference between two frames matters,
- you don't need to convert from cartesian coordinates to polar ones, since you know the actual motion is close to a decaying sinusoid: counting zero-crossings is sufficient.
- Using a simple model for the pendulum (massless rod, infinitely small bob), you don't compute the correct length. If we choose to neglect moment of inertia though, which I did, the length you measure is the distance between the pivot point and the center of mass of the pendulum. Hence, you should choose a fairly small bob, which I couldn't (because I'm too clumsy and can't fix a string on a tiny object).

The next step is to locate the pendulum in this image. I wrote a modified Hough Transform to identify circles in order to do that. To convert the disc to a circle, I used a gradient filter, on the green channel to emphasize the edges:

Once and for all, I manually estimated the radius of the pendulum. Running an HT on this yields the following Hough-space (ie: parameter space):
Extracting the maximum intensity in the above image gives the cartesian coordinates of the pendulum position. I did this on a sequence of 3000 frames, captured at 25 FPS with a resolution of 320x240 pixels. I pinched the pendulum beforehand, not caring whether it was in the right alignment etc: it doesn't matter. Here is an excerpt of the data, for the horizontal position (vertical position doesn't vary enough to be relevant):
As expected, the observed "signal" is a decaying sinusoid. We wish to evaluate the frequency of the latter. IMHO, a Fourier analysis isn't the best choice here, since we know that the signal much ressembles a stable carrier amplitude modulated by a very low frequency decaying function. Simply counting zero-crossings is acceptable in this configuration. According to this formula:l = g/w^2
where l is the pendulum length, g is 9.81 m/s^2 and w = 2*pi*f, where f is the oscillation frequency, the test yields the following results:
f = .958 Hz
l = 27.1 cm
It's funny that I unwillingly built a nearly 1 Hz pendulum ^_^.
Of course, the measured length covers the distance between the pivot point and about the center of the bob.
Currently, the Hough Transform is too slow, so the computations are done offline. To speed things up, one could use a model of the system to estimate the next position of the bob, and only look it up in a small area.
The initial project was to mount the pivot point on a horizontal axis. The position of the pivot would then be controlled by a motor, itself controlled by the Lego Mindstorms RCX brick. In order to do so, I made the necessary physics calculations and coded an RCX Matlab Toolbox (interesting to do actually), but the latter was way too slow to expect anything interesting to be feasible. Damn the infrared protocol ... The idea was to pinch the pendulum, and have the computer automatically move the pivot point in order to stabilize it as fast as possible. It's a nice project, because it involves a lot of math, a bit of physics and practical issues. Unfortunately, it's not realizable with the RCX. At least, not with my software.
If you're aware of any way to control the motors of the RCX brick live from a computer, with a reasonable delay, in whatever language, I would be glad to hear about it!
Kirua
0 comments:
Post a Comment