[PYTHON] [AWS / Tello] I tried operating the drone with my voice Part1

Introduction

This article Evacuation advisory system using drone This is the second chapter of. Please refer to it for the production background.

In addition, the contents of this chapter are based on the following contents, so if you have not read it yet, please read that first. Chapter 1 [AWS / Tello] Building a system for operating drones on the cloud

Overview

Let's operate the Tello drone by voice using Alexa. AWS is used as the infrastructure. First, let's see the completed form in the video. IMAGE ALT TEXT HERE

System Configuration

system.png

things to do

I confirmed the communication between IoT Core and Tello until the last time, so this time Host your Alexa skill endpoint on lambda and publish it to IoT Core. Part1. Skill development / cooperation with lambda Part2. Communication from lambda to IoT Core

Skill development

Skill creation

Log in to the alexa developer console (ADC) and create a custom skill. skillselect1.png backendforalexa.png

If you select "User-defined provisioning" as the backend of the skill, you need to prepare your own lambda function. If you select "Alexa-Hosted", you can use the code editor on the ADC and feel that it is easy for beginners to get involved. Since it communicates with IoT Core, considering future extensibility, here we will do it by the former method of preparing a lambda function by ourselves. That's why I will prepare a new lambda. Make a note of the ARN of the lambda and set it to the default region in the skill endpoint. endpointforalexa.png

Skill Glossary

Since it is kind, I will reconfirm the basic terms of the skill. I will touch on it in detail later.

__Call name __: Password to start a dialogue (session) __Intent __: Intention of dialogue (developer can set freely) __Built-in intent __: Built-in intent by default (cancel, stop, help, etc.) __ Sample utterance __: Password to call a specific intent in a session __Slot __: Something like a variable held in a sample utterance __Built-in slot __: Slots already prepared (there are numbers, facility names, actress names ... amazing) __ Custom Slots __: Slots that developers can set freely

By the way, slots are wonderful because you can flexibly set synonyms and ID specifications.

Skill details

Details of the skills set in this drone control system. (For your reference)

__Call name __: "Controller" __Intent __: Controller / Land Controller intent when you want to move the drone, Land intent when you want to land (Flip intent looks interesting) __ Sample utterance __: For Controller intent ContIntent.png

__Built-in slot __: num (number) __ Custom slot __: direction slot_direc.png

In other words, the Controller intent requires two pieces of information, the direction of travel and the distance. It will be your preference, but you should devise a way to listen back to the distance when only the direction is input by voice with the actual skill. It seems that the dialogue model here can be defined by json, so I will post it in the appendix.

Back end

Play with the lambda you created earlier. It is definitely better to use the "Alexa Skills Kit SDK" here. You can do it without using it, but the json nesting of the request parameter is deep and the processing seems to be troublesome. The language will be Python. Since there are many people who use Nodejs and few people who use Python, I dared to use Python here.

Alexa Skills Kit SDK for Python

First, import ask_sdk_core with lambda.

$ import ask_sdk_core

However, if it is left as it is, the external library cannot be read, so let's add ask_sdk_core as a layer.

You can also pip install to the project locally, zip the entire project and upload it to lambda. The link below summarizes the method and the ecosystem of local development of lambda, so please have a look if you are interested. [AWS / Lambda] How to load Python external library

Since ask_sdk_core is a PurePython library, any environment for creating a zip file for layer should be okay. It was done on MacOS. (Example of python3.7)

$ mkdir -p build/python/lib/python3.7/site-packages
$ pip3 install ask_sdk_core -t build/python/lib/python3.7/site-packages/
$ cd build
$ zip -r ask_sdk.zip .

Add the generated ask_sdk.zip to layer and adapt the layer in lambda to load the library. createlayer.png

layer.png

lambda trigger settings

Of course, this lambda trigger is Alexa Skill Kit, and the skill ID is the ID of the skill you created earlier. trigger.png

Summary

The interaction model of Alexa's skill and lambda have been linked. Next, we will develop lambda code and link IoT Core.

Since it has become longer, I will move on to Part 2. Chapter 3 [AWS / Tello] I tried to operate the drone with voice Part2

appendix

I will put the dialogue model in json. If you have a new intent, please publicize it on GitHub: pray: https://github.com/shoda888/tello_ask_model

