-
Notifications
You must be signed in to change notification settings - Fork 557
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
Auto mission assistant #1538
Merged
m4gr3d
merged 8 commits into
DroidPlanner:release-3.1.7
from
TShapinsky:auto_mission_assistant
Jul 31, 2015
Merged
Auto mission assistant #1538
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
12eecf4
create first iteration of auto mission assistant
TShapinsky 8a8aefb
slim down auto mission assistant
TShapinsky 924fc24
rearrange Layout
TShapinsky 7f4696c
Merge branch 'release-3.1.7' of github.com:Droidplanner/Tower into au…
TShapinsky 8d36442
fix auto mission assistant to work with surveys and missions already …
TShapinsky bfd420d
todo make tooltip appear when marker selected
TShapinsky 705d5e5
prep auto mission assistant
TShapinsky 2ad0365
Merge branch 'release-3.1.7' of github.com:Droidplanner/Tower into au…
TShapinsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,92 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<TextView | ||
<LinearLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/ModeDetail" | ||
style="@style/ModeDetailText" | ||
android:background="@drawable/mode_desc_rectangle" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="@string/mode_auto"/> | ||
android:layout_height="match_parent" | ||
android:gravity="center_horizontal" | ||
android:orientation="vertical"> | ||
|
||
<TextView | ||
android:id="@+id/ModeDetail" | ||
style="@style/ModeDetailText" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:background="@drawable/mode_desc_rectangle" | ||
android:text="@string/mode_auto" /> | ||
|
||
<ProgressBar | ||
android:id="@+id/mission_progress" | ||
style="?android:attr/progressBarStyleHorizontal" | ||
android:layout_width="match_parent" | ||
android:layout_height="20dp" | ||
android:layout_marginBottom="10dp" | ||
android:animationResolution="@android:integer/config_shortAnimTime" | ||
android:indeterminate="false" | ||
android:max="100" | ||
android:progress="0" | ||
android:progressBackgroundTint="@android:color/holo_blue_dark" | ||
android:progressTint="@android:color/holo_blue_dark" /> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="48dp" | ||
android:layout_margin="5dp" | ||
android:background="@drawable/button_blue" | ||
android:gravity="center" | ||
android:orientation="horizontal"> | ||
|
||
<com.andexert.library.RippleView | ||
android:layout_width="80dp" | ||
android:layout_height="match_parent"> | ||
|
||
<ImageView | ||
android:id="@+id/mc_prev" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:clickable="true" | ||
android:scaleType="fitCenter" | ||
android:src="@drawable/ic_skip_previous_white_24dp" /> | ||
</com.andexert.library.RippleView> | ||
|
||
<com.andexert.library.RippleView | ||
android:layout_width="80dp" | ||
android:layout_height="match_parent"> | ||
|
||
<ImageView | ||
android:id="@+id/mc_pause" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:clickable="true" | ||
android:scaleType="fitCenter" | ||
android:src="@drawable/ic_pause_white_24dp" /> | ||
</com.andexert.library.RippleView> | ||
|
||
<com.andexert.library.RippleView | ||
android:layout_width="80dp" | ||
android:layout_height="match_parent"> | ||
|
||
<ImageView | ||
android:id="@+id/mc_restart" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:clickable="true" | ||
android:scaleType="fitCenter" | ||
android:src="@drawable/ic_replay_white_24dp" /> | ||
</com.andexert.library.RippleView> | ||
|
||
<com.andexert.library.RippleView | ||
android:layout_width="80dp" | ||
android:layout_height="match_parent"> | ||
|
||
<ImageView | ||
android:id="@+id/mc_next" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:clickable="true" | ||
android:scaleType="fitCenter" | ||
android:src="@drawable/ic_skip_next_white_24dp" /> | ||
</com.andexert.library.RippleView> | ||
</LinearLayout> | ||
|
||
</LinearLayout> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
158 changes: 155 additions & 3 deletions
158
Android/src/org/droidplanner/android/fragments/mode/ModeAutoFragment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,169 @@ | ||
package org.droidplanner.android.fragments.mode; | ||
|
||
import org.droidplanner.android.R; | ||
|
||
import android.app.Activity; | ||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.IntentFilter; | ||
import android.os.Bundle; | ||
import android.support.v4.app.Fragment; | ||
import android.support.v4.content.LocalBroadcastManager; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ProgressBar; | ||
|
||
import com.o3dr.android.client.Drone; | ||
import com.o3dr.android.client.apis.MissionApi; | ||
import com.o3dr.android.client.apis.VehicleApi; | ||
import com.o3dr.services.android.lib.drone.attribute.AttributeEvent; | ||
import com.o3dr.services.android.lib.drone.attribute.AttributeEventExtra; | ||
import com.o3dr.services.android.lib.drone.attribute.AttributeType; | ||
import com.o3dr.services.android.lib.drone.mission.Mission; | ||
import com.o3dr.services.android.lib.drone.property.VehicleMode; | ||
import com.o3dr.services.android.lib.model.AbstractCommandListener; | ||
|
||
import org.droidplanner.android.DroidPlannerApp; | ||
import org.droidplanner.android.R; | ||
import org.droidplanner.android.proxy.mission.MissionProxy; | ||
|
||
public class ModeAutoFragment extends Fragment implements View.OnClickListener{ | ||
public static final String WPNAV_SPEED = "WPNAV_SPEED"; | ||
private Drone drone; | ||
|
||
private static final IntentFilter eventFilter = new IntentFilter(); | ||
static{ | ||
eventFilter.addAction(AttributeEvent.MISSION_ITEM_UPDATED); | ||
eventFilter.addAction(AttributeEvent.PARAMETER_RECEIVED); | ||
eventFilter.addAction(AttributeEvent.GPS_POSITION); | ||
} | ||
private final BroadcastReceiver eventReceiver = new BroadcastReceiver() { | ||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
final String action = intent.getAction(); | ||
switch (action){ | ||
case AttributeEvent.MISSION_ITEM_UPDATED: | ||
mission = drone.getAttribute(AttributeType.MISSION); | ||
int currentMissionItem = intent.getIntExtra(AttributeEventExtra.EXTRA_MISSION_CURRENT_MISSION_ITEM, 0); | ||
nextWaypoint = intent.getIntExtra(AttributeEventExtra.EXTRA_MISSION_CURRENT_WAYPOINT, 0); | ||
mission.setCurrentMissionItem(currentMissionItem); | ||
break; | ||
case AttributeEvent.GPS_POSITION: | ||
remainingMissionLength = intent.getDoubleExtra(AttributeEventExtra.EXTRA_MISSION_REMAINING_DISTANCE, 0); | ||
updateMission(); | ||
break; | ||
} | ||
} | ||
}; | ||
private Mission mission; | ||
private int nextWaypoint; | ||
private ProgressBar missionProgress; | ||
private double remainingMissionLength; | ||
private boolean missionFinished; | ||
|
||
public class ModeAutoFragment extends Fragment { | ||
|
||
@Override | ||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | ||
return inflater.inflate(R.layout.fragment_mode_auto, container, false); | ||
} | ||
|
||
@Override | ||
public void onViewCreated(View view, Bundle savedInstanceState) { | ||
super.onViewCreated(view, savedInstanceState); | ||
view.findViewById(R.id.mc_pause).setOnClickListener(this); | ||
view.findViewById(R.id.mc_restart).setOnClickListener(this); | ||
view.findViewById(R.id.mc_next).setOnClickListener(this); | ||
view.findViewById(R.id.mc_prev).setOnClickListener(this); | ||
missionProgress = (ProgressBar) view.findViewById(R.id.mission_progress); | ||
} | ||
|
||
@Override | ||
public void onClick(View v) { | ||
if(mission == null){ | ||
mission = drone.getAttribute(AttributeType.MISSION); | ||
} | ||
switch(v.getId()){ | ||
case R.id.mc_pause: { | ||
drone.pauseAtCurrentLocation(); | ||
break; | ||
} | ||
case R.id.mc_restart: { | ||
gotoMissionItem(0); | ||
break; | ||
} | ||
case R.id.mc_next: { | ||
gotoMissionItem(mission.getCurrentMissionItem() + 1); | ||
break; | ||
} | ||
case R.id.mc_prev: { | ||
gotoMissionItem(mission.getCurrentMissionItem() - 1); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void onStart() { | ||
super.onStart(); | ||
LocalBroadcastManager.getInstance(getActivity().getApplicationContext()).registerReceiver(eventReceiver, eventFilter); | ||
} | ||
|
||
@Override | ||
public void onStop() { | ||
super.onStop(); | ||
LocalBroadcastManager.getInstance(getActivity().getApplicationContext()).unregisterReceiver(eventReceiver); | ||
} | ||
|
||
private void gotoMissionItem(final int waypoint){ | ||
if(missionFinished || waypoint == 0){ | ||
VehicleApi.getApi(drone).setVehicleMode(VehicleMode.COPTER_BRAKE, new AbstractCommandListener() { | ||
@Override | ||
public void onSuccess() { | ||
MissionApi.getApi(drone).startMission(true, true, new AbstractCommandListener() { | ||
@Override | ||
public void onSuccess() { | ||
MissionApi.getApi(drone).gotoMissionItem(waypoint,null); | ||
} | ||
|
||
@Override | ||
public void onError(int i) { | ||
|
||
} | ||
|
||
@Override | ||
public void onTimeout() { | ||
|
||
} | ||
}); | ||
missionFinished = false; | ||
} | ||
|
||
@Override | ||
public void onError(int i) {} | ||
|
||
@Override | ||
public void onTimeout() {} | ||
}); | ||
}else{ | ||
MissionApi.getApi(drone).gotoMissionItem(waypoint,null); | ||
} | ||
} | ||
|
||
|
||
|
||
private void updateMission(){ | ||
if(mission == null) | ||
return; | ||
MissionProxy proxy= ((DroidPlannerApp)getActivity().getApplication()).getMissionProxy(); | ||
double totalLength = proxy.getMissionLength(); | ||
missionProgress.setMax((int) totalLength); | ||
missionProgress.setProgress((int) ((totalLength - remainingMissionLength))); | ||
missionFinished = remainingMissionLength < 5; | ||
} | ||
|
||
@Override | ||
public void onAttach(Activity activity) { | ||
drone = ((DroidPlannerApp)activity.getApplication()).getDrone(); | ||
super.onAttach(activity); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TShapinsky the
LinearLayout
children should have thelayout_weight
attribute so they can stretch to fill out all the space within their parent is necessary.