Adding the barking code and the launch file
This commit is contained in:
parent
ef7d32ad8e
commit
f19770db80
|
|
@ -0,0 +1,22 @@
|
|||
import pygame
|
||||
import time
|
||||
import random
|
||||
|
||||
# Initialize pygame mixer
|
||||
pygame.mixer.init()
|
||||
|
||||
# Load the sound file
|
||||
sound = pygame.mixer.Sound("bark5.wav")
|
||||
|
||||
try:
|
||||
while True:
|
||||
# Play the sound
|
||||
sound.play()
|
||||
|
||||
# Wait for the sound to finish playing
|
||||
time.sleep(sound.get_length())
|
||||
|
||||
# Wait for a random interval between plays, e.g., 2 to 5 seconds
|
||||
time.sleep(random.randint(2, 5))
|
||||
except KeyboardInterrupt:
|
||||
print("Playback stopped by user.")
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<launch>
|
||||
<!-- Launch barking.py -->
|
||||
<node name="barking" pkg="my_robot_package" type="barking.py" output="screen"/>
|
||||
|
||||
<!-- Launch bring_ball.py -->
|
||||
<node name="bring_ball" pkg="my_robot_package" type="bring_ball.py" output="screen"/>
|
||||
</launch>
|
||||
Loading…
Reference in New Issue