diff --git a/radarsimlib b/radarsimlib index ae6e453..eec440e 160000 --- a/radarsimlib +++ b/radarsimlib @@ -1 +1 @@ -Subproject commit ae6e453c4bee5b7a2ed2a5f1a1b8dd64a04160ac +Subproject commit eec440eb2ae304a1f6000485dec76e5959c4ce4c diff --git a/src/+RadarSim/MeshTarget.m b/src/+RadarSim/MeshTarget.m index 8988a83..d44d02e 100644 --- a/src/+RadarSim/MeshTarget.m +++ b/src/+RadarSim/MeshTarget.m @@ -24,13 +24,23 @@ origin_; permittivity_; is_ground_; - - end methods (Access = public) - % Construct app + % Constructor for the MeshTarget class. + % + % Parameters: + % points: Array of points defining the mesh. + % connectivity_list: List defining the connectivity of the mesh points. + % location: 1x3 array specifying the location of the target. + % speed: 1x3 array specifying the speed of the target. + % rotation: 1x3 array specifying the rotation of the target in degrees. + % rotation_rate: 1x3 array specifying the rotation rate of the target in degrees per second. + % kwargs: Optional keyword arguments including: + % - origin: 1x3 array specifying the origin of the target (default: [0,0,0]). + % - permittivity: String specifying the permittivity of the target (default: 'PEC'). + % - is_ground: Boolean specifying if the target is on the ground (default: false). function obj = MeshTarget(points, connectivity_list, location, speed, rotation, rotation_rate, kwargs) arguments points diff --git a/src/+RadarSim/PointTarget.m b/src/+RadarSim/PointTarget.m index 1d10b62..04817a0 100644 --- a/src/+RadarSim/PointTarget.m +++ b/src/+RadarSim/PointTarget.m @@ -13,18 +13,29 @@ classdef PointTarget < handle - properties (Access = public) - type_="point"; - location_; - rcs_; - speed_; - phase_; + % PointTarget Class representing a point target in the radar simulation. + % This class defines the properties and methods for a point target, + % including its location, speed, radar cross section (RCS), and phase. + properties (Access = public) + type_="point"; % Type of the target + location_; % Location of the target [x, y, z] + rcs_; % Radar cross section of the target + speed_; % Speed of the target [vx, vy, vz] + phase_; % Phase of the target in radians end methods (Access = public) % Construct app + % PointTarget Constructor for the PointTarget class. + % Initializes the location, speed, RCS, and phase of the target. + % + % Parameters: + % location (1,3): Location of the target [x, y, z] + % speed (1,3): Speed of the target [vx, vy, vz] + % rcs: Radar cross section of the target + % kwargs.phase: Phase of the target in degrees (default: 0) function obj = PointTarget(location, speed, rcs, kwargs) arguments location (1,3) @@ -33,10 +44,10 @@ kwargs.phase = 0 end - obj.location_=location; + obj.location_ = location; obj.speed_ = speed; obj.rcs_ = rcs; - obj.phase_ = kwargs.phase/180*pi; + obj.phase_ = kwargs.phase / 180 * pi; end end end \ No newline at end of file diff --git a/src/+RadarSim/Radar.m b/src/+RadarSim/Radar.m index 6d60b0b..345c2cd 100644 --- a/src/+RadarSim/Radar.m +++ b/src/+RadarSim/Radar.m @@ -14,6 +14,7 @@ classdef Radar < handle properties (Access = public) + % Public properties version_ = ''; tx_; rx_; @@ -29,6 +30,13 @@ methods (Access = public) % Construct app + % Constructor for the Radar class. + % Initializes the radar system with the given transmitter and receiver. + % + % Parameters: + % tx (RadarSim.Transmitter): The radar transmitter object. + % rx (RadarSim.Receiver): The radar receiver object. + % kwargs (struct): Optional parameters for radar location, speed, rotation, and rotation rate. function obj = Radar(tx, rx, kwargs) arguments tx RadarSim.Transmitter @@ -76,6 +84,8 @@ end + % Reset radar + % Resets the radar system by freeing the radar pointer. function reset(obj) if obj.radar_ptr~=0 calllib('radarsimc','Free_Radar',obj.radar_ptr); @@ -83,6 +93,9 @@ function reset(obj) obj.radar_ptr=0; end + % Delete radar + % Destructor for the Radar class. + % Frees the radar pointer and unloads the radar library if loaded. function delete(obj) obj.reset(); if libisloaded('radarsimc') diff --git a/src/+RadarSim/Receiver.m b/src/+RadarSim/Receiver.m index 29ad1b6..0a44dae 100644 --- a/src/+RadarSim/Receiver.m +++ b/src/+RadarSim/Receiver.m @@ -29,6 +29,13 @@ methods (Access = public) % Construct app + % + % Parameters: + % fs - Sampling frequency + % rf_gain - RF gain + % load_resistor - Load resistor + % baseband_gain - Baseband gain + % kwargs - Additional arguments (noise_figure, bb_type, channels) function obj = Receiver(fs, rf_gain, load_resistor, baseband_gain, kwargs) arguments fs @@ -76,6 +83,10 @@ end end + % Add a receiver channel + % + % Parameters: + % rx_ch - An instance of RadarSim.RxChannel function add_rxchannel(obj, rx_ch) arguments obj @@ -108,6 +119,7 @@ function add_rxchannel(obj, rx_ch) obj.channels_ = [obj.channels_, rx_ch]; end + % Reset the receiver function reset(obj) if obj.rx_ptr~=0 calllib('radarsimc','Free_Receiver',obj.rx_ptr); @@ -117,6 +129,7 @@ function reset(obj) obj.channels_ = {}; end + % Delete the receiver and unload the library function delete(obj) obj.reset(); if libisloaded('radarsimc') diff --git a/src/+RadarSim/RxChannel.m b/src/+RadarSim/RxChannel.m index 1c510b1..6e85185 100644 --- a/src/+RadarSim/RxChannel.m +++ b/src/+RadarSim/RxChannel.m @@ -21,12 +21,19 @@ theta_; theta_ptn_; antenna_gain_; - end methods (Access = public) - % Construct app + % Constructor for the RxChannel class. + % + % Parameters: + % location (1,3): The location of the receiver channel. + % kwargs.polarization (1,3): The polarization vector. Default is [0,0,1]. + % kwargs.azimuth_angle: The azimuth angles in degrees. Default is [-90, 90]. + % kwargs.azimuth_pattern: The azimuth pattern. Default is [0, 0]. + % kwargs.elevation_angle: The elevation angles in degrees. Default is [-90, 90]. + % kwargs.elevation_pattern: The elevation pattern. Default is [0, 0]. function obj = RxChannel(location, kwargs) arguments location (1,3) @@ -53,8 +60,6 @@ end obj.antenna_gain_ = max(kwargs.azimuth_pattern); - end - end end \ No newline at end of file diff --git a/src/+RadarSim/Simulator.m b/src/+RadarSim/Simulator.m index 73e06ca..5ac264a 100644 --- a/src/+RadarSim/Simulator.m +++ b/src/+RadarSim/Simulator.m @@ -25,7 +25,8 @@ methods (Access = public) - % Construct app + % Constructor for the Simulator class. + % Loads the 'radarsimc' library if not already loaded and retrieves the version. function obj = Simulator() if ~libisloaded('radarsimc') loadlibrary('radarsimc','radarsim.h'); @@ -43,6 +44,12 @@ end end + % Runs the radar simulation. + % + % Parameters: + % radar (RadarSim.Radar): The radar object. + % targets: List of target objects. + % kwargs: Additional arguments for simulation configuration. function Run(obj, radar, targets, kwargs) arguments obj @@ -104,6 +111,10 @@ function Run(obj, radar, targets, kwargs) end end + % Adds a point target to the simulation. + % + % Parameters: + % target (RadarSim.PointTarget): The point target object. function add_point_target(obj, target) arguments obj @@ -124,6 +135,10 @@ function add_point_target(obj, target) end end + % Adds a mesh target to the simulation. + % + % Parameters: + % target (RadarSim.MeshTarget): The mesh target object. function add_mesh_target(obj, target) arguments obj @@ -179,6 +194,13 @@ function add_mesh_target(obj, target) end + % Generates noise for the radar simulation. + % + % Parameters: + % radar: The radar object. + % + % Returns: + % noise_mat: The generated noise matrix. function noise_mat = generate_noise(obj, radar) boltzmann_const = 1.38064852e-23; Ts = 290; @@ -217,6 +239,7 @@ function add_mesh_target(obj, target) end + % Resets the simulation by freeing targets. function reset(obj) if obj.targets_ptr~=0 calllib('radarsimc','Free_Targets',obj.targets_ptr); @@ -224,6 +247,8 @@ function reset(obj) obj.targets_ptr=0; end + % Destructor for the Simulator class. + % Frees targets and unloads the 'radarsimc' library if loaded. function delete(obj) obj.reset(); if libisloaded('radarsimc') diff --git a/src/+RadarSim/Transmitter.m b/src/+RadarSim/Transmitter.m index 8c2b76d..8363379 100644 --- a/src/+RadarSim/Transmitter.m +++ b/src/+RadarSim/Transmitter.m @@ -31,6 +31,7 @@ methods (Access = public) % Construct app + % This function initializes the Transmitter object with given frequency, time, and other parameters. function obj = Transmitter(f, t, kwargs) arguments f @@ -127,6 +128,8 @@ end + % Add transmitter channel + % This function adds a transmitter channel to the Transmitter object. function add_txchannel(obj, tx_ch) arguments obj @@ -175,6 +178,8 @@ function add_txchannel(obj, tx_ch) obj.channels_ = [obj.channels_, tx_ch]; end + % Reset transmitter + % This function resets the Transmitter object, freeing any allocated resources. function reset(obj) if obj.tx_ptr~=0 calllib('radarsimc','Free_Transmitter',obj.tx_ptr); @@ -185,6 +190,8 @@ function reset(obj) obj.channels_ = {}; end + % Delete transmitter + % This function deletes the Transmitter object and unloads the library if loaded. function delete(obj) obj.reset(); if libisloaded('radarsimc') diff --git a/src/+RadarSim/TxChannel.m b/src/+RadarSim/TxChannel.m index 6dd7c22..d26719f 100644 --- a/src/+RadarSim/TxChannel.m +++ b/src/+RadarSim/TxChannel.m @@ -13,6 +13,10 @@ classdef TxChannel < handle + % TxChannel class represents a transmission channel in the radar simulation. + % This class handles the properties and methods related to the transmission + % channel including location, polarization, delay, angles, patterns, and modulation. + properties (Access = public) location_; polarization_; @@ -29,8 +33,22 @@ end methods (Access = public) - - % Construct app + % Constructor for TxChannel class. + % Initializes the transmission channel with specified location and optional parameters. + % + % Parameters: + % location (1,3): The location coordinates of the transmission channel. + % kwargs.polarization (1,3): The polarization vector (default: [0,0,1]). + % kwargs.delay: The delay in the transmission (default: 0). + % kwargs.azimuth_angle: The azimuth angle range (default: [-90, 90]). + % kwargs.azimuth_pattern: The azimuth pattern (default: [0, 0]). + % kwargs.elevation_angle: The elevation angle range (default: [-90, 90]). + % kwargs.elevation_pattern: The elevation pattern (default: [0, 0]). + % kwargs.pulse_amp: The pulse amplitude. + % kwargs.pulse_phs: The pulse phase. + % kwargs.mod_t: The modulation time. + % kwargs.phs: The phase. + % kwargs.amp: The amplitude. function obj = TxChannel(location, kwargs) arguments location (1,3)