mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-01 18:29:16 +01:00
AndroidGCS: Remove the old fake telemetry
This commit is contained in:
parent
11079a6dd7
commit
1a1aa85d1a
@ -2,14 +2,12 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string-array name="connectTypeArray">
|
<string-array name="connectTypeArray">
|
||||||
<item>None</item>
|
<item>None</item>
|
||||||
<item>Fake</item>
|
|
||||||
<item>Bluetooth</item>
|
<item>Bluetooth</item>
|
||||||
<item>Network</item>
|
<item>Network</item>
|
||||||
<item>HID</item>
|
<item>HID</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="connectTypeValues">
|
<string-array name="connectTypeValues">
|
||||||
<item>0</item>
|
<item>0</item>
|
||||||
<item>1</item>
|
|
||||||
<item>2</item>
|
<item>2</item>
|
||||||
<item>3</item>
|
<item>3</item>
|
||||||
<item>4</item>
|
<item>4</item>
|
||||||
|
@ -113,10 +113,6 @@ public class OPTelemetryService extends Service {
|
|||||||
switch(connection_type) {
|
switch(connection_type) {
|
||||||
case 0: // No connection
|
case 0: // No connection
|
||||||
return;
|
return;
|
||||||
case 1:
|
|
||||||
Toast.makeText(getApplicationContext(), "Attempting fake connection", Toast.LENGTH_SHORT).show();
|
|
||||||
activeTelem = new FakeTelemetryThread();
|
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
Toast.makeText(getApplicationContext(), "Attempting BT connection", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getApplicationContext(), "Attempting BT connection", Toast.LENGTH_SHORT).show();
|
||||||
telemTask = new BluetoothUAVTalk(this);
|
telemTask = new BluetoothUAVTalk(this);
|
||||||
@ -274,149 +270,4 @@ public class OPTelemetryService extends Service {
|
|||||||
public interface TelemTask {
|
public interface TelemTask {
|
||||||
public UAVObjectManager getObjectManager();
|
public UAVObjectManager getObjectManager();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fake class for testing, simply emits periodic updates on
|
|
||||||
private class FakeTelemetryThread extends Thread implements TelemTask {
|
|
||||||
private final UAVObjectManager objMngr;
|
|
||||||
@Override
|
|
||||||
public UAVObjectManager getObjectManager() { return objMngr; };
|
|
||||||
|
|
||||||
FakeTelemetryThread() {
|
|
||||||
objMngr = new UAVObjectManager();
|
|
||||||
UAVObjectsInitialize.register(objMngr);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
System.out.println("Running fake thread");
|
|
||||||
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.setAction(INTENT_ACTION_CONNECTED);
|
|
||||||
sendBroadcast(intent,null);
|
|
||||||
|
|
||||||
//toastMessage("Started fake telemetry thread");
|
|
||||||
UAVDataObject systemStats = (UAVDataObject) objMngr.getObject("SystemStats");
|
|
||||||
UAVDataObject attitudeActual = (UAVDataObject) objMngr.getObject("AttitudeActual");
|
|
||||||
UAVDataObject homeLocation = (UAVDataObject) objMngr.getObject("HomeLocation");
|
|
||||||
UAVDataObject positionActual = (UAVDataObject) objMngr.getObject("PositionActual");
|
|
||||||
UAVDataObject systemAlarms = (UAVDataObject) objMngr.getObject("SystemAlarms");
|
|
||||||
|
|
||||||
systemAlarms.getField("Alarm").setValue("Warning",0);
|
|
||||||
systemAlarms.getField("Alarm").setValue("OK",1);
|
|
||||||
systemAlarms.getField("Alarm").setValue("Critical",2);
|
|
||||||
systemAlarms.getField("Alarm").setValue("Error",3);
|
|
||||||
systemAlarms.updated();
|
|
||||||
|
|
||||||
homeLocation.getField("Latitude").setDouble(379420315);
|
|
||||||
homeLocation.getField("Longitude").setDouble(-88330078);
|
|
||||||
homeLocation.getField("Be").setDouble(26702.78710938,0);
|
|
||||||
homeLocation.getField("Be").setDouble(-1468.33605957,1);
|
|
||||||
homeLocation.getField("Be").setDouble(34181.78515625,2);
|
|
||||||
|
|
||||||
|
|
||||||
double roll = 0;
|
|
||||||
double pitch = 0;
|
|
||||||
double yaw = 0;
|
|
||||||
double north = 0;
|
|
||||||
double east = 0;
|
|
||||||
while( !terminate ) {
|
|
||||||
attitudeActual.getField("Roll").setDouble(roll);
|
|
||||||
attitudeActual.getField("Pitch").setDouble(pitch);
|
|
||||||
attitudeActual.getField("Yaw").setDouble(yaw);
|
|
||||||
positionActual.getField("North").setDouble(north += 100);
|
|
||||||
positionActual.getField("East").setDouble(east += 100);
|
|
||||||
roll = (roll + 10) % 180;
|
|
||||||
pitch = (pitch + 10) % 180;
|
|
||||||
yaw = (yaw + 10) % 360;
|
|
||||||
|
|
||||||
systemStats.updated();
|
|
||||||
attitudeActual.updated();
|
|
||||||
positionActual.updated();
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
private class BTTelemetryThread extends Thread implements TelemTask {
|
|
||||||
|
|
||||||
private final UAVObjectManager objMngr;
|
|
||||||
private UAVTalk uavTalk;
|
|
||||||
private Telemetry tel;
|
|
||||||
private TelemetryMonitor mon;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UAVObjectManager getObjectManager() { return objMngr; };
|
|
||||||
|
|
||||||
BTTelemetryThread() {
|
|
||||||
objMngr = new UAVObjectManager();
|
|
||||||
UAVObjectsInitialize.register(objMngr);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (DEBUG) Log.d(TAG, "Telemetry Thread started");
|
|
||||||
|
|
||||||
Looper.prepare();
|
|
||||||
|
|
||||||
BluetoothUAVTalk bt = new BluetoothUAVTalk(OPTelemetryService.this);
|
|
||||||
for( int i = 0; i < 10; i++ ) {
|
|
||||||
if (DEBUG) Log.d(TAG, "Attempting Bluetooth Connection");
|
|
||||||
|
|
||||||
bt.connect(objMngr);
|
|
||||||
|
|
||||||
if (DEBUG) Log.d(TAG, "Done attempting connection");
|
|
||||||
if( bt.getConnected() )
|
|
||||||
break;
|
|
||||||
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Log.e(TAG, "Thread interrupted while trying to connect");
|
|
||||||
e.printStackTrace();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if( ! bt.getConnected() ) {
|
|
||||||
toastMessage("BT connection failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
toastMessage("BT Connected");
|
|
||||||
|
|
||||||
if (DEBUG) Log.d(TAG, "Connected via bluetooth");
|
|
||||||
|
|
||||||
uavTalk = bt.getUavtalk();
|
|
||||||
tel = new Telemetry(uavTalk, objMngr);
|
|
||||||
mon = new TelemetryMonitor(objMngr,tel);
|
|
||||||
mon.addObserver(new Observer() {
|
|
||||||
@Override
|
|
||||||
public void update(Observable arg0, Object arg1) {
|
|
||||||
if (DEBUG) Log.d(TAG, "Mon updated. Connected: " + mon.getConnected() + " objects updated: " + mon.getObjectsUpdated());
|
|
||||||
if(mon.getConnected() ) {
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.setAction(INTENT_ACTION_CONNECTED);
|
|
||||||
sendBroadcast(intent,null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
if (DEBUG) Log.d(TAG, "Entering UAVTalk processing loop");
|
|
||||||
while( !terminate ) {
|
|
||||||
try {
|
|
||||||
if( !uavTalk.processInputStream() )
|
|
||||||
break;
|
|
||||||
} catch (IOException e) {
|
|
||||||
// This occurs when they communication stream fails
|
|
||||||
toastMessage("Connection dropped");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (DEBUG) Log.d(TAG, "UAVTalk stream disconnected");
|
|
||||||
}
|
|
||||||
};*/
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user