Skip to main content
Version: QTrobot V3

Microphone

The /qtrobot/microphone/... services and /qtrobot/mic/... topics read the robot's internal microphone array and tune its DSP. These examples assume the gateway from Connection is already running.

DSP tuning

ros2 service call /qtrobot/microphone/int/tunning/get qtrobot_interfaces/srv/MicrophoneIntTunningGet "{}"
ros2 service call /qtrobot/microphone/int/tunning/set qtrobot_interfaces/srv/MicrophoneIntTunningSet \
"{name: 'AGCONOFF', value: 1.0}"

Subscribing to microphone events

The microphone event stream tells you when someone is speaking near the robot, and from which direction:

#!/usr/bin/env python3
import rclpy
from rclpy.node import Node
from qtrobot_interfaces.msg import MicEventFrame


class MicEventListener(Node):
def __init__(self):
super().__init__('mic_event_listener')
self.create_subscription(
MicEventFrame,
'/qtrobot/mic/int/event/stream',
self.on_mic_event,
10,
)

def on_mic_event(self, msg: MicEventFrame):
if msg.activity:
self.get_logger().info(f'Voice detected at {msg.direction} degrees')


def main():
rclpy.init()
node = MicEventListener()
rclpy.spin(node)
node.destroy_node()
rclpy.shutdown()


if __name__ == '__main__':
main()

activity is True while voice activity is detected, and direction gives the estimated direction of arrival in degrees (0–359), as computed by the robot's microphone array.

Subscribing to raw microphone audio

ros2 topic echo /qtrobot/mic/int/audio/ch0/stream

ch0 is the internal array's processed/beamformed channel — the one you want for speech. ch1ch4 give the four raw microphone channels, and /qtrobot/mic/ext/audio/ch0/stream carries the external microphone if one is connected. All publish AudioFrameRaw messages, the same type used by Audio.

Next steps

Continue with the Camera tutorial, or see the full microphone namespace in the ROS2 API Reference.