Determining Orientation Off Vertical for Accelerometer Filtering Usage

The Rocketry Forum

Help Support The Rocketry Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

Javacat1

Member
Joined
Jan 10, 2020
Messages
19
Reaction score
11
Location
Chantilly, VA
I'm working as part of my university's Spaceport team to develop a SRAD flight computer to assist with experiment control and future use with an airbrakes system for hybrid motors. We're looking to use a mix of baro + accel + GPS for state derivation, and one of the key points is trying to determine vertical orientation for using the accelerometer as part of a kalman filter to determine altitude (among also being able to determine attitude).
I've read the Madgwick paper Here and also found these two threads: (1, 2) with information, but I'm struggling with making sure we're actually getting proper dynamics information out. Do y'all have any suggestions/places to look that may help?
 
1- once the rocket leaves the pad there is NO Earth direction reference for the Accelerometer
2- Madgwick and most other sensor fusion algorithms require the Accelerometer to have an Earth direction reference. These work great for an Earth based IMU like in Robots.
3- Therefore, one needs another method to determine vertical orientation. The most common is to integrate a Rate Gyro to absolute angle.

There has been much discussion here so do some forum searching and read the threads and paper linked to.
 
I'm working as part of my university's Spaceport team to develop a SRAD flight computer to assist with experiment control and future use with an airbrakes system for hybrid motors. We're looking to use a mix of baro + accel + GPS for state derivation, and one of the key points is trying to determine vertical orientation for using the accelerometer as part of a kalman filter to determine altitude (among also being able to determine attitude).
I've read the Madgwick paper Here and also found these two threads: (1, 2) with information, but I'm struggling with making sure we're actually getting proper dynamics information out. Do y'all have any suggestions/places to look that may help?
You need a gyro.
 
Magnetometer. Get a 9 DOF or 11 DOF (best) sensor chip.
 
Magnetometer. Get a 9 DOF or 11 DOF (best) sensor chip.
I'm curious how well you got a magnometer to work. Visualizing one with my rockets, I notice that as I rotate the rocket as it's pointing "up" it actually moves in a slight cone around my "up" vector. It might be interference from my onboard electronics (I've noticed the sensitivity of that magno is enough to be disrupted by just a wire covering the sensor), but ideally, it would keep the vertical axis aligned with my up vector as it experience rotation. Another person I talked with that made their own flight computer also had issues with getting accurate orientation from the magno, I think for similar reasons. They ended up using a gyro.
 
I'm curious how well you got a magnometer to work. Visualizing one with my rockets, I notice that as I rotate the rocket as it's pointing "up" it actually moves in a slight cone around my "up" vector. It might be interference from my onboard electronics (I've noticed the sensitivity of that magno is enough to be disrupted by just a wire covering the sensor), but ideally, it would keep the vertical axis aligned with my up vector as it experience rotation. Another person I talked with that made their own flight computer also had issues with getting accurate orientation from the magno, I think for similar reasons. They ended up using a gyro.
A magnetometer is useful for compensating for gyro drift. If calibrated (hard to do) it can give you tilt angle relative to the magnetic field vector but not the gravity vector. It will work to determine tilt if you launch from either the north or south magnetic pole.
 
Calibrating isn't hard, I have that down pat. Although, every guide I read on it is crap so it's evidently not well documented. The other thing is mangometers are really sensitive, so you ideally would recalibrate for each launch to account for variances from electronic or anomalous interference.

Basically, what I do is, take the min/max of each axis and then when using values from the magnometer I recalculate the magnometer as -1 to 1 on each axis based off the averages. Normalizing to -1 and 1 makes the data easier to understand rather than using the raw mGuass values I get from it. Then I do a calibration for it sitting upright (collect samples with the flight computer pointing upwards as it will be on the launch pad, and then average them into one sample for each axis) and a "forward" calibration by pointing the "up" direction of the avionics toward north to get the vector (same averaging of multiple datapoints). If it is outside the -1 to 1 range, the calibration is wrong or some other source of magnetism is interfering. I can DM you my calibration code if you like. It's currently made for reading input over serial from my flight computer or telemetry receiver but it should be easy enough to modify for anyone else's data structures.

The problem I have is getting an accurate attitude for each value (pitch, roll, yaw). When I hold my rocket upright (so pitch and yaw should stay the same) and rotate it about its length, instead of seeing the "up" axis of the rocket vector staying aligned with my calibrated up vector, it's offset by a few degrees and forms a conical path when I rotate the rocket (so roll only). I'll have to set up a small experiment to demonstrate it because I feel like I'm having a hard time describing the scenario with words.
 
Calibrating isn't hard, I have that down pat. Although, every guide I read on it is crap so it's evidently not well documented. The other thing is mangometers are really sensitive, so you ideally would recalibrate for each launch to account for variances from electronic or anomalous interference.

Basically, what I do is, take the min/max of each axis and then when using values from the magnometer I recalculate the magnometer as -1 to 1 on each axis based off the averages. Normalizing to -1 and 1 makes the data easier to understand rather than using the raw mGuass values I get from it.
What you are describing is hard-iron calibration, which is locating the center of the locus of mx,my,mz points in all the possible orientation of the magnetometer. An ideal magnetometer will have a locus that fits a sphere. A real magnetometer locus is an ellipse. You need to transform that ellipse into a sphere. That is soft-iron calibration. Both hard and soft calibrations will depend on the installation and surrounding magnetic field disturbing environment.

The determination of attitude from magnetometer data alone is not possible, if it were you would be able to buy tilt compensating compasses that just use a magnetometer. Those don't exist, tilt compensating compasses use a 3D accelerometer to determine the tilt plane of the magnetometer.

If you find a way to do it then patent it, it will make you rich,
 
Here are some references to code that might be useful for magnetometer calibration.

https://github.com/topics/magnetometer-calibration
Thanks for this, we're moving toward a gyro system now. Two things:
1) You wouldn't happen to know if 6DOF systems (Gyro+accel) have a maximum acceleration that the gyros can tolerate, do you? We're currently simulating a max acceleration of 28 g's and so a lot of IMUs don't have the necessary range, but would be cheaper to buy them for just the gyro function off of adafruit than some 3DOF gyros

2) Do you know of any reading specifically regarding mixing gyro with accel to form an absolute reference frame, or should I go bugging some of the department professors about it?
 
Yes, there are Specs in the Gyro chip Data Sheets with the Maximum of what the chip internals can take. A typical value (from MPU5060 acc/gyr chip) is 10,000g for 0.2ms. That equals a drop onto a hard floor.
Look up the data sheet for the chip you have. Not only Max ratings but all the details to properly use the chip.

Take a look at the sensors Adafriut has: https://www.adafruit.com/category/521

There some with higher Accelerometer range plus there are links to the data sheet in the detailed produce description.

Adafruit also has good code for these sensors and also great tutorials to get you going with both hardware and software.
 
Thanks for this, we're moving toward a gyro system now. Two things:
1) You wouldn't happen to know if 6DOF systems (Gyro+accel) have a maximum acceleration that the gyros can tolerate, do you? We're currently simulating a max acceleration of 28 g's and so a lot of IMUs don't have the necessary range, but would be cheaper to buy them for just the gyro function off of adafruit than some 3DOF gyros

2) Do you know of any reading specifically regarding mixing gyro with accel to form an absolute reference frame, or should I go bugging some of the department professors about it?
There may be some acceleration sensitivity on the gyro's, depends on the chip. I haven't seen an issue with the Invesense gyros I use.

You cannot use the acceleration data to provide a reference frame once the rocket is launched. Under thrust and drag there will always be a z-direction reading that will be confused with the gravity vector compensation regardless of the actual trajectory of the rocket. During cost and apogee all the acceleration axes will be close to 0 because the trajectory is ballistic.
 
Thanks for this, we're moving toward a gyro system now. Two things:
1) You wouldn't happen to know if 6DOF systems (Gyro+accel) have a maximum acceleration that the gyros can tolerate, do you? We're currently simulating a max acceleration of 28 g's and so a lot of IMUs don't have the necessary range, but would be cheaper to buy them for just the gyro function off of adafruit than some 3DOF gyros

2) Do you know of any reading specifically regarding mixing gyro with accel to form an absolute reference frame, or should I go bugging some of the department professors about it?
I’ve got the gyro code you need posted to my page on GitHub. PM me if you are interested and I can help you make it work

https://github.com/SparkyVT/HPR-Rocket-Flight-Computer
 
Back
Top