Niryo robot sound
This package contains services to play, stop, import and delete a sound on the robot. It is also possible to set the volume of the robot.
It belongs to the ROS namespace: /niryo_robot_sound
.
Sounds
State |
Description |
Sound |
---|---|---|
Booting |
Sound played while booting |
|
Ready |
Sound played when the robot is ready after booting |
|
Calibration |
Sound played at start of calibration |
|
Connected |
Notify of a connection to Niryo Studio |
|
Reboot |
Sound played at start of a motor reboot |
|
Warn |
Sound played when a warning occurs |
|
Error |
Sound played when a robot/motor/raspberry/program/overheating error occurs |
|
Shutdown |
Sound played at shutdown |
Sound API functions
Sound ROS wrapper
In order to control the robot more easily than calling each topics & services one by one, a Python ROS Wrapper has been built on top of ROS.
For instance, a script playing sound via Python ROS Wrapper will looks like:
from niryo_robot_sound.api import SoundRosWrapper
sound = SoundRosWrapper()
sound.play(sound.sounds[0])
API list
- class niryo_robot_sound.api.sound_ros_wrapper.SoundRosWrapper(hardware_version='ned2', service_timeout=1)
Bases:
object
- property current_sound
Get the current sound being played
- Returns:
current sound name
- Return type:
Optional[str]
- delete_sound(sound_name)
Delete a sound on the RaspberryPi of the robot. If failed, raise NiryoRosWrapperException
- Parameters:
sound_name (str) – name of the sound which needs to be deleted
- Returns:
status, message
- Return type:
(int, str)
- get_sound_duration(sound_name)
Returns the duration in seconds of a sound stored in the robot database raise SoundRosWrapperException if the sound doesn’t exists
- Parameters:
sound_name (str) – name of sound
- Returns:
sound duration in seconds
- Return type:
float
- property hardware_version
- import_sound(sound_name, sound_data)
Delete a sound on the RaspberryPi of the robot. If failed, raise NiryoRosWrapperException
- Parameters:
sound_name (str) – name of the sound which needs to be deleted
sound_data (str) – String containing the encoded data of the sound file (wav or mp3)
- Returns:
status, message
- Return type:
(int, str)
- play(sound_name, wait_end=True, start_time_sec=0, end_time_sec=0)
Play a sound from the robot If failed, raise NiryoRosWrapperException
- Parameters:
sound_name (str) – Name of the sound to play
start_time_sec (float) – start the sound from this value in seconds
end_time_sec (float) – end the sound at this value in seconds
wait_end (bool) – wait for the end of the sound before exiting the function
- Returns:
status, message
- Return type:
(int, str)
- say(text, language=0)
Use gtts (Google Text To Speech) to interpret a string as sound Languages available are: - English: 0 - French: 1 - Spanish: 2 - Mandarin: 3 - Portuguese: 4
- Parameters:
text (string) – text to speek < 100 char
language (int) – language of the text
- Returns:
status, message
- Return type:
(int, str)
- set_volume(sound_volume)
Set the volume percentage of the robot. If failed, raise NiryoRosWrapperException
- Parameters:
sound_volume (int) – volume percentage of the sound (0: no sound, 100: max sound)
- Returns:
status, message
- Return type:
(int, str)
- property sounds
Get sound name list
- Returns:
list of the sounds of the robot
- Return type:
list[string]
- stop()
Stop a sound being played. If failed, raise NiryoRosWrapperException
- Returns:
status, message
- Return type:
(int, str)
- exception niryo_robot_sound.api.sound_ros_wrapper.SoundRosWrapperException
Bases:
Exception
- niryo_robot_sound.api.sound_ros_wrapper.check_ned2_version(func)
Decorator that check the robot version
Package Documentation
ROS topics
Publishers
Topic Name |
Type |
Description |
---|---|---|
/niryo_robot_sound/sound |
Publish the sound being played |
|
/niryo_robot_sound/sound_database |
Publish the list of available sounds and their durations on the robot |
|
/niryo_robot_sound/volume |
Publish the volume of the robot |
|
/rosout |
N/A |
Subscribers
Topic Name |
Type |
Description |
---|---|---|
/niryo_robot_status/robot_status |
niryo_robot_status/RobotStatus |
Publish the robot, log, overheating and joints out of bounds status |
/niryo_studio_connection |
Niryo studio connection heartbeat |
ROS Services
Service Name |
Type |
Description |
---|---|---|
/niryo_robot_sound/get_loggers |
roscpp/GetLoggers |
N/A |
/niryo_robot_sound/manage |
Add or delete a sound in the database |
|
/niryo_robot_sound/overlay |
N/A |
|
/niryo_robot_sound/play |
Play a sound from the robot database |
|
/niryo_robot_sound/set_logger_level |
roscpp/SetLoggerLevel |
N/A |
/niryo_robot_sound/set_volume |
Set the volume percentage between 0 and 100% |
|
/niryo_robot_sound/stop |
Stop the sound being played |
|
/niryo_robot_sound/text_to_speech |
Say a sentence using GTTS |
ROS Parameters
Parameter Name |
Default value |
Simulation value |
Unit |
Description |
---|---|---|---|---|
/niryo_robot_sound/default_volume |
100 |
N/A |
percentage |
Default volume on the real robot |
/niryo_robot_sound/default_volume_simulation |
10 |
N/A |
percentage |
Default volume in simulation |
/niryo_robot_sound/error_sound_delay |
60 |
N/A |
N/A |
N/A |
/niryo_robot_sound/initialized |
True |
N/A |
N/A |
N/A |
/niryo_robot_sound/log_level |
INFO |
N/A |
N/A |
N/A |
/niryo_robot_sound/max_volume |
100 |
N/A |
percentage |
Maximum volume of the robot |
/niryo_robot_sound/min_volume |
0 |
N/A |
percentage |
Minimum volume of the robot |
/niryo_robot_sound/path_robot_sound |
niryo_robot_state_sounds |
N/A |
N/A |
N/A |
/niryo_robot_sound/path_user_sound |
~/niryo_robot_saved_files/niryo_robot_user_sounds |
N/A |
string |
Path to the folder where default robot sounds are stored |
/niryo_robot_sound/path_user_sound_simulation |
~/.niryo/simulation/niryo_robot_user_sounds |
N/A |
string |
Path to the folder where user defined sounds are stored in simulation |
/niryo_robot_sound/robot_sounds/calibration_sound |
calibration.wav |
N/A |
N/A |
N/A |
/niryo_robot_sound/robot_sounds/connection_sound |
connected.wav |
N/A |
N/A |
N/A |
/niryo_robot_sound/robot_sounds/disconnection_sound |
disconnected.wav |
N/A |
N/A |
N/A |
/niryo_robot_sound/robot_sounds/error_sound |
error.wav |
N/A |
N/A |
N/A |
/niryo_robot_sound/robot_sounds/learning_trajectory_sound |
learning_trajectory.wav |
N/A |
N/A |
N/A |
/niryo_robot_sound/robot_sounds/reboot_sound |
reboot.wav |
N/A |
N/A |
N/A |
/niryo_robot_sound/robot_sounds/robot_ready_sound |
ready.wav |
N/A |
N/A |
N/A |
/niryo_robot_sound/robot_sounds/turn_off_sound |
stop.wav |
N/A |
N/A |
N/A |
/niryo_robot_sound/robot_sounds/turn_on_sound |
booting.wav |
N/A |
N/A |
N/A |
/niryo_robot_sound/robot_sounds/warn_sound |
warn.wav |
N/A |
N/A |
N/A |
/niryo_robot_sound/simulation_mode |
True |
N/A |
N/A |
N/A |
/niryo_robot_sound/sound_publish_rate |
1.0 |
N/A |
N/A |
N/A |
/niryo_robot_sound/sound_user_publish_rate |
1.0 |
N/A |
N/A |
N/A |
/niryo_robot_sound/volume_factor |
1.0 |
N/A |
N/A |
N/A |
/niryo_robot_sound/volume_file_path |
~/niryo_robot_saved_files/robot_sound_volume.txt |
N/A |
string |
Path to the file where the volume of the real robot set by the user is stored |
/niryo_robot_sound/volume_file_path_simulation |
~/.niryo/simulation/robot_sound_volume.txt |
N/A |
string |
Path to the file where the volume of the simulated robot set by the user is stored |
/niryo_robot_sound/volume_publish_rate |
1.0 |
N/A |
N/A |
N/A |
ROS Action
Namespace: None