Skip to content
This repository has been archived by the owner on Apr 23, 2023. It is now read-only.

ToboT is an Android Things app to move a vehicle based on the Pimoroni STS Pi Kit.

License

Notifications You must be signed in to change notification settings

tscholze/java-android-things-tobot

Repository files navigation

ToboT

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.

Information

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.

Prerequisites

Required

Optional (for voice control)

Types of remote controls

Build in Explorer HAT buttons

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);
}

Build in mobile-friendly website

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.

Google Assistant

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.

Publications

Contributing

This is a time-by-time sparetime project for myself. That means, no contribution is necessary.

Authors

Just me, Tobi.

License

This project is licensed under the MIT License - see the LICENSE file for details. Dependencies or assets maybe licensed differently.

Acknowledgments

About

ToboT is an Android Things app to move a vehicle based on the Pimoroni STS Pi Kit.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published