Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
rookiepeng committed Jul 13, 2024
1 parent bcb08fe commit 48a171b
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 53 deletions.
53 changes: 30 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.14)

# ## Config for radarsimc
project(radarsimc LANGUAGES CXX)
Expand All @@ -16,8 +16,30 @@ endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# ## header files in "./includes" and "../includes" folders
include_directories("./src/includes" "./src/radarsimcpp/includes")
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") # Windows
include_directories("./src/includes"
"./src/radarsimcpp/includes"
"./src/radarsimcpp/hdf5/lib_win_x86_64/include")
link_directories(${CMAKE_SOURCE_DIR}/src/radarsimcpp/hdf5/lib_win_x86_64/lib)
set(_hdf5_libs
libhdf5
libhdf5_cpp
libhdf5_hl
libhdf5_hl_cpp
shlwapi
)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") # Linux
include_directories("./src/includes"
"./src/radarsimcpp/includes"
"./src/radarsimcpp/hdf5/lib_linux_x86_64/include")
link_directories(${CMAKE_SOURCE_DIR}/src/radarsimcpp/hdf5/lib_linux_x86_64/lib)
set(_hdf5_libs
hdf5
hdf5_cpp
hdf5_hl
hdf5_hl_cpp
)
endif()

if(GPU_BUILD)
enable_language(CUDA)
Expand All @@ -34,7 +56,7 @@ if(GPU_BUILD)
# ## set CUDA building properties
set_target_properties(radarsimc PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
CUDA_ARCHITECTURES "50;61;86")
CUDA_ARCHITECTURES all-major)

