Get linear velocities from accelerometers

Discussions and questions about the Crazyflie Nano Quadcopter
Post Reply
carrilho.meister
Beginner
Posts: 4
Joined: Wed Nov 05, 2014 3:43 pm

Get linear velocities from accelerometers

Post by carrilho.meister »

Hi!

First of all I'd like to compliment the crazyflie developers for the very nice work!

I have both CF 1 and CF 2 and I think they're quite good development platforms.

I'm working on a proposal for an attitude stabilization controller for the CrazyFlie.
I plan to use a technique called "reachability analysis" to improve the robustness of the controller.
I need to implement the designed controller and collect flight data for my experiments.

I'd like to know if someone could indicate some nice material on how to get the linear speeds, with respect to the body frame, from the signals of the accelerometers.

I've seen that there is a function to get the vertical speed in the firmware that uses the quaternions, but I'd like to get the three components of the linear velocity.

All the best regards,

Eduardo
poizone
Member
Posts: 59
Joined: Thu Feb 05, 2015 3:59 am
Location: Ohio, USA

Re: Get linear velocities from accelerometers

Post by poizone »

Pretty sure this is just some basic physics. Accelerometers measure changes in acceleration. If you know the starting velocity and acceleration, then changes in acceleration have the change in velocity built in, and the linear velocity is simply a set of three one dimensional vectors. All this data could be generated with equations found in a college physics textbook and a google search or two.
One day our flies will drown out the sun in an autonomous Skynet of whirring motors and blinking lights.
carrilho.meister
Beginner
Posts: 4
Joined: Wed Nov 05, 2014 3:43 pm

Re: Get linear velocities from accelerometers

Post by carrilho.meister »

Hi poisone,

I think it's a little bit more tricky, accelerometers measure some specific acceleration that includes the gravitational acceleration.

It seems for me that we have to manipulate the measures from the accelerometer along with the readings of the angular rates to get the acceleration.

In "sensorfusion6.c", the function "sensfusion6GetAccZWithoutGravity" gets the vertical acceleration using also the quaternions. I'd need also the values of the other accelerations, not only the vertical one.

I've seen this in the "Beard Quadrotor Notes" and the accompaining material "French Paper":

http://rwbclasses.groups.et.byu.net/dok ... 0-11papers

Cheers,

Eduardo
Greensprings
Member
Posts: 30
Joined: Sat Feb 07, 2015 11:32 pm

Re: Get linear velocities from accelerometers

Post by Greensprings »

F=M*A
poizone
Member
Posts: 59
Joined: Thu Feb 05, 2015 3:59 am
Location: Ohio, USA

Re: Get linear velocities from accelerometers

Post by poizone »

carrilho.meister wrote:Hi poisone,

I think it's a little bit more tricky, accelerometers measure some specific acceleration that includes the gravitational acceleration. It seems for me that we have to manipulate the measures from the accelerometer along with the readings of the angular rates to get the acceleration. In "sensorfusion6.c", the function "sensfusion6GetAccZWithoutGravity" gets the vertical acceleration using also the quaternions. I'd need also the values of the other accelerations, not only the vertical one.

I've seen this in the "Beard Quadrotor Notes" and the accompaining material "French Paper":
http://rwbclasses.groups.et.byu.net/dok ... 0-11papers

Cheers,
Eduardo
Yes, they do include gravity, but only when calculating the vertical acceleration. X and Y dimensions will not include gravity once calculated. Any 3 dimension problem involving gravity is simply 3 one dimensional problems where gravity acts on only one of the dimensions, as explained by basic physics using vectors. You can calculate all of these from the three vectors given by the accelerometers, but you'll need to write these yourself. This codebase, while functional, isn't something I'd call fully featured. It's hackable and useable, yes, but a lot of that means writing application specific code. We don't have a function to return the velocity in the X and Y dimensions, so by all means, write them and submit a pull request to get them added to the main branch.

If you're unfamiliar with 3-dimensional physics, start here to understand the 2D physics first. The 3rd dimension is simply another horizontal dimension unaffected by gravity, and the calculations are intuitively similar to the 2D vector physics described in the link.
One day our flies will drown out the sun in an autonomous Skynet of whirring motors and blinking lights.
carrilho.meister
Beginner
Posts: 4
Joined: Wed Nov 05, 2014 3:43 pm

Re: Get linear velocities from accelerometers

Post by carrilho.meister »

Hi poisone and others,
It would be better if you call me stupid directly.
But I'll help you, once and for all:
The above thread of messages is a proof that I AM STUPID!
Thanks,
Eduardo
poizone
Member
Posts: 59
Joined: Thu Feb 05, 2015 3:59 am
Location: Ohio, USA

Re: Get linear velocities from accelerometers

Post by poizone »

We aren't calling you stupid, just trying to get to the root of your problem. I didn't understand how acceleration, velocity, and position related to each other mathematically for a very long time. Those basic equations are all sorts of useful when it comes to quads, but our codebase isn't as mature as some like cleanflight or baseflight. This means features you might expect for development aren't available. The original CF1 had no altitude hold, and attitude was a bit touchy. We want to be an open and inviting community, because half the additions to the codebase are from the community.
One day our flies will drown out the sun in an autonomous Skynet of whirring motors and blinking lights.
carrilho.meister
Beginner
Posts: 4
Joined: Wed Nov 05, 2014 3:43 pm

Re: Get linear velocities from accelerometers

Post by carrilho.meister »

Dear crazyflyers,
I've realized that I'm not stupid at all!
I've found what I was needing to understand about accelerometers in this paper:
http://www.et.byu.edu/~beard/papers/pre ... eard__.pdf
It's worth of reading if you really want a nice usage of accelerometers.
Cheers,
Eduardo
yuyangch
Beginner
Posts: 1
Joined: Fri May 27, 2016 10:45 pm

Re: Get linear velocities from accelerometers

Post by yuyangch »

I think OP definitely understand the basic physics among distance, velocity and acceleration.
what he is referring to is the translational error calculated purely from its accelerometer. It is accumulated from double integrating accelerometer data.
the paper he linked showed one way to compensate for such error, by considering drag force vs velocity acting on the crazyflie.
Post Reply