Skip to content

14. Interface and application programming

Hero Shot

Assignement requirements

individual assignment:

  • write an application that interfaces a user with an input &/or output device that you made

group assignment:

  • compare as many tool options as possible

Group Assignement

MecMate Controlling App

Overview

Mekamate is a robot designed to help industries manage their inventories and more fluidly exchange different packages on production lines. This repository contains the code for the robot’s management and control application, designed to provide customers with an easy-to-use interface for controlling and monitoring the robot. This document outlines the app’s features and provides a detailed explanation of its implementation, including architecture, key components, and technologies used.

This App will be connected and interact with my Input board by wifi, in order to manage orders of our users and send the right informations to the output board via I2C.

Features

Manual Control

  • Buttons: Connect to, specify start point, end point and send the robot with dedicated buttons.

Automated Tasks

  • Path Seeking: By choosing a starting point and a arrival point, an optimal path is determined and sent to the robot for him to follow.
  • Routine Management: Save and manage routine tasks for quick execution.

Real-Time Monitoring

  • Robot Status: Allows you to know at all times whether the robot is at a standstill, in motion or encountering an obstacle..

  • Alerts: Receive alerts for obstacles, connections and other important events.

Configuration

  • Settings: Customize the app’s settings to suit your preferences.

Implementation Details

Architecture

The app follows a client-server architecture:

  • Client: The mobile application, developed using MIT Inventor App (iOS and Android).

  • Server: A backend server implemented using MIT Inventor App blocks, handling communication between the app and the robot.

  • Robot: Equipped with a microcontroller (e.g., Arduino, Raspberry Pi) and sensors, connected via Wi-Fi.

Technologies Used

  • MIT Inventor App: For building the cross-platform mobile application and its backend using the blocks.
  • MQTT Protocol: For real-time communication between the app and the robot via messages.
  • Wi-Fi: For connectivity between the app and the robot.

Key Components

1. User Interface

  • MIT Inventor App Designer Interface: Utilized for building a responsive and intuitive user interface.

2. Communication

  • MQTT: Established between the app and the server to facilitate real-time data exchange.

  • Wi-Fi: Used to connect the mobile app to the robot, allowing for control and data transmission.

3. Control Logic

  • Manual Control: Processes user input from the buttons, sending control commands to the robot.

  • Automated Tasks: Manages path planning, sending appropriate commands to the robot based on the tasks finded.

4. Real-Time Monitoring

  • Robot Status: Utilizes MQTT to receive and send messages to the robot, thus always knowing its current status.

  • Alerts: Configured to trigger notifications for specific events (e.g., connections, obstacles).

Implementation Steps

1. Setting Up the Development Environment

  • Create an MIT Inventor App Account.
  • Download an MQTT server Client Extension for communication (UrsAI2PahoMqtt preferred).
  • Configure the microcontroller with the necessary firmware to interface with the app.

2. Developing the Mobile App

  • Create the app structure using MIT Inventor App Designer Interface.
  • Implement the user interface for manual control, automated tasks, and real-time monitoring.

3. Implementing the Backend

  • Set up the interactions and the logic behind your user interface in the MIT Inventor App Blocks Interface.
  • Implement MQTT client interactions for real-time control and monitoring.

4. Robot Integration

  • Program the microcontroller to handle commands from the app.
  • Set up Wi-Fi connectivity for communication with the app.
  • Integrate sensors, and configure them to send data to the app.

5. Testing and Calibration

  • Test the app’s functionality in various scenarios.
  • Calibrate the robot’s sensors and controls for accurate operation.
  • Perform usability testing to ensure a smooth user experience.

Getting Started

Installation

  1. Download the App: Download the Mekamate Controlling App Apk from this repository.
  2. Install: Follow the installation instructions for your device.

Connecting Your Robot

  1. Power On: Turn on your robot and ensure it is in pairing mode.
  2. Wi-Fi: Open the app and connect to your robot via Wi-Fi.

User Guide

Manual Control

  • Buttons: Tap the Connect button to connect with the robot, the Location A button to choose the starting point, Location B to choose the destination, and Go to find the shortest path to be sent to the robot.

Automated Tasks

  • Path Seeking: Use the map interface to draw a path for your robot to follow.
  • Routine Management: Save last travels tasks for easy access.

Real-Time Monitoring

  • Sensor Data: View real-time sensor data in the sensor dashboard.
  • Alerts: Configure alert notifications in the settings menu.

MecaMate control App Demo

Input Board Code

#include <WiFi.h>
#include <PubSubClient.h>

const char* ssid = "";
const char* password = "";

const char* mqttServer = "broker.hivemq.com"; // Serveur MQTT (par exemple, HiveMQ public broker)
const char* mqttUserName = "";  // Laisser vide si pas d'authentification
const char* mqttPwd = "";       // Laisser vide si pas d'authentification
const char* clientID = "";
const char* topic = "Travel"; // Topic pour recevoir le chemin

WiFiClient espClient;
PubSubClient client(espClient);

void setup() { 
  Serial.begin(9600);
  Serial.println("Setup started");

  Serial.println("Connecting to WiFi...");
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
  }
  Serial.println("Connected to WiFi");
  setupMQTT();
}
void setupMQTT() {
  client.setServer(mqttServer, 1883);
  client.setCallback(callback);
  Serial.println("MQTT Server is set, connect to send message");
}
void callback(char* topic, byte* payload, unsigned int length) {
  String message;
  for (unsigned int i = 0; i < length; i++) {
    message += (char)payload[i];
  }
  Serial.print("Message arrived in topic: ");
  Serial.println(topic);
  Serial.print("Message: ");
  Serial.println(message);
}

void reconnect() {
  while (!client.connected()) {
    Serial.println("Attempting MQTT connection...");
    if (client.connect(clientID, mqttUserName, mqttPwd)) {
      Serial.println("Connected to MQTT");
      client.subscribe(topic);
      Serial.println("Subscribed to topic: ");
      Serial.println(topic);
    } else {
      Serial.print("Failed to connect, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      delay(5000);
    }
  }
}

void loop() {
  if (!client.connected()) {
    reconnect();
  }
  client.loop();
}

Troubleshooting

Common Issues

  • Connection Problems: Ensure your robot is powered on and connected to the internet. Restart the app and try reconnecting.
  • Firmware Updates: Ensure your robot has the latest firmware installed. Check for updates in the firmware update section.

Files


Last update: July 15, 2024