Skip to content
Snippets Groups Projects
Commit bce36695 authored by Eric Schoeneberg's avatar Eric Schoeneberg :rocket:
Browse files

[DOCS] filter_signal README finalized

parent d2056178
Branches
No related tags found
1 merge request!1Dev
...@@ -6,11 +6,13 @@ This package contains tools to signal-process any ROS2 message. ...@@ -6,11 +6,13 @@ This package contains tools to signal-process any ROS2 message.
1. [About this repository](#about-this-repository) 1. [About this repository](#about-this-repository)
2. [Getting started](#getting-started) 2. [Getting started](#getting-started)
3. [Building and Running](#building-and-running) 3. [Building and Running](#building-and-running)
- [Analyse](#analyse)
- [Filter](#filter)
## About this repository ## About this repository
This package contains two ROS2 Nodes `analyse.py` and `filter.py` to analyse and then signal-process any ROS2 message. Currently This package contains two executables `analyse.py` and `filter.py` to analyse and then signal-process any ROS2 message. Currently
any float part of any message can be filtered with any float part of any message can be filtered with
- Highpass - Highpass
...@@ -20,6 +22,63 @@ any float part of any message can be filtered with ...@@ -20,6 +22,63 @@ any float part of any message can be filtered with
based on your configuration. based on your configuration.
## Getting started
The current package looks like
```bash
filter_signal
├── CMakeLists.txt
├── config
│ ├── analyse.yaml
│ └── filter.yaml
├── filter_config
│ ├── float32.yaml
│ └── imu.yaml
├── filter_signal
│ ├── __init__.py
│ ├── analyse_parameters.py
│ ├── analyse.py
│ ├── filter_parameters.py
│ ├── filter.py
│ ├── filters.py
│ └── utilities.py
├── include
├── launch
│ ├── analyse.launch.py
│ └── filter.launch.py
├── package.xml
├── README.md
└── src
```
Ignore `src` and `include`, they are only part of the used template to add CPP-files in the package later on.
## Building and Running
Note that this package depends on `python3-scipy`, hence please install
```
sudo apt-get install python3-scipy
```
or run `rosdep install --from-paths src -y --ignore-src` within your workspace. To build, please navitage into your workspace (adapt the first line in case it is different than `ros_ws`) and run
```bash
cd ros_ws
source /opt/ros/humble/setup.bash
colcon build
```
If you are using `colcon build --symlink-install` or e.g. using VSCode ROS2 Extention please make sure that all executable python files in
`ros_ws/src/fft/filter_signal/filter_signal` `filter.py` and `analyse.py` are made executable. Hence run
```bash
chmod +x filter.py
chmod +x analyse.py
```
Remember that only message types can be analysed and filtered that are also sourced. Hence if there is an interface package in your workspace (not installed in /opt/ros), make sure to also source the workspace before running. To run, proceed with [Analyse](#analyse) and [Filter](#filter). Note there exists `analyse.launch.py` and `filter.launch.py` launch files with associated `analyse.yaml` and `filter.yaml` configuration files for orientation.
### Analyse ### Analyse
Because any message type is supported, to filter a message you first have to analyse it. `analyse.py` will subscribe to a `topic` of your choice of arbitrary message type (as long as the message definition is sourced). It will then write the structure of the message as `result_file_name.yaml` into a specified `config_path`. The parameter:default_value are as following: Because any message type is supported, to filter a message you first have to analyse it. `analyse.py` will subscribe to a `topic` of your choice of arbitrary message type (as long as the message definition is sourced). It will then write the structure of the message as `result_file_name.yaml` into a specified `config_path`. The parameter:default_value are as following:
...@@ -28,7 +87,7 @@ Because any message type is supported, to filter a message you first have to ana ...@@ -28,7 +87,7 @@ Because any message type is supported, to filter a message you first have to ana
- `config_path`:`~` - `config_path`:`~`
- `result_file_name`:`analytic_result` - `result_file_name`:`analytic_result`
where `~` is the home-directory of the user executing the code. While the resulting file will be of type `.yaml`, do not include `.yaml` in the parameter, the file ending will be added automatically. E.g. result file for an `sensor_msgs.msg.Imu` looks like this: where `~` is the home-directory of the user executing the code. E.g. result file for a `sensor_msgs.msg.Imu` looks like this:
```bash ```bash
angular_velocity: angular_velocity:
...@@ -63,6 +122,8 @@ orientation_covariance: ...@@ -63,6 +122,8 @@ orientation_covariance:
- 0.0 - 0.0
``` ```
While the resulting file will be of type `.yaml`, do not include the file ending `.yaml` in the parameter `result_file_name`. The file ending will be added automatically.
### Filter ### Filter
`filter.py` will subscribe to a topic of your choice and filter the topic according to the configuration file. The parameter:default_value are as following: `filter.py` will subscribe to a topic of your choice and filter the topic according to the configuration file. The parameter:default_value are as following:
...@@ -71,7 +132,8 @@ orientation_covariance: ...@@ -71,7 +132,8 @@ orientation_covariance:
- `config_path`:`~` - `config_path`:`~`
- `config_file_name`:`imu` - `config_file_name`:`imu`
where `~` is the home-directory of the user executing the code. While the configuration file will be of type `.yaml`, do not include `.yaml` in the parameter value, the file ending will be added automatically. Now, given the `analytic_result` from [Analyse](#analyse), we can edit it to become a `config_file` for the filter. For example, take the result file for an `sensor_msgs.msg.Imu`, and assume you want to filter where `~` is the home-directory of the user executing the code. Now, given the `analytic_result` from [Analyse](#analyse), we can edit it to become a `config_file` for the filter.
For example, take the result file for an `sensor_msgs.msg.Imu`, and assume you want to filter
- `angular_velocity.x` with a **lowpass** filter of **4**th order and a cuttoff-frequency of **20.0Hz** - `angular_velocity.x` with a **lowpass** filter of **4**th order and a cuttoff-frequency of **20.0Hz**
- `angular_velocity.y` with a **highpass** filter of **2**nd order and a cuttoff-frequency of **1.0Hz** - `angular_velocity.y` with a **highpass** filter of **2**nd order and a cuttoff-frequency of **1.0Hz**
...@@ -113,54 +175,5 @@ orientation_covariance: ...@@ -113,54 +175,5 @@ orientation_covariance:
- 0.0 - 0.0
``` ```
and load the edited file as the `filter` config file. Once the node is running it will publish into `topic/filtered`. and load the edited file as the `filter` config file. While the configuration file will be of type `.yaml`, do not include `.yaml` in the parameter value `config_file_name`,
the file ending will be added automatically. Once the node is running it will publish into `topic/filtered`.
## Getting started \ No newline at end of file
The current package looks like
```bash
filter_signal
├── CMakeLists.txt
├── config
│ ├── analyse.yaml
│ └── filter.yaml
├── filter_config
│ ├── float32.yaml
│ └── imu.yaml
├── filter_signal
│ ├── __init__.py
│ ├── analyse_parameters.py
│ ├── analyse.py
│ ├── filter_parameters.py
│ ├── filter.py
│ ├── filters.py
│ └── utilities.py
├── include
│ └── cpp_python_package
├── launch
│ ├── analyse.launch.py
│ └── filter.launch.py
├── package.xml
├── README.md
└── src
```
## Building and Running
To build, please navitage into your workspace (adapt the first line in case it is different than `ros_ws`) and run
```bash
cd ros_ws
source /opt/ros/humble/setup.bash
colcon build
```
If you are using `colcon build --symlink-install` or e.g. using VSCode ROS2 Extention please make sure that all executable python files in
`ros_ws/src/fft/filter_signal/filter_signal` `filter.py` and `analyse.py` are made executable. Hence run
```bash
chmod +x filter.py
chmod +x analyse.py
```
Remember that only message types can be analysed and filtered that are also sourced. Hence if there is an interface package in your workspace (not installed in /opt/ros), make sure to also source the workspace before running. To run, proceed with [Analyse](#analyse) and [Filter](#filter). Note there exists `analyse.launch.py` and `filter.launch.py` launch files with associated `analyse.yaml` and `filter.yaml` configuration files for orientation.
\ No newline at end of file
...@@ -10,10 +10,10 @@ from launch.substitutions import LaunchConfiguration ...@@ -10,10 +10,10 @@ from launch.substitutions import LaunchConfiguration
def generate_launch_description(): def generate_launch_description():
# Get the package directories # Get the package directories
cpp_python_package_share = get_package_share_directory('filter_signal') filter_signal_package_share = get_package_share_directory('filter_signal')
# Parameters # Parameters
parameter_file = os.path.join(cpp_python_package_share, 'config', 'analyse.yaml') parameter_file = os.path.join(filter_signal_package_share, 'config', 'analyse.yaml')
declare_namespace_cmd = DeclareLaunchArgument( declare_namespace_cmd = DeclareLaunchArgument(
name='namespace', name='namespace',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment