-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
SF45: Adjust _handle_missed_bins() logic #24248
Conversation
@MaEtUgR do you think this is conceptually better logic? If you have a better idea let me know! Otherwise I can flight test it in the next days. |
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.
You're onto something. I have to continue reviewing through, I didn't get through all the logic yet.
src/drivers/distance_sensor/lightware_sf45_serial/lightware_sf45_serial.hpp
Outdated
Show resolved
Hide resolved
src/drivers/distance_sensor/lightware_sf45_serial/lightware_sf45_serial.cpp
Outdated
Show resolved
Hide resolved
src/drivers/distance_sensor/lightware_sf45_serial/lightware_sf45_serial.cpp
Outdated
Show resolved
Hide resolved
src/drivers/distance_sensor/lightware_sf45_serial/lightware_sf45_serial.cpp
Show resolved
Hide resolved
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.
Good find, and nice cleanup along the way!
When filling the missed bins, the bin indices are temporarily re-numbered such that the 0th bin corresponds to the first bin which is within the FOV
That confused me for a moment, maybe you could instead just say that you loop from the indices always starting from the first bin within the FOV.
Minor comments. Please use const
wherever applicable.
src/drivers/distance_sensor/lightware_sf45_serial/lightware_sf45_serial.cpp
Outdated
Show resolved
Hide resolved
src/drivers/distance_sensor/lightware_sf45_serial/lightware_sf45_serial.cpp
Outdated
Show resolved
Hide resolved
src/drivers/distance_sensor/lightware_sf45_serial/lightware_sf45_serial.cpp
Outdated
Show resolved
Hide resolved
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.
Looks good now. Please clean up the commits into stand-alone functional changes or refactors, then good to go!
src/drivers/distance_sensor/lightware_sf45_serial/lightware_sf45_serial.hpp
Outdated
Show resolved
Hide resolved
src/drivers/distance_sensor/lightware_sf45_serial/lightware_sf45_serial.cpp
Outdated
Show resolved
Hide resolved
These functions help simplify repeated calculations accross driver and collision prevention files that are computing bins, angles and sensor offsets in obstacle maps.
To simplify logic for wrap-around cases and cases in which bins outside the FOV may be filled. Bin indices are offset such that the 0th bin is the first bin within the sensor FOV. This way we can always fill bins from smallest to largest index.
… to incoming sensor data. yaw_cfg is now read into the obstacle_distance message as the angle_offset. The offset is computed once at init and applied to each measurement.
7f5a6e1
to
2164a48
Compare
Solved Problem
When flying with the SF45 rotary lidar, the
_handle_missed_bins
function inlightware_sf45_serial.cpp
can fill bins in the obstacle map that are outside the sensor's FOV. This has negative consequences for the setpoint constraints that are set when flying withCollisionPrevention
. (For example: losing ability to move in direction outside of FOV)Data being added to bins outside the FOV & consequenctly not being able to pitch-up (move backwards):
![image](https://private-user-images.githubusercontent.com/61349849/406093501-6c2aa00e-7f6a-44b8-a071-b6451ebfbe89.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg3NzQ5NzYsIm5iZiI6MTczODc3NDY3NiwicGF0aCI6Ii82MTM0OTg0OS80MDYwOTM1MDEtNmMyYWEwMGUtN2Y2YS00NGI4LWEwNzEtYjY0NTFlYmZiZTg5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA1VDE2NTc1NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTA4YzAyNGJmZGI0N2UwM2Y0ODhlOWY2ZjZiZWJlNmNlY2Y1ZWIxYWEwMmIyNDBjNWM5ZDNkNTZhOTE4MDI4YjgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.cBdea2HiGrLk07ylJ0gl8fGiH_zcxEzG1iRDYP9t3bQ)
Solution
When filling the missed bins, we loop thruough the indices always starting from the first bin within the FOV. (see figure). We loop through these indices, but fill the obstacle map at the original bin indices.
This way we can handle cases in which the
current_bin
(in this illustration bin 6) andprevious_bin
(in this illustration bin 10) are near the bins which are outside the FOV. It also simplifies the logic such that we don't need to consider the wrap-around case.Relevant functions added to
ObstacleMath
library.Test coverage
ObstacleMathTest.cpp
Wrap around case.
![image](https://private-user-images.githubusercontent.com/61349849/406990776-9a59489a-8a05-423e-ac73-81c73c002a92.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg3NzQ5NzYsIm5iZiI6MTczODc3NDY3NiwicGF0aCI6Ii82MTM0OTg0OS80MDY5OTA3NzYtOWE1OTQ4OWEtOGEwNS00MjNlLWFjNzMtODFjNzNjMDAyYTkyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA1VDE2NTc1NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU1ZmRhOTIyOTM1NDRhNDY3YWJkYzU3ZmQzZTYyOGExOWIxYjE3YjdhY2VhODhhMmM5YWRiNmYyMDE3ZGVhNmQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.ShmeSzKz83tfBOkAubwS6gRYfWGP0vULEfsXfqmYNJM)
Bin jumps from 24 to 47. Shortest path to fill the missed bins would be through the bins not in the FOV (~ bins 32 - 40). But we can see that now we fill in the opposite direction. (Not all bins shown as it's messy)