The ROS package provides essential audio capabilities, it is the entry point for ROS to provide audio capabilities.
It supports both step-by-step and one-touch playback, allowing playback from built-in sounds. Additionally, it offers recording functionality, with the option to save to a local file or a topic.
Playback and record capabilities depend on qrb_ros_audio_common.
Use QIRP SDK to build.
-
Build and install QIRP SDK follow qirp-sdk-workflows or Quick start (using the prebuild package)
-
Setup environments follow Set up the cross-compile environment
-
Create
ros_ws
directory in<qirp_decompressed_workspace>/qirp-sdk/
-
Put qrb_audio_manager, qrb_ros_audio_service, qrb_ros_audio_service_msgs and qrb_ros_audio_common_msgs packages under
<qirp_decompressed_workspace>/qirp-sdk/ros_ws
qrb_audio_manager and qrb_ros_audio_service in qrb_ros_audio_service:
git clone https://github.qualcomm.com/QUIC-QRB-ROS/qrb_ros_audio_service.git
qrb_ros_audio_service_msgs and qrb_ros_audio_common_msgs in qrb_ros_interfaces:
git clone https://github.qualcomm.com/QUIC-QRB-ROS/qrb_ros_interfaces.git
-
Build this project
export AMENT_PREFIX_PATH="${OECORE_TARGET_SYSROOT}/usr;${OECORE_NATIVE_SYSROOT}/usr" export PYTHONPATH=${PYTHONPATH}:${OECORE_TARGET_SYSROOT}/usr/lib/python3.10/site-packages colcon build --merge-install --cmake-args \ -Dpython3_ROOT_DIR=${OECORE_TARGET_SYSROOT}/usr \ -Dpython3_NumPy_INCLUDE_DIR=${OECORE_TARGET_SYSROOT}/usr/lib/python3.10/site-packages/numpy/core/include \ -DPYTHON_SOABI=cpython-310-aarch64-linux-gnu -DCMAKE_STAGING_PREFIX=$(pwd)/install \ -DCMAKE_PREFIX_PATH=$(pwd)/install/share \ -DBUILD_TESTING=OFF
-
Push to the device & Install
cd <qirp_decompressed_workspace>/qirp-sdk/ros_ws/install tar czvf qrb_ros_audio.tar.gz lib share scp qrb_ros_audio.tar.gz root@[ip-addr]:/opt/ ssh root@[ip-addr] tar -zxf /opt/qrb_ros_audio.tar.gz -C /opt/qcom/qirp-sdk/usr/
-
Source this file to set up the environment on your device
ssh root@[ip-addr] export HOME=/opt source /opt/qcom/qirp-sdk/qirp-setup.sh export ROS_DOMAIN_ID=xx source /usr/bin/ros_setup.bash
-
Use this launch file to run this package
ros2 launch qrb_ros_audio_service audio_service.launch.py
-
Run qrb_ros_audio_common on another ssh terminal
-
Run below test cases on third ssh terminal
stream_handle indicate the stream created by Audio Service when command is "create". The value can be found on third ssh terminal: if use "ROS Command":
stream_handle=***
if use "Python Script":command create success 1 stream_handle ***
Test Case Using ROS Command Using Python Script Get build-in sound names mkdir -p /opt/qcom/qirp-sdk/usr/share/qrb-audio-manager/sounds
chmod 0755 /opt/qcom/qirp-sdk/usr/share/qrb-audio-manager -R
adb push clip.wav /opt/qcom/qirp-sdk/usr/share/qrb-audio-manager/sounds
chmod 0644 /opt/qcom/qirp-sdk/usr/share/qrb-audio-manager/sounds/*
ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "get-buildin-sound"
}"python3 audio_service_test.py --get-buildin-sound One-touch playback ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "play",
source: "clip",
volume: 100,
}"python3 audio_service_test.py --mode='one-touch' --source='security' --volume=100 One-touch playback and repeat ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "play",
source: "clip",
volume: 100,
repeat: -1,
}"
ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "stop",
stream_handle: 3520332881,
}"python3 audio_service_test.py --mode='one-touch' --source='security' --volume=100 --repeat=-1 Step-by-step playback ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
type: "playback",
command: "create",
source: "/tmp/music.wav",
volume: 100,
}"
ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "start",
stream_handle: 2551300426,
}"
ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "mute",
mute: true,
stream_handle: 2551300426,
}"
ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "mute",
mute: false,
stream_handle: 2551300426,
}"
ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "stop",
stream_handle: 2551300426,
}"
ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "release",
stream_handle: 2551300426,
}"python3 audio_service_test.py --type='playback' --source='/tmp/yesterday_48KHz.wav' --volume=100
python3 audio_service_test.py --set-mute --mute=True --stream_handle=2124364840
python3 audio_service_test.py --set-mute --mute=False --stream_handle=2124364840Step-by-step record ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
audio_info: {
channels: 1,
sample_rate: 16000,
sample_format: 16,
},
type: "record",
command: "create",
source: "/tmp/rec.wav",
}"
ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "start",
stream_handle: 1502099078,
}"
ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "stop",
stream_handle: 1502099078,
}"
ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "release",
stream_handle: 1502099078,
}"python3 audio_service_test.py --type='record' --source='/tmp/rec.wav' --channels=1 --sample_rate=16000 --sample_format=16 Publish recording data publish recording data to /qrb_audiodata:
ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
audio_info: {
channels: 1,
sample_rate: 16000,
sample_format: 16,
},
type: "record",
command: "create",
pub_pcm: true,
}"
publish recording data to /qrb_audiodata. meanwhile, save it to file:
ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
audio_info: {
channels: 1,
sample_rate: 16000,
sample_format: 16,
},
type: "record",
command: "create",
pub_pcm: true,
source: "/tmp/rec.wav",
}"
ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{command: "start",
stream_handle: 806639317,
}"
ros2 topic echo /qrb_audiodata
ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "stop",
stream_handle: 806639317,
}"
ros2 service call /audio_server qrb_ros_audio_service_msgs/srv/AudioRequest "{
command: "release",
stream_handle: 806639317,
}"python3 audio_service_test.py --type='record' --source='/tmp/rec.wav' --channels=1 --sample_rate=16000 --sample_format=16 --pub_pcm=True
ros2 topic echo /qrb_audiodata
qrb_ros_audio_service is licensed under the BSD-3-clause "New" or "Revised" License.
Check out the LICENSE for more details.