Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 40 additions & 49 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
cmake_minimum_required(VERSION 2.8.3)
cmake_minimum_required(VERSION 3.8)
project(gl_depth_sim)


set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_compile_options(-Wall -Wextra)

find_package(catkin REQUIRED COMPONENTS
roscpp # Used for ROS examples
pcl_ros # Used for interfaces extension
tf2_ros # Used for ROS example
tf2_eigen # Used for ROS example
visualization_msgs # Used for ROS example
)
# Used for ROS examples
find_package(ament_cmake REQUIRED)
find_package(PCL REQUIRED QUIET)
find_package(pcl_conversions REQUIRED)
find_package(pcl_ros REQUIRED)
find_package(rclcpp REQUIRED)
find_package(tf2_eigen REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(visualization_msgs REQUIRED)

# Required for core functionality
find_package(glfw3 REQUIRED)
Expand All @@ -24,21 +25,8 @@ find_package(Eigen3 REQUIRED)
find_package(assimp REQUIRED) # Just used for loading models in mesh_loader.h
find_package(OpenCV REQUIRED) # Used for interface extension

catkin_package(
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME} ${PROJECT_NAME}_interfaces
CATKIN_DEPENDS
roscpp
pcl_ros
tf2_ros
tf2_eigen
visualization_msgs
DEPENDS OpenCV
)

include_directories(
include
${catkin_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIRS}
)

Expand All @@ -53,33 +41,46 @@ add_library(${PROJECT_NAME}
src/${PROJECT_NAME}/glad.c
src/${PROJECT_NAME}/glfw_guard.cpp
)
add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(${PROJECT_NAME}
${OPENGL_LIBRARIES}
${ASSIMP_LIBRARIES}
dl
glfw
)

# Libaries for interfacing with opencv and pcl
# ament_target_dependencies(${PROJECT_NAME}
# rclcpp
# pcl_conversions
# pcl_ros
# tf2_ros
# tf2_eigen
# visualization_msgs
# OpenCV
# )
Comment on lines +50 to +58
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comments

Suggested change
# ament_target_dependencies(${PROJECT_NAME}
# rclcpp
# pcl_conversions
# pcl_ros
# tf2_ros
# tf2_eigen
# visualization_msgs
# OpenCV
# )


# Libraries for interfacing with opencv and pcl
add_library(${PROJECT_NAME}_interfaces
src/interfaces/pcl_interface.cpp
src/interfaces/opencv_interface.cpp
)
add_dependencies(${PROJECT_NAME}_interfaces ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(${PROJECT_NAME}_interfaces
${PROJECT_NAME}
${catkin_LIBRARIES}
${OpenCV_LIBRARIES}
)
ament_target_dependencies(${PROJECT_NAME}_interfaces
rclcpp
pcl_conversions
pcl_ros
tf2_ros
tf2_eigen
visualization_msgs
OpenCV
)

# Simulated laser scanner library
add_library(${PROJECT_NAME}_sim_laser_scanner
src/${PROJECT_NAME}/sim_laser_scanner.cpp
)
add_dependencies(${PROJECT_NAME}_interfaces ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(${PROJECT_NAME}_sim_laser_scanner
${catkin_LIBRARIES}
${PROJECT_NAME}
${PROJECT_NAME}_interfaces
)
Expand All @@ -90,7 +91,6 @@ set_target_properties(${PROJECT_NAME}_test PROPERTIES OUTPUT_NAME depth_example
target_link_libraries(${PROJECT_NAME}_test
${PROJECT_NAME}
${PROJECT_NAME}_interfaces
${catkin_LIBRARIES}
)

# Example showing an orbiting camera
Expand All @@ -99,7 +99,6 @@ set_target_properties(${PROJECT_NAME}_orbit PROPERTIES OUTPUT_NAME orbit_example
target_link_libraries(${PROJECT_NAME}_orbit
${PROJECT_NAME}
${PROJECT_NAME}_interfaces
${catkin_LIBRARIES}
)

# Example showing orbiting camera with point cloud publishing in ROS
Expand All @@ -108,17 +107,16 @@ set_target_properties(${PROJECT_NAME}_ros_orbit PROPERTIES OUTPUT_NAME ros_examp
target_link_libraries(${PROJECT_NAME}_ros_orbit
${PROJECT_NAME}
${PROJECT_NAME}_interfaces
${catkin_LIBRARIES}
)

# Example showing sweeping laser scan with point cloud publishing in ROS
add_executable(${PROJECT_NAME}_laser_example src/laser_example.cpp)
set_target_properties(${PROJECT_NAME}_laser_example PROPERTIES OUTPUT_NAME laser_example PREFIX "")
target_link_libraries(${PROJECT_NAME}_laser_example
${PROJECT_NAME}_sim_laser_scanner
${catkin_LIBRARIES}
)

# Install targets
install(
TARGETS
${PROJECT_NAME}
Expand All @@ -128,23 +126,16 @@ install(
${PROJECT_NAME}_orbit
${PROJECT_NAME}_ros_orbit
${PROJECT_NAME}_laser_example
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib/${PROJECT_NAME}
)

install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
install(DIRECTORY include/
DESTINATION include/${PROJECT_NAME})

install(DIRECTORY launch test
DESTINATION share/${PROJECT_NAME}/
)

#############
## Testing ##
#############
#if(CATKIN_ENABLE_TESTING)
# find_package(rostest REQUIRED)
# catkin_add_gtest(utest_node test/utest.cpp)
# target_link_libraries(utest_node
# ${catkin_LIBRARIES}
# ${PROJECT_NAME}_sim_laser_scanner
# )
#endif()
ament_package()
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ This scene shows the classic Stanford Dragon seen by a depth camera orbiting aro

You can run this example in ROS by building this package in your workspace and running:
```
rosrun gl_depth_sim ros_example _mesh:=<PATH_TO_YOUR_MESH>
ros2 run gl_depth_sim ros_example _mesh:=<PATH_TO_YOUR_MESH>
```

You can also set the `_z` and `_radius` parameters.
Expand All @@ -37,7 +37,7 @@ Various properties of the laser scanner, such as minimum and maximum range and a

You can run this example in ROS by building this package in your workspace and running:
```
roslaunch gl_depth_sim laser_example.launch
ros2 launch gl_depth_sim laser_example.launch.py
```

## Usage
Expand Down
14 changes: 0 additions & 14 deletions launch/laser_example.launch

This file was deleted.

48 changes: 48 additions & 0 deletions launch/laser_example.launch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import LaunchConfiguration
from launch_ros.actions import Node
import os
from ament_index_python.packages import get_package_share_directory

def generate_launch_description():
rviz_config = LaunchConfiguration('rviz_config')
mesh_filename = LaunchConfiguration('mesh_filename')

return LaunchDescription([
DeclareLaunchArgument(
'rviz_config',
default_value=os.path.join(
get_package_share_directory('gl_depth_sim'),
'launch', 'laser_example.rviz'
),
description='Path to the RViz config file'
),
DeclareLaunchArgument(
'mesh_filename',
default_value=os.path.join(
get_package_share_directory('gl_depth_sim'),
'test', 'stanford_dragon.stl'
),
description='Path to the mesh file'
),
Node(
package='gl_depth_sim',
executable='laser_example',
name='laser_example',
output='screen',
parameters=[{
'mesh_filename': mesh_filename,
'min_range': 0.1,
'max_range': 30.0,
'angular_resolution': 0.001
}]
),
Node(
package='rviz2',
executable='rviz2',
name='rviz',
output='screen',
arguments=['-d', rviz_config]
)
])
Loading