Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mochi Server

Demo Animation

This is the Go server for the Mochi animatronics project. It brings expressive robot eyes and quirky sounds to life, inspired by Huy Vector's video. It optionally generates the emotions using GenAI (Gemini).

Inspired by: Huy Vector - Build Your Own Dasai Mochi Robot

How It Works

  1. Listens for a Trigger: The server runs on localhost:5000 and waits for a GET request on its /touch endpoint. This request is sent by the ESP32 client when its touch sensor is activated.

  2. Generates Animatronics Data: Upon receiving a request, the server generates data for an animation and a corresponding sound.

    • Online Mode: If a GEMINI_API_KEY is set as an environment variable, the server sends a creative prompt to the Gemini API to generate a unique, emotionally expressive animation and sound.
    • Offline Mode: If the API key is not available, it falls back to a collection of pre-defined animations and sounds stored in builtin.json.
  3. Sends Data to Client: The server encodes the generated data into a compact hex format and sends it to the ESP32 client (expected at http://localhost:5001) via two POST requests:

    • /draw: Sends the eye animation data.
    • /play: Sends the sound data.

The generation and sending process runs in a background goroutine, allowing the server to respond instantly to the ESP32's touch request.

Setup & Usage

Prerequisites

Configuration

  • Server Port: The server runs on port 5000 by default.
  • Client Address: The server sends data to the ESP32 client at http://localhost:5001.
  • These values can be modified by changing the serverPort and endpointBaseURL constants in main.go.

Running the Server

  1. Clone the repository:

    git clone https://github.com/dzonder/mochi-server.git
    cd mochi-server
  2. (Optional) Online Mode: To enable real-time AI generation, set your Gemini API key:

    # For PowerShell
    $env:GEMINI_API_KEY="YOUR_API_KEY"
    
    # For Bash/Zsh
    export GEMINI_API_KEY="YOUR_API_KEY"
  3. Run the server:

    go run .

The server is now running and waiting for a trigger from the ESP32 client.

About

Go server for the GenAI Mochi animatronics project

Topics

Resources

Stars

20 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages