Skip to main content
The qrb_ros_audio_service sample application is a ROS package that delivers core audio functionalities, serving as the primary interface for audio capabilities (currently supporting playback and recording) within the ROS ecosystem.
NoteFor more information, see the qrb_ros_audio_service GitHub repo.

Pipeline for qrb_ros_audio_service

The following figure shows the pipeline. Figure : qrb_ros_audio_service pipeline

ROS nodes/services used in the qrb_ros_audio_service pipeline

ROS topics used in the qrb_ros_audio_service pipeline

Prerequisites

You have Set up the device according to Set up the environment for running sample applications.

Run out-of-the-box qrb_ros_audio_service

  1. Start three commandline terminals on your device and run the following commands to set up the environment.
  2. In the first SSH terminal, run the audio service package using the ros2 launch command.
  3. In the second SSH terminal, run qrb_ros_audio_common.
  4. Check the default devices for the pipewire.
    1. Verify the status of default speaker and handset mic.
    2. If the default speaker or handset mic isn’t set, use wpctl set-default <device-num> to set the default device(s).
  5. In the third SSH terminal, run the test cases using either ROS commands or Python scripts according to the following table.
    1. Note For all step-by-step test cases, stream_handle indicates the stream created by the audio service when the command is create. After the audio service creates a stream, the command prints the value of stream_handle in the third SSH terminal.
      • For the ROS command, you see the following output:
        stream_handle=<***>
      • For the Python script, you see the following output: command create success 1 stream_handle <***>. Download the Python script using
Case nameDescriptionROS command/Python script
One-touch playbackStart playback with a one-touch command. The speaker outputs the audio. Supports the WAV file format. Place the music file on a device path, for example, /tmp/music.wav.
Step-by-step playbackStart playback with step-by-step commands. The speaker outputs the audio. Supports the WAV file format.
Streaming playbackCreate and start a streaming playback. It subscribes to the audio PCM data from the loopback topic. Audio data should be filled with qrb_ros_audio_common_msgs::msg::AudioData.
Start a step-by-step streaming playback:
Start a one-touch streaming playback:
Step-by-step recordUse the default input device to record with step-by-step commands and write the audio data to the /tmp/rec.wav file.
Publish recording data
  • Publish the recording data to a topic (default topic name: qrb_audiodata. You can specify another name using topic_name).
  • The audio data will be filled with qrb_ros_audio_common_msgs::msg::AudioData.
Publish the recording data to a topic (default topic name is “qrb_audiodata”, but it can be specified using topic_name):
Or, publish the recording data to /qrb_audiodata. Meanwhile, save it to a file: