Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add limo speaker package #6

Merged
merged 21 commits into from
Feb 25, 2025
Merged

feat: add limo speaker package #6

merged 21 commits into from
Feb 25, 2025

Conversation

cooperj
Copy link
Member

@cooperj cooperj commented Feb 21, 2025

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Adds a car horn and text to speech support for the LIMO platform. This allows for simple use of the speakers for student projects etc.

Related Tickets & Documents

QA Instructions, Screenshots, Recordings

Please replace this line with instructions on how to test your changes.

Limo should launch the nodes /speaker/play and /speaker/tts with the launch file

ros2 launch limo_speaker limo_speaker.launch.py

You can then use the following lines in the code-server instance to publish the messages.

ros2 topic pub -1 /speaker/tts std_msgs/msg/String "data: 'Hello, LCAS'"
ros2 topic pub -1 /speaker/play std_msgs/msg/String "data: 'car'"
ros2 topic pub -1 /speaker/play std_msgs/msg/String "data: 'clown'"
ros2 topic pub -1 /speaker/play std_msgs/msg/String "data: 'truck'"

and also

ros2 run limo_speaker console_tts
ros2 run limo_speaker console_horn

[optional] Are there any post deployment tasks we need to perform?

Before you merge this branch, a PR needs to be raised against the limo_ros2 repo to merge in josh/car-horn and then this PR updated to have the correct submodule ref.

@cooperj cooperj added the enhancement New feature or request label Feb 21, 2025
@cooperj cooperj self-assigned this Feb 21, 2025
@cooperj
Copy link
Member Author

cooperj commented Feb 21, 2025

limo_drivers-1  | [ERROR] [launch]: Caught exception in launch (see debug for traceback): [Errno 2] No such file or directory: '/opt/ros/lcas/install/limo_speaker/share/limo_speaker/launch/limo_start.launch.py'

Oops!

@cooperj
Copy link
Member Author

cooperj commented Feb 21, 2025

Didn't work, sounddevice module not installed... code-server not openable, have i broken something badly?

limo_drivers-1  | [play_tts-7] Traceback (most recent call last):
limo_drivers-1  | [play_tts-7]   File "/opt/ros/lcas/install/limo_speaker/lib/limo_speaker/play_tts", line 33, in <module>
limo_drivers-1  | [play_tts-7]     sys.exit(load_entry_point('limo-speaker==0.0.0', 'console_scripts', 'play_tts')())
limo_drivers-1  | [play_tts-7]   File "/opt/ros/lcas/install/limo_speaker/lib/limo_speaker/play_tts", line 25, in importlib_load_entry_point
limo_drivers-1  | [play_tts-7]     return next(matches).load()
limo_drivers-1  | [play_tts-7]   File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
limo_drivers-1  | [play_tts-7]     module = import_module(match.group('module'))
limo_drivers-1  | [play_tts-7]   File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
limo_drivers-1  | [play_tts-7]     return _bootstrap._gcd_import(name[level:], package, level)
limo_drivers-1  | [play_tts-7]   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
limo_drivers-1  | [play_tts-7]   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
limo_drivers-1  | [play_tts-7]   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
limo_drivers-1  | [play_tts-7]   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
limo_drivers-1  | [play_tts-7]   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
limo_drivers-1  | [play_tts-7]   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
limo_drivers-1  | [play_tts-7]   File "/opt/ros/lcas/install/limo_speaker/lib/python3.10/site-packages/limo_speaker/playTTS.py", line 3, in <module>
limo_drivers-1  | [play_tts-7]     import sounddevice as sd
limo_drivers-1  | [play_tts-7] ModuleNotFoundError: No module named 'sounddevice'
limo_drivers-1  | [ERROR] [play_tts-7]: process has died [pid 369, exit code 1, cmd '/opt/ros/lcas/install/limo_speaker/lib/limo_speaker/play_tts --ros-args -r __node:=play_tts'].

