ros-drivers / audio_common

Common code for working with audio in ROS
BSD 3-Clause "New" or "Revised" License
86 stars 152 forks source link

Can't cancel loop sounds via action #245

Open bsmiron opened 9 months ago

bsmiron commented 9 months ago

Hi! I'm encountering an issue when using the following ROS2 to cancel a loop sound.

    ros2 action send_goal /sound_play sound_play/action/SoundRequest "{sound_request: {sound: 1, command: 2, volume: 0.8}}"

Although the sound plays successfully, I'm receiving an error from the ActionServer:

    [ERROR] [1703000144.370809778] [sound_play]: Exception in actionlib callback: local variable 'feedback' referenced before assignment
    [INFO] [1703000144.371072712] [sound_play]: Traceback (most recent call last):
      File "/home/bsmiron/workspace/sweep/install/sound_play/lib/sound_play/soundplay_node.py", line 563, in execute_cb
        result.playing = feedback.playing
    UnboundLocalError: local variable 'feedback' referenced before assignment

The message from the action is as follows:

    Waiting for an action server to become available...
    Sending goal:
         sound_request:
      sound: 1
      command: 2
      volume: 0.8
      arg: ''
      arg2: ''

    Goal accepted with ID: d715b2455f1a428b99c52cada1833774

    Result:
        playing: false
    stamp:
      sec: 0
      nanosec: 0

    Goal finished with status: ABORTED

Additionally, I'm encountering a similar issue when attempting to stop the sound using the command:

    ros2 action send_goal /sound_play sound_play/action/SoundRequest "{sound_request: {sound: 1, command: 0, volume: 0.8}}"

The error from the ActionServer is the same:

    [ERROR] [1703000315.212196142] [sound_play]: Exception in actionlib callback: local variable 'feedback' referenced before assignment
    [INFO] [1703000315.212440367] [sound_play]: Traceback (most recent call last):
      File "/home/bsmiron/workspace/sweep/install/sound_play/lib/sound_play/soundplay_node.py", line 563, in execute_cb
        result.playing = feedback.playing
    UnboundLocalError: local variable 'feedback' referenced before assignment

And the message from the action is:

    Waiting for an action server to become available...
    Sending goal:
         sound_request:
      sound: 1
      command: 0
      volume: 0.8
      arg: ''
      arg2: ''

    Goal accepted with ID: 4565d64e98114219a0305f1cabab98bf

    Result:
        playing: false
    stamp:
      sec: 0
      nanosec: 0

  Goal finished with status: ABORTED

Steps to Reproduce:

Start the action server:

      ros2 run sound_play soundplay_node.py 

New terminal run the ros2 actions:

    ros2 action send_goal /sound_play sound_play/action/SoundRequest "{sound_request: {sound: 1, command: 2, volume: 0.8}}
    ros2 action send_goal /sound_play sound_play/action/SoundRequest "{sound_request: {sound: 1, command: 0, volume: 0.8}}"

Expected Behavior: Should manage to cancel the loop via actions using command: 0