Skip to content

Commit

Permalink
update docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
rookiepeng committed Dec 30, 2024
1 parent 413d76a commit efa40ff
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 19 deletions.
2 changes: 1 addition & 1 deletion radarsimlib
16 changes: 13 additions & 3 deletions src/+RadarSim/MeshTarget.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 19 additions & 8 deletions src/+RadarSim/PointTarget.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
13 changes: 13 additions & 0 deletions src/+RadarSim/Radar.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

classdef Radar < handle
properties (Access = public)
% Public properties
version_ = '';
tx_;
rx_;
Expand All @@ -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
Expand Down Expand Up @@ -76,13 +84,18 @@

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);
end
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')
Expand Down
13 changes: 13 additions & 0 deletions src/+RadarSim/Receiver.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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')
Expand Down
13 changes: 9 additions & 4 deletions src/+RadarSim/RxChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -53,8 +60,6 @@
end

obj.antenna_gain_ = max(kwargs.azimuth_pattern);

end

end
end
27 changes: 26 additions & 1 deletion src/+RadarSim/Simulator.m
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -217,13 +239,16 @@ 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);
end
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')
Expand Down
7 changes: 7 additions & 0 deletions src/+RadarSim/Transmitter.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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')
Expand Down
22 changes: 20 additions & 2 deletions src/+RadarSim/TxChannel.m
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand All @@ -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)
Expand Down

0 comments on commit efa40ff

Please sign in to comment.