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

584 feature visualization of lidar object clusters #585

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

michalal7
Copy link
Collaborator

@michalal7 michalal7 commented Dec 18, 2024

Description

Added the visualization for lidar clustered objects. Solved a bug where radar markers did not vanish in the rviz visualiziation. Optimized parameters for the dbscan clustering method in the radar_node and the lidar_distance node.

Fixes #584

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Does this PR introduce a breaking change?

no

Most important changes

Which files functionalities are most important in this PR. On which part should the reviewer be focussed on?

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works (might be obsolete with CI later on)
  • New and existing unit tests pass locally with my changes (might be obsolete with CI later on)

Summary by CodeRabbit

  • New Features

    • Enhanced LiDAR data processing with bounding box visualization for clustered points.
    • Updated radar data filtering and clustering logic for improved accuracy.
  • Bug Fixes

    • Adjusted height filtering criteria for LiDAR points.
  • Documentation

    • Updated method signatures to reflect new parameters and functionalities.

Ralf524 and others added 2 commits December 18, 2024 13:26
…N parameters for lidar and radar clustering. Solve a bug where old markers did not vanish.
@michalal7 michalal7 linked an issue Dec 18, 2024 that may be closed by this pull request
Copy link
Contributor

coderabbitai bot commented Dec 18, 2024

Walkthrough

The pull request introduces enhancements to LiDAR and radar perception modules, focusing on improving data clustering and visualization capabilities. The changes primarily involve modifying the LidarDistance and RadarNode classes in their respective files. Key modifications include adding new publishers for visualizing bounding boxes, updating clustering parameters, and refining point filtering logic. The changes aim to improve the visualization and processing of sensor data for object detection and tracking.

Changes

File Change Summary
code/perception/src/lidar_distance.py - Added new methods for bounding box generation and marker creation
- Updated clustering method with modified parameters
- Added marker visualization publisher
- Adjusted point filtering criteria
code/perception/src/radar_node.py - Modified data filtering parameters
- Updated clustering method sensitivity
- Added namespace and lifetime to bounding box markers
- Removed clear_old_markers function

Assessment against linked issues

Objective Addressed Explanation
Visualize LiDAR object clusters

Possibly related PRs

Suggested labels

perception

Suggested reviewers

  • Ralf524

Poem

🤖 Beep boop, LiDAR's new groove!
Clusters dance, markers bloom
Radar and points now take flight
Visualization shining bright
A rabbit's code-craft in full zoom! 🐰

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
code/perception/src/lidar_distance.py (2)

118-119: Height filtering threshold might be too aggressive.
Currently filtering points below -1.4 on the Z-axis. Verify whether this excludes potentially relevant lower-lying objects, such as curbs or smaller obstacles. Consider making this threshold configurable or adding a margin.


412-412: Marker lifetime is very short.
A 0.1s lifetime for markers might cause flickering in RViz if publish rates drop. If you prefer longer visibility during slower updates, consider a higher value or no expiration (by setting lifetime to 0).

- marker.lifetime = rospy.Duration(0.1)
+ # For a higher or indefinite marker visibility:
+ marker.lifetime = rospy.Duration(1.0)
code/perception/src/radar_node.py (1)

350-352: LGTM: Fixed marker persistence issue

The addition of marker namespace and lifetime properly addresses the issue of radar markers not disappearing in RViz. The 1-second lifetime ensures markers are automatically cleaned up.

Consider making the marker lifetime configurable via ROS parameters for flexibility:

-    marker.lifetime = rospy.Duration(1)
+    marker_lifetime = rospy.get_param('~marker_lifetime', 1.0)  # default 1 second
+    marker.lifetime = rospy.Duration(marker_lifetime)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eabc86e and e73d743.

📒 Files selected for processing (2)
  • code/perception/src/lidar_distance.py (6 hunks)
  • code/perception/src/radar_node.py (3 hunks)
🔇 Additional comments (6)
code/perception/src/lidar_distance.py (4)

10-11: Imports for visualization look good.
The addition of imports for Marker, MarkerArray, and Point appears consistent with the bounding box visualization logic introduced below.


127-139: Straightforward combination of XYZ and cluster labels.
The logic properly stacks labels with coordinates before generating bounding boxes. This is a clean approach and maintains clarity regarding which point belongs to which cluster.


75-86: Ensure consistency between publishers and parameter names.
The new publishers, including "marker_visualization_lidar_publisher", are properly initialized. Double-check that the parameter "~marker_topic" is set correctly in the ROS parameter server to avoid potential mismatches or typos when launching.

✅ Verification successful

Parameter naming and default values are consistent and well-structured

The ~marker_topic parameter is used consistently in both the radar and lidar nodes, with appropriate default values that follow a clear naming convention:

  • Lidar node: /paf/hero/Lidar/Marker
  • Radar node: /paf/hero/Radar/Marker

The parameter doesn't need to be explicitly defined in launch files since both publishers use sensible default values that follow the project's topic naming pattern, making use of ROS's parameter fallback mechanism.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that "~marker_topic" parameter is defined in the relevant launch or parameter files.
# Searching for the param definition.
rg 'marker_topic'

Length of output: 233


Script:

#!/bin/bash
# Let's check the launch files to see if these parameters are defined
fd -e launch | xargs rg 'marker_topic'

# Also check for any yaml config files that might define these parameters
fd -e yaml | xargs rg 'marker_topic'

# Let's also check the full context of both files to understand the parameter usage
echo "=== radar_node.py context ==="
rg -B 5 -A 5 'marker_topic' code/perception/src/radar_node.py