# ## add CUDA includes path
include_directories(${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
Expand All @@ -44,32 +66,17 @@ if(GPU_BUILD)

# ## for MSVC, remove default libs
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# target_compile_options(radarsimc PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:
# --generate-line-info
# --use_fast_math
# --relocatable-device-code=true
# >)
set_target_properties(radarsimc PROPERTIES LINK_FLAGS "/NODEFAULTLIB:\"LIBCMT\"")
endif()

target_link_libraries(radarsimc PUBLIC ${_hdf5_libs})
else()
# ## add source files, ".cpp"
file(GLOB SOURCES "./src/*.cpp" "./src/radarsimcpp/src/*.cpp")

# ## build executable
add_library(radarsimc SHARED ${SOURCES})
# add_executable(radarsimc ${SOURCES})
target_link_libraries(radarsimc PUBLIC ${_hdf5_libs})

# require OpenMP for CPU build
# find_package(OpenMP REQUIRED)

# if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # MSVC
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /openmp")
# elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # gcc/g++
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
# else() # other compiler (not tested)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
# endif()

# link with OpenMP library
# target_link_libraries(radarsim PRIVATE OpenMP::OpenMP_CXX)
# add_executable(radarsimc ${SOURCES})
endif()
20 changes: 10 additions & 10 deletions src/includes/radarsim.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ __declspec(dllexport) t_Transmitter *Create_Transmitter(
* @param ptr_tx_c Pointer to the Transmitter
*/
__declspec(dllexport) void Add_Txchannel(
float *location, float *polar, float *phi, float *phi_ptn, int phi_length,
float *theta, float *theta_ptn, int theta_length, float antenna_gain,
float *mod_t, float *mod_var_real, float *mod_var_imag, int mod_length,
float *pulse_mod_real, float *pulse_mod_imag, float delay, float grid,
t_Transmitter *ptr_tx_c);
float *location, float *polar_real, float *polar_imag, float *phi,
float *phi_ptn, int phi_length, float *theta, float *theta_ptn,
int theta_length, float antenna_gain, float *mod_t, float *mod_var_real,
float *mod_var_imag, int mod_length, float *pulse_mod_real,
float *pulse_mod_imag, float delay, float grid, t_Transmitter *ptr_tx_c);

/**
* @brief Get the number of Tx channels
Expand Down Expand Up @@ -157,11 +157,11 @@ __declspec(dllexport) t_Receiver *Create_Receiver(float fs, float rf_gain,
* @param antenna_gain Antenna gain (dB)
* @param ptr_rx_c Pointer to Receiver
*/
__declspec(dllexport) void Add_Rxchannel(float *location, float *polar,
float *phi, float *phi_ptn,
int phi_length, float *theta,
float *theta_ptn, int theta_length,
float antenna_gain,
__declspec(dllexport) void Add_Rxchannel(float *location, float *polar_real,
float *polar_imag, float *phi,
float *phi_ptn, int phi_length,
float *theta, float *theta_ptn,
int theta_length, float antenna_gain,
t_Receiver *ptr_rx_c);

/**
Expand Down
47 changes: 28 additions & 19 deletions src/radarsim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ t_Transmitter *Create_Transmitter(double *freq, double *freq_time,
* @param grid Ray occupancy checking grid (rad)
* @param ptr_tx_c Pointer to the Transmitter
*/
void Add_Txchannel(float *location, float *polar, float *phi, float *phi_ptn,
int phi_length, float *theta, float *theta_ptn,
int theta_length, float antenna_gain, float *mod_t,
float *mod_var_real, float *mod_var_imag, int mod_length,
float *pulse_mod_real, float *pulse_mod_imag, float delay,
float grid, t_Transmitter *ptr_tx_c) {
void Add_Txchannel(float *location, float *polar_real, float *polar_imag,
float *phi, float *phi_ptn, int phi_length, float *theta,
float *theta_ptn, int theta_length, float antenna_gain,
float *mod_t, float *mod_var_real, float *mod_var_imag,
int mod_length, float *pulse_mod_real, float *pulse_mod_imag,
float delay, float grid, t_Transmitter *ptr_tx_c) {
std::vector<float> phi_vt, phi_ptn_vt;
phi_vt.reserve(phi_length);
phi_ptn_vt.reserve(phi_length);
Expand Down Expand Up @@ -179,11 +179,15 @@ void Add_Txchannel(float *location, float *polar, float *phi, float *phi_ptn,
std::complex<float>(pulse_mod_real[idx], pulse_mod_imag[idx]));
}

ptr_tx_c->_ptr_transmitter->AddChannel(
TxChannel<float>(zpv::Vec3<float>(location[0], location[1], location[2]),
zpv::Vec3<float>(polar[0], polar[1], polar[2]), phi_vt,
phi_ptn_vt, theta_vt, theta_ptn_vt, antenna_gain,
mod_t_vt, mod_var_vt, pulse_mod_vt, delay, grid));
zpv::Vec3<std::complex<float>> polar_complex = zpv::Vec3<std::complex<float>>(
std::complex<float>(polar_real[0], polar_imag[0]),
std::complex<float>(polar_real[1], polar_imag[1]),
std::complex<float>(polar_real[2], polar_imag[2]));

ptr_tx_c->_ptr_transmitter->AddChannel(TxChannel<float>(
zpv::Vec3<float>(location[0], location[1], location[2]), polar_complex,
phi_vt, phi_ptn_vt, theta_vt, theta_ptn_vt, antenna_gain, mod_t_vt,
mod_var_vt, pulse_mod_vt, delay, grid));
}

/**
Expand Down Expand Up @@ -254,9 +258,10 @@ t_Receiver *Create_Receiver(float fs, float rf_gain, float resistor,
* @param antenna_gain Antenna gain (dB)
* @param ptr_rx_c Pointer to Receiver
*/
void Add_Rxchannel(float *location, float *polar, float *phi, float *phi_ptn,
int phi_length, float *theta, float *theta_ptn,
int theta_length, float antenna_gain, t_Receiver *ptr_rx_c) {
void Add_Rxchannel(float *location, float *polar_real, float *polar_imag,
float *phi, float *phi_ptn, int phi_length, float *theta,
float *theta_ptn, int theta_length, float antenna_gain,
t_Receiver *ptr_rx_c) {
std::vector<float> phi_vt, phi_ptn_vt;
phi_vt.reserve(phi_length);
phi_ptn_vt.reserve(phi_length);
Expand All @@ -273,10 +278,14 @@ void Add_Rxchannel(float *location, float *polar, float *phi, float *phi_ptn,
theta_ptn_vt.push_back(theta_ptn[idx]);
}

ptr_rx_c->_ptr_receiver->AddChannel(
RxChannel<float>(zpv::Vec3<float>(location[0], location[1], location[2]),
zpv::Vec3<float>(polar[0], polar[1], polar[2]), phi_vt,
phi_ptn_vt, theta_vt, theta_ptn_vt, antenna_gain));
zpv::Vec3<std::complex<float>> polar_complex = zpv::Vec3<std::complex<float>>(
std::complex<float>(polar_real[0], polar_imag[0]),
std::complex<float>(polar_real[1], polar_imag[1]),
std::complex<float>(polar_real[2], polar_imag[2]));

ptr_rx_c->_ptr_receiver->AddChannel(RxChannel<float>(
zpv::Vec3<float>(location[0], location[1], location[2]), polar_complex,
phi_vt, phi_ptn_vt, theta_vt, theta_ptn_vt, antenna_gain));
}

/**
Expand Down Expand Up @@ -550,7 +559,7 @@ void Run_Simulator(t_Radar *ptr_radar_c, t_Targets *ptr_targets_c, int level,
}
}

scene_c.RunSimulator(level, false, snap_list.ptr_snapshots_, density,
scene_c.RunSimulator(level, false, snap_list.ptr_snapshots_, density, "",
ptr_bb_real, ptr_bb_imag);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/radarsimcpp

0 comments on commit 48a171b

Please sign in to comment.