Skip to content

Open source performances module #11

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions modules/performances/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pyc
.vscode
215 changes: 215 additions & 0 deletions modules/performances/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
##
## Copyright (C) 2017-2025 Hanson Robotics
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <https://www.gnu.org/licenses/>.
##

cmake_minimum_required(VERSION 2.8.3)
project(performances)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
rospy
std_msgs
message_generation
dynamic_reconfigure
)

## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)


## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
catkin_python_setup()

################################################
## Declare ROS messages, services and actions ##
################################################

## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
## * add a build_depend tag for "message_generation"
## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET
## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
## but can be declared for certainty nonetheless:
## * add a run_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
## * add "message_generation" and every package in MSG_DEP_SET to
## find_package(catkin REQUIRED COMPONENTS ...)
## * add "message_runtime" and every package in MSG_DEP_SET to
## catkin_package(CATKIN_DEPENDS ...)
## * uncomment the add_*_files sections below as needed
## and list every .msg/.srv/.action file to be processed
## * uncomment the generate_messages entry below
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)

## Generate messages in the 'msg' folder
add_message_files(
FILES
Event.msg
)

## Generate services in the 'srv' folder
add_service_files(
FILES
Run.srv
RunByName.srv
Stop.srv
Pause.srv
Resume.srv
Current.srv
Load.srv
LoadPerformance.srv
SetProperties.srv
)

## Generate actions in the 'action' folder
# add_action_files(
# FILES
# Action1.action
# Action2.action
# )

## Generate added messages and services with any dependencies listed here
generate_messages(
DEPENDENCIES
std_msgs
)

################################################
## Declare ROS dynamic reconfigure parameters ##
################################################

## To declare and build dynamic reconfigure parameters within this
## package, follow these steps:
## * In the file package.xml:
## * add a build_depend and a run_depend tag for "dynamic_reconfigure"
## * In this file (CMakeLists.txt):
## * add "dynamic_reconfigure" to
## find_package(catkin REQUIRED COMPONENTS ...)
## * uncomment the "generate_dynamic_reconfigure_options" section below
## and list every .cfg file to be processed

## Generate dynamic reconfigure parameters in the 'cfg' folder
generate_dynamic_reconfigure_options(
cfg/Performances.cfg
cfg/Rules.cfg
cfg/Generator.cfg

)

###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if you package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
# INCLUDE_DIRS include
# LIBRARIES performances
# CATKIN_DEPENDS rospy std_msgs
# DEPENDS system_lib
)

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
${catkin_INCLUDE_DIRS}
)

## Declare a C++ library
# add_library(performances
# src/${PROJECT_NAME}/performances.cpp
# )

## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure
# add_dependencies(performances ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Declare a C++ executable
# add_executable(performances_node src/performances_node.cpp)

## Add cmake target dependencies of the executable
## same as for the library above
# add_dependencies(performances_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Specify libraries to link a library or executable target against
# target_link_libraries(performances_node
# ${catkin_LIBRARIES}
# )

#############
## Install ##
#############

# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html

## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
install(PROGRAMS
scripts/runner.py
scripts/speech_motion_controller.py
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

## Mark executables and/or libraries for installation
# install(TARGETS performances performances_node
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )

## Mark cpp header files for installation
# install(DIRECTORY include/${PROJECT_NAME}/
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
# FILES_MATCHING PATTERN "*.h"
# PATTERN ".svn" EXCLUDE
# )

## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
# # myfile1
# # myfile2
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )

#############
## Testing ##
#############

## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_performances.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()

## Add folders to be run by python nosetests
# catkin_add_nosetests(test)
125 changes: 125 additions & 0 deletions modules/performances/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# Performances

A ROS-based system for controlling robot behaviors, animations, and speech for Hanson Robotics robots. This package provides a framework for sequencing and executing robot performances through a combination of speech, gestures, animations, and interactive behaviors.

The Performances package allows you to:
- Load and run predefined performance sequences
- Control robot animations, gestures, and speech
- Manage interactive behaviors through dialog rules
- Coordinate multiple performance timelines
- Configure automated gestures and expressions

## Available Services:

#### `/performances/reload_properties`
`std_srvs.srv.Trigger`
Reads and loads performance configurations from .properties files.
##### Response
* `boolean success`

#### `/performances/set_properties`
`performances.srv.SetProperties`
Sets variables for a specific performance.

##### Arguments
* `string id` - performance id
* `string properties` - a json string of an object containing key value pairs of variables to be set

##### Response
* `boolean success`

#### `/performances/load`
`performances.srv.Load`
Loads performance with the specified id into current session.

##### Arguments
* `id` - performance id

##### Response
* `boolean success`
* `string performance` - json data string of a loaded performance

#### `/performances/load_sequence`
`performances.srv.LoadSequence`
Loads a sequence of performances.

##### Arguments
* `string[] ids` - ids of performances to load

##### Response
* `boolean success`
* `string performances` - json data string of loaded performances

#### `/performances/load_performance`
`performances.srv.LoadPerformance`
Load performance data directly.

##### Arguments
* `string performance` - json data of a performance to load

##### Response
* `boolean success`

#### `/performances/run`
`performances.srv.Run`
Run currently loaded performance(s) at the given time.

##### Arguments
* `float64 startTime` - start time

##### Response
* `boolean success`

#### `/performances/run_by_name`
`performances.srv.RunByName`
Load performance by id and run immediately.

##### Arguments
* `string id` - performance id

##### Response
* `boolean success`

#### `/performances/run_full_performance`
`performances.srv.RunByName`
Load all performances in the specified directory and run immediately.

##### Arguments
* `string id` - path of the directory

##### Response
* `boolean success`

#### `/performances/resume`
`performances.srv.Resume`
Resume runner if paused.

##### Response
* `boolean success`
* `float64 time`

#### `/performances/pause`
`performances.srv.Pause`
Pause runner if currently running.

##### Response
* `boolean success`
* `float64 time`

#### `/performances/stop`
`performances.srv.Stop`
Stop runner if active.

##### Response
* `boolean success`
* `float64 time`

#### `/performances/current`
`performances.srv.Current`
Get information about the current state of runner.

##### Response
`string performances` - json array of currently loaded performances
`float32 current_time` - current run time
`bool running` - run status
`bool paused` - pause status
42 changes: 42 additions & 0 deletions modules/performances/cfg/Generator.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python

##
## Copyright (C) 2017-2025 Hanson Robotics
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <https://www.gnu.org/licenses/>.
##

PACKAGE = 'performances'

from dynamic_reconfigure.parameter_generator_catkin import *
import yaml_config

gen = ParameterGenerator()
# Tracking parameters
gen.add("name", str_t, 0, "Performance path", '')
gen.add("lines", str_t, 0, "Sophia lines", '')
gen.add("pause_between_sentences", double_t, 0, "Pause between sentences", 0.5, 0, 4)
#gen.add("other_rules", str_t, 0, "other_rules", '[]')
# UI schema for gestures and expressions
gen.add("min_speed", int_t, 0, "Min speed of speech ", 100,50,150)
gen.add("max_speed", int_t, 0, "Max speed of speech ", 100,50,150)
gen.add("split_sentences", bool_t, 0, "Do not split to sentences", True)

gen.add("lang", str_t, 0, "Language code (en-US or similar that supported by TTS)", 'en-US')

gen.add("start", bool_t, 0, "Start Generation", True)
gen.add("progress", str_t, 0, "Current Progress", 'idle')
gen.add("node_schema", str_t, 0, '', '{"lines":{"type": "string","format": "textarea"}}')
# package name, node name, config name
exit(gen.generate(PACKAGE, "generator", "Generator"))
Loading