echo "=== lidar_distance.py context ==="
rg -B 5 -A 5 'marker_topic' code/perception/src/lidar_distance.py

Length of output: 1181


565-565: DBSCAN eps parameter changed from 0.3 to 0.4.
Increasing the neighborhood distance may merge clusters that were previously separated. If this is intended, fine. Otherwise, confirm it doesn’t over-cluster objects.

✅ Verification successful

Parameter change to eps=0.4 appears safe to proceed with.
The DBSCAN eps parameter change from 0.3 to 0.4 is used only in one place within the codebase, specifically in the cluster_lidar_data_from_pointcloud function. The function is called from the start_clustering method with default parameters, and there are no test files that directly test this clustering functionality. The parameter change will make the clustering slightly more lenient, potentially merging nearby clusters, but this appears to be an intentional tuning decision for better object detection in the LiDAR processing pipeline.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
#!/bin/bash
# Confirm any references or tests that might rely on a 0.3 EPS value.
rg 'cluster_lidar_data_from_pointcloud'

Length of output: 272


Script:

#!/bin/bash
# Let's check the git history for this specific function to understand the eps parameter change
git log -L :cluster_lidar_data_from_pointcloud:code/perception/src/lidar_distance.py

# Also check for any test files that might be using this function
rg -l "test.*lidar.*distance" 

Length of output: 31


Script:

#!/bin/bash
# Let's check the content of the file to understand the usage context
cat code/perception/src/lidar_distance.py

# Also search for test files with a broader pattern
fd "test.*\.py"

Length of output: 22400

code/perception/src/radar_node.py (2)

164-164: Verify clustering behavior with reduced eps value

Reducing eps from 0.8 to 0.4 will create tighter clusters, which could improve object separation but might also split larger objects into multiple clusters. Please verify this change with different types of objects (vehicles, pedestrians, etc.).

Let's check if there are any test files or recorded data that we can analyze:


34-34: LGTM: Refined height filtering parameters

The adjusted height range (-0.40m to 2m) provides better focus on relevant objects while filtering out ground noise and tall irrelevant objects.

Let's verify if these height parameters align with typical object heights in your dataset:

✅ Verification successful

Height filtering parameters are consistent with radar mounting

The filter parameters (min_z=-0.40, max_z=2) are well-aligned with the radar's mounting height of 0.7m. The range allows detection from ~1.1m below the sensor to ~1.3m above it, which is appropriate for detecting relevant objects while filtering out ground noise and tall irrelevant objects.

  • Comment in code confirms radar mounting height: # radar position z=0.7
  • Default filter_data parameters show this is a more focused range than the function's default of -1m to 100m
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Analyze the height distribution of radar points to validate filter parameters

# Search for any configuration files that might contain radar mounting height or related parameters
rg -g '*.yaml' -g '*.json' -g '*.config' -l 'radar.*height|radar.*z|radar.*mount'

Length of output: 83


Script:

#!/bin/bash
# Let's try a broader search to understand the radar height filtering context
# Search for any files containing filter_data function definition or usage
rg -A 5 -B 5 "filter_data.*z" --type python

# Also search for any comments or documentation about height filtering
rg -A 2 -B 2 "height|z.*filter" --type python

Length of output: 155


Script:

#!/bin/bash
# Search for filter_data function definition and usage without file type restriction
rg -A 5 -B 5 "filter_data.*z"

# Look for the filter_data function definition
ast-grep --pattern 'def filter_data($$$)'

Length of output: 719


Script:

#!/bin/bash
# Let's find the filter_data function implementation and any comments about radar mounting
rg -A 10 "def filter_data"

# Also search for any radar mounting height information in comments
rg "radar.*position|radar.*height|radar.*mount"

Length of output: 668

@michalal7 michalal7 self-assigned this Dec 18, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
code/perception/src/lidar_distance.py (2)

480-487: Remove commented-out code for 2D boxes

The commented-out code for 2D bounding boxes should be removed if it's no longer needed. If it might be needed in the future, consider moving it to a separate branch or documenting why it's kept.


413-413: Consider increasing marker lifetime

The current marker lifetime of 0.1 seconds might be too short, potentially causing flickering in the visualization. Consider increasing it to 0.2-0.5 seconds for smoother visualization while maintaining responsiveness.

-    marker.lifetime = rospy.Duration(0.1)  # Marker visibility duration in seconds
+    marker.lifetime = rospy.Duration(0.3)  # Marker visibility duration in seconds
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e73d743 and ec18434.

📒 Files selected for processing (1)
  • code/perception/src/lidar_distance.py (6 hunks)
🔇 Additional comments (4)
code/perception/src/lidar_distance.py (4)

10-11: LGTM: Visualization message setup

The new imports and publisher setup for marker visualization are well-configured following ROS conventions.

Also applies to: 82-86


122-150: LGTM: Well-structured clustering and visualization implementation

The implementation demonstrates:

  • Proper error handling for empty clusters
  • Clear separation between clustering and visualization logic
  • Efficient use of ROS visualization messages

566-566: Verify the impact of increased DBSCAN epsilon

The DBSCAN epsilon parameter has been increased from 0.3 to 0.4, which will result in more relaxed clustering. Please ensure this change:

  1. Doesn't lead to over-clustering of separate objects
  2. Has been validated with different types of objects and scenarios

118-119: Verify the impact of increased height threshold

The minimum height threshold for point filtering has been increased by 0.3 units. Please verify that this change doesn't affect the detection of important low-lying objects.

@michalal7 michalal7 added this to the Sprint 04 2025-01-13 milestone Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

[Feature]: Visualization of lidar object clusters
2 participants