Shop OBEX P1 Docs P2 Docs Learn Events
Propeller 9-DOF Experimenter board – LIMITED QUANTY — Parallax Forums

Propeller 9-DOF Experimenter board – LIMITED QUANTY

PhotronixPhotronix Posts: 16
edited 2014-10-14 14:56 in General Discussion
A few years ago Hoverfly developed a servo based gimbal controller called the HoverflyGIMBAL that performed well and was adopted by many multirotor filmers. As technology changes quickly this product had a short life as brushless gimbals came on the market. Well we still have about 80 of these boards in stock and not much hope of finding them a gimbal to actuate. So Hoverfly would like to make these surplus boards available to the Parallax community at far below their original retail value (and cost unfortunately).
Each board contains a Parallax Propeller, and ITG-3200 3-axis Gyroscope, ADXL345 3-axis accelerometer, and a HMC5883L 3-axis magnetometer. There are 3 transistor driven outputs for servo control and 3 inputs/outputs.

The Sparkfun Razor IMU is $74.95 including an ATmega328 and these same three sensors. We would like to make the HoverflyGIMBAL available to you for $70 including shipping.

Details:
-Parallax Propeller
-RGB LED
-Accepts from 5v-28v
-5V and 3.3V regulation (onboard jumper for greater than 6V operation)
-3 Digital I/O
-3 Transistor driven digital outputs (0 to 5V)
-ITG-3200 Gyroscope (connected via I2C)
-ADXL345 Accelerometer (connected via I2C)
-HMC5883L Magnetometer (connected via I2C)
-Demo SPIN program
-Micro USB with onboard FTDI (board can operate on USB power alone)
-Schematic

Use it to experiment with these three motion sensors or flash the gimbal firmware and build a gimbal.
Please visit our store to purchase your before they are gone forever.

http://www.shop.hoverflytech.com/products/hoverflygimbal-experimenter-board

Free standard shipping in the US until the end of September. Use code at checkout: XPBSHIP14

Al Ducharme
CEO and President
Hoverfly Technologies, Inc.
«13456

