05.Firmware - reivaxy/kinetix GitHub Wiki

The firmware

I prefer using Platformio on Visual Studio Code, rather than the Arduino IDE

Binary release

You can download a released .bin file from https://github.com/reivaxy/kinetix/releases and upload it to your device.

Using Python from your computer

Start with installing Python if you don't already have it https://www.python.org/downloads/

Then install esptool:

pip install esptool

Depending on your OS you will then run either 'esptool.exe' (Windows) or 'python esptool.py' (others) like this, after replacing the port parameter to the one your ESP32 is connected to and with the name of the binary file.

On Windows you may need to add the path to esptool.exe to your PATH environment variable.

Then run:

esptool --chip esp32s3 --port "COM14" --baud 460800 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 8MB 0x10000 <Name of binary file>

To find the COM port, plug the ESP32-s3 to a USB socket, then:

On Windows, open a CMD: Press Win + R to open the Run dialog. Type cmd and press Enter. In the CMD command, type

mode

On Mac, open a terminal, and type

ls /dev/tty.*

Using a mobile application and wifi or bluetooth

This is not supported yet and will only allow upgrading new versions, but you will always need to flash the first release using one of the other methods .

From the full development environment

See next Chapter.

Development environment

Tools

Install Visual Studio Code: https://code.visualstudio.com/download

Run it, open the Extension dialog, search Platformio and click Install

Sources

If you are not familiar with github, you can just download a released source code zip or tar.gz file from the latest release https://github.com/reivaxy/kinetix/releases and then unzip it to your hard drive.

If you are familiar with github, clone the repository to your hard drive.

Run Visual studio code and create a workspace using the subdirectory with the sources "firmware/esp32"

The platformio.ini file will make sure you have the appropriate board configuration and libraries. You'll need to adapt the COM port to upload and monitor. Pick either a left hand or right hand configuration.

The classes included allow to very easily positions and movements.

A finger position is between 0 (fully open) and 100 (fully closed), no matter what are the actual servo angles matching these position, which can be different from a finger to another, and from left hand and right hand.

A finger movement describes a finger position and a speed, with 1 being the fastest and fractions of 1 being slower (it's actually a step increment rather than a speed).

A hand movement is a collection of 5 finger movements, each having an optional starting delay. For instance when closing all finger, you may want the thumb to end on top, so you will make it start to close a bit later than the others, or move slower.

For instance:

HandMovement* HandMovementFactory::rock() {
   HandMovement *handMovement = new HandMovement(hand, "Rock");
   // Thumb
   handMovement->setFM(0, new FingerMovement(100, 0));
   handMovement->setFM(1, new FingerMovement(0, 0));
   handMovement->setFM(2, new FingerMovement(100, 0));
   handMovement->setFM(3, new FingerMovement(100, 0));
   handMovement->setFM(4, new FingerMovement(0, 0));
   return handMovement;
}

A sequence is a collection of hand movements, each one with a maximum duration.

It can repeat indefinitely or a specific number of times.

For instance:

void MessageProcessor::scratch() {
  log_i("Starting scratch sequence");
  HandMovementFactory *hmf = new HandMovementFactory(hand);
  seq = new Sequence(0); // 0 is repeat forever
  seq->addMovement(hmf->scratchOpen(), 600);
  seq->addMovement(hmf->scratchClose(), 600);
  seq->start();
}

void MessageProcessor::come() {
  log_i("Starting come sequence");
  HandMovementFactory *hmf = new HandMovementFactory(hand);
  seq = new Sequence(5);
  seq->addMovement(hmf->comeOpen(), 500);
  seq->addMovement(hmf->comeClose(), 500);
  seq->start();
}

The MessageProcessor handles messages sent by the App (or any other BLE client) through Bluetooth.

Messages can be configuration read/write, and movement requests.

When using the application to send movement requests, if a sequence was running it will be stopped, and all relative objects freed (minus possible bugs...)

In the roadmap:

  • automatic calibration of min and max positions for each finger, using current sensors (which don't work yet),
  • OTA firmware flashing
  • flash saved configuration, allowing to add custom hand positions ...