Inmoov Scrips / Inmoov Doing Math

 
#1

Hello,

Hello bhouston,

slowly i am finish my inmoov (Juhu)

for some days i got my EZB4 Controllers (2x Juhu)

and now i am checking the possibilities with speech reco and so on.

I am really interested in your doing Math script.... where i can find the subscripts (Repeat Speech 3 / Do math / repeat speech 1)?

And your stuf with the speech control to the neopixel ring is also great... do you have also there a script to share?


Or other question do you share EZB InMoov File?

Greetinxx from a big fan


Boris

#2

@rentaprinta, Here's the script as it stands today, the repeat speech scripts have been removed now that we have a Talk Servo Control to move a servo with text.
Everyone's InMoov's are different so far as servo connection ports and calibration is concerned, so posting my subscripts won't do you any good. You will have to create them for your robot. The "Doing Math" subscript, simply brings the robots arms and hands into position. Then each finger movement has a subscript as well.

Code:


Sayezb(" I like doing math")

sleep(500)

ControlCommand("Script Manager", ScriptStart, "Do math")

sleep(5500)
ControlCommand("Script Manager", ScriptStop, "Do math")

sayezb("ready")
servospeed(D3,0)
servospeed(D4,0)
servospeed(D5,0)
servospeed(D6,0)
servospeed(D7,0)
servospeed(D13,0)
servospeed(D14,0)
servospeed(D15,0)
servospeed(D16,0)
servospeed(D18,0)

:start

$heard = "speech"

WaitForChange($heard)

if($Heard = "won")

$x = 1

elseif($heard="two")

$x = 2

elseif($heard ="three")

$x = 3

elseif($heard = "four")

$x = 4

elseif($heard = "five")

$x = 5

#else

#say("sorry, didn't hear your response correctly")

#GoTo(start)

endif



WaitForChange($heard)

if($heard = "plus one")

$y = 1

elseif($heard = "plus two")

$y = 2

elseif($heard ="plus three")

$y = 3

elseif($heard ="plus four")

$y = 4

elseif($heard = "plus five")

$y = 5

#print($x + $y)

endif





WaitForChange($heard)

if($heard = "what does that equal")

servo(d0,150)

servospeed(d0,3)

servo(d1,90)

servospeed(d1,3)

sayezb("ummm")


ControlCommand("Script Manager", ScriptStart, "Close right Hand")

ControlCommand("Script Manager", ScriptStart, "Close left hand")

Sleep(1500)

Servo(d0,116)

servospeed(d0,3)

servo(d1,118)

servospeed(d1,3)

sleep(1500)

$sum = Abs($x + $y)

Sayezb($x + " plus " + $y + " equals " + $sum)

endif



#print($x + $y)

#Endif



if($sum = 2)

ControlCommand("Script Manager", ScriptStart, "equals two")

elseif($sum = 3)

ControlCommand("Script Manager", ScriptStart, "equals three")

elseif($sum = 4)

ControlCommand("Script Manager", ScriptStart, "equals four")

elseif($sum = 5)

ControlCommand("Script Manager", ScriptStart, "equals five")

elseif($sum = 6)

ControlCommand("Script Manager", ScriptStart, "equals six")

elseif($sum = 7)

ControlCommand("Script Manager", ScriptStart, "equals seven")

elseif($sum =8)

ControlCommand("Script Manager", ScriptStart, "equals seven")

elseif($sum = 9)

ControlCommand("Script Manager", ScriptStart, "equals nine")

elseif($sum = 10)

ControlCommand("Script Manager", ScriptStart, "equals ten")

endif

sleep(4000)

ControlCommand("Script Manager", ScriptStart, "Close right Hand")

ControlCommand("Script Manager", ScriptStart, "Close left hand")

Sleep(500)

GoTo(start)



I am running the neopixel ring off of an Arduino Uno with commands sent to it from the EZB. Here's an example of a script for that.

Code:


#include <Adafruit_NeoPixel.h>


#define PIN 6

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel. Avoid connecting
// on a live circuit...if you must, connect GND first.

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

strip.begin();
strip.show(); // Initialize all pixels to 'off'
}

void loop() {


if (Serial.available())
{


int ib = 0;
ib = Serial.read();


// Stop All display
if (ib == 33) {
strip.show(); // Initialize all pixels to 'off'
}



// ColorWipes
// Blue = "B" or 66
if (ib == 66) {
colorWipe(strip.Color(0, 0, 255), 3); // Blue

}
//Blue White = "P" or 80
if (ib == 80){
colorWipe(strip.Color(0, 0, 255), 3);
colorWipe(strip.Color(0, 0, 0), 3);
}
// Red = "R" or 82
if (ib == 82) {
colorWipe(strip.Color(255, 0, 0), 10); // Red

}
// Green = "G" or 71
if (ib == 71) {
colorWipe(strip.Color(0, 255, 0), 50); // Green
}
if (ib == 87){
colorWipe(strip.Color(0, 0, 0), 3);
}

// ChaseSetting
// White = "w" or 119
if (ib == 119) {
theaterChase(strip.Color(127, 127, 127), 50); // White
}
// Red = "r" or 114
if (ib == 114) {
theaterChase(strip.Color(127, 0, 0), 50); // Red

}

if (ib == 98)
{
theaterChase(strip.Color( 0, 0, 127), 50); // Blue
}

if (ib == 88)
{
rainbow(20);
}
if (ib == 89)
{
rainbowCycle(20);
}

if (ib == 90)
{
theaterChaseRainbow(50);
}


}






}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
for (uint16_t i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}

void rainbow(uint8_t wait) {
uint16_t i, j;

for (j = 0; j < 256; j++) {
for (i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel((i + j) & 255));
}
strip.show();
delay(wait);
}
}

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
uint16_t i, j;

for (j = 0; j < 256 * 5; j++) { // 5 cycles of all colors on wheel
for (i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}

//Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
for (int j = 0; j < 10; j++) { //do 10 cycles of chasing
for (int q = 0; q < 3; q++) {
for (int i = 0; i < strip.numPixels(); i = i + 3) {
strip.setPixelColor(i + q, c); //turn every third pixel on
}
strip.show();

delay(wait);

for (int i = 0; i < strip.numPixels(); i = i + 3) {
strip.setPixelColor(i + q, 0); //turn every third pixel off
}
}
}
}

//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait) {
for (int j = 0; j < 256; j++) { // cycle all 256 colors in the wheel
for (int q = 0; q < 3; q++) {
for (int i = 0; i < strip.numPixels(); i = i + 3) {
strip.setPixelColor(i + q, Wheel( (i + j) % 255)); //turn every third pixel on
}
strip.show();

delay(wait);

for (int i = 0; i < strip.numPixels(); i = i + 3) {
strip.setPixelColor(i + q, 0); //turn every third pixel off
}
}
}
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
if (WheelPos < 85) {
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
} else if (WheelPos < 170) {
WheelPos -= 85;
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
}


and then to send the command from the EZB to the Arduino,

Code:


SendSerial(1. D18,9600,"R1,1")



I hope this helps you out

#3

Hi

Bhouston,

thanx for the fast answer,

i need time to check up your scrips


Boris

#4

Hi Bhouston,

how i can send this serial information to the ardunio?

What Shild or bridge i must buy?

Boris

#5

I have mine connected as follows;
Port 18 on the EZB connected to the Rx on the Arduino
The Arduino is powered with 5V
The ring power wires are connected to 5V and negative and the signal wire to pin 6 on the Arduino.
Load that crazy arduino script on to the ardunio and call for what ever pixel pattern you want in an ez script. As in my example.

#6

Hello bhouston,

today i have time to chekc the neopixel.

1. So i upload your Arduino Script to the Arduino
2. I connect the Neopixel with the Arduino Port 6 and + and -
3. I connect the Arduino on RX0 with D18 on the EZB4


User-inserted image


I make a script with:

Code:

SendSerial(1. D18,9600,"R1,1")



But nothing happend.

I change the Code to:

Code:

SendSerial(1. D18,9600,"R1,66")



Code:

SendSerial(1. D18,9600,"66")



I think 66 is for BLUE, but also nothing works.


I check with the normal NeoScript uploaded on the Arduino and it works on Port 6 . So the Neopixel Ring is correct connected.

But what i did wrong?

Boris

#7

I'm using two EZB's on my project and using the second one for the ring that is why I am using port - 1.D18. ( sorry about that) Try this code if you are only using one EZB

Code:


SendSerial(D18,9600,"66")

#8

hi,

thanx for your help,

but still now light ;-(

I use now your new code

Code:


SendSerial(D18,9600,"66")



i connect with RX0 (also with RX1/RX2/RX3) RX0 is right?

on the EZB on D18 on the white pin! right?

and i have a 24 led ring so i change the Arduino Script :

Code:


#define PIN 6
#define STRIPSIZE 24

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(24, PIN, NEO_GRB + NEO_KHZ800);




?

Boris

#9

It seems, if the EZB4 not send a Serial... (How can i check if the EZB4 send something?)


or the Arduino not receive serial.

#10

I am 1500 km away from my robot so I can't check how it's wired to see if I missed something. Try connecting a ground wire between the EZB and the Arduino.