Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gz] optical flow support #23456

Closed
wants to merge 1 commit into from
Closed

Conversation

dakejahl
Copy link
Contributor

@dakejahl dakejahl commented Jul 26, 2024

Opening this draft PR for review and testing

gz models branch
https://github.com/dakejahl/PX4-gazebo-models/tree/pr-rangefinder

@dirksavage88
Copy link
Contributor

dirksavage88 commented Jul 26, 2024

There is pretty much no drift on the textured world, but even on the lawn world it does drift a bit:

flowtestgz.zip

@dakejahl
Copy link
Contributor Author

I didn't realize gazebo sitl already had flow so I am going to update this to use the OpticalFlow repo
https://github.com/PX4/PX4-SITL_gazebo-classic/blob/main/src/gazebo_opticalflow_plugin.cpp
https://github.com/PX4/PX4-OpticalFlow

@dakejahl
Copy link
Contributor Author

@Jaeyoung-Lim I added the PX4/OpticalFlow in my latest commit. The performance is much worse, it just toilet bowls and wanders. Any ideas?

FYI for testing ensure EKF2_OF_CTRL is enabled and SIM_GPS_USED is set to 0 to ensure only flow is used for position hold.

@Jaeyoung-Lim
Copy link
Member

@dakejahl I would check the camera orientation if it toilet bowls

@dakejahl
Copy link
Contributor Author

@Jaeyoung-Lim The orientation looks correct. I think the issue is the noise, I was seeing this in my original implementation when poor quality keypoints are used in the flow average.
image

@dakejahl
Copy link
Contributor Author

@Jaeyoung-Lim I added the PX4/OpticalFlow in my latest commit. The performance is much worse, it just toilet bowls and wanders. Any ideas?

The issue was quality was -1 and wrapping to 255. I added a fix and it is a lot better now.

@dirksavage88
Copy link
Contributor

It's working. I think there was an issue with the libOpticalFlow in the cmakelist, it was working after I placed it further down in the camera folder's cmakelist, after add_library

@dakejahl
Copy link
Contributor Author

I'm not sure why but sometimes when sim is launched PX4 reports

WARN  [health_and_arming_checks] Preflight Fail: ekf2 missing data
WARN  [health_and_arming_checks] Preflight Fail: No connection to the ground control station	
WARN  [health_and_arming_checks] Preflight Fail: ekf2 missing data

And it never recovers

int quality = _optical_flow->calcFlow(gray_image.data, sim_time, integration_time, flow_x, flow_y);

return quality;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add a sensor plugin for an optical flow sensor, not calculate optical flow inside the gzbridge. Then it is not a bridge anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm yeah I was thinking about that. I need to figure out how to create a gz plugin that is launched with sim since it doesn't exist yet for gz

@dakejahl dakejahl force-pushed the pr-gz_optical_flow branch from f920d27 to 656ed73 Compare July 30, 2024 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants