diff --git a/AndroidExplorerbotServer/bin/AndroidExplorerbotServer.apk b/AndroidExplorerbotServer/bin/AndroidExplorerbotServer.apk
new file mode 100644
index 0000000..c774de7
Binary files /dev/null and b/AndroidExplorerbotServer/bin/AndroidExplorerbotServer.apk differ
diff --git a/AndroidExplorerbotServer/bin/classes.dex b/AndroidExplorerbotServer/bin/classes.dex
new file mode 100644
index 0000000..d7f98dc
Binary files /dev/null and b/AndroidExplorerbotServer/bin/classes.dex differ
diff --git a/AndroidExplorerbotServer/bin/dexedLibs/android-support-v4-7707150e79a0cf40d50b916fde2d881a.jar b/AndroidExplorerbotServer/bin/dexedLibs/android-support-v4-7707150e79a0cf40d50b916fde2d881a.jar
new file mode 100644
index 0000000..5d48323
Binary files /dev/null and b/AndroidExplorerbotServer/bin/dexedLibs/android-support-v4-7707150e79a0cf40d50b916fde2d881a.jar differ
diff --git a/AndroidExplorerbotServer/bin/dexedLibs/usb-serial-for-android-v010-c6d8e36f1aeec7d4e0e59d3c42bf7e59.jar b/AndroidExplorerbotServer/bin/dexedLibs/usb-serial-for-android-v010-c6d8e36f1aeec7d4e0e59d3c42bf7e59.jar
new file mode 100644
index 0000000..a0d78ea
Binary files /dev/null and b/AndroidExplorerbotServer/bin/dexedLibs/usb-serial-for-android-v010-c6d8e36f1aeec7d4e0e59d3c42bf7e59.jar differ
diff --git a/AndroidExplorerbotServer/bin/res/crunch/drawable-hdpi/ic_device_access_video.png b/AndroidExplorerbotServer/bin/res/crunch/drawable-hdpi/ic_device_access_video.png
new file mode 100644
index 0000000..fbe134d
Binary files /dev/null and b/AndroidExplorerbotServer/bin/res/crunch/drawable-hdpi/ic_device_access_video.png differ
diff --git a/AndroidExplorerbotServer/bin/res/crunch/drawable-hdpi/ic_launcher.png b/AndroidExplorerbotServer/bin/res/crunch/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..dd7eb4b
Binary files /dev/null and b/AndroidExplorerbotServer/bin/res/crunch/drawable-hdpi/ic_launcher.png differ
diff --git a/AndroidExplorerbotServer/bin/res/crunch/drawable-mdpi/ic_device_access_video.png b/AndroidExplorerbotServer/bin/res/crunch/drawable-mdpi/ic_device_access_video.png
new file mode 100644
index 0000000..877a31a
Binary files /dev/null and b/AndroidExplorerbotServer/bin/res/crunch/drawable-mdpi/ic_device_access_video.png differ
diff --git a/AndroidExplorerbotServer/bin/res/crunch/drawable-mdpi/ic_launcher.png b/AndroidExplorerbotServer/bin/res/crunch/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..22b93d6
Binary files /dev/null and b/AndroidExplorerbotServer/bin/res/crunch/drawable-mdpi/ic_launcher.png differ
diff --git a/AndroidExplorerbotServer/bin/res/crunch/drawable-xhdpi/ic_device_access_video.png b/AndroidExplorerbotServer/bin/res/crunch/drawable-xhdpi/ic_device_access_video.png
new file mode 100644
index 0000000..064e619
Binary files /dev/null and b/AndroidExplorerbotServer/bin/res/crunch/drawable-xhdpi/ic_device_access_video.png differ
diff --git a/AndroidExplorerbotServer/bin/res/crunch/drawable-xhdpi/ic_launcher.png b/AndroidExplorerbotServer/bin/res/crunch/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..d63fd11
Binary files /dev/null and b/AndroidExplorerbotServer/bin/res/crunch/drawable-xhdpi/ic_launcher.png differ
diff --git a/AndroidExplorerbotServer/bin/res/crunch/drawable-xxhdpi/ic_device_access_video.png b/AndroidExplorerbotServer/bin/res/crunch/drawable-xxhdpi/ic_device_access_video.png
new file mode 100644
index 0000000..71a661e
Binary files /dev/null and b/AndroidExplorerbotServer/bin/res/crunch/drawable-xxhdpi/ic_device_access_video.png differ
diff --git a/AndroidExplorerbotServer/bin/res/crunch/drawable-xxhdpi/ic_launcher.png b/AndroidExplorerbotServer/bin/res/crunch/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..4cdbf63
Binary files /dev/null and b/AndroidExplorerbotServer/bin/res/crunch/drawable-xxhdpi/ic_launcher.png differ
diff --git a/AndroidExplorerbotServer/bin/res/crunch/drawable-xxxhdpi/ic_launcher.png b/AndroidExplorerbotServer/bin/res/crunch/drawable-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..2ebce5d
Binary files /dev/null and b/AndroidExplorerbotServer/bin/res/crunch/drawable-xxxhdpi/ic_launcher.png differ
diff --git a/AndroidExplorerbotServer/bin/resources.ap_ b/AndroidExplorerbotServer/bin/resources.ap_
new file mode 100644
index 0000000..1854540
Binary files /dev/null and b/AndroidExplorerbotServer/bin/resources.ap_ differ
diff --git a/AndroidExplorerbotServer/res/drawable-hdpi/ic_device_access_video.png b/AndroidExplorerbotServer/res/drawable-hdpi/ic_device_access_video.png
new file mode 100644
index 0000000..65c52d0
Binary files /dev/null and b/AndroidExplorerbotServer/res/drawable-hdpi/ic_device_access_video.png differ
diff --git a/AndroidExplorerbotServer/res/drawable-mdpi/ic_device_access_video.png b/AndroidExplorerbotServer/res/drawable-mdpi/ic_device_access_video.png
new file mode 100644
index 0000000..ae5d53b
Binary files /dev/null and b/AndroidExplorerbotServer/res/drawable-mdpi/ic_device_access_video.png differ
diff --git a/AndroidExplorerbotServer/res/drawable-xhdpi/ic_device_access_video.png b/AndroidExplorerbotServer/res/drawable-xhdpi/ic_device_access_video.png
new file mode 100644
index 0000000..a2ba433
Binary files /dev/null and b/AndroidExplorerbotServer/res/drawable-xhdpi/ic_device_access_video.png differ
diff --git a/AndroidExplorerbotServer/res/drawable-xxhdpi/ic_device_access_video.png b/AndroidExplorerbotServer/res/drawable-xxhdpi/ic_device_access_video.png
new file mode 100644
index 0000000..884f0d9
Binary files /dev/null and b/AndroidExplorerbotServer/res/drawable-xxhdpi/ic_device_access_video.png differ
diff --git a/AndroidExplorerbotServer/res/layout/activity_main.xml b/AndroidExplorerbotServer/res/layout/activity_main.xml
index df64219..f9e6171 100644
--- a/AndroidExplorerbotServer/res/layout/activity_main.xml
+++ b/AndroidExplorerbotServer/res/layout/activity_main.xml
@@ -22,4 +22,31 @@
android:text="@string/srv"
android:textAppearance="?android:attr/textAppearanceLarge" />
+
+
+
+
+
+
\ No newline at end of file
diff --git a/AndroidExplorerbotServer/res/values/strings.xml b/AndroidExplorerbotServer/res/values/strings.xml
index 120748d..244d958 100644
--- a/AndroidExplorerbotServer/res/values/strings.xml
+++ b/AndroidExplorerbotServer/res/values/strings.xml
@@ -3,5 +3,7 @@
AndroidExplorerbotServer
Server started
+ Exiting with HOME key will keep the server running. To exit completly press BACK or use the button below.
+ Kill server
diff --git a/AndroidExplorerbotServer/src/it/danieleverducci/explorerbotserver/AppConfiguration.java b/AndroidExplorerbotServer/src/it/danieleverducci/explorerbotserver/AppConfiguration.java
index 9d5f162..d90b882 100644
--- a/AndroidExplorerbotServer/src/it/danieleverducci/explorerbotserver/AppConfiguration.java
+++ b/AndroidExplorerbotServer/src/it/danieleverducci/explorerbotserver/AppConfiguration.java
@@ -21,4 +21,5 @@ package it.danieleverducci.explorerbotserver;
public class AppConfiguration {
public static final int PORT=6787; //The default server port
public static final boolean LOG_ENABLED=false;
+ public static final String DEFAULT_IPCAMERA_APP_PACKAGENAME="com.pas.webcam";
}
diff --git a/AndroidExplorerbotServer/src/it/danieleverducci/explorerbotserver/MainActivity.java b/AndroidExplorerbotServer/src/it/danieleverducci/explorerbotserver/MainActivity.java
index 763c096..e29f9b7 100644
--- a/AndroidExplorerbotServer/src/it/danieleverducci/explorerbotserver/MainActivity.java
+++ b/AndroidExplorerbotServer/src/it/danieleverducci/explorerbotserver/MainActivity.java
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with AndroidExplorerbotServer. If not, see .
-*/
+ */
package it.danieleverducci.explorerbotserver;
@@ -23,10 +23,15 @@ import it.danieleverducci.explorerbot.objects.GamepadPosition;
import java.io.IOException;
import android.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
-public class MainActivity extends Activity implements OnControllerPolledListener {
+public class MainActivity extends Activity implements OnControllerPolledListener, OnClickListener {
private SerialCommunication serial;
+ private ServerNetworkCommunicationThread sct;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -37,10 +42,13 @@ public class MainActivity extends Activity implements OnControllerPolledListener
serial = new SerialCommunication(this);
//Start network communication server
- ServerNetworkCommunicationThread sct = new ServerNetworkCommunicationThread();
+ sct = new ServerNetworkCommunicationThread();
sct.setOnControllerPolledListener(this);
sct.start();
+ //Register interface buttons listener
+ findViewById(R.id.killserverbutton).setOnClickListener(this);
+ findViewById(R.id.startvideo).setOnClickListener(this);
}
@Override
@@ -56,6 +64,11 @@ public class MainActivity extends Activity implements OnControllerPolledListener
@Override
protected void onDestroy() {
+ //Terminate network thread
+ if(sct!=null && sct.isAlive()){
+ sct.setMustExit(true);
+ }
+ //Terminate serial connection to Arduino
if(serial!=null){
try {
serial.closeConnection();
@@ -66,4 +79,25 @@ public class MainActivity extends Activity implements OnControllerPolledListener
super.onDestroy();
}
+ @Override
+ public void onClick(View v) {
+ switch(v.getId()){
+ case R.id.killserverbutton:
+ finish(); //Finishing the activity, onDestroy will be called
+ break;
+ case R.id.startvideo:
+ launchStreamingApp();
+ break;
+ }
+ }
+
+ /**
+ * If the app is installed, start it. Otherwise, open the Android Market for download
+ */
+ private void launchStreamingApp() {
+ Intent launchIntent = getPackageManager().getLaunchIntentForPackage(AppConfiguration.DEFAULT_IPCAMERA_APP_PACKAGENAME);
+ if(launchIntent==null) launchIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + AppConfiguration.DEFAULT_IPCAMERA_APP_PACKAGENAME));
+ startActivity( launchIntent );
+ }
+
}
diff --git a/ArduinoExplorerbotSketch/explorerbot.ino b/ArduinoExplorerbotSketch/explorerbot/explorerbot.ino
similarity index 86%
rename from ArduinoExplorerbotSketch/explorerbot.ino
rename to ArduinoExplorerbotSketch/explorerbot/explorerbot.ino
index 20985a6..5a7082d 100644
--- a/ArduinoExplorerbotSketch/explorerbot.ino
+++ b/ArduinoExplorerbotSketch/explorerbot/explorerbot.ino
@@ -37,6 +37,7 @@ const int hBridge2pin = 10;
#include
Servo steeringServo;
byte gamepadPosition[2];
+byte missedUpdates=0;
void setup(){
steeringServo.attach(servoPin); //steering servo to pin 7
@@ -48,8 +49,16 @@ void setup(){
void loop(){
if(readGamepadPositionFromSerial()){
+ missedUpdates=0;
+ //If data ready, drive motors
steerTo(gamepadPosition[0]);
accelerateTo(gamepadPosition[1]);
+ } else {
+ //If data not ready for 5 times (500ms), stop the robot (for security reasons, e.g. the connection may be dropped)
+ missedUpdates++;
+ if(missedUpdates>5){
+ accelerateTo(63);
+ }
}
delay(100);
}
@@ -80,6 +89,6 @@ void accelerateTo(byte speedByte){
//speedByte = speedByte-64;
}
//analogWrite(hBridgeEnable, speedByte*2);
- if(speedByte<32 || speedByte>96) digitalWrite(hBridgeEnable, HIGH);
+ if(speedByte<47 || speedByte>79) digitalWrite(hBridgeEnable, HIGH);
else digitalWrite(hBridgeEnable, LOW);
}