Package: cltl.backend-naoqi
cltl-backend-naoqiNaoQI Backend for the Pepper Robot.Backend serverThis repository provides a web server that supports connections of the client sources provided in thecltl.backend.source.client_sourcemodule of theLeolani Backendto the Pepper robot. The web server provides endpoints for Audio, Images as well as Text to Speech.The web server can be run on the Pepper robot directly, or from a docker image that can be built from this repository.
Mind that the Docker image will only run on Linux due to networking issues (see below).AudioThe container exposes an endpoint at/audio(GET) that provides an audio stream. The format of the stream is indicated
by the mine type indicated in the response. Currently, this will be chunked audio data with mime typeaudio/L16, i.e.
raw 16bit audio. In the mime type header, additional parameters forrate,channelsandframe_sizeare provided.ImagesThe container exposes an endpoint at/video(GET) that provides an image captured at invocation time. The endpoint
returns a JSON object corresponding tocltl.backend.api.camera.Imagethat contains the raw image data, the image dimensions and depth information. Image dimensions are also inlcude in the
mime type header of the response.Run the backend on the robotTo run the backend directly on the robot, thecltl.backend-naoqipackage with its dependencies needs to be installed
and run on the robot.Package installationOn pepper, a rather old Python version is installed, which causes issues withpip. Also, root access of
thenaouseris restricted.pipcan still be upgraded for thenaouser using (run in a separate directory)wgethttps://files.pythonhosted.org/packages/ca/1e/d91d7aae44d00cd5001957a1473e4e4b7d1d0f072d1af7c34b5899c9ccdf/pip-20.3.3.tar.gz
pipinstall--userpip-20.3.3.tar.gzSince we do not want to interfere with the Python environment on pepper, we install the package in a virutal
environment.For the installation thescripts/download_libs.shandscripts/install_libs.shscripts are provided.The can be downloaded viawget --no-check-certificate https://raw.githubusercontent.com/leolani/cltl-backend-naoqi/main/scripts/backend_naoqi.sh
    wget --no-check-certificate https://raw.githubusercontent.com/leolani/cltl-backend-naoqi/main/scripts/download_libs.sh
    wget --no-check-certificate https://raw.githubusercontent.com/leolani/cltl-backend-naoqi/main/scripts/install_libs.shFirst execute the download script and then the install script.If this fails on the robot, first execute the download script on your local machine (it fails on
the robot due to ssl issues). This will downlaod all necessary packages to a folder calledlib/. Then copy this folder
to the robot using scp:scp -r lib nao@<robot-ip>:<cltl-backend-install-dir>
    scp -r scripts nao@<robot-ip>:<cltl-backend-install-dir>Then log in to the robot, navigate into the directory where thelib/folder was uploaded, and run thescripts/install_libs.shscript. This will create a virtual environment and install the packages inlib/.Running the backendTo run the backend we need to find an unused port that can be used by the web serverand make sure
thefirewall on Pepper allows access it.By default the server uses port8000, which typically is available.To run the server, execute thescripts/backend_naoqi.shscript with one of the optionsstart,run,state,
orstop. Thestartoption can be used to run the server in the background usingnohup, i.e. you can disconnect
from the robot after starting the server. Therunoption will start the script directly and is equivalent tosource venv/bin/activate
python -m cltl.naoqi --naoqi-ip 127.0.0.1 --port 8000ConfigurationAdditional configuration parameters can be added when starting the web server, for a comprehensive list runpython -m cltl.naoqi --helpThis configuration options can be either specified as command line options or environment variables.Text to speechThe robot has Text to Speech (TTS) as built-in feature. To use TTS on the robot, send aPOSTrequests to thetext/(POST) endpoint with the text as payload and mime typetext/plain. The text posted to the robot can
beannotated with animation instructions.Backend Docker containerAt the current moment running the Docker container on works on LINUX, as the--network hostoption for Docker is only available on LINUX and some services registered with the qi framework are not visible to the
ALAudioDevice Module when we run inside the Docker container with a bridge network.Build the backend Docker containerTo build the docker image runmake dockerThis will create a docker image with tagcltl-backend-naoqi. To verify the build was successful runmake testRun the backend Docker containerTo run the docker image use:docker run --rm -it -e CLTL_NAOQI_IP="192.0.0.1" --network host cltl/cltl-backend-naoqiIt is mandatory to provide the IP of the Pepper robot in theCLTL_NAOQI_IPenvironment variable. Further
configurations can be set through environment variables, for a list rundocker run --rm -it cltl/cltl-backend-naoqi python -m cltl.naoqi --helpTest if the backend is workingTo test if the backend is working we can curl the REST API of the backend. The following tests requirenumpyandcv2to be installed for python and thejqandsoxcommand line applications to be installed.
Alternatively redirect the output of thecurlcommand to a file and check the content manually.When testing /video, hitEnteron the image to close it. When testing /audio, mind the echo..curl<backend_ip:port>/image
curl-N<backend_ip:port>/audio|play-traw-esigned-b16-c1-r16000-
curl-H"Content-Type: text/plain"--data"Hallo Stranger!"<backend_ip:port>/textUnit testThe unit tests in this repository require the NAOqi SDK and Python 2.7 to be installed. They are, however, included in
the Docker image provided by this repository and can be run with:make testContributingContributions are what make the open source community such an amazing place to be learn, inspire, and create. Any
contributions you make aregreatly appreciated.Fork the ProjectCreate your Feature Branch (git checkout -b feature/AmazingFeature)Commit your Changes (git commit -m 'Add some AmazingFeature')Push to the Branch (git push origin feature/AmazingFeature)Open a Pull RequestLicenseDistributed under the MIT License. SeeLICENSEfor more
information.AuthorsTaewoon KimThomas BaierSelene Báez SantamaríaPiek Vossen