Skip to content

Conversation

@Hoog-V
Copy link
Member

@Hoog-V Hoog-V commented Mar 24, 2025

Audio Tools V2

This pr contains quite a list of features :)

What has been added

  • Windows support (for both the audio capture & playback node)
  • Automatic packaging for both Windows & Linux Conda when creating a new release
  • Pixi support
  • Playback node

Pixi support

Let's start with Pixi support! This is great, like really great. It is like the platformio for ROS2. Which makes ROS2, normally a pain to install on other platforms then the original Ubuntu, a breeze. Now to use and compile programs easily the only thing you have to do is:
Install it first:
Linux:

curl -fsSL https://pixi.sh/install.sh | bash

Windows (run in powershell):

powershell -ExecutionPolicy ByPass -c "irm -useb https://pixi.sh/install.ps1 | iex"

To use the pixi environment of this repo:

Linux & Windows (Yes both work):

git clone https://github.com/CLFML/ROS2_Audio_Tools.git
cd ROS2_Audio_Tools
pixi install
# Run a build
pixi run build
# Or run vscode (with all paths setup)
pixi run vscode

When building on Windows, always build it as Release or Release with debug info! Debug build will not work!
To do this in vscode: CTRL+SHIFT+P -> CMake: Select Variant

Automatic Conda/Pixi packaging

One of the big issues, I ran into quickly when using ros2 with multiple nodes is: "How to manage all these small packages". Quickly I realized that installing them system-wide is the easiest method. First I created a workflow that simply packages the Audio_Tools ros2 package for Ubuntu Jazzy (native distro, as .deb file). Then I went ahead and created Conda packages for usage with pixi and our custom conda channel. Which includes both Windows and Linux builds, was a hassle to setup but now, it works beautifully.

How do these packaging workflows work?

They run automatically when creating a new release. Three workflows run; 1. Native ROS workflow which produces .deb file, 2. Conda linux packaging workflow, 3. Windows Conda packaging workflow. After run the artifacts (.deb & .tar.bz2) files are uploaded to the newly created release. For Conda I still have to add the manually to our own github-hosted conda-channel: https://github.com/CLFML/conda_ros2_jazzy_channel. In the future it will be done automatically too

How to use the prepackaged node in Ubuntu Noble (native ROS2)?

  1. Go to releases of this repo and download the .deb file.
  2. Double-click the .deb file and install it.
  3. Great! Now you can run the node by running source /opt/ros/jazzy/setup.sh && ros2 run audio_tools audio_capture_node.
    It should run now..

How to use (Windows/Linux with Pixi)?

  1. Create a new project folder
  2. Open this folder in terminal and run: pixi init
  3. Edit the pixi.toml and add these lines:
    under the tag [project]:
channels = ["https://fast.prefix.dev/conda-forge", "https://prefix.dev/robostack-jazzy", "https://clfml.github.io/conda_ros2_jazzy_channel/"]

and under tag [dependencies]:

compilers = ">=1.9.0,<2"
pkg-config = ">=0.29.2,<0.30"
ninja = ">=1.12.1,<2"
ros-jazzy-ros-base = "*"
colcon-common-extensions = "*"
ros-jazzy-audio-tools = "*"
rosdep = "*"

To check your toml should look something like this:

[project]
authors = ["Hoog-V <[email protected]>"]
name = "project"
channels = ["https://fast.prefix.dev/conda-forge", "https://prefix.dev/robostack-jazzy", "https://clfml.github.io/conda_ros2_jazzy_channel/"]
platforms = ["win-64"]

[dependencies]
compilers = ">=1.9.0,<2"
pkg-config = ">=0.29.2,<0.30"
ninja = ">=1.12.1,<2"
ros-jazzy-ros-base = "*"
colcon-common-extensions = "*"
ros-jazzy-audio-tools = "*"
rosdep = "*"

Okay great, now install the pixi environment and run the node:

pixi install
pixi run ros2 run audio_tools audio_capture_node 

Want to add vscode support to the pixi environment?
Add this to the toml:

[target.linux-64.dependencies]
python-devtools = "*"         # Optional but useful
pybind11 = "*"                # Optional, if you work with bindings
numpy = "*"

[target.win-64.dependencies]
python-devtools = "*"

[target.win-64.tasks]
vscode = "code ."

[target.linux-64.tasks]
vscode = 'env -u LD_LIBRARY_PATH code .'

Audio playback node

The audio playback node is able to playback incoming samples on the audio_playback topic (which is changeable through the parameters). For a quick test I linked it with the output of the capture node:

test_audio.py:

from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
    return LaunchDescription([
        # Audio capture node
        Node(
            package='audio_tools',
            executable='audio_capture_node',
            name='audio_capture_node',
            output='screen'
        ),

        # Audio playback node
        Node(
            package='audio_tools',
            executable='audio_playback_node',
            name='audio_playback_node',
            output='screen',
            parameters=[{
                'audio_topic': '/audio_stamped'
            }]
        )
    ])

To run it:

