Skip to content

Commit 5201f6a

Browse files
committed
Refactor radar simulation Cython wrappers and docs
Streamlined and clarified Cython wrapper functions for radar simulation, improving docstrings and parameter descriptions for core conversion and management functions. Removed redundant helper functions and internal documentation from cp_radarsimc.pxd and cp_radarsimc.pyx, focusing on public API. Updated simulator_radar.pyx to reflect new function signatures and parameter handling. Updated submodule src/radarsimcpp.
1 parent bc38d68 commit 5201f6a

File tree

5 files changed

+87
-292
lines changed

5 files changed

+87
-292
lines changed

src/radarsimcpp

src/radarsimpy/includes/radarsimc.pxd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ cdef extern from "libs/free_tier.hpp":
7171
#------------------------------------------------------------------------------
7272
cdef extern from "type_def.hpp":
7373
cdef enum RadarSimErrorCode:
74-
SUCCESS # Operation completed successfully
74+
SUCCESS # Operation completed successfully
7575
ERROR_NULL_POINTER # Null pointer error
7676
ERROR_INVALID_PARAMETER # Invalid parameter provided
7777
ERROR_MEMORY_ALLOCATION # Memory allocation failed
@@ -267,8 +267,8 @@ cdef extern from "simulator_point.hpp":
267267
PointSimulator() except +
268268

269269
# Run point target simulation
270-
void Run(const shared_ptr[Radar[H, L]] & radar, # Radar configuration
271-
const shared_ptr[PointsManager[L]] & points_manager) # Array of point targets
270+
void Run(const shared_ptr[Radar[H, L]] & radar, # Radar configuration
271+
const shared_ptr[PointsManager[L]] & points_manager) # Array of point targets
272272

273273
# Mesh-based Ray Tracing Simulation
274274
# Physics-based 3D mesh target simulation using ray tracing and physical optics
@@ -279,8 +279,8 @@ cdef extern from "simulator_mesh.hpp":
279279
MeshSimulator() except +
280280

281281
# Run mesh simulation with configurable fidelity
282-
RadarSimErrorCode Run(const shared_ptr[Radar[H, L]] & radar, # Radar configuration
283-
const shared_ptr[TargetsManager[L]] & targets_manager, # Targets manager
282+
RadarSimErrorCode Run(const shared_ptr[Radar[H, L]] & radar, # Radar configuration
283+
const shared_ptr[TargetsManager[L]] & targets_manager, # Targets manager
284284
int level, # Simulation level (0=LOW, 1=MEDIUM, 2=HIGH)
285285
L density, # Ray density for physical optics
286286
Vec2[int_t] ray_filter, # Ray index filter [min, max]

src/radarsimpy/lib/cp_radarsimc.pxd

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,7 @@
33
A Python module for radar simulation
44
55
This module provides Cython wrapper functions for interfacing with the C++
6-
radar simulation engine. It contains optimized functions for:
7-
8-
- Point target creation and management
9-
- Radar system configuration and setup
10-
- Complex target modeling with mesh support
11-
- Radar cross-section (RCS) calculations
12-
- Time-varying parameter handling
13-
14-
The module is designed for high-performance radar simulation applications
15-
with support for both trial and full versions with appropriate limitations.
6+
radar simulation engine.
167
178
---
189
@@ -34,16 +25,18 @@ with support for both trial and full versions with appropriate limitations.
3425
from radarsimpy.includes.radarsimc cimport Radar
3526
from radarsimpy.includes.radarsimc cimport TargetsManager
3627
from radarsimpy.includes.radarsimc cimport PointsManager
37-
from radarsimpy.includes.type_def cimport float_t, int_t
38-
from libcpp.complex cimport complex as cpp_complex
28+
from radarsimpy.includes.type_def cimport float_t
3929
from libcpp.memory cimport shared_ptr
4030

4131

4232
# ============================================================================
4333
# Core Conversion Functions
4434
# ============================================================================
4535

46-
36+
# Add a point scatterer to the points manager for simulation
37+
# Converts Python point parameters (location, speed, RCS, phase, shape) to C++
38+
# Validates input parameters and updates the internal points collection
39+
# Raises TypeError for invalid parameter types, ValueError for invalid values
4740
cdef void cp_AddPoint(location, speed, rcs, phase, shape, PointsManager[float_t] * points_manager) except *
4841

4942
# Create a Radar system object for simulation
@@ -56,33 +49,8 @@ cdef shared_ptr[Radar[double, float_t]] cp_Radar(radar, frame_start_time) except
5649
# Raises ValueError for invalid params, RuntimeError for mesh/FreeTier issues
5750
cdef void cp_RCS_Target(target, mesh_module, TargetsManager[float_t] * targets_manager) except *
5851

52+
# Add a complex target to the targets manager for radar simulation
53+
# Converts Python target config to C++ with mesh processing and validation
54+
# Handles time-varying parameters and applies transformations at given timestamp
55+
# Raises ValueError for invalid target params, RuntimeError for mesh/FreeTier issues
5956
cdef void cp_AddTarget(radar, target, timestamp, mesh_module, TargetsManager[float_t] * targets_manager) except *
60-
61-
# ============================================================================
62-
# Helper Functions for Internal Use
63-
# ============================================================================
64-
65-
# Validate that an input vector has exactly 3 elements
66-
# Raises TypeError if not array-like, ValueError if wrong size
67-
cdef void _validate_vector_3d(object vector, str name) except *
68-
69-
# Safely convert unit string to scale factor
70-
# Supports 'm', 'cm', 'mm' units, raises ValueError for unsupported units
71-
cdef float_t _safe_unit_conversion(str unit) except *
72-
73-
# Check mesh size limits for free tier with detailed error messages
74-
# Raises RuntimeError if FreeTier limitations are exceeded
75-
cdef void _validate_mesh_for_free_tier(int_t num_faces) except *
76-
77-
# Convert permittivity value to complex float with validation
78-
# Handles both 'PEC' string and numeric values
79-
# Raises ValueError for invalid permittivity values
80-
cdef cpp_complex[float_t] _convert_permittivity(object permittivity) except *
81-
82-
# Convert permeability value to complex float with validation
83-
# Raises ValueError for invalid permeability values
84-
cdef cpp_complex[float_t] _convert_permeability(object permeability) except *
85-
86-
# Issue standardized deprecation warnings for renamed parameters
87-
# Provides clear migration guidance and consistent warning format
88-
cdef void _warn_deprecated_parameter(str old_param, str new_param) except *

0 commit comments

Comments
 (0)