Hands on with Home Together
Jan 21, 2016 |
👴 This article is about a discontinued version of craft ai
, some information may not reflect what craft ai
can currently do!
For more up to date reading, check our blog
and do not hesitate to visit our website
A couple of weeks ago, we were showcasing our latest smart home demo at CES, as you may have read in a previous blog post. The demo is now playable online!!
As promised, we also made its sources publicly available so that you can play around with the behavior trees, just fork the project on github then add to the workbench! But some explanations might come in handy, so here it goes!
First off, a quick reminder of the scenario that we are playing with: a house (floor plan below) augmented with connected devices (indoor positioning system, light bulbs, TV, blinds, shower head) in which two occupants are living.
One of these occupants, Gisele, wanders around the house randomly.
The other one is controlled by you! You can place the player character in any room and control the corresponding light. Moreover, clicking on the TV will turn it on and place the player inside the living room.
0. living room
1. dining room
Let’s take a look at the craft ai behavior trees that are behind the mechanisms ruling this house.
Each room is ruled by an agent running a common behavior tree, cleverly labeled
Room.bt, described bellow
What it does, under the parallel node, is
- managing light bulb (leftmost branch),
- checking the light intensity value (second branch from the left),
- handling decision undoing (rightmost branch).
The parallel node is set to “propagate to all” so that it will reactivate any child once it has been terminated. The termination condition “fails if any fails”, combined with the “Stall” action as a child, will allow to keep the parallel node from terminating (its other children being designed so that they never fail).
If we take a deeper look at the first branch, we have an embedded behavior tree
RoomPresence.bt that is basically a switch case to take the different combination of presence and light intensity into account. In any case, another embedded behavior tree
RoomPreferences.bt will then be called with specific parameters.
In a first step, this behavior tree:
- does nothing if it is called after an AI decision is undone by one of the inhabitants,
- stores the current light settings then apply the new ones it received as parameters from its parent BT.
In a second step, the BT will keep checking on the light settings to update the preferences with new ones whenever they are manually changed.
This logic here is the basics of each room, but some rooms are equipped with other devices that will impact the rules described above.
Thus, each room is specialized, ie: they are not calling directly
Room.bt but a dedicated behavior tree that embeds
Let’s take the bathroom for instance. It is equipped with a Hydrao shower head which notifies whenever water consumption is excessive, and we want to turn this notification into a visual alert through the light bulbs.
To do so, the agent for the bathroom actually instantiates the
Bathroom.bt behavior tree, that reads as follows:
First, it checks if there is someone inside (for the purpose of the demo, it only checks if the player is inside) to execute a specific branch; otherwise it will simply run
If someone is inside, it will run
Room.bt for 15 seconds, then flashes the bathroom light from red to blue until your exit.
This demo sets an example of what an intelligent home could be with craft ai federating the automation and learning of users’ habits, but it would be possible to extend the use case and account for all of the possible connected devices that could come up in such a place. Imagine: security systems, speakers, thermostats, virtually every electrical device plugged into a connected outlet… and even companion robots.
All of those pieces of technology could be interacting within this unified ecosystem by using the craft ai platform.
Now you can try this at home!
We’re eager to hear what you think, do not hesitate to send us feedback on potential ideas or issues you may encounter.