Skip to content

Commit

Permalink
fix flake8 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
CullenSUN committed Nov 4, 2023
1 parent 2643cd1 commit 5403a6f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 2 additions & 3 deletions mini_pupper_music/launch/music.launch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from launch import LaunchDescription
from launch_ros.actions import Node
from launch.substitutions import LaunchConfiguration
from launch.actions import DeclareLaunchArgument, LogInfo


def generate_launch_description():
music_server_node = Node(
Expand All @@ -12,4 +11,4 @@ def generate_launch_description():
)
return LaunchDescription([
music_server_node
])
])
7 changes: 5 additions & 2 deletions mini_pupper_music/mini_pupper_music/music_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import os
from ament_index_python.packages import get_package_share_directory


class SoundPlayerNode(Node):
def __init__(self):
super().__init__('mini_pupper_music_service')
Expand Down Expand Up @@ -53,7 +54,7 @@ def play_sound_thread(self):
file_name = 'resource/robot1.wav'
package_path = get_package_share_directory(package_name)
sound_file = os.path.join(package_path, file_name)

data, fs = sf.read(sound_file, dtype='float32')
while self.is_playing:
sd.play(data, fs)
Expand All @@ -67,12 +68,14 @@ def stop_sound(self):
# If the thread is still running, stop the sound playback
sd.stop()


def main(args=None):
rclpy.init(args=args)
sound_player_node = SoundPlayerNode()
rclpy.spin(sound_player_node)
sound_player_node.destroy_node()
rclpy.shutdown()


if __name__ == '__main__':
main()
main()
3 changes: 2 additions & 1 deletion mini_pupper_music/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
version='1.0.0',
packages=find_packages(exclude=['test']),
data_files=[
('share/ament_index/resource_index/packages', ['resource/' + package_name]),
('share/ament_index/resource_index/packages',
['resource/' + package_name]),
('share/' + package_name, ['package.xml']),
('share/' + package_name + '/resource', glob('resource/*')),
(os.path.join('share', package_name), glob('launch/*.launch.py')),
Expand Down

0 comments on commit 5403a6f

Please sign in to comment.