-
Notifications
You must be signed in to change notification settings - Fork 18k
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
AP_OpticalFlow: Add initialization support for UPixels UPFLOW optical flow sensor #24187
base: master
Are you sure you want to change the base?
Conversation
uint8_t recv_buf[3]; | ||
|
||
//delay 100ms before initialization | ||
hal.scheduler->delay(100); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really a fan of delays in the init, this is called from the main thread. However, there are a few existing examples in rangefinder...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your feedback. I understand your concern about latency in the main thread, but this is to ensure the sensor is initialized correctly. It is necessary to wait 100 ms for the sensor to initialize after powering up. However, do you have any suggestions or a more elegant approach?
// if failed to receive response code, you can start over from 0xAA. | ||
if ((recv_buf[0] ^ recv_buf[1]) != recv_buf[2]) { | ||
UPFLOW_INIT_FAILED; | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens on this early return? We don't call init a second time, so does this mean the sensor never works ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens on this early return? We don't call init a second time, so does this mean the sensor never works ?
The reason for early return is that if the user inserts the LC302-3C, the sensor will not return any data during the initialization operation, and there is no need to continue the initialization operation. LC302-3C and other sensor versions that do not require initialization will not be affected.
The UPFLOW_INIT_FAILED macro is what I've set during debugging to monitor whether the initialization is successful or not in the ground station.
And I have conducted multiple tests using the Pixhawk 2.4.8 flight controller. For LC306 and LC302-8B, they can be initialized without any issues.
I followed the instructions in the data sheet and modified the code of the Upflow optical flow driver to support LC306 and LC302-8B modules. For more information, please refer to this issue: #23720