Skip to content
Open

Cpp #276

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
36 changes: 34 additions & 2 deletions sound_play/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,18 @@ find_package(ament_cmake REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(audio_common_msgs REQUIRED)
find_package(action_msgs REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(diagnostic_msgs REQUIRED)
find_package(ament_index_cpp REQUIRED)

include_directories(rclcpp audio_common_msgs action_msgs builtin_interfaces)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GST REQUIRED gstreamer-1.0)

include_directories(
include
${GST_INCLUDE_DIRS}
)

set(msg_files
"msg/SoundRequest.msg"
Expand All @@ -33,7 +43,29 @@ rosidl_generate_interfaces(${PROJECT_NAME}
builtin_interfaces
)

ament_python_install_package(${PROJECT_NAME})
# Build C++ soundplay node
add_executable(soundplay_node_cpp src/soundplay_node.cpp)
ament_target_dependencies(soundplay_node_cpp
rclcpp
rclcpp_action
diagnostic_msgs
ament_index_cpp
)
target_link_libraries(soundplay_node_cpp ${GST_LIBRARIES})

# Need to link against the generated interfaces
rosidl_get_typesupport_target(cpp_typesupport_target ${PROJECT_NAME} "rosidl_typesupport_cpp")
target_link_libraries(soundplay_node_cpp "${cpp_typesupport_target}")

install(TARGETS soundplay_node_cpp
DESTINATION lib/${PROJECT_NAME}
)

# Install Python package manually to avoid conflicts with rosidl_generate_interfaces
install(DIRECTORY ${PROJECT_NAME}/
DESTINATION lib/python3.12/site-packages/${PROJECT_NAME}
FILES_MATCHING PATTERN "*.py"
)

install(PROGRAMS
scripts/is_speaking.py
Expand Down
4 changes: 2 additions & 2 deletions sound_play/launch/soundplay_node.launch.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
This launch file starts soundplay_node.py, which is the node that plays
This launch file starts soundplay_node_cpp, which is the C++ node that plays
sounds based on messages on the robotsound topic.
-->

Expand All @@ -8,7 +8,7 @@ sounds based on messages on the robotsound topic.
<arg name="loop_rate" default="100" />
<arg name="default_voice" default="voice_kal_diphone" />

<node name="soundplay_node" pkg="sound_play" exec="soundplay_node.py">
<node name="soundplay_node" pkg="sound_play" exec="soundplay_node_cpp">
<param name="device" value="$(var device)" />
<param name="loop_rate" value="$(var loop_rate)" />
<param name="default_voice" value="$(var default_voice)" />
Expand Down
9 changes: 9 additions & 0 deletions sound_play/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,19 @@
<build_depend>audio_common_msgs</build_depend>
<build_depend>boost</build_depend>
<build_depend>builtin_interfaces</build_depend>
<build_depend>rclcpp</build_depend>
<build_depend>rclcpp_action</build_depend>
<build_depend>diagnostic_msgs</build_depend>
<build_depend>ament_index_cpp</build_depend>
<build_depend>libgstreamer1.0-dev</build_depend>

<exec_depend>action_msgs</exec_depend>
<exec_depend>audio_common_msgs</exec_depend>
<exec_depend>builtin_interfaces</exec_depend>
<exec_depend>rclcpp</exec_depend>
<exec_depend>rclcpp_action</exec_depend>
<exec_depend>diagnostic_msgs</exec_depend>
<exec_depend>ament_index_cpp</exec_depend>
<exec_depend>festival</exec_depend>
<exec_depend>launch_xml</exec_depend>
<exec_depend>rclpy</exec_depend>
Expand Down
Loading
Loading