A real-time multi-channel acoustic sensor monitoring system built on ROS and Foxglove. It receives multi-channel audio data pushed by sensor devices over TCP, processes and publishes the data as ROS topics, and visualizes waveforms and FFT spectra live in Foxglove Studio.
Sensor Device (TCP push)
|
v
tcp_to_ros_node.py
+-- Receive TCP data (32-bit int, multi-channel, 32 kHz)
+-- Publish raw waveform topics: data_pgc_channel_<i>
+-- Publish FFT spectrum topics: fft_channel_<i>
+-- Foxglove Bridge
|
v
Foxglove Studio (live visualization)
| Dependency | Version |
|---|---|
| Ubuntu | 20.04 LTS |
| ROS | Noetic |
| Python | 3.8+ |
| foxglove_bridge | latest (ROS package) |
numpy
scipy
matplotlib
soundfile
pandas
openpyxl
Follow the official guide: http://wiki.ros.org/noetic/Installation/Ubuntu
sudo apt install ros-noetic-foxglove-bridgegit clone <repo_url> tmt_sonic
cd tmt_sonicpip install numpy scipy matplotlib soundfile pandas openpyxlcd ros_ws
catkin_makeEdit the parameters at the bottom of ros_ws/src/tcp_to_ros/src/tcp_to_ros_node.py:
save_path = "/path/to/save/data/" # directory for saving recorded data
_ip = '192.168.0.2' # local IP to listen on
_port = 9999 # listening port
sample_rate = 32000 # sample rate (Hz)
nrChannelsPerFrame = 9 # total hardware channels per frame
channelCount = 6 # number of channels to publishOption 1 - startup script (recommended)
# Load ROS environment
source setup_environment.zsh
# Start all nodes (ROS Master + Foxglove Bridge + tcp_to_ros)
./run.shOption 2 - manual launch
source setup_environment.zsh
roslaunch tcp_to_ros main.launch- Open Foxglove Studio (desktop app or web)
- Connect to
ws://localhost:8765(default Foxglove Bridge port) - Subscribe to the following topics:
data_pgc_channel_0todata_pgc_channel_5- raw waveform per channelfft_channel_0tofft_channel_5- FFT spectrum per channel
Receive and visualize data with matplotlib without ROS:
python readtcp.pyEdit the IP, port, and buffer size at the bottom of the file before running.
Convert recorded .c9 binary files to .npy and .wav format:
python preprocess.pySet file_path and c9_files in preprocess.py to point to your input files. Output is saved to ./mydata/.
Calculate the distance from each sensor node to a reference point using an Excel coordinate file:
python calc.pyProvide a b1-b11.xlsx coordinate file and set the reference point coordinates inside the script.
| Message File | Description |
|---|---|
Int32MultiArrayStamped.msg |
Timestamped int32 array (raw waveform and FFT data) |
Int32Stamped.msg |
Timestamped single int32 value |
SensorDataArray.msg |
Sensor data array with time series |
tmt_sonic/
+-- ros_ws/
| +-- src/
| +-- tcp_to_ros/
| +-- CMakeLists.txt
| +-- package.xml
| +-- launch/
| | +-- main.launch # launch file
| +-- msg/ # custom message types
| +-- src/
| +-- tcp_to_ros_node.py # core ROS node
+-- readtcp.py # standalone TCP receiver & visualizer (debug)
+-- preprocess.py # offline .c9 file preprocessing
+-- calc.py # sensor coordinate distance calculation
+-- run.sh # quick-start script
+-- setup_environment.zsh # ROS environment setup
MIT License
Copyright (c) 2026 sean
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.