pixi run build
pixi shell
# Windows
.\install\setup.bat
# Linux
source install/setup.sh
ros2 launch test_audio.py

Very curious if you guys are so enthousiastic about this, as I am :)

@Hoog-V Hoog-V requested review from RichardKroesen and ducroq March 24, 2025 23:57
@ducroq
Copy link
Contributor

ducroq commented Mar 26, 2025

This is marvelous!
Never heard of pixi, but I do know The Pixies :-).
Later I will test on Windows, right now I am on Ubuntu 24.04.2 LTS.
Building the capture node runs like a charm!
Expected topics are shown:
ros2 topic list
/audio
/audio_info
/audio_stamped
/parameter_events
/rosout

Strangely, though:
ros2 topic echo /audio_info
The message type 'audio_tools/msg/AudioInfo' is invalid

I might be missing some dependencies.

@Hoog-V
Copy link
Member Author

Hoog-V commented Mar 26, 2025

That's probably due to not sourcing the install directory. The echo command does not know the custom msg format I used for the audio capture node without sourcing the install/setup.sh script

@ducroq
Copy link
Contributor

ducroq commented Mar 26, 2025

Double clicking deb, doesn't really give the desired behavior, I need to install via
sudo dpkg -i ros-jazzy-audio-tools_3.11.5-0noble_amd64.deb
sudo apt install ./ros-jazzy-audio-tools_3.11.5-0noble_amd64.deb

source /opt/ros/jazzy/setup.sh && ros2 run audio_tools audio_capture_node runs out of the box!
So, probably I needed to run audio_tools as well when starting the capture node (see previous comment). Indeed, I can confirm that now the right environment is sourced correctly!

In the toml file created by pixi, I have a [workspace] tag, not a [project] tag ?
I created test_audio.py as you suggested, but encountering a "command not found" error "on pixi run build". Should a build command be defined in the pixi.toml file?
[tasks]
build = ...

@Hoog-V
Copy link
Member Author

Hoog-V commented Mar 26, 2025

Yes, when creating your own pixi.toml add build task the same way you would define vscode task (see snippet above). But replace it with build command (colcon build -DCM... for example see the PR included pixi.toml file. It has this already setup)

@ducroq
Copy link
Contributor

ducroq commented Mar 26, 2025

In general, this looks like a very neat system!
As you say this solves the question on "How to manage all these small packages".
So, system-wideinstall and package for Ubuntu Jazzy (native distro, as .deb file) seems the way to go!

@ducroq
Copy link
Contributor

ducroq commented Mar 26, 2025

Yes, when creating your own pixi.toml add build task the same way you would define vscode task (see snippet above). But replace it with build command (colcon build -DCM... for example see the PR included pixi.toml file. It has this already setup)

Right, got it.
However, executable 'audio_playback_node' not found on the libexec directory.

When I check the installed audio tools from ros-jazzy-audio-tools_3.11.5-0noble_amd64.deb it seems to be missing?

ros2 pkg executables | grep audio
audio_tools audio_capture_node

@Hoog-V
Copy link
Member Author

Hoog-V commented Mar 26, 2025

Yes playback node is not in conda & deb package yet, as that is in this pr. Which is not merged yet. After merging it will be built and made available in conda channel and releases. Instead

  1. clone this repo (checkout on dev branch)
  2. use the pixi inside this repo. Run in the root of repo: pixi install & pixi run build & pixi shell. This should build and open a sourced (not package sourced) ros2 shell (with all dependencies installed)
  3. Run linux: source install/setup.sh
    Windows: .\install\setup.bat
  4. Open another shell, go to repo root and run: pixi shell
  5. Now run step 3 in this shell too and run your wished node's in the two shells you've got now.

Or native ros, compile it from source

@RichardKroesen
Copy link

RichardKroesen commented Mar 26, 2025

As a documentational note I had some compiler issues on windows, but after you hinted to install the buildtools it worked fine.

The following link is for the installer of a proper compiler: VS-buildtools.

Also the code quality is neat🔥!

@Hoog-V Hoog-V merged commit 1cf41be into main Mar 27, 2025
4 checks passed
@RichardKroesen
Copy link

Really nice, build out-of-the box with the VS community compiler💯
The examples are also great! And it works nicely. OpenWakeWord model, and you implemented it nicely for embedded linux :D!

Your code quality is just consistent and well structured.

I tried to run the ROS2 with Pixi, however I got something related to none type return:

Starting >>> lowwi
Finished <<< lowwi [1.73s]

Summary: 1 package finished [1.97s]
WNDPROC return value cannot be converted to LRESULT
TypeError: WPARAM is simple, so must be an int object (got NoneType)

Probably I am missing something trivial, since I am still catching up with ROS2 workings.

@Hoog-V
Copy link
Member Author

Hoog-V commented Apr 3, 2025

Luckily this is a warning can be safely ignored. It is related to the tools incompatibilities to the Windows ecosystem, which is not posix compliant. Meaning it will throw warnings quite often about things which are deeper down the software layers just implemented not completely correct as to windows standards. Nothing really I can do short term to these warnings. It will run and work anyways tho.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants