Skip to content

Commit

Permalink
improve docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
rookiepeng committed Dec 30, 2024
1 parent efa40ff commit 076bb65
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 61 deletions.
21 changes: 10 additions & 11 deletions src/+RadarSim/MeshTarget.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,19 @@
end

methods (Access = public)
% Construct app
% Constructor for the MeshTarget class.
% Initializes the mesh target with specified parameters.
%
% 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).
% points (double): Array of points defining the mesh.
% connectivity_list (int32): List defining the connectivity of the mesh points.
% location (1,3 double): Location of the target.
% speed (1,3 double): Speed of the target.
% rotation (1,3 double): Rotation of the target in degrees.
% rotation_rate (1,3 double): Rotation rate of the target in degrees per second.
% kwargs.origin (1,3 double): Origin of the target (default: [0,0,0]).
% kwargs.permittivity (char): Permittivity of the target (default: 'PEC').
% kwargs.is_ground (logical): Flag indicating if the target is on the ground (default: false).
function obj = MeshTarget(points, connectivity_list, location, speed, rotation, rotation_rate, kwargs)
arguments
points
Expand Down
12 changes: 5 additions & 7 deletions src/+RadarSim/PointTarget.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@
end

methods (Access = public)

% Construct app
% PointTarget Constructor for the PointTarget class.
% 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)
% location (1,3 double): Location of the target [x, y, z].
% speed (1,3 double): Speed of the target [vx, vy, vz].
% rcs (double): Radar cross section of the target.
% kwargs.phase (double): Phase of the target in degrees (default: 0).
function obj = PointTarget(location, speed, rcs, kwargs)
arguments
location (1,3)
Expand Down
6 changes: 4 additions & 2 deletions src/+RadarSim/Radar.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@

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.
% kwargs.location (1,3 double): Radar location coordinates (default: [0,0,0]).
% kwargs.speed (1,3 double): Radar speed (default: [0,0,0]).
% kwargs.rotation (1,3 double): Radar rotation in degrees (default: [0,0,0]).
% kwargs.rotation_rate (1,3 double): Radar rotation rate in degrees per second (default: [0,0,0]).
function obj = Radar(tx, rx, kwargs)
arguments
tx RadarSim.Transmitter
Expand Down
25 changes: 15 additions & 10 deletions src/+RadarSim/Receiver.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@
end

methods (Access = public)

% Construct app
%
% Constructor for the Receiver class.
% Initializes the receiver with specified parameters.
%
% Parameters:
% fs - Sampling frequency
% rf_gain - RF gain
% load_resistor - Load resistor
% baseband_gain - Baseband gain
% kwargs - Additional arguments (noise_figure, bb_type, channels)
% fs (double): Sampling frequency.
% rf_gain (double): RF gain.
% load_resistor (double): Load resistor.
% baseband_gain (double): Baseband gain.
% kwargs.noise_figure (double): Noise figure (default: 0).
% kwargs.bb_type (char): Baseband type ('complex' or 'real') (default: 'complex').
% kwargs.channels (cell): Channels (default: {}).
function obj = Receiver(fs, rf_gain, load_resistor, baseband_gain, kwargs)
arguments
fs
Expand Down Expand Up @@ -84,9 +86,10 @@
end

% Add a receiver channel
% Adds a receiver channel to the Receiver object.
%
% Parameters:
% rx_ch - An instance of RadarSim.RxChannel
% rx_ch (RadarSim.RxChannel): The receiver channel object.
function add_rxchannel(obj, rx_ch)
arguments
obj
Expand Down Expand Up @@ -120,6 +123,7 @@ function add_rxchannel(obj, rx_ch)
end

% Reset the receiver
% Resets the Receiver object, freeing any allocated resources.
function reset(obj)
if obj.rx_ptr~=0
calllib('radarsimc','Free_Receiver',obj.rx_ptr);
Expand All @@ -129,7 +133,8 @@ function reset(obj)
obj.channels_ = {};
end

% Delete the receiver and unload the library
% Delete the receiver
% Deletes the Receiver object and unloads the library if loaded.
function delete(obj)
obj.reset();
if libisloaded('radarsimc')
Expand Down
16 changes: 8 additions & 8 deletions src/+RadarSim/RxChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
end

methods (Access = public)
% Construct app
% Constructor for the RxChannel class.
%
% Initializes the receiver channel with specified location and optional parameters.
%
% 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].
% location (1,3 double): The location coordinates of the receiver channel.
% kwargs.polarization (1,3 double): The polarization vector (default: [0,0,1]).
% kwargs.azimuth_angle (1,2 double): The azimuth angle range in degrees (default: [-90, 90]).
% kwargs.azimuth_pattern (1,2 double): The azimuth pattern (default: [0, 0]).
% kwargs.elevation_angle (1,2 double): The elevation angle range in degrees (default: [-90, 90]).
% kwargs.elevation_pattern (1,2 double): The elevation pattern (default: [0, 0]).
function obj = RxChannel(location, kwargs)
arguments
location (1,3)
Expand Down
13 changes: 8 additions & 5 deletions src/+RadarSim/Simulator.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
end

