ToboT is an Android Things app to move a vehicle based on the Pimoroni STS Pi Kit.
It also contains different other remote control methods like a website that is hosted on the vehicle or simple Google Assistant voice commands to let it move it ahead, left, right, backwards or it lets the vehicle stop.
Tobot was never be intend to be more than a great and enjoyable sparetime project. That means, no code is production-ready.
For more information please have a look at the German posts (What is Tobot?, Google Assistant Feature) on my personal blog.
Due to the lost interest of Google in Android IoT and missing support for more modern Raspberry Pis is this project at the moment on hold. I would be happy if this project could live longer.
- Android Things Developer Preview 7 (or maybe higher)
- Pimoroni STS Pi Kit
- Pimoroni Explorer HAT
To check if the app works, it is possible to let the vehicle move by touching the capacitive buttons 1
to 4
of the Explorer HAT.
switch (keyCode)
{
case BUTTON_1_KEYCODE:
return movementRequestListener.requestMovement(MovementCommand.FORWARD);
case BUTTON_2_KEYCODE:
return movementRequestListener.requestMovement(MovementCommand.LEFT);
case BUTTON_3_KEYCODE:
return movementRequestListener.requestMovement(MovementCommand.RIGHT);
case BUTTON_4_KEYCODE:
return movementRequestListener.requestMovement(MovementCommand.STOP);
}
If the Tobot and a browser-enabled device are in the same network, the vehicle could be controlled by using the on Material Design Lite (MTL) based and on the vehicle itself hosted website by surfing to <VEHICLE-IP>:8080
.
You can create a custom Action for the Google Assistant. The shown action is not public available.
Tobot uses also a Firebase Realtime database and a Firebase Function to convert the Action intend into a device-compatible database entry trigger.
The function below is a Frankenstein-information with less to none security. Do not use this in any other case as for playing around!
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const DialogflowApp = require('actions-on-google').DialogflowApp;
// Initialize Firebase app
admin.initializeApp();
exports.receiveAssistantRequests = functions.https.onRequest((request, response) => {
// Create app from request parameters
const app = new DialogflowApp({request: request, response: response});
function handlerRequest(app) {
// Get argument from assistant
const command = app.getArgument('movement-command');
// Create and insert new data base entry for parsed command.
return admin.database().ref('/remote_commands').push({
command: command,
consumerId: "42",
}).then(snapshot => {
app.ask(`Ok, the vehicle will move to ${command}. And now?`);
});
}
app.handleRequest(handlerRequest);
});
The Google Assistant triggers an Action, the Action calls a Firebase Function, the function writes into a Firebase Realtime Database on which the Tobot listens for data changes. If the vehicle recognizes a database event, after some checks it will execute the new command and writes back an acknowledge flag.
- Personal Blog: [Android Things] Der Anfang von ToboT
- Personal Blog: [Google Assistant & Firebase] Fahrtrichtung von ToboT via Stimme steuern
- Hackster.io: ToboT: Android Things-Based, Voice-Controlled Vehicle
This is a time-by-time sparetime project for myself. That means, no contribution is necessary.
Just me, Tobi.
This project is licensed under the MIT License - see the LICENSE file for details. Dependencies or assets maybe licensed differently.
- Qubodup App icon designer (openclipart.org)
- Tim Messerschmidt (Google) For the motivating tweets
- Francesco Azzola Android Things GPIO pins tutorial: Control peripherals
- Google's IoT Developers Community for helping beginners, too