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

Adding Misty Robot #87

Open
wants to merge 47 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
37896a9
Merge pull request #5 from interaction-lab/develop
micolspitale93 Apr 21, 2021
084ebe5
updated face dimensions
pavmassimo Apr 21, 2021
8476cc4
created working docker-compose (docker-compose-full.yml)
pavmassimo Apr 22, 2021
5f1411a
corrected pupils dimension, now it should be good
pavmassimo Apr 22, 2021
ea16541
implementation of harmoni speaker actuators, to be tested
pavmassimo Apr 24, 2021
8e60871
corrected some errors, tested what was testable without the robot
pavmassimo Apr 25, 2021
1ccac6d
some corrections to the implementation of the code, unit testing tries
pavmassimo Apr 25, 2021
42dcbde
actual tests of the speakers with robot, changed names to _misty, cha…
pavmassimo Apr 26, 2021
64262c0
added implementation for complete interaction audio-video-tts
pavmassimo May 1, 2021
e81abaa
added misty_caller to launch automatically displayWebView on Misty
pavmassimo May 1, 2021
897f3f1
added misty caller
pavmassimo May 1, 2021
1ae8f9b
added documentation in the README files, possible to change this.
pavmassimo May 2, 2021
c194353
harmoni_face working, test too
pavmassimo May 3, 2021
6580eac
Merge branch 'interaction-lab:develop' into develop
micolspitale93 May 11, 2021
c01bc47
Merge branch 'interaction-lab:develop' into develop
micolspitale93 May 14, 2021
a2483f1
committing all the relevant changes until v0.1 of documentations.
pavmassimo May 21, 2021
4219904
changed readme
pavmassimo May 21, 2021
584cae7
formatted readme
pavmassimo May 21, 2021
fa94326
Merge branch 'interaction-lab:develop' into develop
micolspitale93 Jul 1, 2021
64dec32
works on harmoni packages + work on harmoni core not to be merged
pavmassimo Jul 4, 2021
f14c353
fixing merging issues
micolspitale93 Jul 5, 2021
7537b4e
update readme for merging conflicts
micolspitale93 Jul 5, 2021
88d616b
update readme speaker for merging conflicts
micolspitale93 Jul 5, 2021
ceb75d8
edit src speaker service for fixing conglicts
micolspitale93 Jul 5, 2021
ec87767
edit configuration tts for fixing conflicts
micolspitale93 Jul 5, 2021
ee231b6
edit aws tts for fixing conflicts
micolspitale93 Jul 5, 2021
d6873bf
fix conflicts tts
micolspitale93 Jul 5, 2021
b65c5ae
fix configuration pattern
micolspitale93 Jul 5, 2021
811598c
fix bot service launch for merging
micolspitale93 Jul 5, 2021
1cd599c
adding compose_templates folder
micolspitale93 Jul 5, 2021
1675ed8
update docker full
micolspitale93 Jul 5, 2021
6b42011
fixing docker compsoe
micolspitale93 Jul 5, 2021
41aac47
web service fixing
micolspitale93 Jul 5, 2021
c5abf36
Merge pull request #12 from micolspitale93/robot/misty
micolspitale93 Jul 5, 2021
003cee7
updating documentation
micolspitale93 Jul 5, 2021
ffab2ce
Merge branch 'robot/misty-robotics' of https://github.com/micolspital…
micolspitale93 Jul 5, 2021
bd4d1cc
update branch
micolspitale93 Jul 5, 2021
c89dad5
minor connections on test
pavmassimo Jul 6, 2021
0f181a2
updating misty for demo working
micolspitale93 Mar 31, 2022
bca25ef
fixing merging conflicts
Mar 31, 2022
1e99194
merging conflicts
Mar 31, 2022
0475e73
renamed face_service as misty_face_service for merging conflicts
Mar 31, 2022
0ae2d1f
adding face_service as pytree
Mar 31, 2022
2c2b7be
del;eting files
Mar 31, 2022
3fa1191
renaming face_service
Mar 31, 2022
f8ab842
removing https
micolspitale93 Mar 31, 2022
04f509f
trying to fix merging issues
nchuramani Apr 12, 2022
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var/
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
*.pem

# Installer logs
pip-log.txt
Expand Down
118 changes: 118 additions & 0 deletions doc/tutorials/Setting-Up-a-New-Robot.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,121 @@
# Setting Up A Robot

STUB -- need to define interfaces that would be attached to


# MISTY robot (API based) V0.1

In order to be able to run HARMONI on an API based robotic platform, a few modifications are needed.

First of all, the IP of the robot, which is needed in most of the _service file, is saved as a ros parameter in the initialization of the harmoni_core/harmoni_common_lib/service_manager.py class; and then retrieved directly in the implementation of the actual service class.

Here are listed the packages and the files that have been modified and added in order to make HARMONI work on the robot.

The docker-compose-full.yml file have been modified in order to be able to run docker in distributed mode, and enable communications between harmoni inside the docker and external networks. In particular, port forwarding paths are necessary, and the network ros_net must not be specified. The network mode must be set to "host".
## Usage

## Parameters

## Testing

## References


### harmoni_actuators

#### harmoni_face

the service of this package does not need to be modified.

A "caller" node file has been added, it's only role is to call the "Display web page" API of the robot.

The node needs to be added to the test and launch files.

The face has been adapted to better fit the robot display, modifying the web/src/js/face.js file.

#### harmoni_gesture

This part of the implementation is still not completed, so the documentation will be adjusted.

Two files have been added to the package: gesture_service_misty.py and misty_gesture_interface.py.

The first one is meant to replace the normal gesture_service file, and thus has been substituted in the launch and test files.

In it, the DO operation that was used before for ordering the robot to make a gesture, has been replaced by a REQUEST operation, which is more in line with the API nature of the interaction.

It is important to remember that when a REQUEST operation is called, it is necessary to set the flag response_received = True when the API call is over.

The parse_gesture_misty() function has been added to the file, and there the gesture described in the xml files in the data folder are processed and for each command composing the gesture an API call is made. A function which prepares the url and the payload for each possible API call has been added to the file, and then the request is forwared to the robot. If the call for any reason timed-out, a second call is made with a longer timeout (sometimes connection problem can happen), and if also that one fails, the function return setting the done flag to false.

Currently the misty_gesture_interface file only publishes some required parameters to ros, but we are planning on moving the api calls described above in this file, in the attempt to better resamble the previous work done on qt. The documentation will be updated consequently.

The xml files contained in data/Misty folder resemble the format for the API calls of the robot, adding only a time parameter which is used for choosing after how much time each single movemente should be performed. Be aware that the time for sending the call is not calculated in a strict manner, so the execution time may consequently be not completely precise.

#### harmoni_speaker
TODO


In this package, the speaker_service_misty.py has been added, and the launch and test files have been modified consequently.

In it, the DO operation that was used before for ordering the robot to play a recording, has been replaced by a REQUEST operation, which is more in line with the API nature of the interaction.

It is important to remember that when a REQUEST operation is called, it is necessary to set the flag response_received = True when the API call is over.

Since Misty needs to recieve the files in base64 format, the file_path_to_audio_data function has been modified to convert the wav file in that format. Currently, the implementation of the robot call providing directly the data is not implemented, and the data must always be given to the node as a wav file. In case free data are provided, the node assumes that it is the tts package calling the speaker, and so retrieve the data where the tts node saves the file as a temporary .wav file.

The function prepares the url and the payload for the API call has been added to the file, and then the request is forwared to the robot. If the call for any reason timed-out, a second call is made with a longer timeout (sometimes connection problem can happen), and if also that one fails, the function return setting the done flag to false.

It is important to note that, since the wav file can be heavier than the maximum file size for the parameters, the payload must be passed as data and not as a parameter to the API call.

An argument robot_ip is provided in the service_manager class.
In misty, the file must either be encoded in base64 or provided as file. In the speaker_service_misty class the data are converted after being uploaded from a .wav file, either that they are provided to the class directly or via path.

To reproduce the file the flag ImmediatelyApply has been set to True in the API call.
The flag OverwriteExisting makes the new file replace the old, since the file is always called with the same name.
Another possible way of doing this was to separate into two different API call, SaveAudio with ImmediatelyApply set to false and then PlayAudioClip.

When replacing harmoni's speaker_service with speaker_service_misty, the type of action that the class performs has been changed from DO to REQUEST: this was done because conceptually we are requesting to an external service (the robot) to perform an action, and not performing the action directly inside HARMONI. This change requires to modify everything that interfaces with the speaker service

Be sure to add the correct robot_ip argument to the launch file if you want to test the case with no exception, or to add a mock one if you to test the exception.

#### harmoni_tts

this package has not been relevantly modified.

#### harmoni_web

this package has not been relevantly modified.

### harmoni_core

#### harmoni_common_lib

the only relevant modification is the addition of the IP of the robot, saved as a ros parameter in the initialization of the harmoni_core/harmoni_common_lib/service_manager.py class. In future this parameter is expected to be passed throught a configuration file. (TODO)

#### harmoni_decision

the configuration file has been modified, adding the parameter gesture: ["misty"] that was previusly commented.

#### harmoni_pattern

two interactions have been added: pattern_scripting/misty_demo.json pattern_scripting/misty_interaction.json and (one for tests and one for the actual interactions). The interactions name must be added also to configuration file too. currently the demos are sort of "mock-ups" of real interactions.

The node has not been relevantly modified.

### harmoni_detectors

this package has not been modified yet.

### harmoni_dialogues

this package has not been modified yet.

### harmoni_sensors

this package has not been modified yet.


### HARMONI face: Using Misty API
An argument robot_ip is provided in the service_manager class.

A class misty_caller has been added to implement automatically a request to display the webView of harmoni face on robot's screen.
17 changes: 17 additions & 0 deletions docker-run-command.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

sudo docker run -it --name harmoni_core --network host --init \
-e "ROS_DISTRO=noetic" \
-e "CATKIN_WS=harmoni_catkin_ws" \
-e "IS_DOCKER_ENV=true" \
-v /home/afar/harmoni_catkin_ws/src/HARMONI/dockerfiles/config/setup_script.sh:"/root/.setup_script.sh" \
-v /home/afar/harmoni_catkin_ws/src/HARMONI/dockerfiles/config/dev_setup_script.sh:"/root/.dev_setup_script.sh" \
-v /home/afar/harmoni_catkin_ws/src/HARMONI/dockerfiles/config/asoundrc:"/root/.asoundrc" \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /home/afar/.ssh/:/root/.ssh:ro \
-v /home/afar/.vimrc:/root/.vimrc:ro \
-v /home/afar/.vim/:/root/.vim/:ro \
-v /etc/timezone:/etc/timezone:ro \
-v /etc/localtime:/etc/localtime:ro \
-v /home/afar/harmoni_catkin_ws/src/HARMONI/:/root/local_mount/HARMONI/ \
-w "/root/harmoni_catkin_ws/src/HARMONI" \
harmoniteam/harmoni:noetic-full bash
62 changes: 62 additions & 0 deletions dockerfiles/compose_templates/docker-compose-full-misty.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
version: "3.7"

services:
harmoni_full:
container_name: harmoni_full
build:
context: .
dockerfile: dockerfiles/harmoni/kinetic/full/dockerfile #substitute $ROS_DISTRO with kinetic for now.
network: host
image: harmoniteam/harmoni:kinetic-full
init: true
environment:
# DISPLAY: $DISPLAY
# QT_GRAPHICSSYSTEM: native
ROS_DISTRO: kinetic
# ROS_MASTER_URI: http://172.18.3.4:11311
IS_DOCKER_ENV: "true"
# ROS_HOSTNAME: harmoni_full
CATKIN_WS: harmoni_catkin_ws
# privileged: true
network_mode: "host"
# networks:
# ros_net:
# ipv4_address: 172.18.3.4
# hostname: harmoni_full
ports:
- "11312:11312"
- "33691:33691"
- "8081:8081" #harmoni_face
- "8082:8082" #harmoni_web
devices:
# - /dev/dri:/dev/dri
- /dev/snd:/dev/snd
# - /dev/video0:/dev/video0
volumes:
# - harmoni_catkin_ws:/root/harmoni_catkin_ws
- ../HARMONI/:/root/local_mount/HARMONI/
# Configuration
- ~/.aws:/root/.aws/
- ./dockerfiles/config/.asoundrc:/root/.asoundrc
- ~/.gcp/private-keys.json:/root/.gcp/private-keys.json
# Other
- /home/.ssh/:/root/.ssh:ro
- /tmp/.X11-unix:/tmp/.X11-unix
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
working_dir: /root/harmoni_catkin_ws/src/HARMONI

command:
tail -f /dev/null
# bash -c "terminator -ue \"echo 'Entering harmoni_full Container... \\n start with roscore and rlharmoniservices' && bash\""

#networks:
# ros_net:
# driver: bridge
# ipam:
# driver: default
# config:
# - subnet: 172.18.3.0/24
# volumes:
# harmoni_catkin_ws:
# wav2letter:
21 changes: 21 additions & 0 deletions harmoni_actuators/harmoni_face/launch/face_service_misty.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- This is an example launch file for how a ROS application could use a node -->
<launch>

<arg name="web_directory_path" value="$(find harmoni_face)/web"/>
<arg name="port" default="8080"/>
<arg name="instance_id" default="default"/>
<param name="instance_id" value="$(arg instance_id)"/>
<rosparam file="$(find harmoni_face)/config/configuration.yaml"/>
<rosparam file="$(find harmoni_decision)/config/misty_configuration.yaml"/>
<node pkg="harmoni_face" type="http_server_runner.py" name="face_http_server" output="screen" args="$(arg web_directory_path) $(arg port)" />
<node pkg="harmoni_face" type="misty_face_service_.py" name="harmoni_face_$(arg instance_id)" output="screen"/>
<node pkg="harmoni_face" type="misty_caller.py" name="misty_caller" output="screen" args="$(arg web_directory_path) $(arg port)" />
<include ns="bridge_face" file="$(find rosbridge_server)/launch/rosbridge_websocket.launch">
<arg name="port" value="9000"/>
<!-- <arg name="ssl" value="true"/>
<arg name="certfile" value="$(find harmoni_face)/web/server_cert.pem"/>
<arg name="keyfile" value="$(find harmoni_face)/web/server_key.pem"/>
<arg name="authenticate" value="false"/>-->
</include>

</launch>
6 changes: 6 additions & 0 deletions harmoni_actuators/harmoni_face/nodes/http_server_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ def is_int(value):
if is_int(args[PORT_IDX]):
port = args[PORT_IDX]
command += ["-p", port]
#command += ["-S"]

#cert_path = args[DIR_IDX] + "/server_cert.pem"
#key_path = args[DIR_IDX] + "/server_key.pem"
#command += ["-C", cert_path]
#command += ["-K", key_path]

p = subprocess.Popen(command)
atexit.register(p.terminate)
Expand Down
Loading