Major changes in this branch: L298N and voice command support
Nothing expensive. The most expensive one is the Android things board, which I got from Google I/O :)
- Android things board (NXP i.MX7D)
- A robot car chassis. I used this one
- L298N motor driver board (included in the above robocar package)
- Power source for DC motor (included in the above robocar package)
- Power source for Android Things (I used my cellphone power bank)
- Microphone and speaker ( I simply used a phone headset(CTIA plug))
- Some pieces of wood and glue
You can ignore the PCA9685 board (not wired, not used).
Both Antonio Zugaldia's and Google's android things robocar use Adafruit stepper & DC Motor hat as the motor controller. Since the robot car kit I ordered already has L298N motor driver, one less thing to buy. Check L298NDriver.java.
Headset & power bank are removed to show the wiring: I'm using pins 12(PWM1)/14(Ground)/29(GPIO2_IO01)/31(GPIO2_IO02)/33(PWM2)/35(GPIO2_IO00)/37(GPIO2_IO05). See https://developer.android.com/things/hardware/imx7d. Make sure to use the ground pin. Basically PWM controls the motor speed, and 2 GPIOs together control the motor current direction so that the wheels can move forward and backward.
Speech recognition engine is using Pocketsphinx on Android(https://github.com/cmusphinx/pocketsphinx-android-demo).
recognizer.addKeyphraseSearch(WAKEUP_SEARCH, ACTIVATION_KEYPHRASE);
File actionGrammar = new File(assetsDir, "commands.gram");
recognizer.addKeywordSearch(ACTION_SEARCH, actionGrammar);
// For continuous recognition, keyword search is preferred to grammar search
Activation keyphrase is used so that the car will not move by accident. My son likes to call it "Mr. crazy car" :). Once it's activated, it'll be ready to take the following commands(in commands.gram):
forward /1e-15/
backward /1e-17/
reverse /1e-17/
left /1e-15/
right /1e-15/
good job /1e-30/
stop /1e-20/
"stop" (to stop the car) and "good job" (to stop the car and de-activate the command mode) are given a higher sensitivity level to avoid having to screaming at the car to make it stop, given the motor noise and the mediocre microphone.
Have fun!