{
    "interactionModel": {
        "languageModel": {
            "invocationName": "controller",
            "intents": [
                {
                    "name": "AMAZON.CancelIntent",
                    "samples": []
                },
                {
                    "name": "AMAZON.HelpIntent",
                    "samples": []
                },
                {
                    "name": "AMAZON.StopIntent",
                    "samples": []
                },
                {
                    "name": "Controller",
                    "slots": [
                        {
                            "name": "num",
                            "type": "AMAZON.NUMBER"
                        },
                        {
                            "name": "direction",
                            "type": "direction"
                        }
                    ],
                    "samples": [
                        "{direction} {num}",
                        " {num}centimeter{direction}Go to",
                        "{direction}To{num}centimeter",
                        "{direction}To{num}Move a centimeter"
                    ]
                },
                {
                    "name": "AMAZON.NavigateHomeIntent",
                    "samples": []
                },
                {
                    "name": "Land",
                    "slots": [],
                    "samples": [
                        "landing",
                        "Landing",
                        "land"
                    ]
                }
            ],
            "types": [
                {
                    "name": "direction",
                    "values": [
                        {
                            "id": "back",
                            "name": {
                                "value": "Behind",
                                "synonyms": [
                                    "back",
                                    "Rear"
                                ]
                            }
                        },
                        {
                            "id": "forward",
                            "name": {
                                "value": "Before",
                                "synonyms": [
                                    "Before",
                                    "Forward"
                                ]
                            }
                        },
                        {
                            "id": "down",
                            "name": {
                                "value": "did",
                                "synonyms": [
                                    "under",
                                    "Descent",
                                    "Down"
                                ]
                            }
                        },
                        {
                            "id": "up",
                            "name": {
                                "value": "up",
                                "synonyms": [
                                    "Up",
                                    "Upward",
                                    "Rise"
                                ]
                            }
                        },
                        {
                            "id": "left",
                            "name": {
                                "value": "Hidari",
                                "synonyms": [
                                    "left"
                                ]
                            }
                        },
                        {
                            "id": "right",
                            "name": {
                                "value": "Migi",
                                "synonyms": [
                                    "right"
                                ]
                            }
                        }
                    ]
                }
            ]
        }
    }
}

Recommended Posts

[AWS / Tello] I tried operating the drone with my voice Part2
[AWS / Tello] I tried operating the drone with my voice Part1
I tried running the DNN part of OpenPose with Chainer CPU
I tried playing with the image with Pillow
I tried a formation flight of a small drone Tello with ESP32: DJI Tello drone formation flight
I tried "smoothing" the image with Python + OpenCV
I tried "differentiating" the image with Python + OpenCV
I tried to save the data with discord
I tried connecting AWS Lambda with other services
I tried playing with the calculator on tkinter
[Introduction to AWS] I tried porting the conversation app and playing with text2speech @ AWS ♪
I tried to learn the sin function with chainer
I tried Amazon Comprehend sentiment analysis with AWS CLI.
I tried to touch the CSV file with Python
I tried to solve the soma cube with python
[MQTT] I tried talking with the device using AWS IoT Core and Soracom Beam
I tried AWS CDK!
I tried to erase the negative part of Meros
I tried to solve the problem with Python Vol.1
I tried AWS Iot
[Introduction to AWS] I tried playing with voice-text conversion ♪
I tried to classify the voices of voice actors
I tried hitting the API with echonest's python client
I wanted to operate google spread sheet with AWS lambda, so I tried it [Part 2]
I tried to visualize the power consumption of my house with Nature Remo E lite
I tried "gamma correction" of the image with Python + OpenCV
I tried to analyze the whole novel "Weathering with You" ☔️
I tried using the Python library from Ruby with PyCall
I tried to find the average of the sequence with TensorFlow
I tried to notify the train delay information with LINE Notify
I tried using the DS18B20 temperature sensor with Raspberry Pi
I tried saving the DRF API request history with django-request
I tried to launch ipython cluster to the minimum on AWS
I tried to divide the file into folders with Python
I tried fp-growth with python
I tried scraping with Python
I tried Learning-to-Rank with Elasticsearch!
I tried the changefinder library!
I tried gRPC with Python
I tried scraping with python
I tried using AWS Chalice
I tried to find out how to streamline the work flow with Excel × Python, my article summary ★
I tried to unlock the entrance 2 lock sesame with a single push of the AWS IoT button
PySpark learning record ② Kaggle I tried the Titanic competition with PySpark binding
I tried scraping the ranking of Qiita Advent Calendar with Python
I tried to describe the traffic in real time with WebSocket
I tried to solve the ant book beginner's edition with python
I tried standalone deployment of play with fabric [AWS operation with boto] [Play deployment]
I tried to automate the watering of the planter with Raspberry Pi
I tried cross-validation based on the grid search results with scikit-learn
I tried to process the image in "sketch style" with OpenCV
I studied with Kaggle Start Book on the subject of kaggle [Part 1]
When I run the exe file with pyinstaller, my PC crashes.
I tried to get started with Bitcoin Systre on the weekend
I tried using PyEZ and JSNAPy. Part 4: Automate ISP setup with PyEZ and JSNAPy
I tried sending an email from the Sakura server with flask-mail
I wrote the basic operation of Pandas with Jupyter Lab (Part 1)
The diagrams were interesting so I tried wrapping them with flask
I tried to process the image in "pencil style" with OpenCV
I tried to expand the size of the logical volume with LVM
I want to check the position of my face with OpenCV!