Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring back kill switch #1511

Merged
merged 6 commits into from
Jul 9, 2015
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies {
compile 'com.android.support:cardview-v7:22.1.0'
compile 'com.android.support:recyclerview-v7:22.1.0'

compile 'com.o3dr.android:dronekit-android:2.3.32'
compile 'com.o3dr.android:dronekit-android:2.3.34'

compile 'me.grantland:autofittextview:0.2.1'
compile(name:'shimmer-android-release', ext:'aar')
Expand Down
16 changes: 3 additions & 13 deletions Android/res/menu/menu_super_activiy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,12 @@
android:id="@+id/menu_download_mission"
app:showAsAction="never"
android:title="@string/download_mission"/>

<item
android:id="@+id/menu_advanced"
android:id="@+id/menu_kill_switch"
app:showAsAction="never"
android:enabled="false"
android:visible="false"
android:title="@string/pref_advanced"
app:showAsAction="never">
<menu>
<item
android:id="@+id/menu_kill_switch"
app:showAsAction="never"
android:enabled="false"
android:visible="false"
android:title="KILL SWITCH"/>
</menu>
</item>
android:title="Kill Switch"/>

</group>

Expand Down
2 changes: 1 addition & 1 deletion Android/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@
<string name="file_saved_success">Datei gespeichert</string>
<string name="firmware_version">Firmware-Version</string>
<string name="help_item_description">Wie man eine Mission plant und fliegt</string>
<string name="label_advaned">Erweitert</string>
<string name="label_advanced">Erweitert</string>
<string name="label_altitude_step">Höhenschritt</string>
<string name="label_enter_filename">Dateinamen eingeben</string>
<string name="label_steps_count">Anzahl Schritte</string>
Expand Down
2 changes: 1 addition & 1 deletion Android/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@
<string name="file_saved_success">File salvato</string>
<string name="firmware_version">Versione Firmware</string>
<string name="help_item_description">Come pianificare e avviare una missione</string>
<string name="label_advaned">Avanzate</string>
<string name="label_advanced">Avanzate</string>
<string name="pref_title_mapbox">Preferenze MapBox</string>
<string name="pref_tts_periodic_alt">Altezza</string>
<string name="pref_tts_periodic_bat_volt">Voltaggio batteria</string>
Expand Down
2 changes: 1 addition & 1 deletion Android/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@
<!-- Help -->
<string name="help_item_description">如何规划和执行飞行任务</string>

<string name="label_advaned">高级设定</string>
<string name="label_advanced">高级设定</string>
<string name="label_steps_count">步数</string>
<string name="label_altitude_step">高度级别</string>
<string name="menu_search_toggle">切换搜索</string>
Expand Down
2 changes: 1 addition & 1 deletion Android/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@

<!-- Help -->
<string name="help_item_description">如何設定和實際操作任務,請點我看影片</string>
<string name="label_advaned">進階設定</string>
<string name="label_advanced">進階設定</string>
<string name="label_steps_count">階層數</string>
<string name="label_altitude_step">階層高度</string>
<string name="menu_search_toggle">切換搜尋</string>
Expand Down
4 changes: 2 additions & 2 deletions Android/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@
<!-- Help -->
<string name="help_item_description">How to plan and fly a mission</string>

<string name="label_advaned">Advanced</string>
<string name="label_advanced">Advanced</string>
<string name="label_steps_count">Number of Steps</string>
<string name="label_altitude_step">Altitude Step</string>
<string name="menu_search_toggle">Toggle Search</string>
Expand Down Expand Up @@ -546,7 +546,7 @@
<string name="pref_map_rotation_title">Enable map rotation</string>
<string name="pref_map_rotation_summary">Check to enable the ability to rotate the map.</string>
<string name="pref_advance_menu_title">Advanced Menu Options</string>
<string name="pref_enable_kill_switch_summary">If enabled, a Kill Switch option will appear under the Advanced section in the menu, allowing to disarm the vehicle immediately.</string>
<string name="pref_enable_kill_switch_summary">If enabled, a Kill Switch option will appear in the menu, allowing immediate vehicle disarming.</string>
<string name="pref_enable_kill_switch_title">Enable Kill Switch</string>
<string name="pref_enable_udp_server_title">Enable UDP server ping</string>
<string name="pref_udp_server_ping_summary">Enable to allow the app to periodically ping the udp server.</string>
Expand Down
3 changes: 1 addition & 2 deletions Android/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@

</PreferenceCategory>

<!-- Disabling kill switch until arducopter v3.3 is out.
<PreferenceCategory
android:title="@string/pref_advance_menu_title">

Expand All @@ -307,7 +306,7 @@
android:summary="@string/pref_enable_kill_switch_summary"
android:title="@string/pref_enable_kill_switch_title"/>

</PreferenceCategory>-->
</PreferenceCategory>
</PreferenceScreen>
</PreferenceCategory>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
import android.view.MenuItem;

import com.o3dr.android.client.Drone;
import com.o3dr.android.client.apis.drone.DroneStateApi;
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent;
import com.o3dr.services.android.lib.drone.attribute.AttributeType;
import com.o3dr.services.android.lib.drone.property.Type;
import com.o3dr.services.android.lib.drone.property.VehicleMode;

import org.droidplanner.android.DroidPlannerApp;
import org.droidplanner.android.R;
Expand All @@ -40,7 +44,6 @@ public abstract class SuperUI extends AppCompatActivity implements DroidPlannerA
static {
superIntentFilter.addAction(AttributeEvent.STATE_CONNECTED);
superIntentFilter.addAction(AttributeEvent.STATE_DISCONNECTED);
superIntentFilter.addAction(SettingsFragment.ACTION_ADVANCED_MENU_UPDATED);
}

private final BroadcastReceiver superReceiver = new BroadcastReceiver() {
Expand All @@ -55,10 +58,6 @@ public void onReceive(Context context, Intent intent) {
case AttributeEvent.STATE_DISCONNECTED:
onDroneDisconnected();
break;

case SettingsFragment.ACTION_ADVANCED_MENU_UPDATED:
supportInvalidateOptionsMenu();
break;
}
}
};
Expand Down Expand Up @@ -175,12 +174,6 @@ public boolean onCreateOptionsMenu(Menu menu) {
menu.setGroupEnabled(R.id.menu_group_connected, true);
menu.setGroupVisible(R.id.menu_group_connected, true);

final boolean isAdvancedEnabled = mAppPrefs.isAdvancedMenuEnabled();
final MenuItem advancedSubMenu = menu.findItem(R.id.menu_advanced);
advancedSubMenu.setEnabled(isAdvancedEnabled);
advancedSubMenu.setVisible(isAdvancedEnabled);

//Enable specific sub items within the advanced menu section.
final MenuItem killSwitchItem = menu.findItem(R.id.menu_kill_switch);
final boolean isKillEnabled = mAppPrefs.isKillSwitchEnabled();
killSwitchItem.setEnabled(isKillEnabled);
Expand Down Expand Up @@ -256,7 +249,20 @@ public void onNo() {
SlideToUnlockDialog unlockDialog = SlideToUnlockDialog.newInstance("disable vehicle", new Runnable() {
@Override
public void run() {
dpApp.getDrone().arm(false);
/* If the vehicle is a Copter running a firmware older than 3.3,
set the vehicle to stabilize. Otherwise, leave the mode alone.
Then send the emergency disarm command.
*/
Drone drone = dpApp.getDrone();
Type droneType = drone.getAttribute(AttributeType.TYPE);
if(droneType !=null){
if(droneType.getDroneType() == (Type.TYPE_COPTER) &&
!droneType.getFirmwareVersion().startsWith("APM:Copter V3.3") &&
!droneType.getFirmwareVersion().startsWith("APM:Copter V3.4")){
DroneStateApi.setVehicleMode(drone, VehicleMode.COPTER_STABILIZE);
}
}
DroneStateApi.arm(drone, false, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That logic is now up in the develop branch for 3DR Services.

}
});
unlockDialog.show(getSupportFragmentManager(), "Slide to use the Kill Switch");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ public class SettingsFragment extends PreferenceFragment implements OnSharedPref
public static final String ACTION_LOCATION_SETTINGS_UPDATED = PACKAGE_NAME + ".action.LOCATION_SETTINGS_UPDATED";
public static final String EXTRA_RESULT_CODE = "extra_result_code";

public static final String ACTION_ADVANCED_MENU_UPDATED = PACKAGE_NAME + ".action.ADVANCED_MENU_UPDATED";

/**
* Used to notify of an update to the map rotation preference.
*/
Expand Down Expand Up @@ -261,17 +259,6 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
}
});
}

final CheckBoxPreference killSwitch = (CheckBoxPreference) findPreference(DroidPlannerPrefs.PREF_ENABLE_KILL_SWITCH);
if(killSwitch != null) {
killSwitch.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
lbm.sendBroadcast(new Intent(ACTION_ADVANCED_MENU_UPDATED));
return true;
}
});
}
}

private void setupUnitSystemPreferences(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,6 @@ public boolean isMapRotationEnabled(){
return prefs.getBoolean(PREF_ENABLE_MAP_ROTATION, DEFAULT_ENABLE_MAP_ROTATION);
}

public boolean isAdvancedMenuEnabled(){
return isKillSwitchEnabled();
}

public boolean isKillSwitchEnabled(){
return prefs.getBoolean(PREF_ENABLE_KILL_SWITCH, DEFAULT_ENABLE_KILL_SWITCH);
}
Expand All @@ -433,6 +429,7 @@ public int getMaxAltitude(){
return getAltitudePreference(PREF_ALT_MAX_VALUE, DEFAULT_MAX_ALT);
}


/**
* @return the min altitude in meters
*/
Expand Down