Skip to content

Commit

Permalink
Merge pull request #2 from uos/fix/optional-embree
Browse files Browse the repository at this point in the history
Required Embree -> Optional Embree
  • Loading branch information
amock authored Feb 12, 2024
2 parents b93da73 + 1dad512 commit ed68b46
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 24 deletions.
73 changes: 53 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ if(TARGET rmagine::optix)
list(APPEND RADARAYS_ROS_DEFINITIONS -DRADARAYS_WITH_GPU)
endif()

if(TARGET rmagine::embree)
list(APPEND RADARAYS_ROS_LIBRARIES radarays_cpu)
set(RADARAYS_WITH_CPU True)
list(APPEND RADARAYS_ROS_DEFINITIONS -DRADARAYS_WITH_CPU)
endif()


add_message_files(
FILES
Expand Down Expand Up @@ -101,7 +107,6 @@ add_library(radarays
src/radarays_ros/radar_algorithms.cpp
src/radarays_ros/ros_helper.cpp
src/radarays_ros/Radar.cpp
src/radarays_ros/RadarCPU.cpp
)

add_dependencies(radarays
Expand All @@ -112,7 +117,6 @@ add_dependencies(radarays

target_link_libraries(radarays
rmagine::core
rmagine::embree
${catkin_LIBRARIES}
${OpenCV_LIBS}
)
Expand All @@ -123,6 +127,26 @@ install(TARGETS radarays
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
)

if(RADARAYS_WITH_CPU)
add_library(radarays_cpu
src/radarays_ros/RadarCPU.cpp
)
add_dependencies(radarays_cpu
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
${PROJECT_NAME}_gencfg
)
target_link_libraries(radarays_cpu
radarays
rmagine::embree
)
install(TARGETS radarays_cpu
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
)
endif(RADARAYS_WITH_CPU)

if(RADARAYS_WITH_GPU)
add_library(radarays_gpu SHARED
src/radarays_ros/image_algorithms.cu
Expand Down Expand Up @@ -160,35 +184,44 @@ add_dependencies(radar_simulator
target_link_libraries(radar_simulator
${catkin_LIBRARIES}
rmagine::core
rmagine::embree
${OpenCV_LIBS}
radarays
)

target_compile_definitions(radar_simulator
PUBLIC ${RADARAYS_ROS_DEFINITIONS}
)
if(RADARAYS_WITH_CPU)
# Enable CPU simulation
target_compile_definitions(radar_simulator PUBLIC RADARAYS_WITH_CPU)
target_link_libraries(radar_simulator
radarays_cpu
)
endif(RADARAYS_WITH_CPU)

if(RADARAYS_WITH_GPU)
# Enable GPU simulation
target_compile_definitions(radar_simulator PUBLIC RADARAYS_WITH_GPU)
target_link_libraries(radar_simulator
radarays_gpu
)
endif(RADARAYS_WITH_GPU)

add_executable(ray_reflection_test src/ray_reflection_test.cpp)

add_dependencies(ray_reflection_test
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
${PROJECT_NAME}_gencfg
)
# TESTS MAINLY PROTOTYPED WITH CPU
if(RADARAYS_WITH_CPU)
add_executable(ray_reflection_test src/ray_reflection_test.cpp)

## Specify libraries to link a library or executable target against
target_link_libraries(ray_reflection_test
${catkin_LIBRARIES}
rmagine::core
rmagine::embree
${OpenCV_LIBS}
radarays
)
add_dependencies(ray_reflection_test
${${PROJECT_NAME}_EXPORTED_TARGETS}
${catkin_EXPORTED_TARGETS}
${PROJECT_NAME}_gencfg
)

## Specify libraries to link a library or executable target against
target_link_libraries(ray_reflection_test
${catkin_LIBRARIES}
rmagine::core
rmagine::embree
${OpenCV_LIBS}
radarays
)

endif(RADARAYS_WITH_CPU)
25 changes: 21 additions & 4 deletions src/radar_simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@

#include <radarays_ros/ros_helper.h>

#include <rmagine/simulation/OnDnSimulatorEmbree.hpp>

#include <radarays_ros/image_algorithms.h>
#include <radarays_ros/radar_algorithms.h>

#if defined RADARAYS_WITH_CPU
#include <rmagine/simulation/OnDnSimulatorEmbree.hpp>
#include <radarays_ros/RadarCPU.hpp>
#endif // defined RADARAYS_WITH_CPU

#if defined RADARAYS_WITH_GPU
#include <rmagine/simulation/OnDnSimulatorOptix.hpp>
Expand Down Expand Up @@ -116,20 +120,32 @@ int main_publisher(int argc, char** argv)

// available computing unit
bool gpu_available = false;
bool cpu_available = false;
#if defined RADARAYS_WITH_GPU
gpu_available = true;
#endif
#endif // defined RADARAYS_WITH_GPU

#if defined RADARAYS_WITH_CPU
cpu_available = true;
#endif // defined RADARAYS_WITH_CPU


if(use_gpu && !gpu_available)
{
std::cout << "Desired computing unit 'GPU' is not available on your system." << std::endl;
return 0;
}

if(!use_gpu && !cpu_available)
{
std::cout << "Desired computing unit 'CPU' is not available on your system." << std::endl;
return 0;
}

if(!use_gpu)
{
// CPU
#if defined RADARAYS_WITH_CPU
rm::EmbreeMapPtr map_cpu = rm::import_embree_map(map_file);

std::cout << "RadarCPU" << std::endl;
Expand All @@ -141,7 +157,8 @@ int main_publisher(int argc, char** argv)
sensor_frame,
map_cpu
);
} else {
#endif // defined RADARAYS_WITH_CPU
} else {
// GPU
#if defined RADARAYS_WITH_GPU
rm::OptixMapPtr map_gpu = rm::import_optix_map(map_file);
Expand All @@ -155,7 +172,7 @@ int main_publisher(int argc, char** argv)
sensor_frame,
map_gpu
);
#endif
#endif // defined RADARAYS_WITH_GPU
}

// image transport
Expand Down

0 comments on commit ed68b46

Please sign in to comment.