Android and Bluetooth 4.0 Fun ! Building the bridges to MRL !

UPDATE 08.10.2016

UPDATE 12.11.2015

Add a split screen mode for Immersive VR and a CardBoard mode toogle button !

Just Put your phone in a Google Cardboard and you are ready for telerobotics !

App supports the Myo Thalmic muscle sensor as well , to remotely grab objects or just move the platform !


UPDATE 09.12.2015

REMOTE TELEPRESENCE USING ANDROID PHONE AS A VR OCULUS FINALLY WORKY !!!!

This is to start Mjpeg streamer : ./mjpg_streamer -i "./input_uvc.so -n -y -f 15 -r 320x240" -o "./output_http.so -n -w ./www"

and this is the script on the raspi 2 side :


#file : /home/Alessandruino/VRAndroidPhone.py edit raw
arduino = Runtime.createAndStart("arduino","Arduino")
arduino.serial.refresh()
sleep(2)
arduino.connect("/dev/ttyACM0")

remote = Runtime.start("remote","RemoteAdapter")
neck = Runtime.createAndStart("neck","Servo")
rothead = Runtime.createAndStart("rothead", "Servo")

sleep(1)

neck.attach(arduino,12)
rothead.attach(arduino,13)

neck.setMinMax(10,170)
rothead.setMinMax(10,170)

neck.setInverted(True)
rothead.setInverted(True)

oculus = Runtime.start("oculus","OculusDIY")

def onOculusData(data):

  neck.moveTo(int(data.pitch))
  rothead.moveTo(int(data.yaw))

oculus.addOculusDataListener(python)
remote.startListening()

UPDATE 04.12.2015

Android Phone is sending euler Angles (yaw, pitch and roll) to MRL OcuslusDIY service ! YAY

So...we are ready to track head movement using a google cardboard :) now we miss video and we are ready to go with telepresence !

 

UPDATE 11.24.2015

Data from Myo is being received in MyRobotLab !!! Myo is connected to Phone, which send the data wireless to myrobotlab on my mac ( in the future on my raspberry pi 2 !)


Hey guys... what we are trying to do is to collect all the data from sensors on Android, writing an app which uses MRL-client.jar library....

What we did so far is this :

As you can see in the video the pairing between myo and phone is done by "touching" them together using signal strength.

There i'm triggering actions like servo.moveTo(value) , but still not sending all the myodata package goodies to mrl !

That's the goal...receive the full packet of data, and trigger actions from myrobotlab instance running on raspi instead from phone...


On another side i'm trying to send the data from the Android , not using TCP and wireless but using serial over Bluetooth 4.0 ! much more reliable than the old bluetooth !

I'm using a 10 $ HM 10 Bluetooth 4.0 module :

here is what i got so far :

the app is sending values like this : 233 , 33 , 0 /n

Where there are 3 values from 0 to 255, sparated by a "," and ending with a /n

this is the arduino code I use to parse the data in arduino :

/*

  Reading a serial ASCII-encoded string.



 This sketch demonstrates the Serial parseInt() function.

 It looks for an ASCII string of comma-separated values.

 It parses them into ints, and uses those to fade an RGB LED.



 Circuit: Common-anode RGB LED wired like so:

 * Red cathode: digital pin 3

 * Green cathode: digital pin 5

 * blue cathode: digital pin 6

 * anode: +5V



 created 13 Apr 2012

 by Tom Igoe



 This example code is in the public domain.

 */




// pins for the LEDs:

const int redPin = 3;

const int greenPin = 5;

const int bluePin = 6;



void setup() {

  // initialize serial:

  Serial.begin(9600);

  // make the pins outputs:

  pinMode(redPin, OUTPUT);

  pinMode(greenPin, OUTPUT);

  pinMode(bluePin, OUTPUT);



}



void loop() {

  // if there's any serial available, read it:

  while (Serial.available() > 0) {



    // look for the next valid integer in the incoming serial stream:

    int red = Serial.parseInt();

    // do it again:

    int green = Serial.parseInt();

    // do it again:

    int blue = Serial.parseInt();



    // look for the newline. That's the end of your

    // sentence:

    if (Serial.read() == '\n') {

      // constrain the values to 0 - 255 and invert

      // if you're using a common-cathode LED, just use "constrain(color, 0, 255);"

      red = 255 - constrain(red, 0, 255);

      green = 255 - constrain(green, 0, 255);

      blue = 255 - constrain(blue, 0, 255);



      // fade the red, green, and blue legs of the LED:

      analogWrite(redPin, red);

      analogWrite(greenPin, green);

      analogWrite(bluePin, blue);



      // print the three numbers in one string as hexadecimal:

      Serial.print(red, HEX);

      Serial.print(green, HEX);

      Serial.println(blue, HEX);

    }

  }

}

But, i want to do this in myrobotlab using Serial service :

this is what i got in serial monitor : 

the 44 should be the "," and the 10 should be the "/n".

How can i parse that to obtain the 3 Integers sent from the app? there is no parseInt() function in Python


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
GroG's picture

Simplify !  The new MyoData

Simplify ! 

The new MyoData is just doubles & a String replaces the previously defined thalmic lab's enum
 
new MyoData checked in - for serialization I usually use things called POJOs - "Plain Old Java Objects" - these are very easy & basic Java classes - all the variables within it are primitive types, or primitive objects (if null needs to be supported), The variables are always "public" and there is no need for setThingy(int thing) or int getThingy() .. - they are just simple containers of data - which makes Serialization work better :)
 
This will let you go from Myo ---> Android --(MyoData)---> MRL
 
To start going the other way - We'd want to make the Serial & Arduino services run on Android
Alessandruino's picture

Cool! Simple myo data is a

Cool! Simple myo data is a good news! I ll try that as soon as I can...

And what about the second part of the post? How can I parse the data in python as I do In arduino ide?

GroG's picture

For the other direction -

For the other direction - wouldn't Serial & Arduino service on Android be good?  Over bluetooth to the Arduino ?

GroG's picture

Whooohooo .... Android is

Whooohooo .... Android is being Borgd !

kwatters's picture

cardboard?

Did you get a google cardboard?   That's awesome!  borg borg borg....  

Alessandruino's picture

Yep... I was really shocked

Yep... I was really shocked by the simplicity and the quality of the result... I advise you purchasing one,as a Vr lover :) !

GroG's picture

Double ! Merry Xmas !  Merry

Double !
Merry Xmas !  Merry Xmas !  

So its an api call to split screen ?  More Jars ! 

:D

 

Alessandruino's picture

No.. It 's not an api...

No.. It 's not an api... Using Bitmap class to draw the split screen... No additional jars beside myo and mrl

GroG's picture

Ran your script .. but I

Ran your script .. but I think oculus has its own arduino defined - shouldn't we just have one arduino ?  The oculus one?

Alessandruino's picture

yes.. it's supposed to be

yes.. it's supposed to be with 2 arduinos... 1 is InMoov arduino(or pan/tilt kit arduino) ...and the  second is for the DIY oculus (instead of using phone, to process data from Gyro/acc with the fpv screen)