Niryo_robot_sound¶
This package deals with the sound of the robot.
Sound Node¶
The ROS Node is made of 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/
.
Parameters - Sound¶
Here is a list of the different parameters that allow you to adjust the default settings of the robot and the system sounds.
Name | Description | Default value |
---|---|---|
default_volume |
Default volume on the real robot | 100 |
default_volume_simulation |
Default volume in simulation | 10 |
min_volume |
Minimum volume of the robot | 0 |
max_volume |
Maximum volume of the robot | 200 |
volume_file_path |
File where the volume of the real robot set by the user is stored | “~/niryo_robot_saved_files/robot_sound_volume.txt” |
volume_file_path_simulation |
File where the volume in simulation set by the user is stored | “~/.niryo/simulation/robot_sound_volume.txt” |
Name | Description | Default value |
---|---|---|
path_user_sound |
Default volume on the real robot | “~/niryo_robot_saved_files/niryo_robot_user_sounds” |
path_user_sound_simulation |
Default volume in simulation | “~/.niryo/simulation/niryo_robot_user_sounds” |
path_robot_sound |
Minimum volume of the robot | “niryo_robot_state_sounds” |
robot_sounds/error_sound |
Sound played when an error occurs | error.wav |
robot_sounds/turn_on_sound |
Sound played at the start-up of the robot | booting.wav |
robot_sounds/turn_off_sound |
Sound played at shutdown | stop.wav |
robot_sounds/connection_sound |
Sound played an Niryo Studio connection | connected.wav |
robot_sounds/robot_ready_sound |
Sound played when the robot is ready | ready.wav |
robot_sounds/calibration_sound |
Sound played at start of calibration | calibration.wav |
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 |
Publisher - Sound¶
Name | Message Type | Description |
---|---|---|
/niryo_robot_sound/sound |
std_msgs/String | Publisesh the sound being played |
/niryo_robot_sound/volume |
std_msgs/UInt8 | Publishes the volume of the robot |
/niryo_robot_sound/sound_database |
SoundList | Publishes the sounds (and their duration) on the robot |
Services - Sound¶
Name | Message Type | Description |
---|---|---|
/niryo_robot_sound/play |
PlaySound | Plays a sound from the robot database |
/niryo_robot_sound/stop |
Trigger | Stops the sound being played |
/niryo_robot_sound/set_volume |
SetInt | Sets the volume percentage between 0 and 200% |
/niryo_robot_sound/text_to_speech |
TextToSpeech | Pronouncses a sentence via GTTS |
/niryo_robot_sound/manage |
ManageSound | Stops a sound being played |
Subscribers - Sound¶
Topic name | Message type | Description |
---|---|---|
/niryo_robot_status/robot_status |
RobotStatus | Retrieves the current robot status, and controls the sound accordingly (see Niryo_robot_status section) |
/niryo_studio_connection |
std_msgs/Empty | Catches Niryo Studio’s connection to make a sound. |
Dependencies - Sound¶
Services & Messages files - Sound¶
SoundList (Message)¶
niryo_robot_sound/SoundObject[] sounds
SoundObject (Message)¶
string name
float64 duration
ManageSound (Service)¶
string sound_name
int8 ADD = 1
int8 DELETE = 2
int8 action
# Data to add a new sound
string sound_data
---
int32 status
string message
PlaySound (Service)¶
string sound_name
float64 start_time_sec
float64 end_time_sec #if 0 or if end_time_sec>sound_duration the entire sound will be played
bool wait_end
---
int32 status
string message
TextToSpeech (Service)¶
string text # < 100 char
int8 ENGLISH = 0
int8 FRENCH = 1
int8 SPANISH = 3
int8 MANDARIN = 4
int8 PORTUGUESE = 5
int8 language
---
bool success
string message
Sound API functions¶
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 look like:
from niryo_robot_led_ring.api import SoundRosWrapper
sound = SoundRosWrapper()
sound.play(sound.sounds[0])
List of functions subsections:
Play sound¶
-
class
SoundRosWrapper
(hardware_version='ned2', service_timeout=1)[source]¶ -
play
(sound_name, wait_end=True, start_time_sec=0, end_time_sec=0)[source]¶ Play a sound from the robot If failed, raise NiryoRosWrapperException
Parameters: Returns: status, message
Return type:
-
set_volume
(sound_volume)[source]¶ 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)
-
stop
()[source]¶ Stop a sound being played. If failed, raise NiryoRosWrapperException
Returns: status, message Return type: (int, str)
-
say
(text, language=0)[source]¶ 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:
-
Sound database¶
-
class
SoundRosWrapper
(hardware_version='ned2', service_timeout=1)[source] -
-
delete_sound
(sound_name)[source]¶ 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)
-