Using the Wacc expansion header for a UART device

Hello!

We are planning to swap our the Stretch gripper for a prosthetic hand that communicates using UART. For our initial testing, we have been using a UART to USB adapter that connects to the hand with TX, RX, GND. After going through the hardware guide again, it seems we could configure the expansion header for Serial UART and do without the adapter. I have checked out the wrist extension header tutorials but am still a bit lost on where to start for a UART sensor.

Any advice pointing me in the right direction would be a big help.

Thanks!
Lionel

At a high level the process would be:

  1. Establish serial comms between the Arduino UART and your gripper
  2. Plumb the new UART device into the Wacc firmware / communication layer
  3. Extend Stretch Body to include the gripper so it can be accessed via Python

Numbers 2 & 3 are fairly straightforward pattern matching from the I2C/SPI tutorials.

Number 1 (establishing serial comms) can be tricky depending on your device and its communication/bandwidth requirements.

To get started on that, it might be easiest for us to just create a UART tutorial comparable to the SPI/I2C one. I’d guess we could have something to you in about 1-2 weeks. Would that work for you?

1 Like

Thanks for your reply, Aaron. We are not in a rush to get this working so that would be perfect.

Thanks,
Lionel

Great, we’ll report back here when the tutorial is ready.

1 Like

Hello Lionel. We’ve posted a tutorial on how to integrate a serial device onto the wrist expansion header.

Good luck, let us know how it goes!

Awesome, thank you so much, Aaron!

Hi Aaron,

The serial sensor tutorial was very helpful! I’m currently still testing with an Arduino emulating the wrist board until I finish the firmware changes.

One small thing, it seems the wacc_calc.py file is missing {self.valid_firmware_protocol = ‘pMyCalc’} in the init method for it to work out of the box. Everything else went very smoothly.

Thanks,
Lionel

Great, glad to hear it. Good catch on the protocol version bug. I’ve updated the documentation and code to now use ‘p99’.

For background, we are developing an automatic firmware updating tool that reads the protocol version. It now expects a number (eg 99) rather than a string. So to future proof the tutorial, we use ‘p99’. For your own custom protocols it really only matters that the protocol ID of the Arduino struct definition, and the protocol ID of the Python class, match.

1 Like

Hi!
Instead of opening a new thread I was looking for information to get started with the expansion header pins on the wrist in the forum.

Unfortunately, all the embedded links in this thread are not available anymore, so are there any updated tutorials or guides? In the Data Transfer Tutorial for example the links lead to the deleted calculator scripts only.

How can I determine which port to use for flashing the expansion pins / SAMD21?

It seems like attaching an Arduino with my individual sensors on it directly into one of the USB ports is the quicker, simpler and safer option than using the extension pins. What is recommended therefore?

Best,
Noor

Hi @roboor, Thank you for bringing the missing/broken links to the Wrist Expansion example scripts to our attention. We can fix it soon and let you know.

In the meantime, you can find all the “hello_wacc” Arduino sketch files used in each Wacc header pin expansion tutorial in this directory:

Once you have modified the hello_wacc Arduino sketch to interact with your attached sensor based on the tutorials above, you will have to flash your Wacc board with your modified hello_wacc sketch to the USB port /dev/hello-wacc. We recommend you to use the Arduino IDE 1.8 to flash the modified “hello_wacc” sketch to the Wacc board using below steps:

  1. Make sure the stretch_firmware repository is cloned to the directory ~/repos
  2. Replace the contents of ~/repos/stretch_firmware/arduino/hello_wacc folder with your modified “hello_wacc” sketch files.
  3. Once the Arduino IDE is installed, open the IDE and set the “Sketchbook location” path found in Files → Preferences to /home/hello-robot/repos/stretch_firmware/arduino. Restart the Arduino IDE to make it recognize the hello_* hardware and sketches.
  4. Open your “hello_wacc” sketch in the Arduino IDE (File → Sketchbook → hello_wacc)
  5. Set the board to “Hello Wacc” (Tools → Boards → ArduinoSAMD* (in sketchbook) → Hello Wacc )
  6. Choose the right Wacc board’s /dev/ttyACM* port in Tools - > Port → /dev/tty* and click upload.
    • You can check which ttyACM* port belongs to the Wacc board (/dev/hello-wacc) using the command: REx_firmware_updater.py --map

Attaching a standalone Arduino with external sensors via wrist USB is doable in multiple ways if you aren’t comfortable modifying the official hello_wacc Arduino sketch and wiring the wrist expansion header pins to interact with your external hardware. I could imagine having a PySerial handle run in a separate thread that could transfer data from the attached Arduino via wrist USB without interfering with the Stretch Body’s main thread.

But the Cons of this approach are you would be missing the part of reading/interacting with the external hardware through the Stretch Body python library that involves a transport layer that uses COBS encoding to transfer data reliably and accurately.

Please let us know if you have more questions.

Best,
Mohamed Fazil

2 Likes