Skip to content

ArmModuleFirmware

Che-Ming Chang edited this page Mar 29, 2024 · 9 revisions

Microcontroller programming for rosserial and servos

The modular arm and hands are controlled via individual ESP32 microcontrollers capable of wireless communication. The current system uses a wired connection via serial USB ports to connect the arms to the central ROS network.

The device is designed to fit different low-level communication protocols for various actuators. We have accommodated standard PWM-driven servos as well as TTL and RS485 communication with the Dynamixel smart actuators.

Arm Microcontroller Setup

ESP32 dev boards were selected based on cost, available I/O, and potential wireless communication interfaces. Although the CP210x USB to UART chip has been known to cause driver and power issues, we settled on the dev board due to it's profile, availability, and price.

Driver link: https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers

Additionally, the ESP dev boards from Espressif systems can be programmed using different firmware and programming languages. The most common being Arduino and Espressif IDF (IoT Development Framework). You can also program these chips with Micropython, Javascript, or even LUA.

We have provided the Arduino code for the ESP32 dev board for control the modular forearm and hand unit at:

https://github.com/newdexterity/Open-Biomanual-Manipulation-System/tree/main/Software/Arduino_ESP32

Prerequisites: Arduino IDE Installed

There are plenty of tutorials on how to set up Arduino for programming ESP32. For Arduino IDE 2 follow the instructions here:

https://randomnerdtutorials.com/installing-esp32-arduino-ide-2-0/

For Legacy Arduino IDE we recommend 1.8.19:

Quick Rundown on installing Arduino IDE 1.8.19

Goto:

https://www.arduino.cc/en/Main/Software

Scroll down until you find the Legacy IDE (1.8.x) section

alt text

Select your operating system and download the software. We used the main computer, the NUC, so we installed the Linux 64-bit version.

Extract and install arduino-1.8.19-linux64.tar.xz

Alternatively, you can install Arduino IDE using scripts

  1. Make sure your Ubuntu system packages are up-to-date:
$ sudo apt update
$ sudo apt upgrade
  1. Download Arduino IDE and extract The following commands download the Arduino IDE version 1.8.19 tar.xz file to a temporary directory named 'arduino':
$ mkdir arduino
$ cd arduino/
$ wget https://downloads.arduino.cc/arduino-1.8.19-linux64.tar.xz
  1. Extract and install the tar.xz file

You should be in the temporary directory named arduino with the tar.xz file in it

$ tar -xvf ./arduino-1.8.15-linux64.tar.xz

To install, run the installed script

$ cd arduino-1.8.15/
$ sudo ./install.sh

By default, Arduino is installed to /usr/local/bin/arduino.

Make sure the system user is added to dialout group (Linux)

To avoid potential problems when using Arduino IDE, add your system user to the dialout group.

Most commonly the error happens when you attempt to upload a sketch and got the following error: "Error opening serial port ..."

If you get this error, you need to set serial port permissions.

$ ls -l /dev/ttyACM*

This should show something like: crw-rw---- 1 root dialout 188, 0 5 apr 23.01 ttyACM0

The data we need is "dialout" (it is the group owner of the file).

Now just add the system user to the group:

$ sudo usermod -a -G dialout <username>

where is your Linux user name. You will need to log out and in again for this to take effect.

In my case it is:

$ sudo usermod -a -G dialout aroa

Installing ESP32 for Arduino

Once the Ardunio IDE is installed, Arduino should be available in the Application list - if not, it can be launched from the command line by running arduino

  1. Open the IDE and go to File->Preferences

  2. Enter the following into the “Additional Board Manager URLs” field. This will add support for ESP32 and ESP8266 boards as well. (we had a few extras)

https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json

https://dl.espressif.com/dl/package_esp32_index.json is a backup link from espressif but it's best to just use the github link.

See the image below. Then, click the “OK” button.

alt text

  1. Open the Boards Manager. Go to Tools > Board >Boards Manager…

  2. Search for ESP32 and install the “ESP32 by Espressif Systems“:

alt text

This will take some time to install.

  1. Then, go to Tools > Board and check that you have ESP32 boards available.

Installing Libraries

You will need the following libraries to compile the Arduino code provided correctly

Dynamixel2Arduino by HongHyun Kim v0.6.3
ESP32Servo by Kevin Harrington v7.0.1
??? EspSoftwareSerial by Dirk Kaar v0.11.0

May have to change &HardwareSerial to &SoftwareSerial in the Dynamixel2Arduino source code if the pin address clashes

https://wiki.ros.org/rosserial_arduino/Tutorials/Arduino%20IDE%20Setup

Compile the code

You can find the code at

https://github.com/newdexterity/Open-Biomanual-Manipulation-System/tree/main/Software/Arduino_ESP32 put the .ino files into their respective folders under your Arduino sketchbook folder for easy access.

WIP

Clone this wiki locally