This project contains a ROS2-based ultrasonic data acquisition and processing system with real-time visualization and parameter control capabilities.
The system consists of five main ROS2 nodes that work together:
- Publisher Node (
publisher.py) - Interfaces with Vitesse hardware to acquire ultrasonic A-scan data - Processor Node (
processor.py) - Processes raw A-scan data and displays real-time visualizations - Controller Node (
controller.py) - Provides a GUI for monitoring and controlling system parameters - Forward Node (
forward_node.py) - Exposes a Trigger service that moves the actuator forward when requested - Backward Node (
backward_node.py) - Exposes a Trigger service that moves the actuator backward when requested
┌─────────────────┐ Ascan Message ┌─────────────────┐
│ │ ──────────────────────> │ │
│ Publisher │ │ Processor │
│ (Hardware I/O) │ │ (Visualization) │
└─────────────────┘ └─────────────────┘
↑ ↑
│ │
│ ROS2 Parameters │
└───────────────────┬───────────────────────┘
│
┌────────────────┐
│ Controller │
│ (GUI) │
└────────────────┘
Purpose: Interfaces with Vitesse ultrasonic hardware to acquire A-scan waveform data from up to 8 channels.
The publisher does not include code on temperature gathering. You should implement your own temperature aquisition code, and there is a segment in the code where you can do this.
Key Features:
- Configures and initializes Vitesse hardware via SPI interface
- Publishes A-scan data at a configurable rate (PRF)
- Supports multi-channel operation with individual channel enable/disable
Parameters:
numAverages(int, 1-1000): Number of waveform averages for noise reductionchannelsOnReceive(int[8]): Receive channel enable flags [1,0,0,0,0,0,0,0] (read-only)channelsOnDrive(int[8]): Channels on driver array (which channels to drive)numCycles(int, 1-3): Number of excitation cycles (read-only)recordLength(float): Recording duration in seconds (read-only)PRF(int, 1-5000 Hz): Pulse repetition frequency (read-only)phaseArrayMicro(int[8]): Per-channel phase delays in microseconds (read-only)delayArrayMicro(int[8]): Per-channel recording delays in microseconds (read-only)samplingMode(int, 16 or 24): Sampling mode (16 or 24 bit)pulseFrequency(int): Pulse frequency in HzopFrequency(int): Operation frequency in Hz
Published Topics:
/ascan(interfaces/msg/Ascan): Contains active channels, encoded waveform data, and temperature
Purpose: Processes raw A-scan data and provides real-time visualization with automatic peak detection.
Key Features:
- Real-time matplotlib-based visualization for active channels
- Automatic subplot arrangement based on number of active channels
- Peak detection and thickness calculation
- Multiple processing modes (first peak, multi-echo, zero crossing)
- Temperature-corrected measurements
Parameters (per channel, ch1-ch8):
ch{N}_sampling_freq(int): Sampling frequency in Hzch{N}_lowbound_time(int): Lower bound time in microsecondsch{N}_minimum_thickness(float): Minimum detectable thickness in mmch{N}_wave_velocity(float): Wave velocity in m/sch{N}_num_cycles(int): Number of cycles for processingch{N}_signal_frequency(int): Signal frequency in Hzch{N}_threshold_snr(float): SNR threshold in dBch{N}_noise_width(int): Noise calculation window widthch{N}_calibration_index(int): Calibration reference indexch{N}_firstPeak(bool): Enable first peak detection modech{N}_multiEcho(bool): Enable multi-echo modech{N}_zeroCrossing(bool): Enable zero crossing detectionch{N}_temperatureCorrected(bool): Enable temperature correction
Subscribed Topics:
/ascan(interfaces/msg/Ascan): Receives waveform data from publisher
Purpose: Provides a PyQt5-based GUI for real-time parameter monitoring and control.
Key Features:
- Automatic discovery of ROS2 nodes and their parameters
- Tabbed interface with separate tabs for each active channel
- Parameter filtering based on configuration file
- Support for various parameter types (sliders, spinboxes, checkboxes)
- Real-time parameter updates with visual feedback
- Configurable display names and parameter bounds
- Buttons to control actuation of motor driver
Configuration (config.json):
multipleTabs: Enable/disable tabbed interfacewhitelist: Enable parameter whitelistinghideReadOnlyParameters: Hide read-only parameterswhitelistNodes: List of nodes to displaywhitelistParameters: Parameters to show per nodeparameterDisplayNames: Custom display names for parametersparameter_bounds: Min/max bounds for numeric parameters
Purpose: The controller includes a calibration mode that temporarily changes the publisher's numAverages parameter to a predetermined number, collects averaged A-scan measurements, and then computes a corrected wave velocity.
How it is used:
- Place the EMAT connected to the first enumerated channel on top of your calibration block
- Enter the calibration block's thickness in the controller GUI
- Start calibration, which sets
numAveragesto 100 on the active publisher - Wait a fixed delay for the hardware to apply the averaging setting
- Collect a series of averaged thickness measurements from the A-scan stream
- Compute a calibrated speed of sound value based on the known thickness and measured average thickness
- Apply the calibrated
wave_velocityvalue to the processor channels
Calculation:
-
The controller records the average measured thickness from the acquired A-scan data
-
It then computes the corrected speed of sound as:
calibrated_speed = current_wave_velocity * (known_thickness / measured_average_thickness) -
This updated speed is applied to all processor channels so subsequent thickness calculations use the calibrated ultrasonic velocity.
The system uses 1-based channel numbering (1-8) for user-facing interfaces:
- Channel parameters are named
ch1_*throughch8_* - Display shows "Channel 1" through "Channel 8"
- The
channelsOnReceiveparameter uses array indices 0-7 internally but presents channels as 1-8 to users
int32[] active_channels # List of active channel numbers (1-8)
string[] ascan_data # Base64-encoded waveform data for each active channel
float32 temperature # Current temperature reading
Usage:
- Start either node with
ros2 run ros_parameter_demo forwardorros2 run ros_parameter_demo backward - The controller GUI exposes "Actuate Forward" and "Actuate Backward" buttons which invoke the corresponding services and display the response in the status bar.
- ROS2 Humble or later (tested on Jazzy) (Desktop Variant is required for processor and controller)
- Vitesse ultrasonic system (for publisher)
- Under the project root folder, run
colcon buildto build all the packages.
- Launch the publisher node (requires Vitesse hardware):
ros2 run ros_parameter_demo publisher- Launch the processor node for visualization:
ros2 run ros_parameter_demo processor- Launch the controller GUI:
ros2 run ros_parameter_demo controller- If you have the actuator peripheral, launch the forward and backward nodes in separate terminals:
ros2 run ros_parameter_demo forwardros2 run ros_parameter_demo backwardTo enable specific receive channels, modify the channelsOnReceive parameter in the publisher file. For example:
[1,0,0,0,0,0,0,0]- Only channel 1 active[1,0,1,1,0,0,0,0]- Channels 1, 3, and 4 active[1,1,1,1,1,1,1,1]- All 8 channels active
Each channel can operate in different processing modes:
- First Peak: Detects the first significant peak in the waveform
- Multi-Echo: Processes multiple reflections
- Zero Crossing: Uses zero-crossing detection for improved accuracy
- Temperature Corrected: Applies temperature compensation to measurements
Note: First Peak and Multi-Echo modes are mutually exclusive.
If you set both in the controller, the processor falls back to which none of the four parameters are set.
config.json: Controller GUI configuration- Channel parameters can be saved/loaded via ROS2 parameter services
- No visualization appears: Ensure at least one channel is enabled in
channelsOnReceive - Controller doesn't show parameters: Controller won't show anything until the publishing node is on. Check that nodes are running and
config.jsonwhitelist is correct. - Hardware errors: Verify Vitesse device is connected and permissions are set correctly.
- Add data logging capabilities
- Implement parameter presets
- Add export functionality for processed data
- Support for additional processing algorithms
- Integration with ROS2 bag recording