After tried two methods not enough reliable, this method is my last chance to find a well way to determinate distance between a tablet and a robot.
This method using the tablet camera and Bluetooth. Principle is pretty simple, we assume that the robot start from position 1 to position 2. When the robot leave position 1, it sends a Bluetooth signal to the tablet saying “I am started” (This signal is only a character). Once the robot is arriving at the position 2 it sends another signal indicating the distance between position 1 and position 2 (in centimeters). So we can ask us several questions about this new way:
Is it possible to communicate with Bluetooth between the robot and an Android device ?
Is the measure will be precise ?
Is one camera enough do measure the distance ?
I began by EV3 robot Bluetooth communication. Bluetooth protocol is pretty simple, there are only some important steps to follow:
1) Connector declaration
NXTCommConnector connector = Bluetooth.getNXTCommConnector();
2) Established connection
NXTConnection connect = connector.waitForConnection(0, NXTConnection.RAW);
3) Stream declaration
DataInputStream dis = connect.openDataInputStream();
DataOutputStream dos = connect.openDataOutputStream();
4) Read or write information
short n = dis.readShort();
dos.writeShort(n);
About Bluetooth on the Nexus 7 tablet, we will use a very simple program, made with processing. First of all, we declared and established the connection between the EV3 robot and the Nexus 7 tablet
bt = new KetaiBluetooth(this);
bt.connectToDeviceByName("EV3");
bt.start();
To send a data you will use :
byte[] data = {'t','e','s','t','\r'};
bt.broadcast(data);
And you will use the event on the buffer to receive the data :
void onBluetoothDataEvent(String who, byte[] data) {
if (isConfiguring)
return;
info += new String(data);
}
Now, we can share information between EV3 robot and the Nexus 7 tablet.
Next step is about picture treatment, I will talk about it in the next post. I used Processing to do picture treatment because it is a more adapted for thus kind of application.