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

[DRAFT] Radar Velocity Detection #103

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
radar_object_detection_node:
ros__parameters:
lidar_topic: /RADAR_TOP
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from launch import LaunchDescription
from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory
import os


def generate_launch_description():
ld = LaunchDescription()
config = os.path.join(
get_package_share_directory('radar_object_detection'),
'config',
'nuscenes_config.yaml'
)

# nodes
radar_detection = Node(
package='radar_vis',
executable='radar_vis_node',
name='radar_velocity_detection_node',
parameters=[config],
arguments=['--ros-args', '--log-level', 'info']
)

# finalize
ld.add_action(radar_detection)

return ld
35 changes: 35 additions & 0 deletions src/perception/radar_object_detection/radar_vis/src/radar_det.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import rclpy
from rclpy.node import Node
from std_msgs.msg import Float32
from radar_velocity_detection.msg import RadarDetections
import numpy as np

class RadarVelocityDetectionNode(Node):
def __init__(self):
super().__init__('radar_velocity_detection_node')

Check failure on line 9 in src/perception/radar_object_detection/radar_vis/src/radar_det.py

View workflow job for this annotation

GitHub Actions / Autopep8

src/perception/radar_object_detection/radar_vis/src/radar_det.py#L3-L9

from std_msgs.msg import Float32 from radar_velocity_detection.msg import RadarDetections import numpy as np + class RadarVelocityDetectionNode(Node): def __init__(self):
self.subscription = self.create_subscription(
RadarDetections,
'/RADAR_TOP',
self.listener_callback,
10)
self.publisher_ = self.create_publisher(Float32, 'velocity', 10)

def listener_callback(self, msg):
velocities = self.detect_velocities(msg.detections)
avg_velocity = np.mean(velocities) if len(velocities) > 0 else 0.0
self.publisher_.publish(Float32(data=avg_velocity))
self.get_logger().info(f'Average velocity: {avg_velocity:.2f} m/s')

def detect_velocities(self, detections):
velocities = [np.sqrt(d.vx**2 + d.vy**2) for d in detections]
return velocities

def main(args=None):
rclpy.init(args=args)
node = RadarVelocityDetectionNode()
rclpy.spin(node)

Check failure on line 30 in src/perception/radar_object_detection/radar_vis/src/radar_det.py

View workflow job for this annotation

GitHub Actions / Autopep8

src/perception/radar_object_detection/radar_vis/src/radar_det.py#L24-L30

velocities = [np.sqrt(d.vx**2 + d.vy**2) for d in detections] return velocities + def main(args=None): rclpy.init(args=args) node = RadarVelocityDetectionNode()
node.destroy_node()
rclpy.shutdown()

if __name__ == '__main__':
main()
Loading