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

Introduction

This article Evacuation advisory system using drone This is the third 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 Chapter 2 [AWS / Tello] I tried to operate the drone with voice Part1

System Configuration

system.png

Lambda

I will write the code of lambda. However, I wrote the completed form, so I will post it. The Alexa Skills Kit SDK for Python documentation was confusing and I had a hard time writing code lol https://github.com/shoda888/alexa2tello/blob/master/lambda_function.py There may be redundant code, so please PR at that time!

Excerpt and explanation

session_attributes: Variables that can be held during the session This time, the slot name is retained. This time, when I said only one of the places where the distance and direction should be entered as a set, I am asking again about the person who did not say it. At that time, it is necessary to memorize the items already mentioned for a short period during the session, and session_attributes is used for that. (I wanted to reset session_attributes on lines 126-128, but I don't know how to reset it, so I'm forcibly substituting None. If you know how to reset it easily: pray :)

session_attr = handler_input.attributes_manager.session_attributes
slots = handler_input.request_envelope.request.intent.slots

resolutions: Entity resolution (← name alone is not enough) When the synonym is set for the slot value, there are times when you want them to be recognized as one group ID. For example, if you register the synonyms "rise" and "upward" for the slot value "up", and register "up" as the group ID, even if you say "rise", "up" Even if you say, it can be recognized as ID "up". In other words, when sending as a command to the drone, it can be incorporated so that "up" can be sent regardless of whether you say "up" or "rise".

direction = slots["direction"].resolutions.resolutions_per_authority[0].values[0].value.name

Communication with IoT Core

iot = boto3.client('iot-data')
def publish(msg):
    #Specify a topic
    topic = 'test/pub'
    #Message content
    payload = {
        "message": msg
    }  

    try:
        #Publish message
        iot.publish(
            topic=topic,
            qos=0,
            payload=json.dumps(payload, ensure_ascii=False)
        )
        return True
    
    except Exception as e:
        print(e)
        return False

that's all! By the way, please specify the role to which the policy that allows publishing to IoT Core is attached to lambda. (Otherwise you can't communicate) The code for the subscriber will be able to communicate with the drone by referring to the contents of the previous chapter and the previous chapter.

Summary

Let's see the completed form in the video. IMAGE ALT TEXT HERE

In the next chapter, let's build a system that judges something from the image and controls the feedback to the drone. "Construction of a system that estimates and notifies the state from information such as the posture of the person whose image was analyzed"

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 implementing DeepPose with PyTorch PartⅡ
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 "binarizing" the image with Python + OpenCV
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 to find the entropy of the image with python
I tried "gamma correction" of the image with Python + OpenCV
I tried to simulate how the infection spreads with Python
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 replacing the Windows 10 HDD with a smaller SSD
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 clustering with PyCaret
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