Skip to content

Commit

Permalink
responding to feedback on PR
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioc76 committed Dec 6, 2024
1 parent 6970891 commit e720cea
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
4 changes: 2 additions & 2 deletions autonav_ws/src/autonav_hardware/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>autonav_hardware</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<version>2025.0.1</version>
<description>Contains ROS nodes responsible for interacting with hardware devices</description>
<maintainer email="[email protected]">tony</maintainer>
<license>MIT</license>

Expand Down
31 changes: 27 additions & 4 deletions autonav_ws/src/autonav_hardware/src/audible_feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
class AudibleFeedbackConfig:
def __init__(self):
self.volume = 1.0
self.autonomous_transition_filepath = os.path.expanduser('~/Documents/imposter.mp3')


class AudibleFeedbackNode(Node):
Expand All @@ -40,7 +41,7 @@ def __init__(self):
def on_audible_feedback_received(self, msg:AudibleFeedback):
self.monitor_tracks()

self.log(f"{len(self.secondary_tracks)}", LogLevel.ERROR)
# self.log(f"{len(self.secondary_tracks)}", LogLevel.DEBUG)
if msg.stop_all:
self.stop_all()
return
Expand All @@ -63,26 +64,42 @@ def on_audible_feedback_received(self, msg:AudibleFeedback):


def play_sound(self, filename, main_track: bool):
if main_track and self.main_track is not None:
return

playback = PySoundSphere.AudioPlayer("ffplay", debug_allow_multiple_playbacks=False)
playback.load(filename)
try:
playback.load(filename)
except:
self.log("invalid filename", LogLevel.ERROR)
return

playback.volume = self.config.get('volume')
playback.play()

if main_track:
self.main_track = playback

else:
self.secondary_tracks.append(playback)


def stop_all(self):
if self.main_track is not None:
self.log(f"{self.main_track}")

for track in self.secondary_tracks:
self.log(f"{track}")

for track in self.secondary_tracks:
track.stop()

self.secondary_tracks = []
self.main_track.stop()
try:
self.main_track.stop()
except:
self.log("No main track", LogLevel.ERROR)

self.main_track = None


Expand Down Expand Up @@ -110,7 +127,13 @@ def monitor_system_state(self):
self.monitor_tracks()
if self.system_state == SystemState.AUTONOMOUS and self.old_system_state != SystemState.AUTONOMOUS:
playback = PySoundSphere.AudioPlayer("ffplay", debug_allow_multiple_playbacks = False)
filename = os.path.expanduser('~/Documents/imposter.mp3')

try:
filename = self.config.get('autonomous_transition_filepath')
except:
self.log("invalid autonomous transition filepath")
return

playback.load(filename)
playback.volume = self.config.get('volume')
playback.play()
Expand Down
1 change: 1 addition & 0 deletions autonav_ws/src/autonav_launch/launch/manual25sim.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<!-- xbox manual control -->
<node pkg="autonav_manual" exec="controller_input.py"/>
<node pkg="autonav_manual" exec="manual_25.py"/>
<node pkg="autonav_hardware" exec="audible_feedback.py" output="screen" emulate_tty="true" />
<!-- <node pkg="autonav_manual" exec="motormessage_listener.py"/> -->

<!-- Other -->
Expand Down

0 comments on commit e720cea

Please sign in to comment.