Misty Lessons
  • Misty Lessons
    • 📖Welcome to Misty Lessons
    • 📚Get to know your Misty
    • 📲Connect to Misty
    • 👩‍💻Misty Studio
    • 🖥️Desktop Environment
    • ⬆️Update your Misty
    • 👥Projects
  • Blockly
    • 🧩Blockly Lessons
      • 🤸Lesson 1: Movement
      • 🎶Lesson 2: Voice and Sound
      • 🎭Lesson 3: Expressions
      • 🎥Lesson 4: Robot Cinema
      • 🛠️Lesson 5: Events
      • ☺️Lesson 6: Face recognition
      • 🔢Lesson 7: Variables and Functions
      • 💬Lesson 8: NLP
    • 🏫Blockly projects
  • Blockly Elements
    • ⚛️Misty Blocks
      • Movement
      • Speech
      • Audio
      • Vision
      • Events
      • Miscellaneous
      • NLP
      • System
    • 🔁Basic Blocks
      • Logic
      • Loops
      • Math
      • Text
      • Lists
    • 🅰️Advanced Blocks
      • Variables
      • Functions
  • Python
    • 🐍Python Lessons
      • 🦿Lesson 1: Loco-motion
      • 🤖Lesson 2 : Build a character
      • 🧠Lesson 3: Create memories
      • ⚒️Lesson 4: Event skills
      • 👀Lesson 5: Expand awareness
      • 🔗Lesson 6: Compact code
      • 🗣️Lesson 7: Start a conversation
  • Python Elements
    • 🐸Misty Python API
      • Motion and Mobility
      • Display and LED
      • Record Assets
      • Change/Remove Assets
      • Stream Assets
      • Get Assets
      • Events
      • Sensor Events
      • Speech and NLP
      • Arduino Backpack
      • System
      • Slam
    • 📗Python Definitions
  • Python Projects
    • 🔮MistyGPT
    • 🚨Misty Intruder Alert
    • 📺Conference Assistant
    • 🏷️QR code detector
    • 🕵️‍♂️Misty follow human
    • 👋Misty wave back
    • 🖲️Misty OA
    • 🌐Get weather
    • 🚚Misty Delivery
    • 🫂Motivational Misty
    • 🖼️Misty Museum Guide
    • 🎃Who for Halloween
  • ARDUINO
    • ♾️Arduino Backpack
    • 🦎Arduino
    • 🔧Arduino Lessons
      • 🔌Arduino to Misty
      • ➕Misty to Arduino
  • ARDUINO PROJECTS
    • 🛠️Misty Tracker
    • 🦾Misty Arm
  • Community Projects
    • 🌤️Misty weather forecaster
  • HARDWARE EXTENSION
    • ⚙️Arduino breadboard support
    • 🦾Misty arm
    • 🥤Tin holder
  • Resource Database
    • 📁Image files
    • 📁Audio files
    • 📁Languages
    • 📁Known objects
    • 📁NLP Actions
    • 📁Action Commands
    • 📁ChatGPT PDF files
    • 📁AR Tag Dictionary
    • ⚙️Technical Specifications
Powered by GitBook
On this page
  1. Python Projects

Misty Delivery

Everyone needs a Misty who can deliver fresh soft drinks!

Last updated 6 months ago

In this project, Misty will be programmed to listen to our favourite drink, and thanks to the NLP understanding it, go straight to the fridge and ask to have it in her amazing.

The first step to create a customized NLP conversation is to program our very unique context.

For the moment this is possible only with Blockly.

In your Misty Studio, click on Programming and then Blockly. From there open Misty's NLP Blockly section and create this context:

Then click on 'Run' and let Misty learn about your drinks choice.

In the Python code, after initializing the variables it's time to build the conversation, the states, the actions and how the flow will go from one to the other.

from mistyPy.Robot import Robot
from mistyPy.Events import Events
import time

misty = Robot("YOUR-ROBOT-IP-ADDRESS")
misty.change_led(0, 0, 255)
misty.move_head(0, 0, 0)
misty.display_image("e_DefaultContent.jpg")

#create conversation
misty.create_conversation(name="DeliveryConv", startingState="StartDelivery", overwrite=True)

#create states
misty.create_state(name= "StartDelivery", speak="What can I get you to drink?", contexts="['DeliveryContext']", listen=True, noMatchSpeech= "Could you please repeat that?",  repeatMaxCount= 3, startAction="listen", overwrite=True)
misty.create_state(name= "DeliveryCoca-cola", speak= "Affirmative! One Coca-Cola, delivered with robotic precision.", listen=False, noMatchSpeech="could you please repeat that?", repeatMaxCount= 3, startAction="ActionCoca-cola", overwrite=True)
misty.create_state(name= "DeliveryFanta", speak= "Excellent choice! Fanta it is! I'll whiz over with that right away.", listen=False, noMatchSpeech="could you please repeat that?", repeatMaxCount= 3, startAction="ActionFanta", overwrite=True)
misty.create_state(name= "DeliverySprite", speak= "One Sprite, coming up! No lemon, no lime, just Sprite!", listen=False, noMatchSpeech="could you please repeat that?", repeatMaxCount= 3, startAction="ActionSprite", overwrite=True)
misty.create_state(name= "DeliveryBeer", speak= "You got it! One beer, perfectly chilled and ready to enjoy.", listen=False, noMatchSpeech="could you please repeat that?", repeatMaxCount= 3, startAction="ActionBeer", overwrite=True)

#map states
misty.map_state(conversation= "DeliveryConv", state= "StartDelivery", trigger= "SpeechHeard", nextState= "DeliveryCoca-cola", triggerFilter="coca-cola", reEntry=False, overwrite=True)
misty.map_state(conversation= "DeliveryConv", state= "StartDelivery", trigger= "SpeechHeard", nextState= "DeliveryFanta", triggerFilter="fanta", reEntry=False, overwrite=True)
misty.map_state(conversation= "DeliveryConv", state= "StartDelivery", trigger= "SpeechHeard", nextState= "DeliverySprite", triggerFilter="sprite", reEntry=False, overwrite=True)
misty.map_state(conversation= "DeliveryConv", state= "StartDelivery", trigger= "SpeechHeard", nextState= "DeliveryBeer", triggerFilter="beer", reEntry=False, overwrite=True)

#create actions
misty.create_action(name="ActionCoca-cola", 
                    script= "LED:255,0,0;IMAGE:coca-cola.png;ARMS:80,40,1000;HEAD:0,0,0,1000;",
                    overwrite= True)

misty.create_action(name="ActionFanta", 
                    script= "LED:255,165,0;IMAGE:fanta.jpg;ARMS:80,40,1000;HEAD:0,0,0,1000;",
                    overwrite= True)

misty.create_action(name="ActionSprite", 
                    script= "LED:0,255,0;IMAGE:sprite.jpg;ARMS:80,40,1000;HEAD:0,0,0,1000;",
                    overwrite= True)

misty.create_action(name="ActionBeer", 
                    script= "LED:255,255,0;IMAGE:beer.jpg;ARMS:80,40,1000;HEAD:0,0,0,1000;",
                    overwrite= True)

def path_to_the_kitchen():
    misty.drive_time(0, 50, 4500)
    time.sleep(5)
    misty.drive_time(40, 0, 8000)
    time.sleep(9)
    misty.drive_time(0, 50, 4500)
    time.sleep(5)
    misty.drive_time(40, 0, 10000)
    time.sleep(11)
    misty.drive_time(0, -50, 4500)
    time.sleep(5)
    misty.drive_time(40, 0, 6000)
    time.sleep(7)
    misty.drive_time(0, -50, 4500)
    time.sleep(5)
    misty.drive_time(0, 0, 2000)
    time.sleep(2)
    
def go_back():
    misty.drive_time(0, 50, 4500)
    time.sleep(5)
    misty.drive_time(40, 0, 6000)
    time.sleep(7)
    misty.drive_time(0, 50, 4500)
    time.sleep(5)
    misty.drive_time(40, 0, 10000)
    time.sleep(11)
    misty.drive_time(0, -50, 4500)
    time.sleep(5)
    misty.drive_time(40, 0, 8000)
    time.sleep(9)
    misty.drive_time(0, -50, 4500)
    time.sleep(5)
    misty.drive_time(0, 0, 2000)
    time.sleep(2)


def Key_Phrase_Recognized(data):
    print(data)
    misty.change_led(0, 255, 0)
    misty.play_audio("s_PhraseHello.wav")
    time.sleep(4)
    misty.start_conversation("DeliveryConv")
    time.sleep(12)
    path_to_the_kitchen()
    misty.move_head(-35, 0, 0)
    misty.speak("Hey, is there anyone that can put this drink in my arm?")
    time.sleep(3)
    go_back()             

misty.register_event(event_name='KPR_event', event_type=Events.KeyPhraseRecognized, callback_function=Key_Phrase_Recognized, keep_alive=True)
misty.keep_alive()

We have also created two functions that represent the path to the fridge in the kitchen and the path to go back to the desk of the user who first asked for Misty's delivery service.

It's possible to trigger the whole system only after saying: "hey Misty!" and she will start listening to your request.

It's also important to import the images that Misty will display to ask for the soft drink like:

Have fun with this new Misty project!

🚚
tin holder arm