Send Commands to Orion over serial USB connection


#1

I want to integrate my Pi running Jasper and my Makeblock Orion board, to create a voice controlled robot. I planned on sending commands to the Orion over a USB connection, which provides a serial interface. This seems relatively straightforward, and there are many tutorials on the web discussing it, such as this one: https://oscarliang.com/connect-raspberry-pi-and-arduino-usb-cable/ I tried this myself but my script didnt work.

I am wondering if this approach of sending data over USB / serial work with the Orion?

My understanding is that the Orion is based on Arduino, so it should work the same. Is that correct?

BTW: I have Jasper running fine as you can see here: https://www.youtube.com/watch?v=UYmUQvPVIe0


#2

OK. So after a little more testing I can answer this myself now. It wasnt working because the USB power connection will power the Orion board…but not the motor outputs. So when I was testing, no motors were running because the battery pack was switched off. Once i realised that I found my code was working. For those interested, here is the initial code I am using to drive the starter robot using single letters passed over the serial/USB connection. Each letter will correspond to a voice commend processed on the Pi by Jasper.

#include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>

#include <MeOrion.h>

double angle_rad = PI/180.0;
double angle_deg = 180.0/PI;
double iSonicSensor;
MeUltrasonicSensor ultrasonic_3(3);
MeDCMotor motor_9(9);
MeDCMotor motor_10(10);

char myChar = ‘z’;

void setup()
{
Serial.begin(9600);
}

void loop(){
if (Serial.available()) {
myChar = Serial.read();
}
if(myChar==‘h’){
//need to call a function to halt
halt();
}
if(myChar==‘f’){
//need to call a function to go forward
forward();
}
if(myChar==‘l’){
//need to call a function to turn left
left();
}
if(myChar==‘r’){
//need to call a function to turn right
right();
}
if(myChar==‘b’){
//need to call a function to go backward
back();
}
}

void halt(){
motor_9.run(0);
motor_10.run(0);
}

void forward(){
motor_9.run(-100);
motor_10.run(100);
}

void left(){
motor_9.run(100);
motor_10.run(100);
}

void right(){
motor_9.run(-100);
motor_10.run(-100);
}

void back(){
motor_9.run(50);
motor_10.run(-50);
}


#3

seems the include statements were handled a bit funny by the forum editor, but you get the idea…


#4

Nice job! FWIW, the forum uses Markdown, so if you put 4 spaces at the beginning of each line the code will format properly. :slight_smile:


#5

Very interesting and thanks for sticking with it. This will definitely be useful.


#6

And here are the results. https://youtu.be/CKDNcqdsZPU

Voice recognition was playing up, and the batteries powering the motors were dying…but you get the idea.

Certain words seem to be difficult to interpret by the online voice to text service (Wit AI)…and that is what accounts for the delay. I had to swap forward for fast, as i kept getting ridiculous translations for forward.


#7

Very nice.
Have you possibly considered using a Bluetooth headset so you can control the ambient noise?


#8