and

limo_drivers-1  | [play_audio-6] Traceback (most recent call last):
limo_drivers-1  | [play_audio-6]   File "/opt/ros/lcas/install/limo_speaker/lib/limo_speaker/play_audio", line 33, in <module>
limo_drivers-1  | [play_audio-6]     sys.exit(load_entry_point('limo-speaker==0.0.0', 'console_scripts', 'play_audio')())
limo_drivers-1  | [play_audio-6]   File "/opt/ros/lcas/install/limo_speaker/lib/limo_speaker/play_audio", line 25, in importlib_load_entry_point
limo_drivers-1  | [play_audio-6]     return next(matches).load()
limo_drivers-1  | [play_audio-6]   File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
limo_drivers-1  | [play_audio-6]     module = import_module(match.group('module'))
limo_drivers-1  | [play_audio-6]   File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
limo_drivers-1  | [play_audio-6]     return _bootstrap._gcd_import(name[level:], package, level)
limo_drivers-1  | [play_audio-6]   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
limo_drivers-1  | [play_audio-6]   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
limo_drivers-1  | [play_audio-6]   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
limo_drivers-1  | [play_audio-6]   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
limo_drivers-1  | [play_audio-6]   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
limo_drivers-1  | [play_audio-6]   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
limo_drivers-1  | [play_audio-6]   File "/opt/ros/lcas/install/limo_speaker/lib/python3.10/site-packages/limo_speaker/playAudio.py", line 3, in <module>
limo_drivers-1  | [play_audio-6]     import sounddevice as sd
limo_drivers-1  | [play_audio-6] ModuleNotFoundError: No module named 'sounddevice'

running sudo pip3 install sounddevice once in the container works as expected? is this a PATH issue?

@cooperj
Copy link
Member Author

cooperj commented Feb 24, 2025

Currently facing an issue where code-server will not work on anything other than the LIMO, this is an upstream issue from code-server themselves, see issue coder/code-server#7219

This is working fine on the LIMOs back screen and if I open an ssh tunnel to the limo, so the page is served over a secure context, then its fine?! ie:

ssh -L 9999:localhost:9999 [email protected]

@cooperj cooperj marked this pull request as ready for review February 24, 2025 11:49
Doing this to quickly test if it merges and works... preventing issues from building up
Copy link
Member

@marc-hanheide marc-hanheide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I conditionally approve, assuming you have tested it works.

# this is using tempfile to make a safe file name
# e.g. tts_a1b2c3.wav
temp = tempfile.NamedTemporaryFile(prefix="tts_", suffix=".wav")
file_path = temp.name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not quite how it should be used, I understand, see https://docs.python.org/3/library/tempfile.html#tempfile.NamedTemporaryFile

I think in your case https://docs.python.org/3/library/tempfile.html#tempfile.mkstemp may be better used, but if it works for you and you have tested this, I'm happy to approve.

@cooperj
Copy link
Member Author

cooperj commented Feb 24, 2025

Still working on it, currently working on getting the .wav files copied over into the share directory

@cooperj
Copy link
Member Author

cooperj commented Feb 24, 2025

limo_speaker doesn't currently automatically launch (do we want that?) but otherwise just works as expected.

To get sound you have to bring it up with

ros2 launch limo_speaker limo_speaker.launch.py 

@marc-hanheide
Copy link
Member

If there are no side effect, I can't see why we wouldn't want to launch it.

RUN curl -fsSL https://code-server.dev/install.sh | sh

USER ros
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why has this been removed? This changes the final image as it leaves it with root user. Is it intentional?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops, I'll add that back… Was modifying it when I was debugging the issues with packages installed into the path.

This line, adds it to the compose hence it was missed.

@marc-hanheide marc-hanheide merged commit 726a4c8 into main Feb 25, 2025
1 check passed
@marc-hanheide marc-hanheide deleted the josh-car-horn branch February 25, 2025 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants