🛠️Lesson 5: Events
Last updated
Last updated
The aim of this lesson is to understand how Misty can interact with her surroundings and respond to user input using events. By the end of this lesson, you'll be able to create your first robot skills with multiple scenarios and outcomes. If you want to know more about Misty's events, you can check out Events.
Up until now you've seen all of the amazing things you can do with Misty, but it doesn't end there. Misty can also receive commands through touch using various sensor event blocks. Let's try it out! Select the bump sensor event block and the touch sensor event found in the 'Events' tab in Misty Blocks, and the run until stopped block from the 'Miscellaneous' tab. It's important to remember that when you are programming Misty to react to the environment you need her to actively monitor her sensors. This is why it's necessary to put a run until stopped block after an event block. If you want her to monitor all the bump or touch sensors at the same time, you can choose 'any' in the drop-down field. For example if you look at the program below, you can see that when you trigger a bump sensor Misty will start the event "Love" , if your press any of her touch sensors you can trigger the event "Hi".
Try to be as creative as you can! If you want to copy this code remember to enable the blocks.
To make Misty react to a specific touch or bump sensor you can choose which of the sensors you want to trigger in the drop-down list. Misty has four bump sensors above her tracks: Front right, Front left, Back right and Back left. On her head you will find six touch sensors: Head front, Chin, Head left, Head right, Head rear and Scruff (Back grip).
By combining different bump and touch sensors you can create and trigger more than one event. For example, you can create a skill where Misty drives forward for 5 seconds if touched on the front of her head and then drives backwards to her original position if you press the front right bumper.
The more capabilities you learn with Misty the more skill you can practice! How would you improve this program?
In most human-robot interactions you will find that robots usually have multiple reactions or answers to the same question, giving each person a unique experience. These kind of interactions are built using a programming concept called 'skill tree'. Imagine that Misty is asking you a question and you want to give more than one answer. The question in this case is the main body of your tree and the answers that you create are your branches growing out of the tree
Now that you've explored Misty's event sensors, let's try creating 4 different events using all of her bump sensors. You can start by having Misty ask you a question like in the example below and create events as responses. Use the drop-down to determine which sensor you want to trigger, remember to select each of the 4 bump sensor. The next stage is to nest your unique blocks in each of the event blocks, like the LED lights in the example below. You can also create more complex sequences with movement and expressions blocks, try it out!
By using all of Misty's bump and touch sensors you can create more complex skills, conversations and interactions. Once you build up your program using multiple sensors you will find that it starts to occupy a lot of space and you will have to manually write in values for each sensor like in the example below.
This style of programming is time consuming and not very versatile, but there is a way to compact your program with an elegant solution. Instead of writing values manually each time, you could use the specific for the touch sensor event. It will return the name of the sensor that you have triggered. If you continue with the example above, you can use the 'create text with' block to build your texts however you prefer and have Misty return the name of the sensor at the end of the text. If you are unsure how to use this block you can check out Text.