aDevGuild / robot-web-controller

Servidor Websockets para controlar um robô usando micro controlador que suporte a framework do Arduino.
MIT License
3 stars 0 forks source link

LLM integration #3

Open AlexandreHiroyuki opened 1 month ago

AlexandreHiroyuki commented 1 month ago

Goal

Make the robot react to a simple test command from the LLM.

Web

Embedded

AlexandreHiroyuki commented 1 month ago

A

AlexandreHiroyuki commented 1 month ago

Messages

"fxxxx" - forward + time with 4 characters in milliseconds "bxxxx" - backward time with 4 characters in milliseconds

AlexandreHiroyuki commented 1 month ago

Encoding the messages with binary should be considered instead of using native strings from JS. Currently, each type of message requires its conversion method, sometimes it's reusable, but sending the wrong type on JS can break the workflow, and it is an error that doesn't show up on compilation time.

It's possible to work the current way, maybe it's a good refactoring to pay attention to the future.

AlexandreHiroyuki commented 1 month ago

Since each module requires procedural execution (order matters), but blocking execution between tasks isn't desirable, I chose to approach the problem with an Active Object design pattern.

A message pump would be undesirable because certain messages require a previous one to be fully executed (like timed engine movements) before it pops out of the queue, blocking other messages that don't need to wait for others to be executed.

AlexandreHiroyuki commented 1 month ago

Objects

AlexandreHiroyuki commented 1 month ago

https://stackoverflow.com/questions/43529031/websockets-and-text-encoding To assign a misunderstanding, despite JS working with UTF-16 strings, the WebSocket protocol defines that UTF-8 must be used in communication.

https://stackoverflow.com/questions/10229156/how-many-characters-can-utf-8-encode With this knowledge in our hands, we can address another misunderstanding about how Unicode formatting works: UTF-8 does not work with a fixed size of bytes for a character, it varies from 1 to 4 bytes.

https://datatracker.ietf.org/doc/html/rfc3629#section-3 A character written with multiple bytes is defined by the most significant bits of each byte.