jeguzzi / robomaster_ros

ROS2 for DJI Robomaster EP and S1
https://jeguzzi.github.io/robomaster_ros
MIT License
49 stars 10 forks source link

the action server failed to start: robomaster_msgs.action.PlaySound, "play" #12

Open UserName-wang opened 6 months ago

UserName-wang commented 6 months ago

the speaker.py: cmd_sound cannot play the wav file. I tried demo1.wav. the below code skipped msg.file. just only passed three parameters to the function play: _self.play(sound_id=msg.soundid, times=msg.times, control=msg.control) by using these new code robomaster s1 can play a wav file: if msg.file and msg.control: self.api.play_audio(msg.file).wait_for_completed() else:
self.play(sound_id=msg.sound_id, times=msg.times, control=msg.control) Maybe it's not the best way to play a wav file, Can someone give me any suggestion?

and the action server play didn't start, I only can find /play/_action/cancel_goal in rqt service caller , but the command: ros2 action list can find /play, strange !!!

    **_self._sound_action_server = rclpy.action.ActionServer(
        node, robomaster_msgs.action.PlaySound, "play", self.execute_play_sound,
        goal_callback=self.new_speaker_goal_callback,
        cancel_callback=self.cancel_callback, callback_group=cbg)_**
jeguzzi commented 2 months ago

Hi @UserName-wang, sorry for the delay.

You can play a wav file using the action CLI

ros2 action send_goal /play robomaster_msgs/action/PlaySound "{file: '<path to the wavfile>'}" --feedback

It will upload the file via FTP, assign it to an ID (printed in the console), and play it.

Btw, I also tried the SDK example https://github.com/dji-sdk/RoboMaster-SDK/blob/master/examples/01_robot/03_play_audio.py and it works.

UserName-wang commented 2 months ago

Hi @UserName-wang, sorry for the delay.

You can play a wav file using the action CLI

ros2 action send_goal /play robomaster_msgs/action/PlaySound "{file: '<path to the wavfile>'}" --feedback

It will upload the file via FTP, assign it to an ID (printed in the console), and play it.

Btw, I also tried the SDK example https://github.com/dji-sdk/RoboMaster-SDK/blob/master/examples/01_robot/03_play_audio.py and it works.

Hi @jeguzzi , the action CLI works!