Skip to content

Commit 271811a

Browse files
committed
Update LidarSimulator API to use target vector
Refactored LidarSimulator interface to accept a vector of targets in the Run method instead of adding targets individually. Updated Cython bindings and usage in sim_lidar to construct and pass the target vector, improving efficiency and clarity of target management.
1 parent 73659eb commit 271811a

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

src/radarsimcpp

src/radarsimpy/includes/radarsimc.pxd

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,10 @@ cdef extern from "simulator_rcs.hpp":
151151
cdef extern from "simulator_lidar.hpp":
152152
cdef cppclass LidarSimulator[T]:
153153
LidarSimulator() except +
154-
155-
# Add a target to the scene
156-
void AddTarget(const Target[T] & target)
157-
154+
158155
# Generate point cloud by ray casting
159-
void Run(const vector[T] & phi, # Azimuth angles (radians)
156+
void Run(vector[Target[T]] & targets,
157+
const vector[T] & phi, # Azimuth angles (radians)
160158
const vector[T] & theta, # Elevation angles (radians)
161159
const Vec3[T] & position) # LiDAR sensor position
162160

src/radarsimpy/simulator_lidar.pyx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ cpdef sim_lidar(lidar, targets, frame_time=0):
9797
numpy.ndarray - A structured array representing the Lidar ray interactions with the scene, including details such as ray origins, directions, and intersections.
9898
"""
9999
cdef LidarSimulator[float_t] lidar_sim_c
100-
100+
101+
cdef vector[Target[float_t]] targets_vt
102+
101103
# Memory view declarations
102104
cdef float_t[:, :] points_mv
103105
cdef int_t[:, :] cells_mv
@@ -133,7 +135,7 @@ cpdef sim_lidar(lidar, targets, frame_time=0):
133135
)
134136

135137
# Add target to pointcloud
136-
lidar_sim_c.AddTarget(Target[float_t](&points_mv[0, 0],
138+
targets_vt.emplace_back(Target[float_t](&points_mv[0, 0],
137139
&cells_mv[0, 0],
138140
<int_t> cells_mv.shape[0],
139141
Vec3[float_t](&origin_mv[0]),
@@ -155,9 +157,10 @@ cpdef sim_lidar(lidar, targets, frame_time=0):
155157
Mem_Copy(&theta_mv[0], <int_t>(theta_mv.shape[0]), theta_vt)
156158

157159
# Perform ray tracing
158-
lidar_sim_c.Run(phi_vt,
159-
theta_vt,
160-
Vec3[float_t](&position_mv[0]))
160+
lidar_sim_c.Run(targets_vt,
161+
phi_vt,
162+
theta_vt,
163+
Vec3[float_t](&position_mv[0]))
161164

162165
# Prepare output
163166
ray_type = np.dtype([("positions", np_float, (3,)),

0 commit comments

Comments
 (0)