|
FP Perception 0.1.2
|
The perception server (fp_perception::PerceptionServer) is a ROS 2 node that loads perception "drivers" as pluginlib plugins and exposes a simple set of ROS interfaces (topics and services) for audio, vision, transcription, speech synthesis, sentiment, and image analysis.
This document focuses on:
fp_perception::DriverBase.pluginlib::ClassLoader<fp_perception::DriverBase>.fp_perception::MicrophoneAudioDriver).AudioSourceDriver, AudioSinkDriver, TranscriptionDriver, SpeechSynthesisDriver, SentimentAnalysisDriver, VisionSourceDriver, and ImageAnalysisDriver.fp_perception::audio_data, fp_perception::text_data, transcription_request, sentiment_request, and image_analysis_request.DriverBase remains the pluginlib base and lifecycle surface; its legacy untyped data hooks are kept only for compatibility with old callers.fp_perception_msgs/*, sensor_msgs/*) and internal typed structs at the node boundary.The server orchestrates and routes data, but the actual device I/O happens in the plugins:
cv::VideoCapture).image_transport.If enabled by parameters, the server starts periodic loops:
publishAudio(): pulls microphone audio chunks and optionally maintains a rolling buffer for transcription; can also publish audio to a ROS topic.publishVideo(): pulls frames from a vision driver and optionally publishes them as sensor_msgs/msg/Image.If enabled by parameters, the server provides:
PerceptionTranscribe)PerceptionSpeech)PerceptionSentiment)PerceptionImageAnalysis)The server uses boolean flags to decide which drivers to load:
use_ros_vision_driveruse_non_ros_vision_driveruse_microphone_driveruse_speaker_driveruse_transcription_driveruse_speech_driveruse_sentiment_driveruse_image_analysis_driverAnd:
use_diagnostics: if true, enabled drivers publish standard ROS 2 health updates on /diagnostics via diagnostic_updater.run_tests: if true, calls test() on each loaded driver during startup.These parameters select which pluginlib class gets loaded:
ros_vision_driver (default fp_perception::DefaultDriver)non_ros_vision_driver (default fp_perception::OpenCVDriver)microphone_driver (default fp_perception::MicrophoneAudioDriver)speaker_driver (default fp_perception::SpeakerAudioDriver)transcription_driver (default fp_perception::OpenAIDriver)speech_synthesis_driver (default fp_perception::OpenAISpeechDriver)sentiment_driver (default fp_perception::SentimentDriver)image_analysis_driver (default fp_perception::OpenAIImageAnalysisDriver)Note: if both use_ros_vision_driver=true and use_non_ros_vision_driver=true, the current server code loads both vision drivers and the publish loop can emit frames from both sources.
interface.audio_input.publish (bool)interface.audio_input.topic (string)interface.audio_input.frame_id (string)interface.audio_input.frequency (int)interface.audio_input.audio_retention_window (int, seconds)interface.audio_input.default_audio_request_window (int, seconds)If enabled, the server publishes fp_perception_msgs/msg/PerceptionAudio at the configured rate.
interface.audio_output.subscribe (bool)interface.audio_output.topic (string)If enabled, the server subscribes to PerceptionAudio and forwards audio samples into the speaker driver.
interface.transcription.provide_service (bool)interface.transcription.service (string)The rolling microphone buffer is sized as:
$$\text{max_samples} = sample_rate \times channels \times buffer_duration$$
where audio_retention_window comes from interface.audio_input.audio_retention_window.
When the buffer exceeds this size, the server drops the oldest samples and keeps the latest window.
interface.speech.provide_service (bool)interface.speech.service_name (string)interface.sentiment.provide_service (bool)interface.sentiment.service_name (string)interface.image_analysis.provide_service (bool)interface.image_analysis.service_name (string)interface.vision_input.publish (bool)interface.vision_input.topic (string)interface.vision_input.frame_id (string)interface.vision_input.frequency (int)If use_ros_vision_driver=true, the server can republish frames from the ROS image subscriber driver. If use_non_ros_vision_driver=true, the server can also publish frames from the OpenCV driver.
The checked-in config currently enables the ROS vision path and publishes on perception/camera.
AudioBuffer.PerceptionTranscribe with use_device_audio=true.PerceptionSpeech with PerceptionText.use_device_audio=true, server forwards synthesized audio to the speaker driver.use_diagnostics=true, instrumented drivers publish diagnostic_msgs/msg/DiagnosticArray updates on /diagnostics.PerceptionSentiment with use_device_audio=true.(label, score).PerceptionImageAnalysis with a prompt.use_device_vision=true, server captures a frame from the configured vision driver; otherwise it uses the request-provided sensor_msgs/Image.