Comments

  • PhotronixPhotronix Posts: 16
    edited 2014-09-10 19:43
    I want to thank everyone that has ordered one of our 9-DOF Experimenter boards. As promised I have attached example code and the schematic.

    If you haven't ordered yours but are considering it....they are going fast.

    9DOFHoverflyExperimenterBoard.zip

    9DOFExperimenterSCH.pdf
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-09-11 01:30
    Any chance of a one axis code example of eliminating drift by combining the gyro output, the accelerometer output, and a Kalman filter? This might close the deal on some of us more timid shoppers.

    It doesn't even have to be a Kalman filter as I see there are other alternatives that might even be a smaller faster bit of code.
  • PublisonPublison Posts: 12,366
    edited 2014-09-11 07:47
    Al,

    Question. What is SensorDriver.cons in the SensorDriver.SPIN file?
  • PhotronixPhotronix Posts: 16
    edited 2014-09-11 08:17
    Publison wrote: »
    Al,

    Question. What is SensorDriver.cons in the SensorDriver.SPIN file?

    That was a mistake. Its now corrected. Please re-download the ZIP.
  • PublisonPublison Posts: 12,366
    edited 2014-09-11 08:38
    Thanks for the prompt reply Al!

    My order just went in.

    Jim
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-09-12 17:04
    Well, I ordered a couple yesterday, and I can already say I have learned more than I had imagined or expected.. just reading in anticipation of their arrival.

    9DOF may be more sensors than one really needs for 'most things', but having them available is assuring. I am beginning to wonder about pairing the yaw gyro with yaw compass for better tracking. Apparently the yaw accelerometer does not offer useful data under normal circumstances.

    I am already pondering if some of the i/o might interface an SDcard for more ambitious programs.

    Kalman filters seem not very feasible on microcontrollers, so other sensor fusion solutions are very interesting.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-09-12 19:27
    Whilst trying to figure out the maths side of using the HoverFly 9-DOF Exp. Bd, I came across an interesting object in OBEX.

    It seems to be a very helpful resource. 'General MEMS Sensor Model'.

    It seems that for data rates > 100Hz for a single sensor, a uM-FPU3.1 is deployed. I suppose that some of the i/o pins on the HoverFly might allow for that to be attached. It is SPI or I2C interface.
    http://www.parallax.com/product/604-00050
    http://www.micromegacorp.com/products.html

    http://obex.parallax.com/object/17
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-09-13 05:44
    I seem to have made a lot of progress on how to code these Nine Degrees of Freedom devices with the Propeller.

    Kalman filters are just too slow for the kind of real-time results that people want. Along came a newer filter, the Mahoney filter that applied to 6 DOF, and this has since been improved upon for 9 DOF devices (also called MARG).by Madgwick.

    Madgwick seems to have published a paper in 2010 that can be downloaded from the web that extended Mahoney's 6DOF solution to 9DOF. But the best part is that he provided C code for both 6DOF IMU devices and 9DOF MARG devices,

    So this seems to be a very good fit with the HoverFly Experimenter's Board. One can begin with either Catalina C or SimpleIDE/gcc. It may work well without a FPU.

    Not only is the performance excellent, the configuration is far less involved than Kalman filters.

    .Samples at rates >2000Hz may actually be feasible.
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-09-13 18:08
    I got my hoverfly board in the mail today. It's a very nice looking board. I plugged it into a USB port on my computer, and once my computer loaded the appropriate driver I was able to view the serial output in PST. It displayed the raw outputs from the accelerometer, gyro and compass. It looks like it should be fun to play around with. I might finally get back to working on my finless rocket with a gimbaled motor mount.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-09-14 02:50
    Well, we have another thread going that is pretty heavy into tracking down leading-edge code using Madgwick.

    What I provided is just the beginning code and it apparently has been much improved. One site openly declares that Madgwick is open-source, so that should ease some concerns.

    Everything seems to have been developing in C with testing on Arduino or Arduino clones. It would be nice to see a Propeller solution entering the arena. It should perform comparatively well and there has been at least one blog that has demonstrated that both code and processor speed can significantly enhance Madgwick.

    I have high hopes that the Propeller will have Cogs left over for PID motor control.

    You might want to purchase a cheap Bluetooth interface from DealExtreme for initial development.
    http://www.dx.com/p/jy-mcu-arduino-bluetooth-wireless-serial-port-module-104299
    That would allow you a wireless link to a desktop computer which would display your data graphically.


    http://www.x-io.co.uk/open-source-imu-and-ahrs-algorithms/

    http://mbed.org/users/aberk/code/IMUfilter_HelloWorld/
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-09-15 21:42
    My HoverFly order arrived today.. all seems in good order. I still have to power them up. Nice big mounting holes look like I can use rubber grommets to absorb some vibration.

    This offer is only until the end of September... there is still time if someone wants one.

    Heater came up with more recent and up-to-date links for Madgwick code. What I posted above was his first proof of concept, works but very conservative hardware setup. Some flaws have been removed and it now runs faster, reputed to run up to 5000Hz if everything is right.

    I only need about 250Hz. And for quadflyers, 200Hz seems acceptible.

    Spent a bit of time today learning about the differences between the Kalman filter, the Complimentary filter, and the Mahoney and Madjwich (which are close together). Also tried to fill in gaps on my knowledge of matrix mathematics, though one doesn't need all of that to get this working.

    ====
    On a more practical note, I see the Hoverfly 18 pin output is really set up with only 6 i/o connections. All i/o to the Propeller has 10K resistors which with protect the Propeller if inputs are 5V logic.

    Of the six, 3 deliver only 5V output, and 3 can go either 3.3V output or 5/3.3V input.

    My situation is that I need 4 outputs to run an L293 Twin H-bridge. So I guess I will use the 3 dedicated 5V outputs and adapt one of the others witha transistor to do the same. It is not a big chore.

    That will leave me with 2 i/o for other stuff, maybe an ADC chip for multiple IR collision avoidings. It seems 16 i/o on the Propeller remain unavailable. None the less, it is possible to use what you have to drive a quad-copter or fixed-wing aircraft and maybe include a GPS device.
  • PublisonPublison Posts: 12,366
    edited 2014-09-16 11:38
    Mine seems to work fine with the loaded code. It seems to be the same code in Post #2. I tried to load the code from the HoverFly site for the HoverFlyGIMBAL, but that might be for the new brush-less version board.


    (From the Spin file)
    This object provides data from ITG3200, ADXL345, and HMC5883L sensors.
    Data is update at a rate of 200Hz for the ITG3200 and ADXL345 and 50Hz for the HMC5883L

    HoverFly PST.jpg


    Like it says in the file, move it around for some groovy colors from the RGB LED. :)
    655 x 368 - 92K
  • JasonDorieJasonDorie Posts: 1,930
    edited 2014-09-16 16:21
    I just bought two of these. It'll take a while, but I'm going to see if I can make it "pair" with a HoverFly sport or open board. If this board does all the IMU and sensor calcs, and just pushes the result to the main board using a fast RS232 or Beau's high speed comm object, it should leave a bunch of cogs left for doing extra work.

    I envision the cog workload laid out like this:

    Main:
    - Main flight control
    - Read remote inputs
    - Run motor outputs
    - Comm object
    - Serial debug channel
    - extra : SD data logger (?)

    Gimbal:
    - Read all sensors
    - DCM IMU code
    - Float math
    - Comm object
    - extra : altimeter ?
    - extra : GPS ?

    My existing DCM solution is at the point where it either needed a PASM rewrite or a 2nd chip to make it work, and I was already leaning toward the 2nd chip, but not looking forward to setting up another set of boards. This should make a nice shortcut.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-09-16 22:22
    Looking forward to hearing more about your project.. just getting started with all this.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-09-17 01:27
    Publison wrote: »
    Gyro does 200Hz, and acel and compass at 50Hz.

    In the back of my mind, I have been looking and those figures and a bit concerned. I think I need to have 200Hz iterations to my motor control.

    It seems I could fudge a bit and provide good Gyro updated on every cycle while providing the Acel values 4 times before revision. Any comments?
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-09-17 05:21
    According to this
    Data is update at a rate of 200Hz for the ITG3200 and ADXL345 and 50Hz for the HMC5883
    the readings from the accelerometer are updated at 200Hz, and not 50Hz. I haven't looked at the code to determine if that is correct.

    Loopy, 200Hz should be more than enough, and 100Hz is probably sufficient, though faster is better. Probably the biggest limiting factor in your control loop will be the slew rate of your motors.
  • Heater.Heater. Posts: 21,230
    edited 2014-09-17 05:35
    Loopy,

    For what application do you need a 200Hz iteration rate?

    If it's for a balancing bot my gut feeling is that 50Hz is a plenty fast enough sample rate.

    My reasoning is that one only needs to sample at twice the expected bandwidth of the system you are trying to control. Nyquist and all that. Perhaps 3 of 4 times faster for good measure.

    So, how fast to we expect the bot to be moving under the influence of gravity and it's drive motors? Certainly not up in the hundreds of hertz.

    Anything above that frequency is just noise, motor vibration for example, and not contributing anything to the accuracy of control.

    Having said that if I were using analogue sensors I would filter their output to a 10 or 20 hertz bandwidth before they entered the control circuitry. To get rid of the noise. Similarly when using digital sensors it may be beneficial to sample them as fast as they can go and digitally filter that sample stream down to the required 10 or 20 Hz.

    So actually perhaps it's better to do the opposite of what you suggest. Read the gyro at it's 200Hz rate, filter than down to a 50Hz roll off, a moving average, and combine that with the 50Hz accelerometer rate. Run the control loop at 50Hz. All in nice lock step.

    The nbot, for example, runs it's control loop at 20Hz.

    I have not thought about copters but again it would surprise me if a 200Hz control loop rate were required especially for big machines. How fast can you change the speed of the motors for example? I don't think you can noticeably cycle the thrust at 200Hz if only due to rotor and blade inertia. Anyone done any tests on this?

    Or do you mean actual motor control? (As opposed to the higher level attitude control). That may be a slightly different issue. But again my guess is ample rate requirements are dictated by the response of the system, motors, wheel inertia etc.
  • Dave HeinDave Hein Posts: 6,347
    edited 2014-09-17 05:55
    Another thing to consider is the fundamental time constant of the system you're trying to control. It's much easier to balance a tall object than it is a short one because of the longer time constant. Just try balancing a pencil versus a broomstick in your hand. You will see that it's virtually impossible to balance a pencil, but it's fairly easy to balance a broomstick. That's because the broomstick has a much longer time constant than a pencil does because it has a longer moment arm. Gravitational acceleration is the same for both of them, but it takes more time for a broomstick to fall over than it does a pencil due to their lengths.

    Controlling the gimbaled rocket motors on the Saturn V was "easy" compared to trying to do it on a small model rocket. Because the Saturn V was over 300 feet long it would take several seconds for it to fall over. So the time constant is on the order of seconds, and relatively slow hydraulic cylinders were used to position the rocket motors. A small model rocket will fall over in less than a second, so the actuators must react must faster -- on the order of 10s of milliseconds.
  • PublisonPublison Posts: 12,366
    edited 2014-09-17 07:29
    Dave Hein wrote: »
    According to this the readings from the accelerometer are updated at 200Hz, and not 50Hz. I haven't looked at the code to determine if that is correct.

    Loopy, 200Hz should be more than enough, and 100Hz is probably sufficient, though faster is better. Probably the biggest limiting factor in your control loop will be the slew rate of your motors.

    Thanks Dave. That was a typo. Fixed my post.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-09-17 09:30
    Thanks for all the input... I just started out with a document that mentioned that balancing bots need 200Hz motor updates. Youall have provided a more refined explanation.

    I got excited with one blog that claimed 5000Hz updates was feasible with Madgwick filters, but I guess that was done with input from a data file rather than real world sensors.

    I don't need to push the device to race horse break neck limits. I just want to get started with some realistic figures. And even then, I suspect some of you are far ahead of me with all this. I will try to learn at my own pace, and maybe help other slow pokes to move ahead.
  • Heater.Heater. Posts: 21,230
    edited 2014-09-17 09:59
    Do you have a link to that document you are reading? I'd be interested to see if the is any justification for that 200Hz update rate in there.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-09-17 10:07
    Heater. wrote: »
    Do you have a link to that document you are reading? I'd be interested to see if the is any justification for that 200Hz update rate in there.

    As best as I can recall, there was no justification --- I just made a mental note that the project seemed successful and worth emulation. It may well have been the analog balancing bot in Dale's Homegrown Robots.

    Now that I have been assured that slower rates will suffice for just about any project one might desire with an IMU, I can let it go.
  • ratronicratronic Posts: 1,451
    edited 2014-09-17 10:52
    I ordered one of these as Jason's DCM code uses the gyro and acc. from this board. I am one of the slow pokes that will be trying to keep up with Loopy,
  • Heater.Heater. Posts: 21,230
    edited 2014-09-17 11:54
    Loopy,

    Dale's bot is analog so there is no idea of sample rates in there. Looking at his schematic I don't see any filtering of the the accel and gyro inputs so I guess the whole system is operating at whatever the bandwidth is achieved by the sensors, op amps, motors, masses combination. That is limited by the lowest bandwidth item in the loop which the mechanical stuff so guess it's a few tens of hertz.

    Where running the control loop at too high a rate, or having too much bandwidth if it is analogue, might hurt is when there is noise on the sensors. Motor vibrations or general thumps and bumps of riding over rough terrain say. Then you end up controlling according to a signal that is not really relevant to the attitude control job at hand.

    I can't really offer a more refined explanation for my feeling that a high repetition rate of the control loop is pointless if not detrimental. It's just that if the forces and masses involved in the mechanics of the thing mean that it cannot physically be made to oscillate meaningfully above a certain frequency then there seems to be no point in trying to control it at frequencies orders of magnitude above that.

    However, at risk of seeming to contradict myself, perhaps it is better to run that Madgwick filter at as high a rate as the sensor inputs can deliver or your processor will allow. The filter's job is to merge gyro, accel and magnetometer data into single orientation. My first guess is that it would be better to allow that filter to chew on as much data as you can feed it. Throwing information away can't be good right?

    Thing is I don't see that it is necessary that the filter and the attitude control loop all run at the same iteration rate. They are different subsystems. Perhaps "over sampling" at the input and filtering is a good thing.

    On the other hand Madgwick himself says that the filter did not work noticeably better at high frequencies. I don't know what the limits are there. Is it the accuracy or bandwidth of the sensors themselves?

    It may well be the best way to find out is to build the bot and implement ones best guess at a control system given the information we have available. It would be great to be able to tweak around with iteration rates and see what the reality about them is.

    I'm going to read the Madgwick paper again. Not that I stand a chance of understanding 99% of it but his conclusions are interesting. That should get me to sleep tonight.
  • JasonDorieJasonDorie Posts: 1,930
    edited 2014-09-17 13:26
    In my code, I was initially running the sensor loops at 2000hz because I was doing integration, and figured that the integration would be more accurate (hence less drift) if it was done as fast as the sensors allowed. The actual flight code was done at 250hz (or 200hz in the DCM version). I didn't notice a difference between 200 and 250, other than having to tune my PID values a little differently (which is expected when your 't' value changes).

    The justifications I've seen for running a high-speed control loop vary. The systems tend to have some built in latency, so if you read your sensors, then do some calculations, then send some servo output values, with a 50hz update, it might actually be 25hz (2 loops) by the time your sensor readings start affecting the motors. With a 200hz update rate, the time gap between when you take a reading and when it's applied is much smaller, which can lead to a "tighter" control feel. This would be much more relevant on small quads, or quads with variable pitch props, or quads using UltraESC or similar high-rate controllers. On a larger quad using normal motor controllers it's probably wasteful to run the flight code above 100hz, but I haven't tested that. :)
  • Heater.Heater. Posts: 21,230
    edited 2014-09-17 13:54
    Jason,

    Interesting, thank you.

    What size is your copter? How heavy is it?

    It's not clear to me how upping the control iteration rate helps overcome the latency, mostly in spinning up and down the motors I would guess, at least past a certain point. But I can't argue with real world experience.
  • JasonDorieJasonDorie Posts: 1,930
    edited 2014-09-17 14:00
    Mine have typically been about the size of the Elev-8. I've done one significantly larger, and one significantly smaller, too - The small one was less than a foot in diameter, less than 500g total weight, and would fly for 20 minutes on a 3-cell 2000mAh battery. It's very responsive, because the mass is so little - The motors change speed much faster than a larger quad.

    MicroQuad.jpg
    720 x 960 - 91K
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-09-18 00:19
    @JasonDorie
    Welcome ... I noticed that you have been a contributor to DIY Drone and the 2011 Propeller DCM thread -- both very helpful.

    @Heater
    I don't keep copious notes, I just print to PDF whatever on the web seems a worthwhile reference. So I can't quite locate the 200hz motor control rate. Dale's analog balancing computer has a triangular wave generator that may be 200Hz.

    In any event, it occurred to me that fixed wing R/C airplanes have long done very well with servos that update at 50Hz. And there have been successful balancing bots using continuous rotations R/C servos. So I am no longer concerned with pushing data rates to higher extremes.

    +++++++++++
    The maths in Madgwick has been a very interesting research project.

    I needed to get up to speed with a general background on matrix maths and determinants, especially with a focus on square matrices and in combination with vector maths. I happen to have a hard copy of 'A History of Mathematics, 2 ed.'; Boyer, Merzbach; so I have been using that to help out... and it has.

    Matrix maths is part of 'modern algebra' and most of the development has been done since the 1800s. Traditionally, it was thought there as one and only one algebra - the real number algebra that is faithfully taught in high school. But with matrices, that began to be challenged, and C.S. Peirce managed to demonstrate that as many as 162 algebras were possible, and that all but 3 were not really worth considering as 'true algebras'.

    The three that were worthwhile were: [a] real number algebra; complex number algebra (known for representing the imaginary number components and widely used in electronics); and [c] quaternion algebra (which is very handy with vectors and applies to a Jacobian matrix),

    So it seem that quaternion algebra eliminates the use of more computing burden than trying to apply trig and angles.

    There is a lot of interesting history as the maths were developed so recently and represent a core subject for 'rocket science'. C.S. Pierce was rather notorious as he got kicked out of John Hopkins University for refusing to give up his live in lady friend while still married to his first wife. http://en.wikipedia.org/wiki/Charles_Sanders_Peirce He had gotten into Harvard by publishing and extending work on matrix maths that his father had started, much of what put Harvard into the same class as British and German universities that were leading in the subject. But C.S. Pierce went off the deep end with a mystical pursuit of the idea that everything could be represented in Threes. He even contributed a major concept to Linguistics and Semiotics in terms of three categories of symbolic representation. But in the end, nobody wanted to fit the whole world into patterns of threes, so he ended in disrupt.

    Nonetheless, his Three Algebras seem to be core to representing the physical world and moving through it. So I am very interested to learn more about Quaternions, and the 3rd algebra. I wasn't aware of how significant this was. It seems to have been what triggered Pierce's mystical passion for three-ness.

    Since the output of the Madgwick filter is a Quaternion format, there is a necessary step in converting that output to useful motor response in computer code. Apparently the is a desire to move from that to a Cosine matrix. I haven't gotten into that yet. It is in 2011 thread in the Propeller forum under the heading of Propeller DCM (Directional Cosine Matrix). That brings you back into Roll, Pitch, and Yaw from the Quaternion format.

    It is all a very interesting puzzle. I suspect the same maths are very useful for study of the motions of sub-atomic particles or astronomical observations. In fact, there are some astronomers of note involved in the history of matrix maths.

    So... by playing with programing a quad-copter, one may actually be acquiring kit for a career in serious study in leading edge science research. We still have a lot to learn about what the lowly electron does and why some materials are ferromagnetic while their alloys and other materials resist being ferromagnetic. Some of this may apply to charged particles.
  • Heater.Heater. Posts: 21,230
    edited 2014-09-18 01:08
    Loopy,
    ...it seem that quaternion algebra eliminates the use of more computing burden than trying to apply trig and angles. ...I am very interested to learn more about Quaternions...
    Strangely enough I did not read myself to sleep with the Madgwick paper but noticing that it's output is a quaternion ended up distracted by this "what on Earth is a quternion?" question.

    I found this great lecture about Quaternions by Dr Bryan Duggan of the Dublin Institute of Technology.
    https://www.youtube.com/watch?v=LB6U849kwXc&list=UUyCtwxWozKoX3iMd75S3N1g
    It's part of a game developers course. The lecture does not go deep into Quaternion maths but covers everything we need to know to use them. Check out the brilliant "Quaternion Poem".

    Then the is this nice intro to quaternions: https://www.youtube.com/watch?v=dttFiVn0rvc&list=PLW3Zl3wyJwWNWsJIPZrmY19urkYHXOH3N from Jorge Rodriguez https://www.youtube.com/user/BSVino.

    Seems the game developers are learning all that useful maths we need to fly quadcopters and balance bots in the real world!
    Since the output of the Madgwick filter is a Quaternion format, there is a necessary step in converting that output to useful motor response in computer code.
    I found a way to convert a Quaternion into Euler angles here: http://mbed.org/users/aberk/code/IMUfilter/file/8a920397b510/IMUfilter.cpp Note: that the actual Madgwick filter in there is the buggy one that produces NaNs.
    void IMUfilter::computeEuler(void){
     
        //Quaternion describing orientation of sensor relative to earth.
        double ESq_1, ESq_2, ESq_3, ESq_4;
        //Quaternion describing orientation of sensor relative to auxiliary frame.
        double ASq_1, ASq_2, ASq_3, ASq_4;    
                                  
        //Compute the quaternion conjugate.
        ESq_1 = SEq_1;
        ESq_2 = -SEq_2;
        ESq_3 = -SEq_3;
        ESq_4 = -SEq_4;
     
        //Compute the quaternion product.
        ASq_1 = ESq_1 * AEq_1 - ESq_2 * AEq_2 - ESq_3 * AEq_3 - ESq_4 * AEq_4;
        ASq_2 = ESq_1 * AEq_2 + ESq_2 * AEq_1 + ESq_3 * AEq_4 - ESq_4 * AEq_3;
        ASq_3 = ESq_1 * AEq_3 - ESq_2 * AEq_4 + ESq_3 * AEq_1 + ESq_4 * AEq_2;
        ASq_4 = ESq_1 * AEq_4 + ESq_2 * AEq_3 - ESq_3 * AEq_2 + ESq_4 * AEq_1;
     
        //Compute the Euler angles from the quaternion.
        phi = atan2(2 * ASq_3 * ASq_4 - 2 * ASq_1 * ASq_2, 2 * ASq_1 * ASq_1 + 2 * ASq_4 * ASq_4 - 1);
        theta = asin(2 * ASq_2 * ASq_3 - 2 * ASq_1 * ASq_3);
        psi = atan2(2 * ASq_2 * ASq_3 - 2 * ASq_1 * ASq_4, 2 * ASq_1 * ASq_1 + 2 * ASq_2 * ASq_2 - 1);
     
    }
    
    That at least gets you the angle of tilt of a balancing bot to use.
    ...by playing with programing a quad-copter, one may actually be acquiring kit for a career in serious study in leading edge science research...
    Yes indeed. Turns out that when we put man on the moon NASA did not use quaternions in the navigation/guidance systems. As a result they had to have big red warning messages when the Lunar Lander system got into attitudes the "old" maths could not handle (gimble lock). The usefulness of quaternions has only been discovered relatively recently. Certainly it was not covered in any of the maths we did back in uni in the late 1970's.

    Too late for a career change for me but I must say Loopy, you do have a way of finding juicy challenges for this old brain. Fascinating.



    P.S. Do check out the young Dr Sebastian Madgwick himself demoing his IMU/AHRS here :https://www.youtube.com/watch?v=BXsGWoOMtmU&list=UUZdLJBtwk1MK7lxG_xRHI2Q and here https://www.youtube.com/watch?v=ZYyyaJgKsDg&index=29&list=UUZdLJBtwk1MK7lxG_xRHI2Q he has a ton of other interesting videos there as well.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2014-09-18 01:32
    Methinks the YouTube show and tell will not suffice.

    http://3dgep.com/understanding-quaternions/

    One must wade through algebra and complex numbers to get to quaternions.
    At least I have found what a tuple is useful for in computing - both complex numbers and quaternions tend to rely on paired values.

    (I also came across some work on octonions (aka biquaternions http://en.wikipedia.org/wiki/Biquaternion), but I strongly suspect they will only be useful for jumps thorugh hyperspace. I will set that aside for now.

    =========
    Too late for a career change? I am 66 with a Bachelors in Fine Arts and an incomplete Masters in TESOL. You just have to have the desire and the knowledge will unfold.

    BTW, Sir William Rowan Hamilton is credited with the creation of quaternions, Charles Sanders Pierce just extended the recognition of their usefulness.

    Once again, we see that if you want to be truly famous -- become a mathematician... long remembered after the world will have forgotten Lady Gaga.

    ++++++++++
    Most amazing is I am actually beginning to be able to visualize what this stuff does.. a very big WoW.
Sign In or Register to comment.