I want the copter to hover over a black circle, but the ground is a blank floor with no texture. How can I use the accelerometer parameters to calculate the speed of the aircraft without using the optical flow to control the stability of the aircraft?

Hi @Shuo_Chen

You can’t get ground speed or air speed from accelerometer but you can calculate swing speed of craft.

You need to integrate acceleration to get the velocity.

v(t)=∫tt=0a.dt

There are a number of ways of doing this numerically.

I assume that you get these readings regularly with a spacing of δt , for example δt=100ms

or something like that.

About the simplest way to do it is

v(t)=v(0)+∑a×δt

where v(t) is the velocity at time t

but there are more sophisticated ways of doing it - I will not repeat them here, but you might want to look at using Simpson’s rule, which is described here.

The problem is complicated by velocity being three dimensional - so you need to integrate in each of the three dimensions x, y and z separated.

It depends how the craft gives you the information about the acceleration, but if you get ax, ay and az

at regular intervals then you can do the following…

```
vx += ax * dt;
vy += ay * dt;
vz += az * dt;
```

if you get accleration as a raw number and angle then you will have to convert from I guess polar coordinates to xyz components to be able to add them up.

Total speed, |v| is, of course, given by

|v|=√v2x+v2y+v2z

I would, of course, try to start at v=0

Curious One, raises a really interesting point about g- the best way to test this is to code it and try it - shake the craft and see if the velocity returns to zero when it is at rest after shaking it or moving it…