Skip to content

Conversation

@PedroS235
Copy link
Contributor

Client Library for Botzo Robot Communication

I've started building a client library for Botzo that handles communication between the microcontroller and the host computer (Raspberry Pi). This PR is still a draft as the work is ongoing.

What's Implemented

Serial Communication Interface

  • Currently supports serial/USB communication with the microcontroller
  • Designed to be easily extended for other protocols (like UDP) in the future

Simple Packet Protocol
All communication uses a simple packet structure:

[START] [LENGTH] [COMMAND] [DATA...] [CHECKSUM] [END]

Where:

  • START (1 byte): Marks packet beginning (0x3C, '<')
  • LENGTH (1 byte): How many bytes of data (0-254)
  • COMMAND (1 byte): What type of command this is
  • DATA (0-254 bytes): The actual command data
  • CHECKSUM (1 byte): Error detection using XOR
  • END (1 byte): Marks packet end (0x3E, '>')

How It Works

The protocol handles creating packets for different commands. For example, a basic ping to check the connection:

interface = Interface()
protocol = Protocol()
packet = protocol.create_ping()
response = interface.send_and_wait(packet)

Main Component: BotzoClient

The BotzoClient class is the main entry point. It wraps all the complexity of the communication layer, so you don't have to deal with packets and protocols directly.

Design Benefits

  • Swappable Communication Interfaces
  • The design allows switching communication methods easily. If we decide to use a different interface (like TCP or UDP), we just need to create a new interface class and everything else should work the same way.

Two-Way Communication

  • Send commands to the MCU (like move servo, read sensors)
  • Receive continuous data streams from the MCU (like IMU data at a fixed rate)

For example, we can start IMU streaming where the MCU automatically sends sensor data at regular intervals without needing to request each reading.

Next Steps

This requires matching firmware on the microcontroller that implements the same protocol, which is currently being developed in parallel.

This is very basic, only contains the implemention to ping and set a
GPIO
This commit brings a change in name to the package. Now it is named
botzo_sdk. This will serve the main entry point to interact with the
microcontroller/hardware and offers a BoztoClient which handles all the
communication behind the scenes with the MCU.

The current state is still very limited and still needs development in
order to obtain a stable version.

For now, supported features are connect and disconnect, sending and
receiving packets -> PING command is working. Additionally, it already
handles when a stream of data is enabled, the case for the IMU. However,
BotzoClient is not yet ready for this.
@GRINGOLOCO7
Copy link
Collaborator

Thank you for the contribution. Looking forward to see the progress. Looking promessing.
Currently, as you noticed, we comunicate between Arduino Mega and Raspberry py 4 via USB. In order to implement your contribution on botzo we should replace the Arduino with a microcontroller with WiFi or Bluetooth?
In that case how do you reccomend to update the circuit design for the documentation? Maybe showing two versions?

@PedroS235
Copy link
Contributor Author

@GRINGOLOCO7 yes, I am aware that you are using the Mega and Pi 4 via USB. This current implementation is exactly for that purpose, that's what Serial means, as in USB is a serial protocol. The good thing about this is that it's should be relatively easier to expand to other protocols.

Now in my case I am using an ESP32, which is more powerful and also offers Wi-Fi + Bluetooth, and it's very inexpensive. I would argue that using an Arduino Mega today is not a very good solution giving that an ESP32 is very cheap and small too.

Now, the firmware the only say drawback is that with Arduino Mega we cannot use FreeRTOS, it's basically a very tiny operating system. But I guess I could support both versions if you guys would like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants