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
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!
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
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.
Let's see the completed form in the video.
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