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

Kinetic/fix/vertical fov bug #266

Open
wants to merge 12 commits into
base: kinetic-devel
Choose a base branch
from

Conversation

yShzZpp
Copy link

@yShzZpp yShzZpp commented Jul 13, 2023

Subject: Pull Request: Modification for spatioTemporalVoxelLayer

Dear Steve,

I hope this message finds you well. I am submitting my first Pull Request for your repository, [Repository Name], and I would greatly appreciate your review and consideration. I have made modifications to the code related to the usage of the spatioTemporalVoxelLayer, as I encountered compatibility issues with the kinetic version of the library when using a Livox radar.

The Livox radar has a field of view (FOV) ranging from -7° to 53°. However, the existing code simply divides the FOV by two as a parameter, resulting in an incomplete clearance of the costmap in the upper half, while the lower half is cleared properly.

To address this issue, I have made the following modifications to the code:

Replaced the "vertical_fov_angle" parameter with two parameters: "vertical_fov_start_angle" and "vertical_fov_end_angle." This allows for accurate definition of the vertical FOV range and resolves the clearance issue.
I have thoroughly tested these modifications on the Livox radar. However, I must note that I do not have access to a depth camera for comprehensive testing. Therefore, I have only submitted the modifications for the 3D radar functionality.

I genuinely value your expertise and would greatly appreciate your feedback, suggestions, or any optimizations you may have. This Pull Request holds significant meaning for my professional career, and I am committed to making any necessary changes to ensure its successful integration into the project.

Thank you for taking the time to review my code, despite your busy schedule. I look forward to your response.

Best regards,
zzpp

Copy link
Owner

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

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

I think it would be wise to have this as an 'in addition to' feature instead of 'in place of'. The vast majority of users don't have asymmetric frustrums so having the option to continue to use the current API is preferable.

src/frustum_models/depth_camera_frustum.cpp Outdated Show resolved Hide resolved
src/frustum_models/depth_camera_frustum.cpp Outdated Show resolved Hide resolved
@yShzZpp
Copy link
Author

yShzZpp commented Jul 21, 2023

Dear Steve,
In this latest revision, I have made changes to incorporate FOV segmentation for 3D LiDAR scans. The segmentation will only be enabled when "model_type = 1" and "use_start_end_angle = true". For cases involving a depth camera, this feature will remain inactive.
Best regards,
zzpp

Copy link
Owner

@SteveMacenski SteveMacenski left a comment

Choose a reason for hiding this comment

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

Much better!

include/spatio_temporal_voxel_layer/measurement_buffer.hpp Outdated Show resolved Hide resolved
src/frustum_models/three_dimensional_lidar_frustum.cpp Outdated Show resolved Hide resolved
@yShzZpp
Copy link
Author

yShzZpp commented Jul 24, 2023

Dear Steve,
I wanted to express my gratitude for your patient guidance and support during the review process. I have made further adjustments to the code.
In this revised version, I have implemented a method that utilizes only a single constructor. I carefully considered your feedback and worked diligently to ensure that the code adheres to the best practices and standards of the project.
I kindly request you to review this latest iteration, and if there are any lingering issues or concerns, please do not hesitate to point them out. I am fully committed to patiently continue refining the code until it meets your expectations.

Once again, I extend my heartfelt appreciation for your valuable input and guidance. Your support is pivotal in my journey of growth and improvement as a developer.

Thank you for taking the time to review my work. I look forward to your feedback.

Best regards,
zzpp

