Skip to content

LEM-RPTU/ros2_dsp_filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ROS2 Package for Signal Filtering utilizing FFT

ROS2 package to filter generic time series (e.g. IMU data) using DSP (Digital Signal Processing) tools.

Table of Contents

  1. About this Repository
  2. Getting Started
  3. Building and Running
  4. Working with this Code

example Example of a lowpass-filtered signal consisting of three white noised sines with different amplitudes, frequencies and phase shifts.

Raw Data Fourier Filtered Data Fourier

And the associated example Fourier plots.

About this Repository

The repository consists of two standalone ROS2 packages:

  • sample_signal: This package allows you to create different signals consisting of various periodic elements enriched by white noise and/or a base signal to test the filter_signal package.
  • filter_signal: This package applies an FFT transform to any specified ROS2 topic (which should be analyzed first) and displays the data in the frequency domain. Based on this analysis, the user can choose a suitable filter and apply it to the live topic to get a filtered result with a small delay.

Both packages are documented with their own README files. It is advised to start with the sample_signal package if you are not very familiar with DSP. We also highly recommend using PlotJuggler for data visualization purposes. Why wouldn't you!?

Plotjuggler Meme

Getting Started

The current repository tree looks like

ros2_dsp_filters
    ├── README.md
    ├── docs
    ├── filter_signal
    │   ├── CMakeLists.txt
    │   ├── config
    │   ├── filter_config
    │   ├── filter_signal
    │   ├── fourier_config
    │   ├── include
    │   ├── launch
    │   ├── package.xml
    │   ├── README.md
    │   └── src
    └── sample_signal
        ├── CMakeLists.txt
        ├── config
        ├── include
        ├── launch
        ├── LICENSE
        ├── package.xml
        ├── README.md
        ├── sample_signal
        └── src

To get started, please read filter_signal/README.md and sample_signal/README.md.

Building and Running

Dependencies

This repository depends on python3-scipy and python3-numpy, hence please install

sudo apt-get install python3-scipy python3-numpy

or run rosdep install --from-paths src -y --ignore-src within your workspace.

Building

Create ros2 workspace and source folder, if needed:

mkdir -p ros2_ws/src

Clone the package into the src of your ros2 workspace, source and build:

cd ros2_ws/src
git clone git@github.com:LEM-RPTU/ros2_dsp_filter.git
cd ..
source /opt/ros/humble/setup.bash
colcon build

Running

To check the default setup run in two different terminals:

source /opt/ros/humble/setup.bash
source install/setup.bash
ros2 launch sample_signal launch.py

and

source /opt/ros/humble/setup.bash
source install/setup.bash
ros2 launch filter_signal filter.launch.py

Use Plotjuggler and you should see a result similar to the example as the beginning of this README.

Working with this Code

The workflow is

  1. Generate a signal using sample_signal-package or find another source of a ROS2-message you want to FFT-analyse and/or filter.
  2. Analyse the ROS2 message which you are publishing using filter_signal's analyse functionality
  3. Plot the Fourier-Transform of the ROS2 message's components of your choice using filter_signal's fourier functionality
  4. Design a digital filter for the ROS2 message's components of your choice using filter_signal's filter functionality
  5. (optional) Plot the Fourier-Transform of both the filtered and the raw ROS2 message using filter_signal's fourier functionality again
  6. (non-optional) Enjoy a filtered ROS2 message