|
|
View previous topic :: View next topic |
Author |
Message |
curt2go
Joined: 21 Nov 2003 Posts: 200
|
Quaternions.... Again... |
Posted: Sat Oct 22, 2016 7:34 pm |
|
|
Well I am still very stuck. I am able to calculate quaternions in my code from euler angles. I am using the XL and gyro to do this. I have been able to prove the quaternions with an online simulator. My problem is that I need to know direction of travel, angle of travel between the 2 quaternions, so I can see what angle the player is swinging at and if their angle and speed is changing during the swing. I have been struggling with this issue for 3 weeks now. I know its not totally a code question but that will come next when I need to code it.
For those of you who don't know what i am doing i am tracking a bat. The real problem is the batter will never hold the bat the same way. They can rotate it in their hand (rotating x) and then my zgyro and ygyro readings don't mean the same things.
Maybe quaternions is not the best way to go. If anyone can help I am at a loss here. Thank you, Thank you , Thank you to anyone who can shed some light.
24EP256GP206 running at 140MHz. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19512
|
|
Posted: Sun Oct 23, 2016 2:54 am |
|
|
What you are looking for is an IMU path generator. This is what takes feeds from an IMU unit (which at heart is what you have), and then works out how the IMU has physically moved.
Now before this you will need filtering.
I'd suggest starting with the code here:
<http://www.instk.org/Tk/index.html>
Particularly the path generators.
Provided you have some way of triggering a 'start', so the operations are only over a very short time, the results may well be acceptable.
However 'beware'. This is why projects like the Micro-PNT, take a long time to come to fruition. To make this work requires a lot of computation at very short intervals, and will drift quite rapidly on most sensors. Applications wanting such measurements at present, generally either have a physical reference for the position (so systems like 'glove' controllers for robots), or use imaging techniques to give an absolute position in space (systems like the 3D locators used by animation studios). Ones using just inertial sensing will always currently add another input that can give a reference (can just be magnetometers, or ultrasonic, IR, or radio references).
Big problem is integration error. To go from the 'rate of change' figures from the accelerometers and gyros, you integrate to get velocity, then have to integrate again to get position. Tiny errors at the first level, get compounded. These solid state sensors are not actually that accurate, and the results therefore will not be that good. You also need to know the initial conditions (position and velocity at the start). Sensors with lower drift, tend to be larger and more expensive...
For some references to various levels of project doing this, look at:
<http://www.intorobotics.com/accelerometer-gyroscope-and-imu-sensors-tutorials/>
The sheer amount of work, is why the Micro-PNT project was trying to integrate this into a single module, and why it has taken so long..... |
|
|
curt2go
Joined: 21 Nov 2003 Posts: 200
|
|
Posted: Sun Oct 23, 2016 9:54 am |
|
|
I do believe I have everything working. I can run it all in real time and get many samples per second. I am integrating and combining with Accelerometer data with complimentary filter. My issue is that i have quaternions calculated but don't really know how to equate that to a movement. I can put multiple quaternions from a swing into the simulator and see the swing happen so I know my data is right but I don't know how to actually get that data out of the swing in to z movement( parallel to the ground) and y movement( perpendicular to the ground, up and down ) of the swing. Is this where the multiplication of quaternions comes in?
The big issue at the end of the day is knowing z and y regardless of how the batter is holding the bat and rotating it in his hands while swinging. Maybe i am over complicating things by using the quaternions. Let me know what you guys think. Thanks for any input. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19512
|
|
Posted: Sun Oct 23, 2016 12:10 pm |
|
|
Quaternions just specify rotations. This is why you need an initial position. You multiply the quaternions to give the 'total' rotation, and then use the initial direction vector, and rotate this by the final quaternion, to get the final direction. |
|
|
curt2go
Joined: 21 Nov 2003 Posts: 200
|
|
Posted: Sun Oct 23, 2016 12:40 pm |
|
|
I have an initial position. Then I have the bat moving in different position but each time it moves the last position becomes the position that I compare to.
But the vectors and such you talk about are part of the stuff I am struggling with so you have suggestions but I need the math to figure this stuff out. Sorry for not knowing a lot here but its not my strength. Let me know if you can set me up with some math to figure this out. Maybe using quaternions is not the right approach to this for what I need. Thanks for any input.
Here is some raw data I am collecting Q1[0.45,0.88,-0.07,-0.05](initial position) Q2[0.44,0.86,0.04,-0.23](swung to the left) . I am checking the positional information with a simulator at a site http://quaternions.online/ which is really awesome because I just put them in and can see the exact orientation of my bat. Each quaternion shows me the position I am in at that time very accurately.
I need to be able from 2 quaternions like this 1) The direction of travel 2) The angle of travel 3) how far it rotated on the z axis 4) if it moved up or down on the y axis. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19512
|
|
Posted: Mon Oct 24, 2016 12:24 am |
|
|
Which is why I said you need a path generator.
The point about Quaternions, is that they are a small way of storing/handling rotations, with the marvellous feature that they allow multiple ones to be combined by simply multiplying. So you can have a list of ten (say), multiply them together to give a single quaternion, that defines the total rotation. Brilliant way of handling multiple rotations.
The path generator, is designed to take a number of motions from a IMU, and give the actual motion path, which is what you appear to want;. |
|
|
curt2go
Joined: 21 Nov 2003 Posts: 200
|
|
Posted: Mon Oct 24, 2016 8:53 am |
|
|
Thanx. It seems I have some more work ahead of me. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|