-
Notifications
You must be signed in to change notification settings - Fork 0
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
466 add radar sensor #522
466 add radar sensor #522
Conversation
WalkthroughThe changes introduce a new radar node to the perception module's launch file and implement the corresponding processing class in a new Python file. The Changes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 7
🧹 Outside diff range and nitpick comments (3)
code/perception/src/radar_node.py (1)
1-64
: Consider enhancing radar data processing capabilitiesThe current implementation only publishes minimum velocity, which might be limiting. Consider:
- Adding configuration options for velocity processing (min, max, average)
- Publishing additional radar data fields that might be useful for perception
- Adding filtering capabilities for noise reduction
- Including radar object detection and tracking functionality
This would make the radar node more versatile and useful for various perception tasks.
Would you like assistance in implementing any of these enhancements?
🧰 Tools
🪛 Ruff (0.7.0)
5-5:
lidar_filter_utility
imported but unusedRemove unused import:
lidar_filter_utility
(F401)
10-10:
sensor_msgs.msg.Image
imported but unusedRemove unused import:
sensor_msgs.msg.Image
(F401)
code/perception/launch/perception.launch (2)
83-86
: Consider adding parameter documentation.Consider adding inline documentation for the radar node parameters, similar to other nodes in this file (e.g., the vision node's model parameter documentation).
Add documentation like this:
<node pkg="perception" type="radar_node.py" name="radar_node" output="screen"> + <!-- + point_cloud_topic: Topic for filtered RADAR PointCloud2 data + range_topic: Topic for processed RADAR range measurements + --> <param name="point_cloud_topic" value="/carla/hero/RADAR_filtered"/> <param name="range_topic" value="/carla/hero/RADAR_range"/> </node>
83-86
: Consider adding control loop rate parameter.Other perception nodes (kalman_filter, position_heading_publisher) include a control loop rate parameter. Consider whether the radar node would benefit from similar rate control.
Example addition:
<node pkg="perception" type="radar_node.py" name="radar_node" output="screen"> + <param name="control_loop_rate" value="$(arg control_loop_rate)" /> <param name="point_cloud_topic" value="/carla/hero/RADAR_filtered"/> <param name="range_topic" value="/carla/hero/RADAR_range"/> </node>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
code/perception/launch/perception.launch
(1 hunks)code/perception/src/radar_node.py
(1 hunks)doc/perception/radar_node.md
(1 hunks)
🧰 Additional context used
🪛 Ruff (0.7.0)
code/perception/src/radar_node.py
5-5: lidar_filter_utility
imported but unused
Remove unused import: lidar_filter_utility
(F401)
10-10: sensor_msgs.msg.Image
imported but unused
Remove unused import: sensor_msgs.msg.Image
(F401)
🪛 LanguageTool
doc/perception/radar_node.md
[grammar] ~8-~8: It appears that a hyphen is missing in the noun “To-do” (= task) or did you mean the verb “to do”?
Context: ...data-output-for-each-detected-point) - Todo ## Radar offsets - x: 2 - y: ...
(TO_DO_HYPHEN)
[grammar] ~33-~33: It appears that a hyphen is missing in the noun “To-do” (= task) or did you mean the verb “to do”?
Context: ...ity - AzimuthAngle - ElevationAngle ## Todo - Discuss further processing of radar ...
(TO_DO_HYPHEN)
🔇 Additional comments (1)
code/perception/launch/perception.launch (1)
83-86
: LGTM! Node configuration follows established patterns.
The radar node configuration is well-structured and follows the same pattern as the existing lidar node, maintaining consistency in the codebase.
code/perception/src/radar_node.py
Outdated
class RadarNode: | ||
"""See doc/perception/lidar_distance_utility.md on | ||
how to configute this node | ||
""" |
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.
Fix documentation reference and typo
The class documentation references an incorrect markdown file and contains a typo:
- References "lidar_distance_utility.md" instead of the radar documentation
- "configute" should be "configure"
Apply this diff:
class RadarNode:
- """See doc/perception/lidar_distance_utility.md on
- how to configute this node
+ """See doc/perception/radar_node.md on
+ how to configure this node
"""
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
class RadarNode: | |
"""See doc/perception/lidar_distance_utility.md on | |
how to configute this node | |
""" | |
class RadarNode: | |
"""See doc/perception/radar_node.md on | |
how to configure this node | |
""" |
code/perception/src/radar_node.py
Outdated
if __name__ == "__main__": | ||
lidar_distance = RadarNode() | ||
lidar_distance.listener() |
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.
🛠️ Refactor suggestion
Update variable name to match radar functionality
The variable name still references lidar instead of radar.
Apply this diff:
if __name__ == "__main__":
- lidar_distance = RadarNode()
- lidar_distance.listener()
+ radar_node = RadarNode()
+ radar_node.listener()
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
if __name__ == "__main__": | |
lidar_distance = RadarNode() | |
lidar_distance.listener() | |
if __name__ == "__main__": | |
radar_node = RadarNode() | |
radar_node.listener() |
code/perception/src/radar_node.py
Outdated
def callback(self, data): | ||
"""Callback function, filters a PontCloud2 message | ||
by restrictions defined in the launchfile. | ||
|
||
Publishes a Depth image for the specified camera angle. | ||
Each angle has do be delt with differently since the signs of the | ||
coordinate system change with the view angle. | ||
|
||
:param data: a PointCloud2 | ||
""" | ||
|
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.
Update method documentation to reflect radar functionality
The documentation describes lidar-related functionality (depth images) instead of radar velocity processing.
Apply this diff:
def callback(self, data):
- """Callback function, filters a PontCloud2 message
- by restrictions defined in the launchfile.
-
- Publishes a Depth image for the specified camera angle.
- Each angle has do be delt with differently since the signs of the
- coordinate system change with the view angle.
-
- :param data: a PointCloud2
+ """Process radar PointCloud2 data and publish minimum velocity.
+
+ Extracts velocity information from radar data and publishes
+ the minimum velocity as a Float32 message.
+
+ Args:
+ data: PointCloud2 message containing radar data with velocity field
"""
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def callback(self, data): | |
"""Callback function, filters a PontCloud2 message | |
by restrictions defined in the launchfile. | |
Publishes a Depth image for the specified camera angle. | |
Each angle has do be delt with differently since the signs of the | |
coordinate system change with the view angle. | |
:param data: a PointCloud2 | |
""" | |
def callback(self, data): | |
"""Process radar PointCloud2 data and publish minimum velocity. | |
Extracts velocity information from radar data and publishes | |
the minimum velocity as a Float32 message. | |
Args: | |
data: PointCloud2 message containing radar data with velocity field | |
""" | |
code/perception/src/radar_node.py
Outdated
def listener(self): | ||
""" | ||
Initializes the node and it's publishers | ||
""" | ||
# run simultaneously. | ||
rospy.init_node("lidar_distance") | ||
self.bridge = CvBridge() | ||
|
||
# publisher for radar dist_array | ||
self.dist_array_radar_publisher = rospy.Publisher( | ||
rospy.get_param("~image_distance_topic", "/paf/hero/Radar/velocity"), | ||
Float32, | ||
queue_size=10, | ||
) | ||
|
||
rospy.Subscriber( | ||
rospy.get_param("~source_topic", "/carla/hero/RADAR"), | ||
PointCloud2, | ||
self.callback, | ||
) | ||
|
||
rospy.spin() |
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.
Update node name and remove unused CvBridge
The listener method contains remnants from lidar code:
- Incorrect node name "lidar_distance"
- Unused CvBridge initialization
Apply this diff:
def listener(self):
"""
Initializes the node and it's publishers
"""
- # run simultaneously.
- rospy.init_node("lidar_distance")
- self.bridge = CvBridge()
+ rospy.init_node("radar_velocity")
# publisher for radar dist_array
self.dist_array_radar_publisher = rospy.Publisher(
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
def listener(self): | |
""" | |
Initializes the node and it's publishers | |
""" | |
# run simultaneously. | |
rospy.init_node("lidar_distance") | |
self.bridge = CvBridge() | |
# publisher for radar dist_array | |
self.dist_array_radar_publisher = rospy.Publisher( | |
rospy.get_param("~image_distance_topic", "/paf/hero/Radar/velocity"), | |
Float32, | |
queue_size=10, | |
) | |
rospy.Subscriber( | |
rospy.get_param("~source_topic", "/carla/hero/RADAR"), | |
PointCloud2, | |
self.callback, | |
) | |
rospy.spin() | |
def listener(self): | |
""" | |
Initializes the node and it's publishers | |
""" | |
rospy.init_node("radar_velocity") | |
# publisher for radar dist_array | |
self.dist_array_radar_publisher = rospy.Publisher( | |
rospy.get_param("~image_distance_topic", "/paf/hero/Radar/velocity"), | |
Float32, | |
queue_size=10, | |
) | |
rospy.Subscriber( | |
rospy.get_param("~source_topic", "/carla/hero/RADAR"), | |
PointCloud2, | |
self.callback, | |
) | |
rospy.spin() |
code/perception/src/radar_node.py
Outdated
#!/usr/bin/env python | ||
import rospy | ||
import ros_numpy | ||
import numpy as np | ||
import lidar_filter_utility | ||
from sensor_msgs.msg import PointCloud2 | ||
|
||
# from mpl_toolkits.mplot3d import Axes3D | ||
# from itertools import combinations | ||
from sensor_msgs.msg import Image as ImageMsg | ||
from cv_bridge import CvBridge | ||
|
||
from std_msgs.msg import Float32 | ||
|
||
# from matplotlib.colors import LinearSegmentedColormap | ||
|
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.
🛠️ Refactor suggestion
Clean up imports and remove lidar-related dependencies
The imports section contains several issues:
- Unused imports flagged by static analysis:
lidar_filter_utility
andImageMsg
- Commented out imports that should be removed
- Lidar-related imports in a radar node suggesting possible copy-paste errors
Apply this diff to clean up the imports:
#!/usr/bin/env python
import rospy
import ros_numpy
import numpy as np
-import lidar_filter_utility
from sensor_msgs.msg import PointCloud2
-
-# from mpl_toolkits.mplot3d import Axes3D
-# from itertools import combinations
-from sensor_msgs.msg import Image as ImageMsg
from cv_bridge import CvBridge
-
from std_msgs.msg import Float32
-
-# from matplotlib.colors import LinearSegmentedColormap
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
#!/usr/bin/env python | |
import rospy | |
import ros_numpy | |
import numpy as np | |
import lidar_filter_utility | |
from sensor_msgs.msg import PointCloud2 | |
# from mpl_toolkits.mplot3d import Axes3D | |
# from itertools import combinations | |
from sensor_msgs.msg import Image as ImageMsg | |
from cv_bridge import CvBridge | |
from std_msgs.msg import Float32 | |
# from matplotlib.colors import LinearSegmentedColormap | |
#!/usr/bin/env python | |
import rospy | |
import ros_numpy | |
import numpy as np | |
from sensor_msgs.msg import PointCloud2 | |
from cv_bridge import CvBridge | |
from std_msgs.msg import Float32 |
🧰 Tools
🪛 Ruff (0.7.0)
5-5: lidar_filter_utility
imported but unused
Remove unused import: lidar_filter_utility
(F401)
10-10: sensor_msgs.msg.Image
imported but unused
Remove unused import: sensor_msgs.msg.Image
(F401)
coordinates = ros_numpy.point_cloud2.pointcloud2_to_array(data) | ||
msg = np.min(coordinates["Velocity"]) | ||
self.dist_array_radar_publisher.publish(msg) |
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.
Add error handling for radar data processing
The callback lacks validation and error handling for the radar data processing.
Apply this diff to add proper error handling:
- coordinates = ros_numpy.point_cloud2.pointcloud2_to_array(data)
- msg = np.min(coordinates["Velocity"])
- self.dist_array_radar_publisher.publish(msg)
+ try:
+ coordinates = ros_numpy.point_cloud2.pointcloud2_to_array(data)
+ if "Velocity" not in coordinates.dtype.names:
+ rospy.logerr("Radar data missing Velocity field")
+ return
+ if len(coordinates) == 0:
+ rospy.logwarn("Received empty radar data")
+ return
+ msg = np.min(coordinates["Velocity"])
+ self.dist_array_radar_publisher.publish(msg)
+ except Exception as e:
+ rospy.logerr(f"Error processing radar data: {e}")
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
coordinates = ros_numpy.point_cloud2.pointcloud2_to_array(data) | |
msg = np.min(coordinates["Velocity"]) | |
self.dist_array_radar_publisher.publish(msg) | |
try: | |
coordinates = ros_numpy.point_cloud2.pointcloud2_to_array(data) | |
if "Velocity" not in coordinates.dtype.names: | |
rospy.logerr("Radar data missing Velocity field") | |
return | |
if len(coordinates) == 0: | |
rospy.logwarn("Received empty radar data") | |
return | |
msg = np.min(coordinates["Velocity"]) | |
self.dist_array_radar_publisher.publish(msg) | |
except Exception as e: | |
rospy.logerr(f"Error processing radar data: {e}") |
<param name="point_cloud_topic" value="/carla/hero/RADAR_filtered"/> | ||
<param name="range_topic" value="/carla/hero/RADAR_range"/> |
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.
💡 Codebase verification
Warning: RADAR topics mismatch detected
The RADAR topics referenced in perception.launch (/carla/hero/RADAR_filtered
and /carla/hero/RADAR_range
) don't match the actual topics used in the radar_node.py implementation:
- radar_node.py subscribes to
/carla/hero/RADAR
- radar_node.py publishes to
/paf/hero/Radar/velocity
Additionally, the node doesn't use the parameters point_cloud_topic
and range_topic
defined in the launch file.
- Update perception.launch to use correct topics:
<param name="source_topic" value="/carla/hero/RADAR"/> <param name="image_distance_topic" value="/paf/hero/Radar/velocity"/>
- Or modify radar_node.py to use the launch file parameters
🔗 Analysis chain
Verify the existence of RADAR topics.
The node references filtered RADAR data topics. Let's verify these topics exist in the system.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Search for RADAR topic definitions and usage
# Expected: Find corresponding topic definitions in sensor setup or CARLA configuration
# Search for RADAR topic definitions
rg -l "RADAR_filtered|RADAR_range" --type python --type xml
# Search for any RADAR-related configurations
fd -e yaml -e xml -e json | xargs rg "RADAR" -l
Length of output: 175
Script:
#!/bin/bash
# Let's check the content of the dev_objects.json to understand RADAR configuration
cat code/agent/config/dev_objects.json
# Let's also search for any RADAR-related topics in launch files
find . -name "*.launch" -type f -exec grep -l "RADAR" {} \;
# Search for any RADAR-related code in Python files (using find since rg doesn't support python)
find . -name "*.py" -type f -exec grep -l "RADAR" {} \;
Length of output: 6497
Script:
#!/bin/bash
# Let's check the radar_node.py to understand how these topics are used
cat code/perception/src/radar_node.py
# Also check the perception launch file to see the full context
cat code/perception/launch/perception.launch
Length of output: 5362
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.
Consider implementing the recommended changes suggested by CodeRabbitAI for the perception.launch file. Approved, as it is working fine and updates are already in progress under issue #454.
Description
Added simple radar node and md file for documentation of radar sensor
Fixes # (466)
Type of change
Please delete options that are not relevant.
Does this PR introduce a breaking change?
No
Most important changes
radar node, md file
Checklist:
Summary by CodeRabbit
New Features
Documentation