methods (Access = public)

% Constructor for the Simulator class.
% Loads the 'radarsimc' library if not already loaded and retrieves the version.
function obj = Simulator()
Expand All @@ -48,8 +47,12 @@
%
% Parameters:
% radar (RadarSim.Radar): The radar object.
% targets: List of target objects.
% kwargs: Additional arguments for simulation configuration.
% targets (cell): List of target objects.
% kwargs.density (double): Density (default: 1).
% kwargs.level (char): Level ('frame', 'pulse', 'sample') (default: 'frame').
% kwargs.noise (logical): Noise flag (default: true).
% kwargs.ray_filter (1,2 double): Ray filter (default: [0, 10]).
% kwargs.interf (struct): Interference (default: []).
function Run(obj, radar, targets, kwargs)
arguments
obj
Expand Down Expand Up @@ -197,10 +200,10 @@ function add_mesh_target(obj, target)
% Generates noise for the radar simulation.
%
% Parameters:
% radar: The radar object.
% radar (RadarSim.Radar): The radar object.
%
% Returns:
% noise_mat: The generated noise matrix.
% noise_mat (double): The generated noise matrix.
function noise_mat = generate_noise(obj, radar)
boltzmann_const = 1.38064852e-23;
Ts = 290;
Expand Down
27 changes: 21 additions & 6 deletions src/+RadarSim/Transmitter.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,20 @@
end

methods (Access = public)
% Construct app
% This function initializes the Transmitter object with given frequency, time, and other parameters.
% Constructor for Transmitter class.
% Initializes the Transmitter object with given frequency, time, and other parameters.
%
% Parameters:
% f (double): Frequency.
% t (double): Time.
% kwargs.tx_power (double): Transmission power (default: 0).
% kwargs.pulses (uint32): Number of pulses (default: 1).
% kwargs.prp (double): Pulse repetition period (default: NaN).
% kwargs.f_offset (double): Frequency offset (default: NaN).
% kwargs.pn_f (double): PN frequency (default: NaN).
% kwargs.pn_power (double): PN power (default: NaN).
% kwargs.frame_time (double): Frame time (default: [0]).
% kwargs.channels (cell): Channels (default: {}).
function obj = Transmitter(f, t, kwargs)
arguments
f
Expand Down Expand Up @@ -129,7 +141,10 @@
end

% Add transmitter channel
% This function adds a transmitter channel to the Transmitter object.
% Adds a transmitter channel to the Transmitter object.
%
% Parameters:
% tx_ch (RadarSim.TxChannel): The transmitter channel object.
function add_txchannel(obj, tx_ch)
arguments
obj
Expand All @@ -144,7 +159,7 @@ function add_txchannel(obj, tx_ch)
phi_ptn_ptr = libpointer("singlePtr",tx_ch.phi_ptn_);

theta_ptr = libpointer("singlePtr",tx_ch.theta_);
theta_ptn_ptr = libpointer("singlePtr",tx_ch.theta_ptn_);
theta_ptn_ptr=libpointer("singlePtr",tx_ch.theta_ptn_);

if isempty(tx_ch.pulse_mod_)
tx_ch.pulse_mod_ = ones(1, obj.pulses_);
Expand Down Expand Up @@ -179,7 +194,7 @@ function add_txchannel(obj, tx_ch)
end

% Reset transmitter
% This function resets the Transmitter object, freeing any allocated resources.
% Resets the Transmitter object, freeing any allocated resources.
function reset(obj)
if obj.tx_ptr~=0
calllib('radarsimc','Free_Transmitter',obj.tx_ptr);
Expand All @@ -191,7 +206,7 @@ function reset(obj)
end

% Delete transmitter
% This function deletes the Transmitter object and unloads the library if loaded.
% Deletes the Transmitter object and unloads the library if loaded.
function delete(obj)
obj.reset();
if libisloaded('radarsimc')
Expand Down
24 changes: 12 additions & 12 deletions src/+RadarSim/TxChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@
% 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.
% location (1,3 double): The location coordinates of the transmission channel.
% kwargs.polarization (1,3 double): The polarization vector (default: [0,0,1]).
% kwargs.delay (double): The delay in the transmission (default: 0).
% kwargs.azimuth_angle (1,2 double): The azimuth angle range in degrees (default: [-90, 90]).
% kwargs.azimuth_pattern (1,2 double): The azimuth pattern (default: [0, 0]).
% kwargs.elevation_angle (1,2 double): The elevation angle range in degrees (default: [-90, 90]).
% kwargs.elevation_pattern (1,2 double): The elevation pattern (default: [0, 0]).
% kwargs.pulse_amp (double): The pulse amplitude.
% kwargs.pulse_phs (double): The pulse phase in degrees.
% kwargs.mod_t (double): The modulation time.
% kwargs.phs (double): The phase in degrees.
% kwargs.amp (double): The amplitude.
function obj = TxChannel(location, kwargs)
arguments
location (1,3)
Expand Down

0 comments on commit 076bb65

Please sign in to comment.