From 92b1c70ddaffb2b93c0720bf045912c69eca708b Mon Sep 17 00:00:00 2001 From: Davide De Tommaso Date: Fri, 8 Apr 2022 17:53:54 +0200 Subject: [PATCH] Added custom action timeout --- examples/4.Actions/7.custom_action_timeout.py | 50 +++ examples/4.Actions/json/complete_action.json | 286 ------------------ 2 files changed, 50 insertions(+), 286 deletions(-) create mode 100644 examples/4.Actions/7.custom_action_timeout.py delete mode 100644 examples/4.Actions/json/complete_action.json diff --git a/examples/4.Actions/7.custom_action_timeout.py b/examples/4.Actions/7.custom_action_timeout.py new file mode 100644 index 0000000..b1f7c5e --- /dev/null +++ b/examples/4.Actions/7.custom_action_timeout.py @@ -0,0 +1,50 @@ +# BSD 2-Clause License +# +# Copyright (c) 2022, Social Cognition in Human-Robot Interaction, +# Istituto Italiano di Tecnologia, Genova +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +hamlet=""" +To be, or not to be, that is the question: +Whether 'tis nobler in the mind to suffer +The slings and arrows of outrageous fortune, +Or to take arms against a sea of troubles +And by opposing end them. To die—to sleep +... +""" + + +from pyicub.helper import iCub, PyiCubCustomCall + +icub = iCub() + +speak = PyiCubCustomCall(target="speech.say", args=(hamlet,), timeout=5.0) + +action = icub.createAction() +step = icub.createStep() +step.addCustomCall(speak) +action.addStep(step) + +icub.play(action) \ No newline at end of file diff --git a/examples/4.Actions/json/complete_action.json b/examples/4.Actions/json/complete_action.json deleted file mode 100644 index 8205ff1..0000000 --- a/examples/4.Actions/json/complete_action.json +++ /dev/null @@ -1,286 +0,0 @@ -{ - "steps": [ - { - "name": "step/1", - "limb_motions": { - "right_arm": { - "part_name": "right_arm", - "checkpoints": [ - { - "pose": { - "target_joints": [ - -90.0, - 20.0, - 10.0, - 90.0, - 0.0, - 0.0, - 0.0, - 60.0, - 20.0, - 20.0, - 20.0, - 10.0, - 10.0, - 10.0, - 10.0, - 10.0 - ], - "joints_list": null - }, - "duration": 1.0, - "timeout": 0.0 - }, - { - "pose": { - "target_joints": [ - 0.0, - 15.0, - 0.0, - 25.0, - 0.0, - 0.0, - 0.0, - 60.0, - 20.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0 - ], - "joints_list": null - }, - "duration": 1.0, - "timeout": 0.0 - } - ] - } - }, - "gaze_motion": null, - "custom_calls": [ - { - "target": "gaze.lookAtAbsAngles", - "args": [ - 0.0, - 15.0, - 0.0 - ] - }, - { - "target": "emo.neutral", - "args": [] - } - ], - "offset_ms": null - }, - { - "name": "step/2", - "limb_motions": { - "left_arm": { - "part_name": "left_arm", - "checkpoints": [ - { - "pose": { - "target_joints": [ - -90.0, - 20.0, - 10.0, - 90.0, - 0.0, - 0.0, - 0.0, - 60.0, - 20.0, - 20.0, - 20.0, - 10.0, - 10.0, - 10.0, - 10.0, - 10.0 - ], - "joints_list": null - }, - "duration": 1.0, - "timeout": 0.0 - }, - { - "pose": { - "target_joints": [ - 0.0, - 15.0, - 0.0, - 25.0, - 0.0, - 0.0, - 0.0, - 60.0, - 20.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0 - ], - "joints_list": null - }, - "duration": 1.0, - "timeout": 0.0 - } - ] - } - }, - "gaze_motion": null, - "custom_calls": [], - "offset_ms": null - }, - { - "name": "step/3", - "limb_motions": { - "right_arm": { - "part_name": "right_arm", - "checkpoints": [ - { - "pose": { - "target_joints": [ - -90.0, - 20.0, - 10.0, - 90.0, - 0.0, - 0.0, - 0.0, - 60.0, - 20.0, - 20.0, - 20.0, - 10.0, - 10.0, - 10.0, - 10.0, - 10.0 - ], - "joints_list": null - }, - "duration": 1.0, - "timeout": 0.0 - }, - { - "pose": { - "target_joints": [ - 0.0, - 15.0, - 0.0, - 25.0, - 0.0, - 0.0, - 0.0, - 60.0, - 20.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0 - ], - "joints_list": null - }, - "duration": 1.0, - "timeout": 0.0 - } - ] - }, - "left_arm": { - "part_name": "left_arm", - "checkpoints": [ - { - "pose": { - "target_joints": [ - -90.0, - 20.0, - 10.0, - 90.0, - 0.0, - 0.0, - 0.0, - 60.0, - 20.0, - 20.0, - 20.0, - 10.0, - 10.0, - 10.0, - 10.0, - 10.0 - ], - "joints_list": null - }, - "duration": 1.0, - "timeout": 0.0 - }, - { - "pose": { - "target_joints": [ - 0.0, - 15.0, - 0.0, - 25.0, - 0.0, - 0.0, - 0.0, - 60.0, - 20.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0, - 0.0 - ], - "joints_list": null - }, - "duration": 1.0, - "timeout": 0.0 - } - ] - } - }, - "gaze_motion": { - "checkpoints": [ - [ - 20.0, - 0.0, - 0.0 - ], - [ - -20.0, - 0.0, - 0.0 - ], - [ - 0.0, - 0.0, - 0.0 - ] - ], - "lookat_method": "lookAtAbsAngles" - }, - "custom_calls": [ - { - "target": "emo.smile", - "args": [] - } - ], - "offset_ms": 500 - } - ], - "name": "default" -} \ No newline at end of file