Skip to content

Basic interface

Jensah edited this page May 21, 2021 · 9 revisions

The Basic interface consists of the following:

MQTT

a a a a a a a a a a a a a a a a a a a a a a

Arduino

MQTT is used on the Alset Vehicle (Arduino Board) and the Android Application. The connection can be configured to connect to any host.

The car subscribes to the following topics:

namespace mqtt_topic 
{
    const auto CONTROL_GLOBAL = "/smartcar/control/#";
    const auto CONTROL_SPEED = "/smartcar/control/speed";
    const auto CONTROL_STEERING = "/smartcar/control/steering";
    const auto TELEMETRY_SPEED = "/smartcar/telemetry/speed";
    const auto TELEMETRY_FRONT_ULTRASONIC = "/smartcar/telemetry/frontUltrasonic";
    const auto TELEMETRY_BACK_INFRARED = "/smartcar/telemetry/backInfrared";
    const auto CAMERA = "/smartcar/camera";
}

Each topic is then published through stand-alone methods:

Camera:

void publishCameraFrame()
{
#ifdef __SMCE__
        Camera.readFrame(frameBuffer.data());
        mqtt.publish(mqtt_topic::CAMERA, frameBuffer.data(), frameBuffer.size(), false, 0);
#endif
}

Speed:

void publishCarSpeed()
{
      mqtt.publish(mqtt_topic::TELEMETRY_SPEED, String(car.getSpeed()));
}

Front Ultrasonic Sensor:

void publishFrontUltrasonic()
{
#ifdef __SMCE__
    const long distance = frontUSSensor.getDistance();
    static long previousDistance = -1;

    if (distance == previousDistance) {
        return;
    }

    previousDistance = distance;

    mqtt.publish(mqtt_topic::TELEMETRY_FRONT_ULTRASONIC, String(distance));
#endif
}

Back Infrared Sensor:

void publishBackInfrared()
{
#ifdef __SMCE__
    const long distance = backIRSensor.getDistance();
    static long previousDistance = -1;

    if (distance == previousDistance) {
        return;
    }

    previousDistance = distance;

    mqtt.publish(mqtt_topic::TELEMETRY_BACK_INFRARED, String(distance));
#endif
}

User Interface

Park & Drive Mode

Speedometer

Joystick component

Clone this wiki locally