Events

The events blocks enable Misty to respond to changes in her environment and perform actions accordingly. Events provide a reactive programming model, allowing Misty to autonomously respond to you through real-time user input. In order to create this autonomous interaction, you must create skills and robot applications that are driven by events and with logic that listens for and responds to incoming environmental data.

When we are running an event we need to make sure Misty monitors her environment and sensor input at all times so she knows what's happening. To do this you will need to place a 'run until stopped' block from the 'Miscellaneous' tab in Misty Blocks.

All the event blocks work in the same way:

They wait for something to happen (bump sensor, keyphrase, face recognition, etc.) and if they are triggered they will execute the code nested inside them. If the checkbox is selected in an event block, it will let Misty know that she has to repeat it. It means that if you want to execute the event only once when its triggered you don't have to select the checkbox. Otherwise, you select it and the event will be executed as long as the event is verified.

For example :

  • If our program is: to touch Misty's head and say "Hi", we want it to happen only once.

  • If our program is: to record my voice as long as I press on the bump sensor, we want it to be repeated.

Event Message

This block is really important if we want to use information from an event. It transmits the event message associated with each event block. For example, when you triggering face recognition and Misty sees person's face that has a FaceID, you can use that information to start trigger another event with an action sequence. For example if Misty's sees you and recognizes your face, you can program her to send your name to trigger an event block with a greeting.

To receive event messages in an event block, you must create event listeners. We sometimes refer to the process of creating an event listener as registering for an event. You will find more information about how to do this in Lesson 5: Events. When you register for an event, you can:

  • filter out unwanted data by specifying which properties an event message should include

  • apply event conditions and validations or rules that define what kind of data an event listener can receive from a particular event type

  • set a debounce value, or how frequently a particular event type should send event messages (this is useful for event types that provide a constant stream of new data, instead of sending data just once when a particular event occurs)

Tactile sensors

Misty has 4 bump sensor that you can use to trigger events. You can either choose to trigger a sequence by touching any of Misty's bumps or select one of them in the drop-down. The names of the bump sensors are: front left, front right, back left and back right.

The second block is the touch sensor event and you can also choose to trigger any sensor or select a specific sensor. There are six possibilities: head front, head back, head left, head right, chin and scruff.

A triggered bump or touch sensor will create an event message that you can use in other events.

Vision events

With these two blocks, you can build events related to Misty's face and object recognition. You can use these blocks to build a skill that recognizes different objects or people. In the text field you can insert the name of the object or person you are looking for or leave it empty and don't limit the robot.

The event message in the first block is the name of the object recognized, in the second block is the name of the face recognized.

Audio events

With these two blocks, you can build skills using Misty's audio and speech capabilties. With the first block, the event waits for the audio to complete, meanwhile, the second block is used to trigger an event when a keyphrase is recognized.

The event message in the first block is a boolean message, true if the audio is completed, false if not. In the second block the event message is the keyphrase that Misty has recognized.

Driving events

You can use these two blocks to control Misty's position in a particular space.

The first block waits for a drive encoders event. You can select several parameters to check:

left distance [mm], right distance [mm], left speed [mm/s], right speed [mm/s].

You can also set a < or a > condition to be respected and of course, you need to insert the value in millimeters for the condition.

In this case, your output will be true or false.

The second block checks and regulates the time of flight sensors. Even in this case, there are several parameters like: Front right distance [m], Front center distance [m], Front left distance [m], Back distance [m], Front right downward [m], Front left downward [m], Back right downward [m] and Back left downward [m].

Please note that this time the values are expressed in meters and not in millimetres. As it was for the previous block you can set a < or a > condition to be respected and of course, you need to insert the value in metres for the condition. Also in this case your output will be true or false.

Hazard event

You can use this block to run a sequence Misty encounters a "hazard". A hazard can be a bump sensor o motor malfunction, critical internal error, cliff edge sensors being triggered, excessive speed, among others.

If you want to find out more about possible hazard you go to Misty's developer documenation here: https://docs.mistyrobotics.com/misty-ii/robot/sensor-data/#hazardnotification

Last updated