Uncategorized

Ready-made hacks: Improving jaw synchronization in robotic skulls


Realistically moving the robot’s jaw in sync with its synthesized voice was a challenge. Frightprops has a PicoTalk servo controller for about $80. Skulltronix offers the SON of Chuckee motherboard for $125. While somewhat pricey, these boards offer servo controls for eyes, pan, tilt, and more in addition to the chin.

Eventually, my own talking skull project, Hedley the Skull, should have text-to-speech conversion via his onboard Raspberry Pi. I envision various applications that output Hedley’s voice to the speakers while simultaneously outputting positional data to the chin controller. Letting Hedley “speak” the results via Amazon’s voice service, scripts, or even MQTT messages opens up a lot of interesting presentation possibilities.

While off-the-shelf motherboards were promising, I decided they weren’t flexible enough for my purposes. I would like to be able to adjust how the audio is actually analyzed so that I can get the best synchronization of the audio with the jaw movement.

By combining hardware, firmware and software, real-time audio/chin movement can be achieved using Arduino and Raspberry Pi. Today we’ll look at the Arduino chin side of the equation. The Raspberry Pi sound and application aspects will be discussed later in the story.

Arduino Jaw Controller

In an earlier “Ready-made Hacks: Robot Skull Hedley Talks” story, we looked at how to use an Arduino with a small electret microphone to move the jaw servo. I have since modified the servo constraints and added code to read the serial data from Hedley’s Raspberry Pi 3 instead of from the hardwired microphone input. Jaw servo is connected to digital pin 6. The code will eventually be transferred to Hedley’s Raspberry Pi 3, so he doesn’t need an external computer for operation.

A huge breakthrough was reducing the number of cranial jaw positions to 10 and scaling the serial input to accommodate that range of motion. I reasoned that just sending “0” through “9” as text strings would keep the data transfer size to a minimum. From fully open to fully closed, the jaw travel is only about 30 degrees. Divide this by 10 and we get a value of approximately 3 degrees of movement per step.

In real life, moving the servo in three-degree increments provides reasonably well-synchronized jaw movement without the twitchiness of previous versions of the code. We could probably reduce the number of degrees per step to get higher resolution and smoother motion. This means we must also make corresponding changes to the serial data size.

Another real world note is that I used an almost antique Arduino NG as the jaw servo controller. This old board ran at 16MHz and used 8-bit data addressing. Its horsepower is certainly very modest compared to the latest Arduino modules.

Still, NG was fully capable of tracking data from a Linux laptop running a program that handles speech audio analysis, and there was no noticeable delay between the audio and jaw movements. In the world of microcontrollers, performance tends to improve over time, so using an older board for initial prototyping is a very good baseline to start with. As the project matures, things will become smoother and more capable with new hardware/software.

Update code

The Arduino NG code is very simple. Be sure to specify the NG board when compiling and uploading, otherwise, you’ll get errors and the jaw won’t move at all. Also don’t forget that you must press the reset button before uploading firmware using the NG board.

Variables are initialized at the beginning of the file.

Pay attention to the opening and closing values. These were discovered through trial and error. These numbers apply to my servo and jaw mechanism geometries, so you’ll need to do some experimenting to find the values ​​that work for your situation. If the servo slams against the stop, be prepared to pull the USB cable immediately.

There is also an initial position value “s” of 105. If the NG gets any data over the USB (serial) line, such as location data being sent to it from a Raspberry Pi audio analysis application, its firmware will be corrupted and you’ll be sitting there wondering why nothing happens. Once the board is powered on, the program will run and move the jaws to a safe position at the end of the 10-second startup period. I just have to wait for jaws to initialize and then I know I can safely start sending jaws stuff. With no jaw movement, I knew I had to re-flag the NG’s firmware.

Next, we open the serial port and start accumulating characters until we receive “\n”. The string is then converted to an integer and fed into the mapping function. The mapping function scales the open and closed jaw positions to numbers 0 to 9 in the input.

Finally, the scaled jaw position numbers are sent to the jaw servo system, and the program loops through the serial data stream of the audio analysis program currently running on the Linux laptop. I’m working on moving the analysis to the Raspberry Pi, although we’re not quite there yet.

what’s next

I’m very pleased with the jaw-syncing of the audio analysis data. I wrote a processing language program on a Linux laptop to play audio and convert the amplitude of the sound into the required sequence of zero to nine values. The full-size hobby servo seemed perfectly capable of swinging Hedley’s chin in a 30-degree arc while speaking.

Soon I will be installing a small speaker on the roof of Hedley’s mouth so that the sound comes from the right place. Of course, Headley had to have his own microphone when we were on stage.

This should be a really cool effect when everything finally comes together.

Stay tuned for coverage of audio analysis programs using language processing in an upcoming article.

Featured image from Pixabay.

group Create with sketches.



Source link

LEAVE A RESPONSE

Your email address will not be published. Required fields are marked *