Hi, this is actually not in the arducopter program imo.
But if you don't want something very accurate, you could put your copter in a loiter state facing wind and monitor it's pitch angle. It would be quite easy to program a flight mode that automatically faces wind...
you can extract from this pitch angles and the yaw measure the horizontal force in both North/South and East/West directions if you know the weight of your copter.
Now, linking the force and the wind velocity will be much harder as it depends on your copter aerodynamism...
So, the easiest way would be to calibrate your copter (measure pitch angle for a known wind velocity - copter still facing wind!).
How to calibrate it? not very hard neither.
Wait for a very calm day (no wind at all) and apply different constant pitch angles during many seconds, wait for the stable velocity to be reached and you've got a couple of (pitch angle / copter=wind velocity). Do it for several pitch angles and you could draw the curve wind_vel= f(pitch_angle).
NB: Using the formula of the dynamic pressure won't be very accurate as the copter's aerodynamis changes with it's pitch angle.
This first solution is better as, because you have calibrated and found this curve, you have instant wind velocity and direction. But you have to calibrate it first, that is the disadvantage...
Second solution that would require to develop a more complicated program but:
- no need to calibrate your copter to get the wind_vel/pitch_angle curve
- disadvantage: you don't have instant wind_vel but 30-60s average one
step 1: copter loitering and facing wind to identify the wind direction and the average pitch required to face it.
step 2 : facing wind, apply constant pitch angle superior to the previous averaged one. wait for 10s to get stable velocity and average it for 5-10s (V1).
step 3 : change yaw heading by 180° to have the wind back but keep the same pitch angle. wait for 10s to get stable velocity and average it for 5-10s (V2).
step 4 : now compute the average of these both velocities to get the wind velocity Vwind = (V1+V2)/2
That 2nd method requires a constant wind or you may have wrong result so I would definitelly prefer the first one.
Hope this helps
Thank very much for your help.
Could give me this method in detail?
Basically, when you're loitering, apply yaw correction to get 0 roll angle.
stay loitering and compute a sliding average of pos_control.get_accel_target() x and y that tell you in which direction the copter is going (here, facing wind).
From the values of acc_x and acc_y, you can find the wind direction: eg acc_x = 10, acc_y=0 => wind comming from North.
X positive = north = Yaw 0°
X negative = South = Yaw 180° or -180°
Y positive = East = Yaw 90°
Y negative = West = Yaw -90°
and once you have the wind direction, send new yaw angle setpoint.
BTW what's the aim of it? that won't give an accurate result and consume a lot of energy compared to traditionnal wind sensors...
thank very much.
I have understanded the methord for measuring wind.It's very good.I need program mission planner.now I Compile the mission planner code,but there are many errors.I don't know the reason?Could you give me the mission planner code compiled?
Thank you very much.
my email addres:email@example.com
It's a good idea.
Directly measuring wind with copter is simply,but it really won't give an accurate result and ..than do you have any good idea?Does traditionnal wind sensors use pressure sensors?
I'm not sure you will get something working by modifying Mission Planner.
I thought rather of Arducopter code but before starting this, you should study the different possibilities. Maybe a sensor like anemometer would give better results and copter's code would be there just to identify wind direction.
But not sure anybody already setup an anemometer / APM... try googling it.