@@ -52,8 +52,8 @@ namespace geometry
class ThreeDimensionalLidarFrustum : public Frustum
{
public:
ThreeDimensionalLidarFrustum(const double& vFOV, const double& vFOVPadding,
const double& hFOV, const double& min_dist, const double& max_dist);
ThreeDimensionalLidarFrustum(const double& vFOV, const bool& use_start_end_angle, const double& vEFOV,const double& vSFOV,
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
ThreeDimensionalLidarFrustum(const double& vFOV, const bool& use_start_end_angle, const double& vEFOV,const double& vSFOV,
ThreeDimensionalLidarFrustum(const double& vFOV, const bool& use_start_end_angle, const double& vEFOV, const double& vSFOV,

Copy link
Owner

Choose a reason for hiding this comment

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

I also doubt this line is < 100 lines

double tan_vFOV_squared;
if (_use_start_end_angle)
{
tan_vFOV_squared = (v_padded < 1e-9 ? _tan_vSFOV_squared : _tan_vEFOV_squared);
Copy link
Owner

Choose a reason for hiding this comment

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

Why not compare to 0?

// {
// return false;
// }
const double v_padded = transformed_pt[2] + _vFOVPadding;
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think this necessarily works for the negative case, because the padding is always positive even when the transformed point coordinates are negative, that's why we have fabs above.

// return false;
// }
const double v_padded = transformed_pt[2] + _vFOVPadding;
double tan_vFOV_squared;
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
double tan_vFOV_squared;
double tan_vFOV_squared = _tan_vFOVhalf_squared;

Then remove the else statement.

src/measurement_buffer.cpp Outdated Show resolved Hide resolved
src/measurement_buffer.cpp Show resolved Hide resolved
src/spatio_temporal_voxel_grid.cpp Outdated Show resolved Hide resolved
@yShzZpp
Copy link
Author

yShzZpp commented Aug 1, 2023

Dear Steve,
In this latest revision, I have diligently addressed the areas you highlighted and made the necessary modifications.
Additionally, I would like to extend my sincerest apologies for not paying attention to the formatting issues in my previous submissions. I have now taken the time to rectify all the formatting problems throughout the code.
Best regards,
zzpp

@@ -101,7 +111,13 @@ bool ThreeDimensionalLidarFrustum::IsInside(const openvdb::Vec3d &pt)

// // Check if inside frustum valid vFOV
const double v_padded = fabs(transformed_pt[2]) + _vFOVPadding;
Copy link
Owner

Choose a reason for hiding this comment

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

Please make sure to test, in detail, this logic, since we've found now 2 different errors in it that weren't caught before. test the boundaries of the different conditions and make sure this finally now works properly at the correct limit conditions

Copy link
Author

Choose a reason for hiding this comment

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

I'm really sorry. I'm a beginner, and I've tried my best to locate where the problem might be, but with no success so far. I'm not sure if this will inconvenience you, but I still hope you could lend me a hand and point out where the issue lies. I'll do my best to fix it.

Copy link
Owner

Choose a reason for hiding this comment

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

I don't know if there is an issue - I'm simply asking for you to write some tests to make sure this is correct in dealing with your different start/end FOV angles. If its not working, then look back at the geometry :-)

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure how to write tests, but I can describe our application scenario to you.
Our robot is a cuboid (1.000.50.3) with a front end that has a height of 0.7cm. Previously, we used 2D lidars, which only provided information about a single plane at a height of 0.2 meters. Now, due to new requirements, the robot needs to perceive obstacles below a height of 3 meters in front. Because the robot design is fixed, a 3D lidar can only be installed in the front part of the robot, at a height of 0.47 meters.

The lidar we are using is from Livox, with a FOV of -7° to 53°. Assuming our mounting angle is a roll angle of 90°, the angles it can see are illustrated in the diagram below.

Therefore, in the existing code, if I set the vertical FOV (vfov) to 114 degrees, points with positive values on the z-axis in the lidar's coordinate system will be correctly cleared. However, points with negative z-values or those below -7° will be cleared as well, which is not the desired outcome. On the other hand, if the vfov is set to a value less than 114 degrees, there will be residual points on the positive z-axis that cannot be cleared.
livox

Copy link
Owner

Choose a reason for hiding this comment

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

I can appreciate that - so what's the problem? What aren't you able to test about your own code contribution to make sure it actually does what you want it to do? Previous iterations of this PR clearly didn't work properly so I can tell you didn't test in detail to make sure the behavior you want as working. What are you going to test now with the changes to ensure your changes work as expected?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants