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
3 changes: 1 addition & 2 deletions ros_gz/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
<exec_depend>ros_gz_sim</exec_depend>
<exec_depend>ros_gz_sim_demos</exec_depend>
<exec_depend>ros_gz_image</exec_depend>
<!-- See https://github.com/gazebosim/ros_gz/issues/40 -->
<!--exec_depend>ros_gz_point_cloud</exec_depend-->
<exec_depend>ros_gz_point_cloud</exec_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
Expand Down
86 changes: 42 additions & 44 deletions ros_gz_point_cloud/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,67 +1,65 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.20)

project(ros_gz_point_cloud)

# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra)
endif()

find_package(catkin REQUIRED COMPONENTS
roscpp
sensor_msgs)

find_package(ignition-gazebo2 2.1 QUIET REQUIRED)
set(GZ_SIM_VER ${ignition-gazebo2_VERSION_MAJOR})

find_package(ignition-rendering2 QUIET REQUIRED)
set(GZ_RENDERING_VER ${ignition-rendering2_VERSION_MAJOR})

find_package(ignition-sensors2 QUIET REQUIRED)
set(GZ_SENSORS_VER ${ignition-sensors2_VERSION_MAJOR})

catkin_package()
find_package(ament_cmake REQUIRED)
# Provides the ament_cmake_ros_core::ament_ros_cxx_standard interface target,
# which sets the C++ standard (C++20 on Rolling) used across the ROS 2 core.
find_package(ament_cmake_ros_core REQUIRED)
find_package(point_cloud_transport REQUIRED)
find_package(rclcpp REQUIRED)
find_package(sensor_msgs REQUIRED)

include_directories(
include
${catkin_INCLUDE_DIRS}
)
find_package(gz_common_vendor REQUIRED)
find_package(gz-common REQUIRED)
find_package(gz_math_vendor REQUIRED)
find_package(gz-math REQUIRED)
find_package(gz_plugin_vendor REQUIRED)
find_package(gz-plugin REQUIRED)
find_package(gz_rendering_vendor REQUIRED)
find_package(gz-rendering REQUIRED)
find_package(gz_sim_vendor REQUIRED)
find_package(gz-sim REQUIRED)

set(plugin_name RosGzPointCloud)
add_library(${plugin_name} SHARED
src/point_cloud.cc
src/point_cloud.cpp
)
target_include_directories(${plugin_name} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
target_link_libraries(${plugin_name}
ignition-gazebo${GZ_SIM_VER}::core
ignition-rendering${GZ_RENDERING_VER}::core
ignition-sensors${GZ_SENSORS_VER}::core
${catkin_LIBRARIES}
ament_cmake_ros_core::ament_ros_cxx_standard
gz-common::gz-common
gz-math::gz-math
gz-plugin::register
gz-rendering::gz-rendering
gz-sim::gz-sim
point_cloud_transport::point_cloud_transport
rclcpp::rclcpp
${sensor_msgs_TARGETS}
)

install(TARGETS ${plugin_name}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

install(
DIRECTORY
examples/
DESTINATION
${CATKIN_PACKAGE_SHARE_DESTINATION}/examples
share/${PROJECT_NAME}/examples
)

# TODO(CH3): Install symlink to deprecated library name. Remove on tock.
string(REPLACE "RosGz" "RosIgn" plugin_name_ign ${plugin_name})
if(WIN32)
# symlinks on Windows require admin privileges, fallback to copy
ADD_CUSTOM_COMMAND(TARGET ${plugin_name} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:${plugin_name}>"
"$<TARGET_FILE_DIR:${CATKIN_PACKAGE_LIB_DESTINATION}>/${plugin_name_ign}")
else()
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink ${plugin_name} ${plugin_name_ign} WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
INSTALL(FILES ${PROJECT_BINARY_DIR}/lib/${plugin_name_ign} DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()

ament_package()
Empty file removed ros_gz_point_cloud/COLCON_IGNORE
Empty file.
90 changes: 67 additions & 23 deletions ros_gz_point_cloud/examples/depth_camera.sdf
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,32 @@

Try it out:

1. Start ROS core:
1. Source your ROS 2 workspace, for example:

roscore
. <ws>/install/setup.bash

2. Make sure Gazebo Sim can find the point cloud plugin by adding your lib install directory
2. Make sure Gazebo Sim can find the point cloud plugin by adding its lib install directory
to the path, for example:

export GZ_SIM_SYSTEM_PLUGIN_PATH=<ws>/install/lib/
export GZ_SIM_SYSTEM_PLUGIN_PATH=<ws>/install/ros_gz_point_cloud/lib

or, if the workspace was built with `--merge-install`:

export GZ_SIM_SYSTEM_PLUGIN_PATH=<ws>/install/lib

3. Load the example world, unpaused:

gz sim -r examples/depth_camera.sdf

4. Launch RViz to visualize the point cloud:

rosrun rviz rviz
ros2 run rviz2 rviz2

5. On RViz, add the `/depth_camera/points` topic for `PointCloud2` messages and change the fixed frame
to `map`. You should see the point cloud.
5. On RViz, add the `/ros_gz/custom_params/link/depth_camera/points` topic for `PointCloud2`
messages and change the fixed frame to `map`. You should see the point cloud.

The plugin has no `<namespace>`, so the topic is placed under the sensor's scoped name,
`/<world>/<model>/<link>/<sensor>`.

-->
<sdf version="1.6">
Expand All @@ -32,28 +39,28 @@
<real_time_factor>1.0</real_time_factor>
</physics>
<plugin
filename="ignition-gazebo-physics-system"
name="ignition::gazebo::systems::Physics">
filename="gz-sim-physics-system"
name="gz::sim::systems::Physics">
</plugin>
<plugin
filename="ignition-gazebo-sensors-system"
name="ignition::gazebo::systems::Sensors">
filename="gz-sim-sensors-system"
name="gz::sim::systems::Sensors">
<render_engine>ogre2</render_engine>
</plugin>
<plugin
filename="ignition-gazebo-scene-broadcaster-system"
name="ignition::gazebo::systems::SceneBroadcaster">
filename="gz-sim-scene-broadcaster-system"
name="gz::sim::systems::SceneBroadcaster">
</plugin>

<gui fullscreen="0">

<!-- 3D scene -->
<plugin filename="GzScene3D" name="3D View">
<ignition-gui>
<plugin filename="MinimalScene" name="3D View">
<gz-gui>
<title>3D View</title>
<property type="bool" key="showTitleBar">false</property>
<property type="string" key="state">docked</property>
</ignition-gui>
</gz-gui>

<engine>ogre2</engine>
<scene>scene</scene>
Expand All @@ -62,9 +69,46 @@
<camera_pose>-6 0 6 0 0.5 0</camera_pose>
</plugin>

<!-- Plugins that add functionality to the scene -->
<plugin filename="EntityContextMenuPlugin" name="Entity context menu">
<gz-gui>
<property key="state" type="string">floating</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="showTitleBar" type="bool">false</property>
</gz-gui>
</plugin>
<plugin filename="GzSceneManager" name="Scene Manager">
<gz-gui>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</gz-gui>
</plugin>
<plugin filename="InteractiveViewControl" name="Interactive view control">
<gz-gui>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</gz-gui>
</plugin>
<plugin filename="CameraTracking" name="Camera Tracking">
<gz-gui>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</gz-gui>
</plugin>

<!-- World control -->
<plugin filename="WorldControl" name="World control">
<ignition-gui>
<gz-gui>
<title>World control</title>
<property type="bool" key="showTitleBar">false</property>
<property type="bool" key="resizable">false</property>
Expand All @@ -77,7 +121,7 @@
<line own="left" target="left"/>
<line own="bottom" target="bottom"/>
</anchors>
</ignition-gui>
</gz-gui>

<play_pause>true</play_pause>
<step>true</step>
Expand All @@ -89,7 +133,7 @@

<!-- World statistics -->
<plugin filename="WorldStats" name="World stats">
<ignition-gui>
<gz-gui>
<title>World stats</title>
<property type="bool" key="showTitleBar">false</property>
<property type="bool" key="resizable">false</property>
Expand All @@ -102,7 +146,7 @@
<line own="right" target="right"/>
<line own="bottom" target="bottom"/>
</anchors>
</ignition-gui>
</gz-gui>

<sim_time>true</sim_time>
<real_time>true</real_time>
Expand All @@ -112,9 +156,9 @@
</plugin>

<plugin filename="ImageDisplay" name="Image Display">
<ignition-gui>
<gz-gui>
<property key="state" type="string">docked</property>
</ignition-gui>
</gz-gui>
</plugin>
</gui>

Expand Down Expand Up @@ -308,7 +352,7 @@
<include>
<pose>0 1 3 0.0 0.0 1.57</pose>
<uri>
https://fuel.ignitionrobotics.org/1.0/openrobotics/models/Construction Cone
https://fuel.gazebosim.org/1.0/OpenRobotics/models/Construction Cone
</uri>
</include>

Expand Down
Loading
Loading