Open truongbuu opened 8 years ago
i agree with you @truongbuu
and i think you just add a few lines to initialize those variables
// intializing
float x_rate=0;
float y_rate=0;
float flow_x=0;
float flow_y=0;
am i correct?
Yes. And it seems like these lines should be:
float pixel_x = flow_x - x_rate; // mrad float pixel_y = flow_y - y_rate; // mrad
@truongbuu i tried the code as it's and only changed the initialization thing and when i test it it gives bad results so i just integrated the velocity from the "base" code and it's ok but i was wondering can i get the position (dx,dy,dt) from the PX4Flow please let me know what did you do to solve this?
@Mahmoud-Teama ` x_rate = sensor.gyro_x_rate_integral() / 10.0f; y_rate = sensor.gyro_y_rate_integral() / 10.0f;
flow_x = sensor.pixel_flow_x_integral() / 10.0f; // mrad
flow_y = sensor.pixel_flow_y_integral() / 10.0f; // mrad
if(quality>100){ float pixel_x = flow_x - x_rate; // mrad 0.8 alr float pixel_y = flow_y - y_rate; // mrad
// Scale based on ground dis and compute speed
// (flow/1000) * (ground_dis/1000) / (timespan/1000000)
move_x += pixel_x * ground_dis/1000000 -0.02*sin(x_rate/1000); // m sin is compensation for
move_y += pixel_y * ground_dis/1000000 -0.02*sin(y_rate/1000); // tilt the sensor
velo_x = move_x*1000000/timespan;
velo_y = move_y*1000000/timespan;}`
@Mahmoud-Teama By the way, you should filter to the data for getting better results. I use averaging of 10 and the result is quite nice.
@truongbuu , I've been trying to get this code/library working, and am having issues. Could you share your best functioning version?
Hi,
I have a question about the estimation program. What is the 0.02 constant multiplied to the sin function ? and why are you doing the gyro compensation here? I had a look into the firmware libraries and from the codes there I got the impression that the angular rotation is already compensated for in the final flow measurement results.
It seems like you havent initialize the type in pose_estimate.ino ` x_rate = sensor.gyro_x_rate_integral() / 10.0f; // mrad