Software apps and online services
Linking a reward like ice cream to a chore like a clean room can be an effective parenting tool... or not. After all, a clean room is a pretty subjective thing. Clean to a kid can mean something else entirely to the parent. Who's to judge?What Gets Measured Gets Done
Just how messy is the room anyhow? What's needed is an objective referee to make the call.
Enter the Walabot Mess-o-Meter! The last word in mess.Mess-o-Meter: Mess Radar
The Walabot is a great sensor for detecting a mess.
The Walabot Radar mode gives a terrain map of objects in the field of view, in our case, the bedroom environment.
Compared to a WebCam is immune:
- To lighting conditions - light's off won't hide the mess!
- To camoflague - can't hide your mess by making it background color
- To coverup - can't hide your mess by putting blanket over it all
- To noise - the contour maps are better at revealing depth dimension
But how can we detect if this is a mess?Differential Comparison
What is a mess? Objects out of place compared to where they should be.
So to detect a mess we capture a radar map of a 'Clean Room' and then subtract it from the map of the current room. A perfectly clean room with nothing out of place will be completely black. Any mess will show up as a difference map which can be converted in to a single number.
A Mess Percent. (Mess %)
Now that we have an objective value for messiness we need to use it to unlock the Ice Cream.The Setup
The setup is simply to point the Walabot to the floor. Originally I had hoped to be able to detect the outline of individual objects and this might be possible with more fine tuning. However the floor is quite 'bright' and lots of reflections and echo's occur in that zone. So while it can easily detect the mess, it's harder to say what the mess actually is.
One of constraints for this project was to work within the Alexa Smart Home API framework. This way the Virtual Breadboard Smart Home Alexa Skill and Virtual Breadboard Smart Home Alexa Controls could be leveraged to make Alexa integration and deployment really easy.
The task here is to try combine the available Alexa Smart Home building blocks in new and novel ways without having to roll and deploy a completely new Alexa Skill.
Unfortunately the constraints are quite heavy. For example there are really only 2 voice queries in the current version of the Alexa SmartHome API
- LockState ie 'Alexa, is DEVICENAME Locked/Unlocked'
- Temperature ie ' Alexa, what is the Temperature of DEVICENAME'
Hopefully Alexa will expand on this in the future but those are the choices.
Unlocking sounded most fun, a bit like unlocking levels in a game, and that constraint led to the idea of creating the Unlock ICE Cream Application.Alexa, Is Ice Cream Unlocked?
It's a simple question. Let's express it in terms of VBB components
If Mess (%) < Threshold (%) then ICE Cream is UNLOCKED
- Mess: Alexa.PercentageController
- Threshold: Alexa.PercentageController
- Ice Cream: Alexa.LockController
- FunctionBlock: Expression = LT (P1, P2)
The Mess device is an Alexa.Percentage Control which displays and drives a voltage level at the current percentage set by Mess. The Mess % can be manually set by sliding the level control for testing purposes.
In the live application the Mess % is set programmatically by the Walabot Smart Alexa Sensor as discussed in the next section.Threshold: Alexa.PercentageController
The Theshold device is an Alexa.Percentage Control which displays and drives a voltage level at the current percentage set by Theshold. The Theshold % is set by the Parent to the level corresponding the acceptable level of mess before the Ice Cream becomes locked.Ice Cream: Alexa.LockController
The Ice Cream device is a Lock Control and has two IO pins and an interactive Lock Slider. It supports a Lock command and the all important LockState query.
Only the LockState query is used and the slider should be set to OFF otherwise Alexa will report the ICE CREAM as jammed according the following table:
- Requested state is HIGH, actual state HIGH reported lockState is LOCKED
- Requested state is LOW, actual state HIGH reported lockState is LOCKED
- Requested state is HIGH, actual state LOW reported lockState is JAMMED
- Requested state is LOW, actual state LOW reported lockState is UNLOCKED
Having ICE CREAM Jammed might be fun so definitely try it anyway!Function Block: Expression = LT (P1, P2)
The actual decision to Unlock the Ice Cream is made by the FunctionBlock which compares the two voltage levels. If the Mess is less than the threshold the LockState is LOW (UNLOCKED) otherwise it is LOCKED (or JAMMED!)
The Walabot SDK ships with C# reference projects. For this project the C# SensorApp_SampleCode project was used as a starting point and converted into a Smart Alexa Sensor by integrating the VirtualBreadboard.SmartHomeApi Client to send Mess data programmatically to the Mess Control.Virtual Breadboard Alexa Smart HomeClient API (C#)
Developed as a testing tool for the Alexa Virtual Breadboard Skill it turns out to be very useful for other applications to be able to programmatically discover, connect and control Smart Home devices using the Alexa SmartHome API interfaces.
With only a few lines of code it is possible to expose the VBB Alexa Controls in the running VBB Smart Home Application and programmatically control them.
//Namespace using VirtualBreadboard.Alexa.Client; //Setup SmartHomeApi api = SmartHomeApi.Connect(<username>, <password>); api.Discover(); AlexaEndpoint device = api.GetNamedDevice("Mess"); IAlexaPercentageController mess = device.GetInterface<IAlexaPercentageController>(); //Data int percent = CalculateMessPercent(); // On Change.. mess.SetPercentage(percent);
Other Applications of the C# Client Can Include
- Smart Home Apps - The Amazon Alexa App does something similar
- Smart Sensors (this)
- Smart Actuators
The Walabot is a really fun sensor. It's super sensitive but the way it detects things can take some getting used to. It's worth playing with to put in your toolbox and keep it's capabilities in mind as you design solutions to future projects.