Skip to content

About

The ROS package provides essential audio capabilities, it is the entry point for ROS to provide audio capabilities.

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Β 
Β 

Repository files navigation

QRB ROS Audio Service

This ROS package delivers essential audio capabilities for playback and recording

Qualcomm Ubuntu Jazzy


πŸ‘‹ Overview

πŸ“Œ qrb_ros_audio_service is a ROS package that provides core audio functionalities. It serves as the primary interface for audio playback and recording within the ROS ecosystem.

architecture
  • QRB ROS Audio Service : A ROS node that creates a service server, responds to requests from the application, and translates them into operations on the Audio Manager.
  • QRB ROS Audio Common : A ROS node that acts as a bridge between QRB ROS Audio Service and QRB Audio Common Lib.
  • QRB Audio Manager : Executes audio operations provided by the Audio Service, based on stream configurations.
  • QRB Audio Common Lib : Provides audio functionalities by calling PulseAudio APIs.

πŸ”Ž Table of Contents

πŸ“Œ If the content is extensive, we recommend adding a table of contents.

βš“ APIs

πŸ“Œ qrb_ros_audio_service APIs

ROS Interfaces

Interface Name Type Description
Service /audio_service qrb_ros_audio_service_msgs::srv::AudioRequest Allows ROS applications to send service requests for audio playback and recording.

πŸ“Œ qrb_ros_audio_common APIs

ROS parameters

Name Type Description Default Value
Stream_type string Specifies the stream type for the action: "playback" for audio playback or "capture" for audio recording. default_stream
action_name string Specify the name of action default_action
topic_name string Specify the name of topic default_topic

ROS Interfaces

Interface Name Type Description
Action /ros_audio_playback qrb_ros_audio_common_msgs::action::AudioCommon Action for playback function, specify action name by action_name parameter
Action /ros_audio_capture qrb_ros_audio_common_msgs::action::AudioCommon Action for record function, specify action name by action_name parameter.
Subscriber /qrb_audiodata qrb_ros_audio_common_msgs::msg::AudioData Used for streaming audio playback. Subscribes to raw audio data from this node. Can modify the topic name using the --topic_name parameter.
Publisher /qrb_audiodata qrb_ros_audio_common_msgs::msg::AudioData Used for streaming audio recording. Publishes real-time raw audio data during recording. Can modify the topic name using the --topic_name parameter.

πŸ“Œ qrb_audio_common_lib APIs

Function Parameters Description
uint32_t audio_stream_open(const audio_stream_info & stream_info, stream_event_callback_func event_callback) stream_info:A structure specifies the configuration of stream.
stream_event_callback_func: callback function.
Open stream, will return stream_handle on succeed.
int audio_stream_start(uint32_t stream_handle) stream_handle: A unique identifier for steam Start stream, return 0 on succeed.
int audio_stream_mute(uint32_t stream_handle, bool mute) stream_handle: A unique identifier for stream.
mute: Boolean flag indicating whether to mute the stream.
Mute or unmute stream. return 0 on succeed.
int audio_stream_stop(uint32_t stream_handle) stream_handle: A unique identifier for stream. Stop stream, return 0 on succeed
size_t audio_stream_write(uint32_t stream_handle, size_t length, void * buf) stream_handle: A unique identifier for stream.
length: Size to write.
buf: Point to data buffer.
Write buffer to playback stream, return actually written length.

🎯 Supported Targets

Development Hardware Hardware Overview
Qualcomm Dragonwingβ„’ RB3 Gen2

✨ Installation

Important

PREREQUISITES: The following steps need to be run on Qualcomm Ubuntu and ROS Jazzy.
Reference Install Ubuntu on Qualcomm IoT Platforms and Install ROS Jazzy to setup environment.
For Qualcomm Linux, please check out the Qualcomm Intelligent Robotics Product SDK documents.

Add Qualcomm IOT PPA for Ubuntu:

# Install Qualcomm PPA
sudo add-apt-repository ppa:ubuntu-qcom-iot/qcom-ppa
sudo add-apt-repository ppa:ubuntu-qcom-iot/qirp
sudo apt update

Install Packages

# Install QRB ROS Audio packages
sudo apt install ros-jazzy-qrb-ros-audio-common ros-jazzy-qrb-ros-audio-service

πŸš€ Usage

  1. Use this launch file to run this package.
    source /opt/ros/jazzy/setup.sh
    ros2 launch qrb_ros_audio_common component.launch.py
  2. On another ssh terminal.
    source /opt/ros/jazzy/setup.sh
    ros2 launch qrb_ros_audio_service audio_service.launch.py
  3. Run test cases on a third ssh terminal.
  • push music file to device path like /tmp/xxx.wav.
  • download test script.
    wget https://raw.githubusercontent.com/qualcomm-qrb-ros/qrb_ros_audio_service/main/tests/audio_service_test.py
  • setup ros2 env.
    source /opt/ros/jazzy/setup.sh
  • Step-by-step playback (sound will output on speaker)
    python3 audio_service_test.py --type='playback' --source='/tmp/xxx.wav' --volume=100
  • Step-by-step record (will record sound input from mic and save to file)
    python3 audio_service_test.py --type='record' --source='/tmp/rec.wav' --channels=1 --sample_rate=16000 --sample_format=16
  • Streaming playback
    python3 audio_service_test.py --type='playback' --channels=1 --sample_rate=16000 --sample_format=16 --pub_pcm=True --volume=100 --topic_name='loopback'
  • Streaming record (if start Streaming playback and Streaming record sound will loopback from mic to speaker)
    python3 audio_service_test.py --type='record' --source='/tmp/rec.wav' --channels=1 --sample_rate=16000 --sample_format=16 --topic_name='loopback'

πŸ‘¨β€πŸ’» Build from Source

Step 1: Install dependencies:

# Install build tools and dependencies
sudo add-apt-repository ppa:ubuntu-qcom-iot/qcom-ppa
sudo add-apt-repository ppa:ubuntu-qcom-iot/qirp
sudo apt update
sudo apt install build-essential cmake pkg-config

# Install ROS2 Jazzy (if not already installed)
# Follow instructions at https://docs.ros.org/en/jazzy/Installation.html
sudo apt install ros-jazzy-rclcpp ros-jazzy-rclcpp-components ros-jazzy-ament-cmake-auto ros-jazzy-std-msgs ros-jazzy-qrb-ros-audio-common-msgs ros-jazzy-qrb-ros-audio-service-msgs libpulse-dev libsndfile1-dev

Step 2: Clone and Build

# setup ros2 env
source /opt/ros/jazzy/setup.sh

# Navigate to your ROS2 workspace
cd ~/ros2_ws/src

# Clone the repository (if not already cloned)
git clone https://github.com/qualcomm-qrb-ros/qrb_ros_audio_service.git

# Build
cd ~/ros2_ws
colcon build

# Source the workspace
source install/setup.bash

🀝 Contributing

We love community contributions! Get started by reading our CONTRIBUTING.md.
Feel free to create an issue for bug reports, feature requests, or any discussion πŸ’‘.

πŸ“œ License

Project is licensed under the BSD-3-clause License. See LICENSE for the full license text.

About

The ROS package provides essential audio capabilities, it is the entry point for ROS to provide audio capabilities.

Resources

Code of conduct

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages