Difference between revisions of "Visual navigation for Acrob or SBOT robot with Android with camera ( Marek Kádek, Jana Sucháneková)"
(→Postup riešenia) |
(→Postup riešenia) |
||
Line 27: | Line 27: | ||
Amarino.connect(this, DEVICE_ADDRESS); | Amarino.connect(this, DEVICE_ADDRESS); | ||
} | } | ||
− | |||
@Override | @Override | ||
Line 35: | Line 34: | ||
unregisterReceiver(arduinoReceiver); | unregisterReceiver(arduinoReceiver); | ||
} | } | ||
− | |||
public class ArduinoReceiver extends BroadcastReceiver { | public class ArduinoReceiver extends BroadcastReceiver { | ||
@Override | @Override | ||
− | + | public void onReceive(Context context, Intent intent) { | |
− | + | String data = null; | |
− | + | final String address = intent.getStringExtra(AmarinoIntent.EXTRA_DEVICE_ADDRESS); | |
− | + | final int dataType = intent.getIntExtra(AmarinoIntent.EXTRA_DATA_TYPE, -1); | |
− | + | if (dataType == AmarinoIntent.STRING_EXTRA) { | |
− | + | data = intent.getStringExtra(AmarinoIntent.EXTRA_DATA); | |
− | + | if (data != null){ | |
− | + | try { | |
− | + | // tu mozeme spracovat data, ktore robot posle na mobil | |
− | + | } | |
− | + | catch (Exception e) { | |
− | + | } | |
− | + | } | |
− | + | } | |
− | + | } | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Zdroje == | == Zdroje == | ||
# [http://www.amarino-toolkit.net/ Amarino toolkit] | # [http://www.amarino-toolkit.net/ Amarino toolkit] |
Revision as of 10:41, 12 June 2013
Úvod
Cieľom projektu Editing Visual navigation for Acrob with Android with camera bolo vytvoriť robota, reagujúceho na vizuálne podnety v labyrinte pomocou snímania okolia kamerou mobilu s operačným systémom Android. Robot má byť spojený s telefónom pomocou protokolu bluetooth.
Postup riešenia
V prvej etape tvorby projektu bolo základom zložiť robota. (OBBBBBBBR)
V druhej etape sme vytvorili bluetooth spojenie medzi robotom a mobilným telefónom, pomocou knižnice Amarino - Android meets Andruino. Z rôznych zdrojov a diskusií na internete sme sa dozvedeli, že vytvorenie spojenia z android bluetooth na bluetooth modul robota je mnohokrát problémové a chyby sú ťažko odhaliteľné. Veľa rád práve smerovalo na použitie knižnice Amarino na riešenie tohoto problému.
Postup tvorby spojenia:
- Android zariadenie spárujeme s bluetooth modulom.
- Na android zariadenie nainštalujeme Amarino.
- Vytvoríme projekt v eclipse a do build path pridáme knižnicu.
Ukážka nadviazania spojenia pomocou knižnice:
private static final String DEVICE_ADDRESS = "00:06:66:03:73:7B"; private ArduinoReceiver arduinoReceiver = new ArduinoReceiver(); @Override protected void onStart() { super.onStart(); registerReceiver(arduinoReceiver, new IntentFilter(AmarinoIntent.ACTION_RECEIVED)); Amarino.connect(this, DEVICE_ADDRESS); }
@Override protected void onStop() { super.onStop(); Amarino.disconnect(this, DEVICE_ADDRESS); unregisterReceiver(arduinoReceiver); }
public class ArduinoReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { String data = null; final String address = intent.getStringExtra(AmarinoIntent.EXTRA_DEVICE_ADDRESS); final int dataType = intent.getIntExtra(AmarinoIntent.EXTRA_DATA_TYPE, -1); if (dataType == AmarinoIntent.STRING_EXTRA) { data = intent.getStringExtra(AmarinoIntent.EXTRA_DATA); if (data != null){ try { // tu mozeme spracovat data, ktore robot posle na mobil } catch (Exception e) { } } } }