Hi there, I’m doing a project to make drone hovering indoors. I use my own FPGA board and write the flight controller code refering to pixhawk opensource.So far, I can fly the FPGA drone manually and the drone can hold its altitude by using ultrasonic, but the drone still drift left and right.
So I use px4flow to measure the vx(flow_x) and vy(flow_y) of the drone. I hope I can use px4flow to achieve hovering, but the raw output of flow_x and flow_y read from px4flow seens unstayble. The value changes a lot if vibrating the sensor. I wonders how pixhwak flight controller deals with the px4flow raw output value?
Are there any suggestions or reference opensource code?
Hi, what we do in PX4 is to remove the optical flow generated by the angular velocity of the drone (using gyro data) and then fuse the result into an Extended Kalman filter (named EKF2 in PX4) as an aiding source to get a velocity estimate.
Do you already have an EKF onboard to estimate the attitude of the drone?
If you just have a complementary filter to estimate the attitude of your drone, you can then just make another simple complementary filter using the accelerometers and the optical flow (scaled by the range finder) to get a smoother velocity estimate in body frame.
Sorry for the late reply. I didn’t notice the notifications.
So PX4 only takes the pixel_movement calculated by px4flow,and scaled it by another rangefinder to transform the pixel_movement into velocity in real word.Later, PX4 feed the velocity in EKF2 to get a better predicted velocity, and the velocity value is then feed into the PID system to let the drone hover. For example, if the velocity is positive, the PID system would tell the drone to fly back. Is that correct?
What if the drone rotate around the z axis (yaw drift). Assume the pitch and roll angle is zero. From my understanding of px4flow, the optical_value would change since the picture px4flow takes is also rotating. Does the gyro compensation in PX4 also takes yaw rotation into consideration or it only takes pitch and roll compensation?
If the sensor is centered, there is no compensation to do for a yaw rate because the xy flow is null. If the sensor isn’t on the Z axis of the body frame you can specify EKF2_OF_POS_X/Y/Z and EKF2 will compensate for the XY flow generated by a yaw rotation of the drone.
What I want to do is provide the PID system a more accurate x y velocity, so it seems how EKF2 compensate for raw optical flow read from PX4Flow is important for me.