Upload files to "dogbot_bark"

This commit is contained in:
Rady LY 2024-03-13 15:28:58 +01:00
parent 7adbd5c314
commit 9fda233c88
5 changed files with 117 additions and 0 deletions

View File

@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.0.2)
project(dogbot_bark)
## Find catkin and any catkin packages
find_package(catkin REQUIRED COMPONENTS
rospy
std_msgs
)
## Declare a catkin package
catkin_package()
## Mark executable scripts (Python etc.) for installation
## This ensures the node can be run from anywhere and not just the source directory
catkin_install_python(PROGRAMS scripts/bark.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
install(DIRECTORY src/
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/src
FILES_MATCHING PATTERN "*.wav"
)
## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
${catkin_INCLUDE_DIRS}
)

BIN
dogbot_bark/Dog Barking.wav Normal file

Binary file not shown.

BIN
dogbot_bark/Dog Woof.wav Normal file

Binary file not shown.

23
dogbot_bark/bark.py Normal file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env python
import rospy
from std_msgs.msg import String
import os
import rospkg
def callback(data):
rospy.loginfo("Received a command to bark")
# Get the path of the 'dogbot_bark' package
rospack = rospkg.RosPack()
package_path = rospack.get_path('dogbot_bark')
sound_file_path = os.path.join(package_path, 'src', 'Dog Woof.wav')
os.system(f'aplay {sound_file_path}') # Play the sound file
def listener():
rospy.init_node('bark_listener', anonymous=True)
rospy.Subscriber("bark_command", String, callback)
rospy.spin()
if __name__ == '__main__':
listener()

65
dogbot_bark/package.xml Normal file
View File

@ -0,0 +1,65 @@
<?xml version="1.0"?>
<package format="2">
<name>dogbot_bark</name>
<version>0.0.0</version>
<description>The dogbot_bark package</description>
<!-- One maintainer tag required, multiple allowed, one person per tag -->
<!-- Example: -->
<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
<maintainer email="dy11@todo.todo">dy11</maintainer>
<!-- One license tag required, multiple allowed, one license per tag -->
<!-- Commonly used license strings: -->
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
<license>TODO</license>
<!-- Url tags are optional, but multiple are allowed, one per tag -->
<!-- Optional attribute type can be: website, bugtracker, or repository -->
<!-- Example: -->
<!-- <url type="website">http://wiki.ros.org/dogbot_bark</url> -->
<!-- Author tags are optional, multiple are allowed, one per tag -->
<!-- Authors do not have to be maintainers, but could be -->
<!-- Example: -->
<!-- <author email="jane.doe@example.com">Jane Doe</author> -->
<!-- The *depend tags are used to specify dependencies -->
<!-- Dependencies can be catkin packages or system dependencies -->
<!-- Examples: -->
<!-- Use depend as a shortcut for packages that are both build and exec dependencies -->
<!-- <depend>roscpp</depend> -->
<!-- Note that this is equivalent to the following: -->
<!-- <build_depend>roscpp</build_depend> -->
<!-- <exec_depend>roscpp</exec_depend> -->
<!-- Use build_depend for packages you need at compile time: -->
<!-- <build_depend>message_generation</build_depend> -->
<!-- Use build_export_depend for packages you need in order to build against this package: -->
<!-- <build_export_depend>message_generation</build_export_depend> -->
<!-- Use buildtool_depend for build tool packages: -->
<!-- <buildtool_depend>catkin</buildtool_depend> -->
<!-- Use exec_depend for packages you need at runtime: -->
<!-- <exec_depend>message_runtime</exec_depend> -->
<!-- Use test_depend for packages you need only for testing: -->
<!-- <test_depend>gtest</test_depend> -->
<!-- Use doc_depend for packages you need only for building documentation: -->
<!-- <doc_depend>doxygen</doc_depend> -->
<buildtool_depend>catkin</buildtool_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_export_depend>rospy</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>std_msgs</exec_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->
</export>
</package>