|
ugmeytt2tp3640349109.gif
' q4 A7 u( D7 r. ?
点击上方蓝色字体,关注我们
- i& N' a- w q$ U" J, j6 g5 w
6 l; S1 X4 A( G
6 z9 @! p& {9 _第三篇文章准备单独拿出来写,因为在大疆为人机的所有功能中,航线规划的功能最为复杂,也相当的繁琐,这里需要说仔细一点,可能会将代码进行多步分解。4 ~4 _4 |, ?. N) G
1
0 V% _! t1 m- T R: Z航线规划9 J3 }6 C* Q- j8 ]' U. I2 M
航线打点 7 Q# l4 L' V/ Y7 j
# K; y0 S" z/ D& r# Z: E在地图中手动选择点位选择完成航线打点;若打点位置错了可进行点位删除。% [" E5 ?# q8 J; { I. H0 B
0t5y504ypvo640349209.png
) E% K) \+ m7 H" @- u1 \" ?/ D- k7 g( H# W
航点设置 : r' m% J. y6 z$ Q; q
8 k% E- X* V0 ^9 h( [可对航线点位进行设置,如飞行高度,速度(慢速:3m/s;中速: 7m/s;高速:10 m/s)、任务结束后操作及航向,点击[设置]按钮完成设置。* c4 D' z+ e+ `& S2 ]; U4 W
2aevnqbz3vn640349309.png
4 |- B. |, {9 e; n; r7 p设置完成后会显示总距离及飞行总时间。1 |9 A0 n8 @) N8 K: p& J. `: x
qrbujj1efjc640349410.png
% d( m+ C J# ~/ V; Y6 `5 C j
! z9 [. R+ K1 \4 n# I4 m) j航线上传
9 H. r1 p" Q: ?+ F; j% I$ B! q/ L1 @) K4 j0 C; Z8 {% }6 B }
点击[上传]按钮,进行航线上传。可以进入本地存储中选择航线文件进行上传,航线文件为 .kml结尾。3 M" y1 l/ H$ a" r
me2wru3akkh640349510.png
/ w: j% |2 ~. u& K0 Z" o! ^+ A$ ~- S7 H/ E
航线执行 1 t7 ^9 b/ |8 z
; N3 i E. h/ F. S) r点击 [开始]按钮,则可对航线进行执行。若中途需要暂停也可点击[暂停]安装进行暂停操作。
: s7 N9 O/ _ k& [ X3 p, B
xscqcxw5atv640349610.png
# t [0 S" c) B/ _2 S: M2 a! N% @7 G/ m$ P! _* s
航线管理
* z7 i6 o5 |7 ^1 ]
( g. a# I! ~ k按钮即可进入航线管理界面。
* A' \" _5 u D1 ]" l9 O5 r4 I, f8 ? l# s' I1 M
ovfdczahavi640349710.png
. f6 a e0 I* ~& n
# l, ^2 w, G4 y0 n& F4 U获取航线 / \ B' C" S0 d J" H
G, D0 f' U3 k
点击[获取]按钮,即可将航线信息展示到地图界面中。- M5 |" Q6 L8 Q l# ~( h$ E4 U1 l& u5 _
% J; k# e \2 T, e0 b/ F9 F. \9 H- F
! |; L3 c0 C. z9 n2. `& D# _* c+ y. ~. V" v
主要功能代码
. G+ z" Y8 b6 \7 {. o6 x创建activity_setting_route.xml及SettingRouteActivity文件。/ ?- A9 ~7 ?6 n# k% P9 ~! e- T
; R7 K3 v4 W; @( j
4 C$ r* \( f' v" N4 jactivity_setting_route.xml6 g- ^5 A/ `* v4 f
8 W/ Y# H+ R) {; j" q' _Linearlayout xmlns:android="http://schemas.android.com/apk/res/android"
0 q. F- a: ~+ S# {' T xmlns:app="http://schemas.android.com/apk/res-auto"* }, B" |, c! S& [% B
xmlns:tools="http://schemas.android.com/tools"
3 T( @" b% N) M7 x android:layout_width="match_parent"( D. ]/ T; @' n- v- d
android:layout_height="match_parent"
/ q/ r. ?! [# S x1 p3 V- h android:orientation="vertical": m& p& k% Q, b7 |" @1 z. Y V
tools:context=".ui.SettingRouteActivity">
9 e6 A% J& k. [; k include. s* s& @6 [" y" e0 P3 j% s
android:id="@+id/layout_route"( h. v3 q2 g& z2 _' h8 ~2 Q
layout="@layout/activity_toolbar">include>7 S" y& [# t$ M
RelativeLayout
- E+ O2 \9 F6 B' G( p- l5 a android:layout_width="match_parent"9 }7 d8 b/ B$ a$ ?$ R6 e/ R
android:layout_height="match_parent">/ B1 m; t2 J4 z! t- Q% T, [) M' s( a2 O
com.amap.api.maps.MapView
9 J# a! y* V7 Q android:id="@+id/map"
: h6 c# I0 A0 y' {0 q$ _ android:layout_width="match_parent"! ]( A3 g! v- P2 p6 y" S
android:layout_height="match_parent" />
9 d2 c7 u( N% J2 O LinearLayout
$ S$ w/ o$ g5 B$ [7 M5 w4 q android:layout_width="wrap_content"
2 {9 B4 d3 |3 Z android:layout_height="wrap_content"! J W5 ^- k* V, |3 x$ }5 ^, m6 k- @+ s
android:layout_alignParentTop="true"" U o& O, g9 J/ Q! U( o0 ^
android:layout_centerInParent="true"
/ a, t& H7 m3 S9 i' g: ` android:layout_marginTop="5dp">4 n$ Q; n$ c% S( S/ t
Button
! n: s: S4 }4 l" S8 c$ `3 s android:id="@+id/btn_delete"
' T0 {: C7 e) \ android:layout_width="60dp"/ F. Y7 H7 D+ y. Z, J
android:layout_height="30dp"
& h9 ~/ u+ }( F6 R6 z k" n9 K* j android:visibility="gone"
5 v! f& N: [" z4 L android:text="删除"
' `, y$ {2 H" {: E* J% ~ android:textColor="@color/white"
3 r) d( o% d( [% u) ^8 @ android:background="@drawable/button_task_background">Button>
3 V8 B2 r8 w! @0 a Button
, O( k% R9 ^" P, S1 ^ android:id="@+id/btn_finish"
7 \: ^/ }# r8 [' V ^ n2 M android:layout_width="60dp"
1 p& }) Y0 ?0 X6 [ android:layout_height="30dp"
F) j. _% U" ` android:visibility="gone"% W3 c. C& ]" X l/ Q5 l
android:textColor="@color/white"
@ g# i- p# G, ]9 u: Z8 t android:background="@drawable/button_task_background"
2 X" t. Y+ i- q( m android:text="完成">Button>
- ]# S3 X8 I/ { Button
+ x# Z' e' E2 i! h$ M4 q android:id="@+id/btn_setting"6 q) i' ~* M* Y' ~
android:layout_width="60dp"
8 \- @* N# ^# m$ D android:layout_height="30dp"
3 e6 t1 \1 H# ]* a/ Y android:visibility="gone"( D# W6 j4 w1 s% Q" G( ~; A$ {
android:textColor="@color/white"8 K6 q5 f+ t2 U- f# Q
android:background="@drawable/button_task_background" `1 E4 o! e/ M5 p8 W
android:text="设置">Button>
# c: K2 }( V. K7 | Button
$ ]* n; t: l; |1 P- P1 E. O android:id="@+id/btn_upload"- |3 h9 r2 r4 q* j# N3 P0 |' `* l
android:layout_width="60dp"$ y4 j; e5 L3 A2 V
android:layout_height="30dp"
0 e0 `8 q6 u8 E& l3 b" Z9 T android:visibility="gone"
$ r+ c: T* M& G, ]& j' d7 {2 J android:textColor="@color/white"' p U$ p( i- T9 R% ]3 R
android:background="@drawable/button_task_background"
- Q# V' g2 y" {0 C/ C7 O android:text="上传">Button>
# q- k* `1 l, |3 C. s) n7 t5 Z- ` Button
( z1 ^" Z3 e" ]! G b android:id="@+id/btn_start"0 w/ ~" P2 i5 e ?4 A
android:layout_width="60dp"
6 P; M+ v0 a) E; W5 A+ j android:layout_height="30dp" o) C- N/ }, T- u) d
android:visibility="gone") v7 c" N- S: v7 L* e( D. ~3 Z9 F
android:textColor="@color/white"
* @! ^3 z0 U2 w android:background="@drawable/button_task_background"' ^2 R$ y1 ~( o6 k4 t- C# E7 G
android:text="开始">Button>
' I2 a; D1 M* s+ q5 D/ y' b; I Button& o4 x: ~, ]8 ^7 Y
android:id="@+id/btn_stop"
5 s) a* @ d& A$ f% g' ~. E android:layout_width="60dp"
- g& l1 x+ I1 Z- }2 n0 _& A android:layout_height="30dp"
4 p O: P+ I4 i' K5 {: C) ^' m android:visibility="gone"
m+ b% g) b8 w4 p* O- r) A android:textColor="@color/white"
# ]4 v2 V2 ^- J9 y android:background="@drawable/button_task_background"
& `" d8 {$ S- e android:text="暂停">Button>/ n7 f f# P3 B" |! Y' v
LinearLayout>
: q' [- t& X+ Q LinearLayout4 Y* e# J. _* I) `: f! a
android:id="@+id/ll_information"" G9 N* P% U0 T
android:layout_width="wrap_content"; y: w; R# r: [6 v3 j
android:layout_height="wrap_content"# y2 p [. A: v; o5 h
android:layout_alignParentBottom="true"
6 ~- n: n9 s1 t' Q android:layout_centerInParent="true"
/ e \! Q- q% ?* b) X* [- F/ I7 ^2 V android:layout_marginBottom="5dp"
9 |% V& X8 Z; d* y, |: a$ m9 m; u$ a android:padding="10dp"
4 H9 E) m6 u' ]3 y; k- T6 G' m android:visibility="gone"
! \; S) j' T* t c' r: ^( i9 W android:background="@color/color_nav_Item_unselected">+ J/ M! A4 ]# @/ K; Y
TextView. `% }/ A: J3 u- y
android:id="@+id/tv_height"
( m2 A8 _4 n& ^" E1 e6 [6 V4 ^2 I android:layout_width="wrap_content"
$ _" }/ \+ _$ L4 `' p% p android:layout_height="wrap_content"+ L% J( T1 q7 Y" n7 ~) R
android:text="高度:"' o& j" ?5 Z$ B3 s ]0 f) U3 \6 q. g; C! C
android:textColor="@color/white"
' [+ F5 _$ c% c# D1 o >TextView>. W( `; N1 h$ J. ^" f0 X
TextView. o( o7 K- [5 {9 T. v3 F
android:id="@+id/tv_speed"
I" `2 p s. r$ }$ g% B android:layout_width="wrap_content"
# S# N; ]0 `, ^ android:layout_height="wrap_content"
# t3 s/ m9 n) |$ C) T" ` i, S android:text="速度:"
! M- f- U8 F0 J9 e" o: M2 z! R android:textColor="@color/white"/ v' c& _/ w0 X4 U& h
android:layout_marginLeft="10dp"- M5 w5 ]9 t% _+ |# [& ? B2 \
>TextView>
- n1 T7 i& o! |& X; [3 U% ], F TextView, K" Y' N. d$ _) G3 R' s5 [. k
android:id="@+id/tv_count"
4 S1 F% r6 N% i" j- S android:layout_width="wrap_content"
# X* K* ~$ A, s, [) i android:layout_height="wrap_content"* d- A* m2 ]+ y) z p; M0 W1 I
android:text="航点数:"! j$ ?$ t8 ` B
android:textColor="@color/white"
# W5 p: R, z# W; m7 a7 ^/ I9 }% G android:layout_marginLeft="10dp"4 J+ C6 ~9 G% v7 a
>TextView>
Z. `* R e+ B$ I( I; ` TextView3 v1 ?$ `6 g( E2 U, }( I
android:id="@+id/tv_distance"4 o8 z. C/ M. _% D2 ]/ d* N
android:layout_width="wrap_content"
" Z& m# d, L/ A' G0 O7 x android:layout_height="wrap_content"
$ u2 ~- W+ Z9 C# y android:text="总距离:"
, x9 _2 ?( w- `; |/ v1 U3 G. J1 }' D android:textColor="@color/white"
/ F; q5 L! _/ N. H android:layout_marginLeft="10dp"0 n6 }( W" U' I0 T
>TextView>
; Y4 H e6 i O: j9 w3 _! p) }$ s TextView- |3 x3 l* g- c2 U1 \
android:id="@+id/tv_time"
: A3 d% T2 P) J3 D. I2 i# M' s android:layout_width="wrap_content"
0 k0 l+ e# X* n# |! P: T android:layout_height="wrap_content"
* ]" L% `/ z9 K5 A6 Q2 f- a& | android:text="总时间:"
- A+ ]3 m4 ]* K' q android:textColor="@color/white"8 A u3 G! h0 j( ]
android:layout_marginLeft="10dp"
J- D6 o* ^1 l/ e3 I5 A3 M- u >TextView># _3 N+ P' `) L0 d p
LinearLayout>0 C P; F3 x I B% t4 t2 Q
RelativeLayout>. o. n2 i( A/ K2 V/ h
LinearLayout>
, B! u/ E0 j6 b2 S, tSettingRouteActivity
& Y+ U& S8 q+ Q0 p' l
& w4 @/ n# T; j% W: _! W5 B. apublic class SettingRouteActivity extends BaseActivity implements AMap.OnMarkerClickListener, View.OnClickListener, AMap.OnMapClickListener, LocationSource, AMapLocationListener, AMap.InfoWindowAdapter {* g1 \2 v ~/ l3 K
@BindView(R.id.layout_route)5 ?" ]: l# @9 d4 r$ m) Y+ _- W2 N
View mViewLayoutToolbar;8 S4 y. [$ j& C: ?/ M: v4 T% ?
@BindView(R.id.ll_route)+ I2 r6 o- D- T* Y4 F7 n0 `
LinearLayout mLinearLayout;+ Y* h: v; r3 w% t7 F) M; b
@BindView(R.id.tv_toolbar_title), Q& X/ N4 }! [
TextView mTextViewToolbarTitle;
; `+ D( j& T1 J7 b5 a6 v: Y // @BindView(R.id.map)
0 D, @8 }( ~- d0 i // MapView mMapView;0 Z2 S. `% n1 [" a3 @/ v
@BindView(R.id.btn_delete)/ u7 B; A" w; s3 P2 X- Y, n& k
Button mButtonDelete;( W% n: V+ Y0 \' V; b# ?+ H! h
@BindView(R.id.btn_finish)
" }! k4 c: x! `- Q- i6 e Button mButtonFinish;$ x) A" J- Q1 K4 v [# s, Q
@BindView(R.id.btn_setting)
% ?: h* c! l5 M* F; H Button mButtonSetting;
7 F% s6 c# h! ] @BindView(R.id.btn_upload)
- T5 \' H/ f% h' c U Button mButtonUpload;
4 B: T5 O; k" _0 n$ b& @ @BindView(R.id.btn_start)# G9 A" G$ Q! t
Button mButtonStart;
1 i, _4 ^2 I' Q; J& Z, r @BindView(R.id.btn_stop)1 w5 b! U' B4 W4 \( \
Button mButtonStop;3 e7 d. c1 Q+ ` r/ K, j/ H g% e
@BindView(R.id.ll_information)0 r+ |# X/ D( K( r. ^: l8 R. O- w3 t
LinearLayout mLinearLayoutInformation;
( s6 m; U4 p% l8 w( `+ j @BindView(R.id.tv_height)$ s/ f) V1 J8 M P
TextView mTextViewHeight;( T5 G! W* F) Y& ~ C1 B& G
@BindView(R.id.tv_speed)
4 x6 F" r: S! R8 @ TextView mTextViewSpeed;
' N, t; `" c: N, N, R% ? @BindView(R.id.tv_count)
) f3 N' s9 l4 {! P- r TextView mTextViewCount;: X$ P: X) I) [3 H
@BindView(R.id.tv_distance)# X0 C3 X( _4 u s! H0 ~( f
TextView mTextViewDistance;
( H3 q9 }* V$ ^2 Q8 V @BindView(R.id.tv_time)+ a, P7 W. } N. x
TextView mTextViewTime;9 _. I- L8 x% k# P
private MapView mMapView;/ q. ?% J3 v8 t7 W
private OnLocationChangedListener mListener;7 b6 c8 X. l- r$ ?8 V* @
private AMapLocationClient mlocationClient;
! V% D9 K9 d5 Y/ W& h private AMapLocationClientOption mLocationOption;
' N; u+ c4 q% W5 f private double D_latitude, D_longitude;
! n- ~# a, m* j! y- g* a private UiSettings mUiSettings;- m( ^- u: g. J3 W6 D3 Z
private AMap aMap;
" z+ s1 s, F7 f private Marker droneMarker = null;: C, N4 s& j2 P9 L
private float altitude = 100.0f;
% U& N1 w9 m; t: N# u: {5 [ private float mSpeed = 10.0f;* V2 b6 w- A; S# k' r
private boolean isAdd = false;/ X% l+ p) l- U: T( _
private final Map[I] mMarkers = new ConcurrentHashMap[I]();/ r; U; ]/ I- v5 P
private Marker mClickMarker; b7 C8 N6 { t8 P9 U- F$ _9 ]
private List waypointList = new ArrayList();
. W2 G0 O& b7 T, X- d6 [8 {7 [ private List mLatLng = new ArrayList();
4 P* T9 m* h; m" C* d+ e% @ private List mPointInfo = new ArrayList();
- h3 n- }5 k- \# W& i3 O/ u public static WaypointMission.Builder waypointMissionBuilder;
( E9 g7 r% w- ?; a, A! N private FlightController mFlightController;1 ~: k2 D- d+ d" F7 z! K" U6 b3 s9 D$ W
private WaypointMissionOperator instance;
0 E2 n) V1 l/ }' e private WaypointMissionFinishedAction mFinishedAction = WaypointMissionFinishedAction.NO_ACTION;
+ S$ ~2 L4 t! l3 _1 s* s* N7 G private WaypointMissionHeadingMode mHeadingMode = WaypointMissionHeadingMode.AUTO;
7 g! u; w9 v% x+ w- S5 j private SQLiteHelper mSQLiteHelper;5 a% G( a m/ E5 G3 u
private String FinishedAction, HeadingMode;( r7 K- c) G9 l r" f; n
//自定义窗体
5 d( }# S9 J9 w9 t# S7 i View infoWindow = null;
$ Q; V0 \: l3 \0 ?7 o- w, U int speed_RG_id = 0;
1 I& h9 z: B2 M1 B8 e" Q# v/ Z int actionAfterFinished_RG_id = 0;
+ Q* S' R3 ?/ t. u$ w$ Q3 V' s' n int heading_RG_id = 0;/ G# ^6 u/ n% ~6 `; Q
//kim2 S$ H1 u3 o9 u9 I2 n
static ReadKml readKml = new ReadKml();
% J6 Q) |4 @0 [ P5 B9 ?8 [ private static List sampleList = readKml.getCoordinateList();
1 R1 g+ D% V, O V: M @Override# m2 h8 u3 A( t' h. ^
public void initViews() {1 ?) z- F% T1 X4 j/ y$ w
mLinearLayout.setVisibility(View.VISIBLE);
0 k! F) Z( x) a* k: @4 y# L mTextViewToolbarTitle.setText("航线规划");
) y6 I( l! F, |9 A. j7 u, [ IntentFilter filter = new IntentFilter();4 N1 u2 n! B8 b; `( x5 U2 c7 }# H4 X9 H
filter.addAction(ReceiverApplication.FLAG_CONNECTION_CHANGE);' R+ c) |! O+ s
registerReceiver(mReceiver, filter);
. l/ }$ x# d% R9 o& c mMapView = findViewById(R.id.map);) K7 e/ d/ G" Q
mMapView.onCreate(InstanceState);
% _, W# Y, _3 @7 p& H+ b initMapView();( C& R2 i6 Y2 ^/ Y: q) M r* @ s
addListener();8 h$ j' s1 j4 X' @2 [
onProductConnectionChange();
8 j* X- n+ \; H# R# X$ Q& @8 a }
: b) k% U% j& Y) o' g+ r @Override
; U. z% F; e @! R" H protected void onResume() {
, A$ ?$ k- w9 m+ C9 D' D$ j2 ?. n super.onResume();) l8 L. w) r3 v" d1 s# N# \" l
initFlightController();/ ]6 @5 @/ P. D* K) o8 o
mMapView.onResume();
u/ o: A* V4 k% O- R+ i }: y0 f7 z0 X& i7 M4 @7 D+ R
/**
; Y/ `# H5 K* L# c4 s7 Z- ~ * 方法必须重写2 F$ F% b& X2 i0 a4 [
*/
3 V1 r: c* K3 E, M) f `# y @Override0 o9 r; ]5 c# a3 Y9 e/ e/ r" V, F
protected void onSaveInstanceState(Bundle outState) {
/ n4 {" Q. \( \7 J; w' z' p super.onSaveInstanceState(outState);
# J/ ^: Z; F# H( G& k1 w2 M mMapView.onSaveInstanceState(outState);
, N' s" p8 O* t+ {4 o+ [' V/ U }: w" L( B" n. e; ]9 g2 i- T9 e$ V
@Override* w) i" q0 _# u8 C+ v5 I& y* m% f
protected void onPause() {
- v9 s) b4 V( K: }( e super.onPause();
4 S- ~ u( i0 M8 P7 T mMapView.onPause();9 o! S7 _( X" n5 {* E
deactivate();
9 C v* B) N9 u; C }
5 L1 [9 J- [9 S) S6 _ @Override
7 b9 F/ U: p. D- _! Z* p/ ]7 q( R protected void onDestroy() {" I' f3 R( u: |; T# w
super.onDestroy();5 l$ {" Q5 ?5 k- o
unregisterReceiver(mReceiver);
: ?5 W! Y/ L& K) m5 K5 N* g" c& { removeListener();
|7 \) t- U; _ mMapView.onDestroy();
$ D+ ]0 M. v+ ~) S2 z6 V( { if (null != mlocationClient) {; C' _5 R: ]1 @
mlocationClient.onDestroy();5 D% y+ r. G" U$ n- N) p- d* Q
}/ L5 B5 L, O6 g7 G. I- r, Y8 ], j
}
$ S+ U2 `+ l n0 r& ~8 a [# e @Override
9 d+ B( [ |3 ?3 G l4 m public void initDatas() {# ~7 i2 b5 I5 b# E4 Q4 h% T; c. }, |
}8 j" I5 r5 O" T5 V z* o
@Override# Y3 X( B' |0 ^' b) _$ {
protected void requestData() {' ?- N- m- a) M/ g5 E: Y. r: ~
}
( L2 R7 Z' \/ j' m; x private void initMapView() {4 }( b2 t% c. P& d, Z
if (aMap == null) {
+ E% }2 W( F, j v' H7 H3 d aMap = mMapView.getMap();
$ H- G+ x2 f5 {4 [ mUiSettings = aMap.getUiSettings();6 U3 L3 y* v* i. p
mUiSettings.setMyLocationButtonEnabled(true);
4 O4 O" k' I" k mUiSettings.setScaleControlsEnabled(true);" ^! y% f5 l* E4 q6 s6 M3 I. {
aMap.setOnMapClickListener(this);// add the listener for click for amap object
7 u9 Y# B( @2 a/ ^, p9 a/ R aMap.setLocationSource(this);7 Q N# I0 M0 n/ }1 Z% z- ]
aMap.setMyLocationEnabled(true);- i, b# J2 q- P$ a3 R& H$ X
aMap.setInfoWindowAdapter(this);
1 Z" r! ]- B$ b' N% Q& K aMap.setOnMarkerClickListener(this);; Y# l+ Z/ i i, L' M) c0 O
setupLocationStyle();# a N `$ v8 O4 u% F U
}
+ |# T4 y. o$ @: _ }
* v% J1 z- n/ i7 F# J! k6 p private void setupLocationStyle() {
7 ]) I/ X& R- r: m$ w) l2 }' F // 自定义系统定位蓝点
2 f; z* `8 }% T; N; L" f MyLocationStyle myLocationStyle = new MyLocationStyle();
' s% G( T; {, s: B // 自定义定位蓝点图标
8 M- D ]; W `% H% Y- w7 M# p myLocationStyle.myLocationIcon(BitmapDescriptorFactory.1 \; m( v a6 L- j3 l" R5 ]
fromResource(R.mipmap.icv_gps_point_36dp));1 t$ i! d8 c7 }# p ^1 K- I
// 自定义精度范围的圆形边框颜色: A7 U# ?1 I, t
myLocationStyle.strokeColor(Color.parseColor("#00000000"));
& y# p& N* h( m) L) d0 R //自定义精度范围的圆形边框宽度
. O3 C2 F: d4 F" ~- B- R$ O8 X myLocationStyle.strokeWidth(5);' W1 j5 ?$ ?8 `5 ?: [! e8 z
// 设置圆形的填充颜色
+ x( ^& Y7 s# _! @7 x# S myLocationStyle.radiusFillColor(Color.parseColor("#00000000"));9 V2 o& ]0 h# t8 C
// 将自定义的 myLocationStyle 对象添加到地图上
& c( P" k& S/ r( e aMap.setMyLocationStyle(myLocationStyle);
8 I0 S2 ^0 G: E1 A# r7 D5 G }
, J& Q. e5 i+ h( q c4 y @OnClick({R.id.img_kml_input, R.id.img_setting_route, R.id.img_start_fly, R.id.btn_delete,
: k0 H: n6 `$ ] h2 R R.id.img_setting_clear, R.id.btn_finish, R.id.btn_setting, R.id.btn_upload,/ b3 U* U4 i3 C( ^% L J( G: A
R.id.btn_start, R.id.btn_stop, R.id.img_back})' m$ r8 `, }6 Z8 v0 h
@Override# A7 E+ W! k' Q- \$ _9 l
public void onClick(View v) {: o' a. m% r3 b8 q; `
switch (v.getId()) {8 ]% C% d' K. O! h/ w- P3 t8 N
case R.id.img_back:
9 k7 ]. y3 M6 w/ j; I SettingRouteActivity.this.finish();* Z2 F* X. |6 ^+ y# t* ?
break;
" B4 K8 Q7 Y& W# W case R.id.img_kml_input:" [9 F- B3 G+ O5 G( [) W8 m
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);: j! n) B- {8 U3 ?) O. P1 v
intent.setType("*/*");//设置类型,我这里是任意类型,任意后缀的可以这样写。9 |5 l4 o/ L# r& W: m
intent.addCategory(Intent.CATEGORY_OPENABLE);: T+ @; D: t+ s7 o
startActivityForResult(intent, MyStatic.REQUEST_CODE_FILE);/ J' k$ ?9 l( C5 Z) @
break;' L& g" T( E0 u
case R.id.img_setting_route:
/ t- Z: j4 a% A3 p enableDisableAdd();
. U3 ]0 v A: }6 g6 ]: W& C break;
5 U$ I% `5 R4 E5 E case R.id.img_setting_clear:
1 b( `/ J7 [; A6 {4 {8 j runOnUiThread(new Runnable() {8 N3 s" Z& \. ~3 [4 }4 y) n/ m* J- h
@Override) c0 y" [2 R4 q' h; Y- h X
public void run() {
9 A/ C- T4 K7 Y aMap.clear();
, q1 L( f4 o% e mMarkers.clear();0 m- c- x9 J# Q- N, _( q
mPointInfo.clear();
5 n1 w/ O9 J5 i& c mLinearLayoutInformation.setVisibility(View.GONE);
+ A$ p" J) l( t! c0 o' F; C mButtonFinish.setVisibility(View.GONE);
g+ ]8 o. h9 k3 M mButtonSetting.setVisibility(View.GONE);
5 @/ l6 W* g6 a% _2 H# F: \# a mButtonUpload.setVisibility(View.GONE);
; P# F* L* Y( g- e mButtonStart.setVisibility(View.GONE);
) [7 }/ h7 Q; ]5 [3 E0 H2 p( V( x9 w mButtonStop.setVisibility(View.GONE);
+ [- K+ X/ T! w. a+ k& w2 n: h* Q }. K4 o: O( t; H" c! }# D0 {
});
8 ^- c1 |: M% w- [+ r; f7 _ waypointList.clear();# ^9 e5 t6 U5 f+ T$ l2 E" \' y }
waypointMissionBuilder.waypointList(waypointList);
& |6 w% P- M5 r( o3 _ break;- Z: C6 s' Q5 F$ ^" [
case R.id.img_start_fly:
6 c4 k- S- q7 N2 }+ l6 t, g J- i# O atyAction(WaypointActivity.class, MyStatic.REQUEST_CODE_ID);
8 j# Y+ { ?: y* P% L. T" {( M break;
4 `; Q$ Z9 ~1 J case R.id.btn_delete:
5 N6 P- B* C$ [" ` runOnUiThread(new Runnable() {
" ]/ J$ u8 i5 r& n, ` @Override
/ v5 t7 x# R* C. V) M public void run() {
' n9 |# T% X/ U+ t/ i! l3 F aMap.clear();) d! o7 a% Y; F M: l
}
( t9 ~+ K- Q6 T) Z8 \' V$ w });) X/ ]4 w3 f: C' h2 m( _- Z0 }; l3 i9 j
for (int i = 0; i if (mMarkers.get(i).getTitle().equals(mClickMarker.getTitle())) {
6 C8 Z, K/ \( { h4 t for (int j = i; j 1; j++) {4 A& d! v# K0 l# ]. _" C( ?. a
mMarkers.put(j, mMarkers.get(j + 1));
, L! A A5 _6 {9 v }& d4 q* U' k$ J5 ^5 U2 u
mMarkers.remove(mMarkers.size() - 1);$ r3 F3 F6 _0 B+ Y; g, k
}
) {0 I1 G$ [- B# W2 [ b: a }
& v H [6 v2 }0 H, z1 x for (int i = 0; i "航点" + (i + 1));
& I% R+ j( B' X& V8 Y }: ]; n' `4 `/ X+ m' @; ]4 ]) L
updateMarkWaypoint();
. F! G1 e* \6 p- ^9 X: C break;
: j0 |$ ?! N4 l' _ case R.id.btn_finish:
5 Q, f% |9 d/ X2 [+ g3 I MyLog.d("航点数:" + waypointMissionBuilder.getWaypointCount());2 T0 \( f' H( J8 l1 _3 b9 {1 l ^
MyLog.d("总距离:" + waypointMissionBuilder.calculateTotalDistance());& M4 i& x ?& p* u/ H+ l P
MyLog.d("总时间:" + waypointMissionBuilder.calculateTotalTime());. @3 W3 {9 W8 ], N f u
isAdd = false;
- ^# x' b. T! i- {6 B7 s mButtonFinish.setVisibility(View.GONE);" B# u* b1 D p# l$ p
mButtonSetting.setVisibility(View.VISIBLE);
9 \; T) H6 C8 K/ `# x3 ] mButtonUpload.setVisibility(View.VISIBLE);) l4 @% E2 F7 I1 ^3 A* J
showSettingDialog();
6 }: g1 R( s2 b" U5 m/ ^ break;
) f [: G1 i6 W7 ~: O7 o case R.id.btn_setting:3 c h& T' x* k3 L& G h% W1 |
showSettingDialog();8 ?$ ~% Y- T* e" i& ]- t. |' h
break;0 F& {- y0 ?; \0 J
case R.id.btn_upload:, E+ g4 {" R; N$ d" w4 x2 l& n
uploadWayPointMission();
6 u3 `, b3 ~+ `% G/ L g, Z$ B3 k break;
( S8 G Q1 `8 j) F+ H Z( y& ]9 ^ case R.id.btn_start:' W" @: P* S1 L& R! ^% }3 R+ d
startWaypointMission();( ^; e/ J' o$ P2 [8 X, ^( _
break; N; f. R) _( a$ ]4 k( ^7 ^
case R.id.btn_stop:
) k; g2 f/ G O* T& R9 g2 ^ stopWaypointMission();
# b% T' v' V4 `: N, \& P" m# K break;. E7 T1 O- |" j- S" z$ _ i
}/ c: |! \2 G" c b
}
) {4 v, _2 `8 t4 | private void enableDisableAdd() {
$ o; ^% Q: M8 b- h5 N j if (isAdd == false) {0 b! S( N1 I8 r" s! z5 }: m- z
isAdd = true;
% ?8 s0 f, A" A' F% S2 @ mButtonFinish.setVisibility(View.VISIBLE);
) U2 o2 D6 U0 V1 R0 M8 g4 ] } else {" o* W. V. R X% Z. S0 j' R
isAdd = false;. ^' y. T; D$ K; R! @+ C
}
( E1 G4 u5 T9 z8 a }
5 |' C6 C" E' k private void initFlightController() {
( U! V) p) G; B BaseProduct product = ReceiverApplication.getProductInstance();
! a+ l4 Z9 @/ S) H& \ if (product != null && product.isConnected()) {9 a+ G. ]; f: W" R: D5 B# h3 \) @
if (product instanceof Aircraft) {
1 Q [7 R& E( {$ g) G; `( F mFlightController = ((Aircraft) product).getFlightController();! E* F* m& H( [; ^) _/ \1 m
}' G% v8 C: U+ y- M' G: O6 X
}
7 N6 U o1 d Z if (mFlightController != null) {
. w* y; Z6 @) w$ F) [ H3 \2 i- O mFlightController.setStateCallback(4 q" p* J- Q/ y3 p; A5 V
new FlightControllerState.Callback() {4 s# ~* q1 z' a) y) y
@Override( K7 h" @, k) t2 r
public void onUpdate(FlightControllerState) b: b4 a' N F8 F% n( U
djiFlightControllerCurrentState) {
. s' W5 j/ N& J" b! w if (djiFlightControllerCurrentState.getAircraftLocation().getLatitude() != 0.0 && djiFlightControllerCurrentState.getAircraftLocation().getLongitude() != 0.0) {) n9 R2 a, P% g, e2 }" q
D_latitude = djiFlightControllerCurrentState.getAircraftLocation().getLatitude();# U+ s7 v6 }1 d( W* p
D_longitude = djiFlightControllerCurrentState.getAircraftLocation().getLongitude();
, t/ e- H6 }( ]! K6 n4 m3 I! t; ` }4 u6 y8 ?- T/ D0 ` g, k0 r
updateDroneLocation();
& N5 e2 [7 d- z6 ~/ E5 u0 y4 r }5 [8 T( [! i: z7 X2 |
});' Q( E. [9 H9 G9 @# r
}8 a: K) R, U) u' A( t, W- ^/ e
}
/ l O- ]5 F" ?2 V- n& J private void updateDroneLocation() {0 @# L9 d9 l+ J, a, ?% Y* D
LatLng pos = new LatLng(D_latitude, D_longitude);
1 z$ \6 ?' T; P$ y0 y7 I, m //Create MarkerOptions object+ O- w' X% U7 h( E5 T8 w9 ?; ]1 Q
final MarkerOptions markerOptions = new MarkerOptions();
6 k% t% F% W, c" D1 X1 U9 V8 B markerOptions.position(pos);
) l( U8 s/ D3 }, C1 j; I$ p markerOptions.icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_aircraft_write_36dp));4 `' k f1 g; E& y# \
runOnUiThread(new Runnable() {# r7 L h+ |/ ?. j0 N
@Override
/ R7 ^7 b& _9 H1 t; w public void run() {4 J% Z/ a, P$ h. A0 u0 m
if (droneMarker != null) {9 H8 E' {, X9 m3 @5 Y5 E' E
droneMarker.remove();( u d, ?% K# o
}
( N6 a( L/ w% J: w+ m: y if (checkGpsCoordination(D_latitude, D_longitude)) {
$ N8 H' @3 J+ E droneMarker = aMap.addMarker(markerOptions);* R* n( n" w* q. @$ Z- z
}! U- {8 t+ X' I N0 @2 ^& g
}
" j# H0 Y' f$ [# R' w/ u });
, X4 F) P; _# K& `9 y }
3 ?3 X- x$ p1 O7 B6 Q public static boolean checkGpsCoordination(double latitude, double longitude) {
/ k$ a' W- s% I: B1 Q return (latitude > -90 && latitude 90 && longitude > -180 && longitude 180) && (latitude != 0f && longitude != 0f);7 z* g* W1 T( E
}
* W) [; ?, p. u; m" I protected BroadcastReceiver mReceiver = new BroadcastReceiver() {
9 X: Q. e# { f# n0 c @Override
1 q/ i+ n' m& n6 p* d: _( d; Q public void onReceive(Context context, Intent intent) {
- \- E+ k. J6 [4 z2 S0 B onProductConnectionChange();
- ]1 C; v2 A0 L1 ~ }
" u/ a4 _" T0 N9 X5 ]6 p };$ L( c' w r1 _! c0 ? q7 ~
private void onProductConnectionChange() {
) p: Y( o# X R+ A2 G initFlightController();* m& s6 O6 {# L7 G* F2 b
}- q; Q# [ E5 A3 n
private void addListener() {
# ]2 e, H. j* U7 e if (getWaypointMissionOperator() != null) { O. ~4 c: ^2 V5 U# x: _4 v% x
getWaypointMissionOperator().addListener(eventNotificationListener);
- O( C) `" N, Q- {3 V) U1 z: f }/ v; o" @! i, R6 ?) d2 [
}! r, l) F' ^+ O/ Y7 ]3 E$ Q
private void removeListener() {( v2 B! B' K7 a, d X) {6 `
if (getWaypointMissionOperator() != null) {: N9 w! T( w2 j6 @! v* Q+ x
getWaypointMissionOperator().removeListener(eventNotificationListener);- O! T, U; G# h+ K
}) ]: o# T' G% W( G- \
}
0 V1 O7 N% b3 h8 U' W4 p private WaypointMissionOperatorListener eventNotificationListener = new WaypointMissionOperatorListener() {
0 a/ }! \, N, V% j! w, g @Override
9 S. q+ v) n8 @0 f/ J public void onDownloadUpdate(WaypointMissionDownloadEvent downloadEvent) {
' n% ~# ?* d9 A/ b. b7 h }; D ?/ }6 ^% |; C u& X
@Override
/ c* v9 s* X6 E. c! s public void onUploadUpdate(WaypointMissionUploadEvent uploadEvent) {; D) Z- @/ n+ M, c1 Y( J* B4 Q0 F
}
6 E$ p0 g9 C0 t @Override
1 M$ r4 Q2 O& X0 E* ~6 J) ` public void onExecutionUpdate(WaypointMissionExecutionEvent executionEvent) {
/ a) Z* Z" _6 t5 ]/ @5 B }
8 p8 P2 ^6 B4 h& B% m @Override) S- p2 Q/ T- W5 ~3 G
public void onExecutionStart() {. \) P8 G8 C% @. G+ x/ N) I
}
% Z( p2 Y" P% z/ K% ] J @Override
" t& D! {* b$ x2 [+ H* h+ f! V public void onExecutionFinish(@Nullable final DJIError error) {
; o2 M P5 @! x" G showToasts("Execution finished: " + (error == null ? "Success!" : error.getDescription()));7 m4 x$ S- Y% z* h# }/ O) a
}" @1 u* {0 w( e0 a/ d2 q# X W7 A
};/ V& x5 O3 e2 q& j* s
public WaypointMissionOperator getWaypointMissionOperator() {1 c8 Y7 ~; D: l+ T& S, A
if (instance == null) {& g% b1 s6 B' R8 M( I' L7 I0 \
instance = DJISDKManager.getInstance().getMissionControl().getWaypointMissionOperator();
8 e5 e q" J6 X! E d% u- q) J }
( ~$ |& {+ ]5 C return instance;
: c* [. P% Y& H5 ^- k4 v }
( F* X, Z2 ]% b9 r& t+ X @Override D: b0 m! J4 s
public void onMapClick(LatLng point) {( L7 o6 q3 ?2 R
if (isAdd == true) {; G5 V- T, h. q! u* v
markWaypoint(point);
; m+ A5 j0 {* m9 L M8 |) K Waypoint mWaypoint = new Waypoint(point.latitude, point.longitude, altitude);. \- L) }$ q" l! Q+ [
//Add Waypoints to Waypoint arraylist;: `; D+ f4 T* I# k* @3 p
if (waypointMissionBuilder != null) {
2 s) z$ ~" _7 j, e) N _ waypointList.add(mWaypoint);) V! j+ j' }4 ?7 }2 a" \
waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());
- E( Q6 S/ {! @: K } else {
' k6 H8 W" G c; V, c5 m waypointMissionBuilder = new WaypointMission.Builder();
; C8 P- X: e! f! @/ `# v% ^ waypointList.add(mWaypoint);3 l0 k0 I4 D' t, ]5 r
waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());1 y% h7 e* N9 o' m/ @
}" z L& f, n2 N
mTextViewCount.setText("航点数:" + waypointMissionBuilder.getWaypointCount());+ B4 ~, |; V7 W& f
mTextViewDistance.setText("总距离:" + Math.round(waypointMissionBuilder.calculateTotalDistance()) + "m");0 j& H" `* Q$ {* {
mTextViewTime.setText("总时间:" + Math.round(waypointMissionBuilder.calculateTotalTime()) + "min");$ }5 t2 P* c9 @' v, a8 G& `* k
} else {
6 P: }4 B& w% y8 c if (mClickMarker != null && mClickMarker.isInfoWindowShown()) {
5 O: c9 Q. G& J2 C7 y mClickMarker.hideInfoWindow();
4 N2 `* X1 M) ~ mButtonDelete.setVisibility(View.GONE);
( q# z7 K' s5 o/ ^. Y }; P p+ H- z3 q" y
// showToasts("当前未开启增加点模式");
& O' U$ T9 M1 ]- |$ [ }; Z9 u/ d( a$ E/ l9 f3 b& t' ]
}
$ J: e( E0 m6 j) }9 p- B private void markWaypoint(LatLng point) {
/ V2 Y$ a2 W- H2 L8 w5 k/ M; f8 w MarkerOptions markerOptions = new MarkerOptions();
8 B) c( j5 B" @% j' T8 o markerOptions.position(point);
# f0 u9 ?/ P8 Z/ { e7 w mPointInfo.add(new PointInfo(point.latitude, point.longitude));3 m' c6 t5 O1 \# |! [2 p
markerOptions.title("航点" + (mMarkers.size() + 1));* e" k) Z2 L: n$ L
markerOptions.snippet("事件:");1 `5 R; M- D8 J
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
5 T6 z$ c7 X7 t markerOptions.infoWindowEnable(true);
$ x5 M* Z* u' R! g Marker marker = aMap.addMarker(markerOptions);4 b7 V- h& d) z$ t
mMarkers.put(mMarkers.size(), marker);6 L7 ]' {+ j3 P m1 D
marker.showInfoWindow();( ]9 l) t% K2 m, T# K7 s( N6 H7 g
if (mMarkers.size() > 0) {
3 s+ r' c% i0 M# d5 [ mLatLng.clear();
3 Y; D$ f/ m5 Z. E PolylineOptions PolylineOptions = new PolylineOptions();8 i0 n$ [6 H; L' v2 Q% V
for (int i = 0; i 10);
5 w/ q$ d. ]$ A8 t1 P PolylineOptions.color(Color.argb(255, 1, 1, 1));
; y; i/ U3 o: r4 Z# q- m aMap.addPolyline(PolylineOptions);% t5 Z, d! t. j$ ?
}. i9 P8 x7 q+ j. }2 E
}
; Y0 p) M5 c+ i4 v# |- P private void updateMarkWaypoint() {7 h. z; R/ n* V- m* K" H
mLatLng.clear();
) D2 I- c; y$ c1 W2 A waypointList.clear();
. s6 [: ^7 f2 |' s mPointInfo.clear();
) P! L2 c! a- B, u waypointMissionBuilder.waypointList(waypointList);
! x# }$ r) S+ B" c for (int i = 0; i new PointInfo(mMarkers.get(i).getPosition().latitude, mMarkers.get(i).getPosition().longitude));
' L0 Y0 S) n' J$ m' W- ]) J# Q5 `6 Y# l MarkerOptions markerOptions = new MarkerOptions();
6 r/ V- o6 a, ` Waypoint mWaypoint = new Waypoint(mMarkers.get(i).getPosition().latitude, mMarkers.get(i).getPosition().longitude, altitude);+ w/ R' X1 L8 n) {6 l [3 ^2 D* r6 J
waypointList.add(mWaypoint);
4 U1 {# n- |0 _- l. ]& Z- i markerOptions.position(mMarkers.get(i).getPosition());
5 C& Q- E; d) a1 Z7 | markerOptions.title(mMarkers.get(i).getTitle());( M* Z; o& V+ K U6 y+ `8 y
markerOptions.snippet(mMarkers.get(i).getSnippet());
* K9 b. i" f7 ]* Y1 T7 b2 E6 d, U markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));# O5 ?& s) p1 y: |6 S! P7 I9 T$ y' n! i
aMap.addMarker(markerOptions);
6 @# G5 a& D+ n: X8 p% |$ E mLatLng.add(mMarkers.get(i).getPosition());
/ G9 Y p" c, e8 C; W }
0 c9 B3 t! r5 b0 C8 c if (mMarkers.size() > 0) {
: e4 q; I, @ m' Z PolylineOptions PolylineOptions = new PolylineOptions();
8 b' } w9 ]% `; {9 D" l PolylineOptions.addAll(mLatLng);: o7 F4 i6 @. ~4 S8 O! \9 O( Q1 [
PolylineOptions.width(10);
; T( t' j/ n, _) A' T) { PolylineOptions.color(Color.argb(255, 1, 1, 1));9 }1 M2 |4 s" k: m! M! h- U9 F
aMap.addPolyline(PolylineOptions);
, G$ W+ ~1 ?4 k( h0 E( N8 ^ }
7 s9 g2 ]1 ~& {8 ^6 ^$ @5 W& O3 { waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());, H& {4 R- O3 A8 [- C: p* W! {
mTextViewCount.setText("航点数:" + waypointMissionBuilder.getWaypointCount());
: [8 }, x/ H% j1 p mTextViewDistance.setText("总距离:" + Math.round(waypointMissionBuilder.calculateTotalDistance()) + "m");
: ]% @* R1 ] a3 s8 j# D; Y mTextViewTime.setText("总时间:" + Math.round(waypointMissionBuilder.calculateTotalTime()) + "min");
6 |* ~7 l9 j; _9 l/ S MyLog.d("航点数:" + waypointMissionBuilder.getWaypointCount());
& [5 X. y& S# _ T2 L1 @. G MyLog.d("总距离:" + waypointMissionBuilder.calculateTotalDistance());
6 W7 ?( b Y: Y; O3 j. y MyLog.d("总时间:" + waypointMissionBuilder.calculateTotalTime());) }8 L) {2 e$ @+ L
mButtonDelete.setVisibility(View.GONE);3 b# {' m, w! z4 K9 d4 i" @
}) U7 m. `* r# r2 A
) K. T; P1 r) O/ @9 v
/**
1 s, d4 d5 |( l- O7 S+ v4 b * 定位成功后回调函数! P S3 r* @! ?: C" r% K( x
*/
5 j$ z3 j( O! T' |: {" i: A @Override
z$ f1 `! M) |; N, M) h public void onLocationChanged(AMapLocation amapLocation) {
- W* w6 j* a, H+ U' ]: p if (mListener != null && amapLocation != null) {
1 E* h- f9 Q% @8 C* x: V if (amapLocation != null
8 z* N, l) j( t4 o* A, k && amapLocation.getErrorCode() == 0) {
" `, [4 X9 g7 Z D_latitude = amapLocation.getLatitude(); //获取纬度) z/ a: m b4 y; g; g$ t' Y- P
D_longitude = amapLocation.getLongitude(); //获取经度
. s4 Y0 i! s9 g* J% |: }7 s mListener.onLocationChanged(amapLocation);// 显示系统小蓝点
/ N$ R( B* U& \% | aMap.moveCamera(CameraUpdateFactory.zoomTo(18));
3 h9 d9 O3 F% t9 R1 ^ } else {
- y( Z: p6 @, C' j1 Z String errText = "定位失败," + amapLocation.getErrorCode() + ": " + amapLocation.getErrorInfo();3 v1 v" j, Q6 {: n' v
Log.e("AmapErr", errText);
. l) f1 z+ T( P/ t }
5 S y9 Y4 i: |( ^6 D" I5 c }- L8 L3 t. D3 e0 [2 ~3 i2 g( j
}
- G g1 f6 B3 b* r# q/ M9 d @Override) P+ L1 z: J6 D
public void activate(OnLocationChangedListener listener) {
/ |3 E3 {- \" f& D1 C mListener = listener;
$ b+ }8 [+ L9 Y' p1 d* ?3 D if (mlocationClient == null) {
8 q6 z7 ^/ z" m. k try {3 M# ~8 U& l! E% }
mlocationClient = new AMapLocationClient(this);
0 H p8 F$ M% f! [ } catch (Exception e) {
" C' o6 @) ~- k' ^, h e.printStackTrace();
( z$ G8 O8 G3 P) R }
$ t3 I( |8 I* [; G& T5 I/ b mLocationOption = new AMapLocationClientOption();
' t% z1 F5 G2 z% f% O //设置定位监听
2 a5 n# g6 H o' } mlocationClient.setLocationListener(this);
1 H' n( W p! f6 Y0 g( c //设置为高精度定位模式
4 U; K/ C' S6 H& O' Z* A: M mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
" j6 J/ w1 }3 ~ //设置定位参数 H+ `$ ~. P& f
mLocationOption.setOnceLocation(true);
5 B+ b: N/ H( L" I \ mlocationClient.setLocationOption(mLocationOption);
) D) ?, F9 O. w9 h" @# @ // 此方法为每隔固定时间会发起一次定位请求,为了减少电量消耗或网络流量消耗,
, |, Y# B0 K+ A3 }7 h t6 b // 注意设置合适的定位时间的间隔(最小间隔支持为2000ms),并且在合适时间调用stopLocation()方法来取消定位请求& t5 e T# x$ U- t2 ?; H) @
// 在定位结束后,在合适的生命周期调用onDestroy()方法
* J1 `. U7 l3 A* O/ a: z- H // 在单次定位情况下,定位无论成功与否,都无需调用stopLocation()方法移除请求,定位sdk内部会移除6 W! \7 [. W7 J8 D7 M S: H
mlocationClient.startLocation();, s0 w- n8 K# ~2 I( Q9 \4 c5 C
}
/ e" f5 l! [/ a3 v }
6 J0 x% T3 X } D# Q @Override9 b1 h& w$ E* W, X: V i7 V$ Z
public void deactivate() {8 s3 A9 E) P7 ]( U5 K
mListener = null;
- D& Z1 Y( V8 E/ \( M4 Z if (mlocationClient != null) {: i. A9 A8 x) K! H( ?/ i% k9 h
mlocationClient.stopLocation();4 V% T- B* \6 ^! l6 t: u& m
mlocationClient.onDestroy();
: q/ ^3 q" g8 J- s$ w( j' J }) p! R3 s( U5 C9 x
mlocationClient = null;! @5 \0 K. A8 C
}3 D* [' V# t1 Q" Y" U M
@Override
, T/ O3 ^" t3 u public View getInfoWindow(Marker marker) {: K& _* s$ \5 y* h& M& r
if (infoWindow == null) {% T, s, @0 K( Z* K v ~
infoWindow = LayoutInflater.from(this).inflate(R.layout.amap_info_window, null);8 f! r% o1 X3 G: X- B8 i
}8 n% F2 O# A+ [
render(marker, infoWindow);
6 Y' u, R% A( u$ M2 c return infoWindow;8 R6 l+ T8 o8 `; }8 H, p- y
}7 P- s' |/ }, d: p# V% J3 a+ t+ M1 \
/*** o- j0 O& o+ O% n/ l5 @/ O
* 自定义infoWindow窗口+ {/ L& h# m6 Z. _% e
*/3 T2 @- N5 I9 w0 @
private void render(Marker marker, View infoWindow) {
6 n/ |) _! J6 w; q TextView title = infoWindow.findViewById(R.id.info_window_title);( J: |, a. V3 S
TextView content = infoWindow.findViewById(R.id.info_window_content);3 A% q+ n: |2 T8 F3 f# w; @/ g
title.setText(marker.getTitle());
: G$ d& @! Q2 a$ n content.setText(marker.getSnippet());
4 \4 {: P8 X8 J7 z) e5 R }; [6 M& q$ G0 {0 I, F* j9 l2 P8 c
/ L# x! W, n8 S% _# o8 N/ m- \- T) C# b @Override
7 b+ p4 X2 K$ S" D/ E public View getInfoContents(Marker marker) {
1 R9 ]! J! R1 b return null;
; _% G$ A" l# [9 L2 d: v% \+ Q8 { }! I3 K- N7 J1 Z( h; ^! b
@Override0 a1 h. Y% _. W3 ?, V
public boolean onMarkerClick(Marker marker) {# ]3 x$ v1 p+ G% }2 L
marker.showInfoWindow();9 z0 ]) \& O7 q x
mClickMarker = marker;& V8 Q0 e/ d6 X& ^- b ~& S
mButtonDelete.setVisibility(View.VISIBLE);
" s R q) \8 t- [ // aMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(marker.getPosition(),18,0,0)));
1 B* d& W4 m: T# E7 a% i, a+ ~$ [ return true;
7 A* c/ v# U1 ?! y1 T }
) {' ^; w2 H( n/ e2 x) U private void showSettingDialog() {5 q- ^8 X8 J) n3 U7 F
LinearLayout wayPointSettings = (LinearLayout) getLayoutInflater().inflate(R.layout.dialog_waypointsetting, null);. g! D6 U9 _3 b9 r5 v# k* J
final TextView wpAltitude_TV = (TextView) wayPointSettings.findViewById(R.id.altitude);
& o! {. Y6 b) M- u. {" ~ RadioGroup speed_RG = (RadioGroup) wayPointSettings.findViewById(R.id.speed);/ I) q6 k1 }/ e/ _
RadioGroup actionAfterFinished_RG = (RadioGroup) wayPointSettings.findViewById(R.id.actionAfterFinished);
% z8 G9 S: P+ r) \6 X$ c# j RadioGroup heading_RG = (RadioGroup) wayPointSettings.findViewById(R.id.heading);% Z# Q/ h3 h7 t" e) q* s
wpAltitude_TV.setText(Math.round(altitude) + "");4 L8 G2 L% m3 \2 E2 i
if (speed_RG_id != 0) {( @( c$ ^3 X5 I4 T7 p6 |1 u
RadioButton radioButton = (RadioButton) speed_RG.findViewById(speed_RG_id);
/ S- W& I/ m5 l; B' |; N radioButton.setChecked(true);
: A7 h" U7 l5 N& m. s }/ h1 X0 U) X* y% E Q% ~
if (actionAfterFinished_RG_id != 0) {& V8 x/ y0 L4 q* Z# c/ e" a
RadioButton radioButton = (RadioButton) actionAfterFinished_RG.findViewById(actionAfterFinished_RG_id);
C% q& R8 R, l8 ~ radioButton.setChecked(true);
# o0 I0 C6 a+ K- s0 ^; W$ E }$ g! m7 k+ Y9 H& }
if (heading_RG_id != 0) {" x; ]0 H+ s; x8 z/ O
RadioButton radioButton = (RadioButton) heading_RG.findViewById(heading_RG_id);
4 @* h+ i H. j. {8 H+ } radioButton.setChecked(true);
9 W; E/ K' e" W7 `: W. ?' K }
: a3 P& j0 X! z6 B speed_RG.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
# x, x. s5 A/ \& d" X2 r6 ] @Override
0 o3 U9 ^; w1 h+ s9 E* N: K public void onCheckedChanged(RadioGroup group, int checkedId) {
: d3 r) h; O0 I n if (checkedId == R.id.lowSpeed) {
/ \+ V, ]6 d1 u8 q; |) B+ L% ^ mSpeed = 3.0f;
# m. D6 f: C1 F% n' O9 y0 H$ B } else if (checkedId == R.id.MidSpeed) {" f) {6 H O2 T- H7 U
mSpeed = 5.0f;$ H5 F+ G5 q$ e% B7 m5 ^8 ~
} else if (checkedId == R.id.HighSpeed) {( F8 R; T5 f; I" d5 c- A# `" k
mSpeed = 10.0f;8 ^6 a+ A5 R& P& F% Q
}# T2 k7 T, S7 n& C# y
speed_RG_id = checkedId;$ f2 s0 A; T& {% d* \5 }
}4 f. }8 f4 x+ W S+ P+ u% s
});
8 L1 ?' w1 W$ \. } actionAfterFinished_RG.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { ~# O G: M# ~7 F
@Override
# C1 d2 b+ f( y9 L a9 O; I' s3 [ public void onCheckedChanged(RadioGroup group, int checkedId) {1 m- q d- ?1 r* a
MyLog.d("选择动作完成");
0 r" B4 v# |: D- k* C! U: D if (checkedId == R.id.finishNone) {# q/ Z/ v6 Y- [8 M0 s# C$ h
mFinishedAction = WaypointMissionFinishedAction.NO_ACTION;- _. A- Z2 g1 y( q
FinishedAction = "0";
5 [3 {& @7 c* g% W U } else if (checkedId == R.id.finishGoHome) {
3 Z3 e% q* u G: [ mFinishedAction = WaypointMissionFinishedAction.GO_HOME;6 J5 [1 _# s: n i1 b5 j
FinishedAction = "1";5 C Q: e+ P( X( R, P
} else if (checkedId == R.id.finishAutoLanding) {
6 B. l' {+ E* x mFinishedAction = WaypointMissionFinishedAction.AUTO_LAND;' J% K" B3 j" f- O* E
FinishedAction = "2";. Y; z. S$ }& y; A& L% W2 r3 O
} else if (checkedId == R.id.finishToFirst) {+ B* F9 W+ _% Q' O% [
mFinishedAction = WaypointMissionFinishedAction.GO_FIRST_WAYPOINT;" u, f$ m( h e, ^; s& G; N
FinishedAction = "3";! ]: O0 S- t1 d6 }
}
% [, ^- L( T5 u* c, H* q4 r4 l" u actionAfterFinished_RG_id = checkedId;
; [$ t- }: Z0 x/ \& d# ~ }7 A& y0 h# O7 j! A
});
' m# u9 m, D* D heading_RG.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {3 X6 A( @: ]- S7 v! s
@Override) @% {1 T% w M. y1 a! l
public void onCheckedChanged(RadioGroup group, int checkedId) {
+ r, f2 R3 e5 |+ H7 j8 {* w" O. L MyLog.d("选择标题");7 |7 D4 j* v& q8 W* P
if (checkedId == R.id.headingNext) {8 X8 @* k) ~1 Y! f6 d9 Q
mHeadingMode = WaypointMissionHeadingMode.AUTO;
2 E7 P5 k4 I3 i# N HeadingMode = "0";( N- M: Z$ w# D4 ~2 b
} else if (checkedId == R.id.headingInitDirec) {
2 P7 m9 M8 B* z# L! B: x, c, a5 E mHeadingMode = WaypointMissionHeadingMode.USING_INITIAL_DIRECTION;
4 F# A3 k% t5 M7 J* g, x HeadingMode = "1";
* F4 q G% ^5 m* ~ } else if (checkedId == R.id.headingRC) {& { P! h- q7 z0 x
mHeadingMode = WaypointMissionHeadingMode.CONTROL_BY_REMOTE_CONTROLLER;4 O- {+ t+ ?- h! `3 i
HeadingMode = "2";
7 T- w- w# s9 K, G8 [$ ^6 ^5 q } else if (checkedId == R.id.headingWP) {
2 y4 @* e) ]+ r3 }7 W4 T+ o mHeadingMode = WaypointMissionHeadingMode.USING_WAYPOINT_HEADING;- \* O/ X6 z- f( y; Q) [3 N4 \& G
HeadingMode = "3";
% Q- y" v* p/ V/ f$ | }
. n" A) x0 m7 D4 Z) ~7 V: b heading_RG_id = checkedId;/ R' @4 V0 G! ~! M1 A5 o( \) X
}
w. o5 d: `* o! {9 R- p });3 z$ g& W2 g- X' T5 ]
new AlertDialog.Builder(this)
8 I6 o9 x9 Y E v; V .setTitle("航点设置")$ y/ Z% h0 c! G8 x# _
.setView(wayPointSettings)
- I, a( ?& x$ j3 L, _ .setNeutralButton("设置", new DialogInterface.OnClickListener() {) T( f. W& f* D
public void onClick(DialogInterface dialog, int id) {
) a& P6 h6 G5 c, w String altitudeString = wpAltitude_TV.getText().toString();% V0 b7 p9 v4 M# S% M: \6 o
altitude = Integer.parseInt(nulltoIntegerDefalt(altitudeString));1 I3 p5 a# z0 o: N) W$ N" n `5 F% j
MyLog.e("altitude " + altitude);
$ l6 n+ P" C+ x, e MyLog.e("speed " + mSpeed);
% n- d" @, h {6 x4 S MyLog.e("mFinishedAction " + mFinishedAction);
9 W( `& }) {! I3 z5 Q MyLog.e("mHeadingMode " + mHeadingMode);
2 I! B# L' T% H% B- ~) y configWayPointMission();
+ X5 {# e9 N, F, I' w }
: X* h( a/ |: C& J* z- F- x })( j, b" F& ?# Z- l
.setCancelable(false)
; v+ n1 e# f9 `( z5 F5 l .create()! p: w) G s1 p6 x8 |* ~
.show();5 K8 V+ ]# n) i
}5 _4 }: C& w4 O6 b4 H
String nulltoIntegerDefalt(String value) {) R5 r5 T5 r* O% d
if (!isIntValue(value)): N; ?1 y8 o k& m7 D! Q) Q
value = "0";" M7 G8 I. q! z- t
return value;
# x& T3 O V1 `5 K) ~$ B. _ }
/ C9 g3 n# e. M8 z1 r8 d! c3 T3 C boolean isIntValue(String val) {; S$ t5 z5 r, V: ~" ?. V
try {
1 P( o) g& I$ s4 o; J( C val = val.replace(" ", "");
7 y# e8 _# L8 p3 k! f9 Y3 S Integer.parseInt(val);* ]& I+ E0 Z+ Y1 s
} catch (Exception e) {! H( p$ z% A/ K* L7 K/ @
return false;4 V4 b) H! X4 L1 e8 r+ e/ s" Q
}" R3 o% v9 g& H5 e3 ]
return true;
" S* P: `: E# i0 O- L) A }
: o) i, l! h2 s6 W/ Q private void configWayPointMission() {
+ L6 M0 X/ ?1 c2 @ if (waypointMissionBuilder == null) {
+ A; R$ W* h+ }9 H0 a; N waypointMissionBuilder = new WaypointMission.Builder().finishedAction(mFinishedAction)1 M2 W+ {# L8 T6 Q: M$ ]! @
.headingMode(mHeadingMode)* p+ _# s( F( v* A7 _! Q6 M* t
.autoFlightSpeed(mSpeed)) r5 K5 E% `: i1 s! `6 q
.maxFlightSpeed(mSpeed)
% X: e* ~, }. Q .flightPathMode(WaypointMissionFlightPathMode.NORMAL);
' O; t- a, Z; L% ?$ g, O: [ } else {$ o. S7 v8 a, N* n
waypointMissionBuilder.finishedAction(mFinishedAction)
# l! w5 G! A3 X; X& D- p' L .headingMode(mHeadingMode)
2 _ A8 O+ D6 `, u( x$ _" { .autoFlightSpeed(mSpeed)4 Z! h! m% C" c& o
.maxFlightSpeed(mSpeed)
/ A( R; ?% t* I- w1 H$ C .flightPathMode(WaypointMissionFlightPathMode.NORMAL);
" I: J# |0 V! H& [ }5 U* ^+ s Z; q7 _+ d5 C
if (waypointMissionBuilder.getWaypointList().size() > 0) {$ S" `) _# R4 [3 v' J
for (int i = 0; i if (error == null) {, h1 B' G2 K" Z* @
if (mLinearLayoutInformation.getVisibility() == View.GONE) {: d* N0 m2 d; n) t
mLinearLayoutInformation.setVisibility(View.VISIBLE);
3 q4 f1 X1 P8 G+ Q$ o9 G ~ }
( O8 Y8 q- T; u0 U: G mTextViewHeight.setText("高度:" + altitude + "m");
/ G* f- c, L- [* f mTextViewSpeed.setText("速度:" + mSpeed + "m/s");
$ T4 I4 B$ M4 z& }2 F7 O$ I mTextViewCount.setText("航点数:" + waypointMissionBuilder.getWaypointCount());
% D0 Z4 f6 a+ A1 b mTextViewDistance.setText("总距离:" + Math.round(waypointMissionBuilder.calculateTotalDistance()) + "m");! E6 h$ v9 D5 w$ a$ G
mTextViewTime.setText("总时间:" + Math.round(waypointMissionBuilder.calculateTotalTime()) + "min");- v( E+ B0 B( T( K5 U* W- k
MyLog.d("航点数:" + waypointMissionBuilder.getWaypointCount());+ v$ L. |& ^7 ^. R, P3 |$ w9 K" D
MyLog.d("总距离:" + waypointMissionBuilder.calculateTotalDistance());! K* z3 T0 Z" M
MyLog.d("总时间:" + waypointMissionBuilder.calculateTotalTime());
: z& c. R" K$ m% P* G showToasts("航路点配置成功");* k( E% F0 |+ `/ V# T
} else {
6 \; D, n! g( t, n/ Q' G showToasts("航路点配置失败 " + error.getDescription());
* m, Y* ^ v. w- @: g2 k }
: y& c1 ?+ q' N5 p }8 M- i+ A! W! J3 |5 ]1 m" Z6 G
private void uploadWayPointMission() {* w8 X7 n4 ?4 ?' ~* w7 X: K# C
getWaypointMissionOperator().uploadMission(new CommonCallbacks.CompletionCallback() {
6 O" y7 j! N. b- I i @Override% e* W& h+ v+ p3 L# S
public void onResult(DJIError error) {: o z4 j7 z& u6 R9 i# @
if (error == null) {
! {* p. ]8 S$ D. ?. S# o# R! R, {6 i" q6 z runOnUiThread(new Runnable() {
6 f) y( |' u1 P2 Z @Override' |/ E6 `1 d# L7 X& A7 z% s* I8 J- }
public void run() {- _* x8 a' f1 m. H
mButtonSetting.setVisibility(View.GONE);
# T: C5 E8 i2 G) `5 F C mButtonUpload.setVisibility(View.GONE);
4 a3 P0 E& ~1 n# W! f [, s mButtonStart.setVisibility(View.VISIBLE);) h: I. z( W; M6 P
mButtonStop.setVisibility(View.VISIBLE);
$ S- v! T# s- q5 @+ e+ z& w' Y }% o+ l3 Z# }, ^. p1 i; \* \' h. x
});. A$ H% b) r. ~ {& w# n/ a( e
showToasts("任务上传成功!");
0 S% ~& s" p* m) F mSQLiteHelper = new SQLiteHelper(SettingRouteActivity.this);2 I8 ?: n% [9 ^- k7 y* h9 k, S
MyLog.d("航点值:" + GsonUtil.GsonString(mPointInfo));- |. a, B0 n( q( Z+ X
mSQLiteHelper.doInsert(GsonUtil.GsonString(mPointInfo), altitude, mSpeed, HeadingMode, FinishedAction,4 i( H2 y8 k) ]: A0 j0 z9 @
waypointMissionBuilder.getWaypointCount(), Math.round(waypointMissionBuilder.calculateTotalDistance()),
! _; ^; `2 e' h. M Math.round(waypointMissionBuilder.calculateTotalTime()), DateUtils.getCurrentDate());0 R+ Z3 z" o* V4 b% T
mSQLiteHelper.close();
5 Q$ m7 g; T- N } else {
9 o! Q$ ], G; r showToasts("任务上传失败, error: " + error.getDescription() + " retrying...");* E6 [. T: g% k7 i3 U" P8 e
getWaypointMissionOperator().retryUploadMission(null);- I" _2 y& R0 ^1 ^+ u3 Z& |
}, g, R& R* E7 J: G- T
}
# V) u7 c1 J8 d# z });
) _' F* B, R7 x X }
6 L- V* {7 s9 T# |3 B$ R/ E private void startWaypointMission() {
4 ? ^% r( N$ \5 v getWaypointMissionOperator().startMission(new CommonCallbacks.CompletionCallback() {
+ n% {6 z( |$ ]; k, \ @Override
9 M6 h8 n! `' b% r public void onResult(DJIError error) {
$ A. j* o' B. j4 M' h8 v showToasts("任务开始: " + (error == null ? "成功" : "失败:" + error.getDescription()));2 J+ I7 |& Q9 u* o' a$ d0 a# D
}) A5 x- `. s6 s. Q
});
5 a- N1 E: k8 O }
e, ]. I: y1 e" C" d4 U1 x& V% E private void stopWaypointMission() {/ y! g0 q1 U1 M
getWaypointMissionOperator().stopMission(new CommonCallbacks.CompletionCallback() {. m, X7 y8 d, O$ M0 T
@Override
% _+ h( V1 ^& d* K. i public void onResult(DJIError error) {
' g) _8 w& e. B! D& m; _0 D showToasts("任务暂停: " + (error == null ? "成功" : "失败" + error.getDescription()));2 C) Q0 [2 x% b* Z+ y
}, A* ^% n# l1 q& ]
}); j; v; O8 ?# u" B8 F9 G
}
* D. q! H8 _: b+ P7 b1 A @Override7 g$ j* |2 K& {0 m) L1 Q6 k; m" j9 g
protected void onActivityResult(int requestCode, int resultCode, Intent data) {# g0 y" w; D8 { V6 k+ }$ K T
switch (requestCode) {
, B$ A- p! F$ j, Y case 101:
$ b" I4 z. y# {6 E) m int Id = data.getExtras().getInt("id");3 ]! }) G" t9 z
MyLog.d("返回的ID:" + Id);* D* y l) U! o) m% Z
if (Id > -1) {) `* _7 s% Z1 T+ d. @( @) ^
refreshMapPoint(Id);
9 r1 ]) C- E; q8 d# B }
" R- Z# X N% y9 D) Z3 ~. C break;% K( z/ m4 t) N1 @) Y; U1 a$ t, `
case 102:
. s* M1 e% u& Y/ d' @, c if (data.getData() != null) {
k. i: o( I/ K( g# ~ Uri uri = data.getData();//得到uri,后面就是将uri转化成file的过程。8 p/ _7 [( Z* ?+ u% F! L: a' W: ?
String img_path = uri.getPath();/ ^8 C0 L- M+ j( B4 y) J
try {( S0 B# T& T& @; h; D, ]$ J
if (!TextUtils.isEmpty(img_path)) {3 _: f( P, m( K& f8 h2 Q
readKml.parseKml(img_path);
2 W/ }4 i g Y2 h& t' s6 L s addSampleMarker();
' [8 m7 ]/ O, \2 _+ |7 v6 H. [ }
: Y# r! l! B( Y3 v+ S } catch (Exception e) {
. s! h- {" M% x4 D1 b e.printStackTrace();, X e/ B! P- J% C) D1 v, U
}
, g4 u- R6 q- W, O) Z8 E }
- z! E& O N: E* M0 {2 n break;! {+ v- L) Y8 i
default:% e: g) X- G# ]! C
break;
6 W( j! e+ }5 }7 V }, g# j4 e# k0 e8 w; t3 ^5 B; v
}# C. i4 x f* F4 c3 j6 h2 J
private void refreshMapPoint(int id) {0 U2 Y( O" h7 l' }! O
aMap.clear();
1 U9 M/ v' @! \! o, d mMarkers.clear();
$ o* @- D# b; k2 m* H. g7 I mPointInfo.clear();% x2 S) O* ]0 l! A
mLinearLayoutInformation.setVisibility(View.GONE);/ K* n, e8 @$ K A
mButtonFinish.setVisibility(View.GONE);
, j X+ k4 Q, s: K mButtonSetting.setVisibility(View.GONE);; k5 M7 U& i- s' N G7 F
mButtonUpload.setVisibility(View.GONE);+ }5 I) \9 i3 w; B3 b) R
mButtonStart.setVisibility(View.GONE);$ K7 V b. Z9 `$ ?+ a
mButtonStop.setVisibility(View.GONE);
8 Y3 z! g* P8 v7 f0 k* ` waypointList.clear();# `" I! a* K. {9 F" M
mSQLiteHelper = new SQLiteHelper(SettingRouteActivity.this);
, q2 i9 `% d4 k) o3 h Cursor c = mSQLiteHelper.doSelectWaypoint(id);
, F" z* I" i+ t0 A ]1 [8 w9 B if (c != null) {3 D0 O' T9 W Y: j8 g2 E
if (c.moveToNext()) {- `& `) |9 R, s4 q
MyLog.d("航点:" + "{'pointInfo':" + c.getString(1) + "}");' P* {" {5 a( ^
mPointInfo.addAll(GsonUtil.GsonToBean("{'pointInfo':" + c.getString(1) + "}", Root.class).getPointInfo());( N* o& i5 b, g* w6 f2 e
altitude = c.getFloat(2);
9 g4 b$ ]2 l, I2 [2 q9 K mSpeed = c.getFloat(3);
3 o- `& y. s# ]) F) v switch (c.getString(4)) {
% Q6 ~) y! O- k$ S9 s4 e0 J! f case "0":
; G: T5 `/ c& i% } mHeadingMode = WaypointMissionHeadingMode.AUTO;
# ~# v' g& w2 v7 v" a& x6 ^0 l break;
- L! j: z9 b% I; V" T7 U case "1":% }* I& S9 g) {, |4 X
mHeadingMode = WaypointMissionHeadingMode.USING_INITIAL_DIRECTION;" M( o- M& ]+ F6 Q
break; r2 a [4 C& M$ ?1 z7 R% n
case "2":1 `( N( V/ d9 B
mHeadingMode = WaypointMissionHeadingMode.CONTROL_BY_REMOTE_CONTROLLER;0 q/ f( o1 ~2 {" a: I! `9 g
break;) P, }1 ?0 y& g
case "3":9 _- D3 T( q9 c( K9 W: w
mHeadingMode = WaypointMissionHeadingMode.USING_WAYPOINT_HEADING;' A- L" W$ ^( p4 F* [ |
break;/ M7 A; u+ a0 u8 Y& L9 T
case "4":- x; U! n3 k2 |
mHeadingMode = WaypointMissionHeadingMode.TOWARD_POINT_OF_INTEREST;5 z# g5 g. P& g+ v/ ]1 X/ w% `
break;
( _" {1 V, Z$ l }
) N. m( O) X9 s. }/ t2 V* M switch (c.getString(5)) {6 Q1 X2 Q1 q5 _8 f9 v( ^+ C
case "0":
8 c! S, E8 n2 I# |0 _6 q mFinishedAction = WaypointMissionFinishedAction.NO_ACTION;+ S# |& s5 d( m/ b) u$ E3 V
break;
% T. ^; O8 U# ^( \( n case "1":+ `# \& C; s- x2 ~
mFinishedAction = WaypointMissionFinishedAction.GO_HOME;, @6 [: H/ D/ D: i# i
break;
/ f" y0 W e# h3 u9 l! \$ u+ y case "2":% I# d: ^0 |% c. ?% a
mFinishedAction = WaypointMissionFinishedAction.AUTO_LAND;
8 K0 k4 D9 e6 k5 J5 \0 z break;
* M3 r, g* ?# ?9 X; C6 S case "3":
: ?9 y% y J! ^- m4 K2 O, v mFinishedAction = WaypointMissionFinishedAction.GO_FIRST_WAYPOINT;
g9 V7 C9 G( W8 T/ S9 O break;
7 O" b9 W: y6 [! G) M* A: i case "4":* E9 @: h/ ^9 h/ f9 _
mFinishedAction = WaypointMissionFinishedAction.CONTINUE_UNTIL_END;
" N( C6 V4 G+ z; C. a break;. J4 o3 \9 ]) L1 h0 d" V
}
R; A( k; N) A q9 }* i }% E; Y" _1 H( w7 U# Y$ O
}
1 q8 Z" P9 f5 p7 l; b6 `! I for (int i = 0; i new LatLng(mPointInfo.get(i).getLatitude(), mPointInfo.get(i).getLongitude()));6 D; Y5 n4 e. C, T- j. Y
Waypoint mWaypoint = new Waypoint(mPointInfo.get(i).getLatitude(), mPointInfo.get(i).getLongitude(), altitude);
( _/ L# g0 U7 E" T; X0 s if (waypointMissionBuilder != null) {1 |) v3 n' c0 v, r" e% L! V, i
waypointList.add(mWaypoint);
" j9 \: A; ]9 t3 l, x: }; n waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());5 @; F% {2 E! h, }3 f% I6 n
} else {
" @. y! N4 T. r# w waypointMissionBuilder = new WaypointMission.Builder();( l, K. G/ \3 p; q1 l1 L
waypointList.add(mWaypoint);
$ u$ g# \1 c7 Z waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());
7 }; y+ M2 I' f) S0 {4 k }( b+ m/ ~' y7 p; q0 ~
}$ C; q9 }* q3 L! K
aMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(mPointInfo.get(0).getLatitude(), mPointInfo.get(0).getLongitude()), 18, 0, 0)));0 R6 w3 h+ z! y: H* b9 Z
ResultconfigWayPointMission();+ ^1 K/ Z8 T) G( l4 ?
getWaypointMissionOperator().uploadMission(new CommonCallbacks.CompletionCallback() {/ ^0 a$ [ O1 }0 j' b0 b' z
@Override8 b3 Q* u$ [: ~9 Z( E, J
public void onResult(DJIError djiError) {
4 E' s, n3 u# ]$ R7 ` if (djiError == null) {
f6 g7 S6 | U showToasts("获取任务成功!"); E2 a2 E4 i2 \# N& J
}% f. y& B, \4 \# ?2 E- J. c6 u
}0 i: J% k0 K" ~2 C+ C* P
});/ |. L2 {, ^6 D+ z& q% ]- w: j1 X
}! b' m7 y5 M- Q; t( H2 o6 v
private void showWaypoint(LatLng point) {; m8 M; u6 }6 d% P0 D R
MarkerOptions markerOptions = new MarkerOptions();4 g6 }: y8 L) Y( o- U' V' [( J
markerOptions.position(point);
8 c& U/ e, f, a; }) r. w markerOptions.title("航点" + (mMarkers.size() + 1));
' e& A& g# l5 g3 P4 ]7 n! F- Y markerOptions.snippet("事件:");
9 T3 Y' f" K3 k) x* [ markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
2 Z# Y) u" r9 @/ o" V8 p markerOptions.infoWindowEnable(true);
* I+ C% {: j4 ~. z Marker marker = aMap.addMarker(markerOptions);
3 A3 M, u0 S; G( O: @! j mMarkers.put(mMarkers.size(), marker);9 \$ p- s/ W. [
marker.showInfoWindow();
1 ^& \" \0 @) C$ w if (mMarkers.size() > 0) {# x0 |- x( W! I2 o% }! K! x& u
mLatLng.clear();
7 N, w4 p* U: |9 X! `9 J PolylineOptions PolylineOptions = new PolylineOptions();
6 X( V' U& {1 }! h0 f for (int i = 0; i 10);
8 \! Y9 p6 T2 k+ s, ~ PolylineOptions.color(Color.argb(255, 1, 1, 1));
7 D1 C) \$ N/ } aMap.addPolyline(PolylineOptions);
9 K8 _! j# W% j8 K" [7 F* H8 k }
' k& A4 L' X7 u0 ]' l$ s- j }
* k9 @1 m/ R. I. F5 T private void ResultconfigWayPointMission() {+ a" S5 r* g' B; \% t O
if (waypointMissionBuilder == null) {) O/ U! Q4 Q9 [# U( ^/ L3 N8 F
waypointMissionBuilder = new WaypointMission.Builder().finishedAction(mFinishedAction)
; ^ p8 N4 O7 G8 u1 _; I5 p8 ` .headingMode(mHeadingMode)3 H5 u. W2 t }7 n2 `5 g
.autoFlightSpeed(mSpeed). u4 } O5 u. O1 d8 C
.maxFlightSpeed(mSpeed)3 Q& c$ F) }" X# v+ f# g+ k/ Y
.flightPathMode(WaypointMissionFlightPathMode.NORMAL);
7 a4 T4 n6 p8 r+ m/ l$ K; R } else {5 r; ]$ b$ @4 W
waypointMissionBuilder.finishedAction(mFinishedAction)
3 X( \9 p" r* C6 a .headingMode(mHeadingMode)
/ d7 D3 `" D' y# e1 H/ b .autoFlightSpeed(mSpeed)
' H* d2 w* O5 `: ~5 H j .maxFlightSpeed(mSpeed)
% T" r) A/ m8 S1 K .flightPathMode(WaypointMissionFlightPathMode.NORMAL);
* \1 o7 s' u- ? [6 Q f I$ E- T }5 h s3 M1 g+ ?7 q
if (waypointMissionBuilder.getWaypointList().size() > 0) {; Q- q F9 r3 e7 c$ u7 e% E5 x
for (int i = 0; i if (error == null) {1 w$ U" u; l2 l
if (mLinearLayoutInformation.getVisibility() == View.GONE) {
, f& H, u4 A1 I+ x mLinearLayoutInformation.setVisibility(View.VISIBLE);9 Q+ \3 _* H7 u+ \9 X
}6 x7 _! t& q6 W6 g
mButtonStart.setVisibility(View.VISIBLE);3 G6 `4 A+ V: G5 _" t1 n( l! s
mButtonStop.setVisibility(View.VISIBLE);
2 N8 ^9 q" Y, R9 g mTextViewHeight.setText("高度:" + altitude + "m");
" j2 y' S4 M/ f9 O mTextViewSpeed.setText("速度:" + mSpeed + "m/s");
2 V$ d0 x. X2 a/ E# M mTextViewCount.setText("航点数:" + waypointMissionBuilder.getWaypointCount());
- D. r' i5 G ~* c% n F mTextViewDistance.setText("总距离:" + Math.round(waypointMissionBuilder.calculateTotalDistance()) + "m");
. a" j5 i# E3 @% T" Z6 ]! z mTextViewTime.setText("总时间:" + Math.round(waypointMissionBuilder.calculateTotalTime()) + "min");
+ Z8 G- c+ z# K3 M/ j }
0 W, ^5 d% S; M" [ }; S I$ V8 o& C" B
private void addSampleMarker() {
. l, p0 l$ Q3 r. w, n if (ReadKml.addSampleSuccess) {) h; U3 ~$ j% R! S* l
aMap.clear();
' b: z0 ?9 T0 i8 I1 h. T7 H mMarkers.clear();+ a0 c7 ^9 [% t; U+ }5 j& Q
mPointInfo.clear();1 h% p9 K& E/ g- _( s" M
waypointList.clear();
* [/ V! j& N* W0 H2 v if (mLinearLayoutInformation.getVisibility() == View.VISIBLE) {1 S/ J. w# Q; ~7 x
mLinearLayoutInformation.setVisibility(View.GONE);% v. z+ o: n9 g/ Y1 t/ K; m
} ]4 q# t9 x3 i9 a
mButtonFinish.setVisibility(View.GONE);
4 D- I8 z, ^& C* {' b. U mButtonSetting.setVisibility(View.GONE);5 k) [! D, P$ C
mButtonUpload.setVisibility(View.GONE);
( t, i x% K, y9 b/ m/ { mButtonStart.setVisibility(View.GONE);4 o2 `& {% I3 x6 R- Q0 Z7 ` N- ]. g
mButtonStop.setVisibility(View.GONE);6 B- m" K4 L- v
for (int i = 0; i new LatLng(sampleList.get(i).getX(), sampleList.get(i).getY()));
1 A% F2 ^3 p- t1 `, ?) p* x/ \ Waypoint mWaypoint = new Waypoint(sampleList.get(i).getX(), sampleList.get(i).getY(), altitude);
/ Q; h1 P% k' |+ i6 g //Add Waypoints to Waypoint arraylist;
& X3 r. u X. g/ \ if (waypointMissionBuilder != null) {5 h9 @) u8 q! z0 b' {1 N
waypointList.add(mWaypoint);
) }. f v( M- G& X* [* k waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());5 m, }( H$ I1 |
} else {2 ?' h7 _/ E7 @; c& j7 [) _9 e
waypointMissionBuilder = new WaypointMission.Builder();
+ u# n, J( J& M ^7 N, Z3 G3 { waypointList.add(mWaypoint);
2 k) P1 Z8 }9 `5 N$ u waypointMissionBuilder.waypointList(waypointList).waypointCount(waypointList.size());' V: f D6 n2 H) X
}' S$ Z* D. L# e
}( l# ~+ A+ l Q- ~# m, ~5 i
aMap.moveCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(sampleList.get(0).getX(), sampleList.get(0).getY()), 18, 0, 0)));
! f1 H$ c4 d9 W$ O4 M: K$ g$ { showSettingDialog();. V3 Y" k" m! I$ E9 x/ r
mButtonSetting.setVisibility(View.VISIBLE);
6 ^* k9 W0 Z/ X. i mButtonUpload.setVisibility(View.VISIBLE);+ p* C; U2 q! ?- ^( @9 {6 [
} else {/ M: ?- u% r5 c7 E& {4 u
Log.d("MainActivity", "addSampleSuccess is false or aMap is null");% r9 g% G7 v: w: w
}) E" A1 {9 C& A
}& l- J4 a/ E$ Y! B* u' t, A8 }- G
6 Q, j8 d: Z9 S3
9 J. P4 F* v( F1 N航线管理
/ ^" Y7 ]9 e2 c* H' {* P8 ?$ H: V创建activity_waypoint.xml和WaypointActivity文件。
$ s0 |9 v8 p/ U: W2 _
, N) `% l3 r1 Q U6 F( [( W: w6 K4 e& uactivity_waypoint.xml
$ J2 s4 m" [. S. ]3 Y4 F$ E
& n* h' a( l3 v$ A& u5 ] P; ^LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"# z7 _" Q5 ^" {: c
xmlns:app="http://schemas.android.com/apk/res-auto"
" D" \1 m) \0 q* h xmlns:tools="http://schemas.android.com/tools"
0 r b7 v" s$ |* q android:layout_width="match_parent") l% u$ F9 K3 m( \
android:layout_height="match_parent"# v: v! u! }/ _& D6 n; G, |" V
tools:context=".ui.WaypointActivity"
* e( k2 T+ p0 r7 A9 T android:orientation="vertical". H; T' i( j9 N4 v
android:background="@drawable/shape_corner_eight">
& @/ ?9 N" `8 `: l include9 t2 ?: G* [1 S: N G- b
android:id="@+id/layout_waypoint" S, U1 @, [5 Q/ d |, \" K
layout="@layout/activity_toolbar">include>! |; y2 ]0 }7 n% W- Q( n
View* O/ p7 o( Z& Q# N3 c; |$ D$ V
android:layout_width="match_parent"1 ?+ a; _8 _8 q6 [1 m ?
android:layout_height="1dp"
4 ^9 S T8 ^3 _8 S% H' x android:background="#5B6782"
9 l* v) |1 c' P9 u% p) n9 S1 c. R android:layout_marginTop="1dp"* ^+ X# [8 ~( j4 P
android:layout_marginRight="20dp"
" r, ^ a$ N. {. ] android:layout_marginLeft="20dp"
( `/ ~1 y8 }0 e# H4 a >View> N Z, R! T2 k1 W! c; K: ~9 ~! o/ d
androidx.recyclerview.widget.RecyclerView) B6 ?% w( t" q! G$ ?
android:id="@+id/rv_waypoint"
* O: }3 x1 ]: H" g' f' S android:layout_width="match_parent"
, C$ L' D! z6 b0 ~& V android:layout_height="match_parent"9 O7 l m0 f. O8 l7 q7 s, m. F
android:layout_marginRight="20dp" a9 ]7 M4 W1 d
android:layout_marginLeft="20dp">androidx.recyclerview.widget.RecyclerView>
# a$ A+ v! l2 T. K; O8 ?LinearLayout>
# z$ P! L# M/ {8 X2 P9 f8 |0 m% WWaypointActivity) H+ Z6 q2 E' v* U( l+ o
' G s4 `! C; X% t% k# k' y; n@Layout(R.layout.activity_waypoint)! \% J- e8 K, p: N
public class WaypointActivity extends BaseActivity implements View.OnClickListener {0 V2 R, X/ y$ j6 a' O
@BindView(R.id.layout_waypoint)7 x; f) d& o. D" H
View mViewLayoutToolbar;6 F$ S1 |1 v. b
@BindView(R.id.ll_waypoint)
4 }( o0 U- e: R4 e LinearLayout mLinearLayout;' }& V# J1 A" G% n8 K5 ~0 z7 y+ r: e
@BindView(R.id.tv_toolbar_title)
8 d% p7 z" V, i& m4 d7 _$ G TextView mTextViewToolbarTitle;
5 ^& q, t- N, I4 f @BindView(R.id.rv_waypoint)
1 ~$ h# [- l9 ?5 o1 J8 e RecyclerView mRecyclerView;4 {( Y8 X+ v* [* t3 X# C2 n& ^, ?
private SQLiteHelper mSQLiteHelper;; C9 ~* `6 ?% I
private List mWaypointInfo = new ArrayList();
' r+ V( a; i3 `# h private WaypointAdapter mWaypointAdapter;8 C- I3 R' K) F% D" F
private List[I] mWaypointId = new ArrayList();
* ]7 }! `% q! [, W* \ private String StrId = "";% C" u: |$ o6 K% N* V* [2 }! @/ F
@Override6 @' Q0 u! n7 ?# U& q" l$ h
public void initViews() {
2 I" k$ |2 R* t7 {$ W$ \3 R7 | mLinearLayout.setVisibility(View.VISIBLE);/ }' s- v- ~6 c# Q$ g( Z& g% Z) B1 u
mTextViewToolbarTitle.setText("航线管理");6 Z, M7 q0 X5 b' j* @
MyStatic.isChoose = false;
9 j) ]. g- V+ {% f }- N r9 d+ E' v1 c7 l+ a8 x# t* {4 v @
@Override- [; c. A$ `* X
public void initDatas() {
& A" B3 N& T3 f, q! P5 y, z mSQLiteHelper = new SQLiteHelper(WaypointActivity.this);
7 Z9 j( g! n( O$ \/ n# K- D0 \ Cursor c = mSQLiteHelper.doSelect();
: J) E# o: J. i2 r: s0 i& O if (c!=null){( p5 H; p3 ^3 `
while (c.moveToNext()){; ]9 }% O g* i6 p
mWaypointInfo.add(new WaypointInfo(c.getInt(0),c.getString(1),c.getFloat(2),c.getFloat(3),
5 y3 U3 ^' F S2 f. K c.getString(4),c.getString(5),c.getString(6),c.getInt(7),c.getInt(8),& x9 t9 W9 R, p, k& U; E% h _
c.getInt(9),c.getString(10)));
% p" `; V& X% ?% j$ W5 b( l }1 v: _* r1 g' C
}
, w! Z( r/ n2 v7 B3 |6 i7 M6 i c.close();. b: @, z/ Q8 S: w! C% }
mSQLiteHelper.close();; {0 i ~1 H' y/ n2 ?/ j* R3 w
mWaypointAdapter = new WaypointAdapter(R.layout.item_waypoint);& T! W( u1 ?+ ]
mWaypointAdapter.setNewData(mWaypointInfo);6 X6 l. z8 `7 Y6 y" e0 H
initRv(mRecyclerView,mWaypointAdapter);& L% h; ]: l, S2 G7 }; m, H
mWaypointAdapter.setOnItemchildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
# [: x1 P8 S9 Y5 `3 n @Override
1 S) F- P; X) E( z u# D public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {' {8 S8 V, L$ \- _5 J
Intent intent = new Intent();
* @1 q* p) p7 Q intent.putExtra("id", mWaypointInfo.get(position).getId());
$ ]: J8 f6 ]) B% d9 B1 O setResult(RESULT_OK, intent);
1 @2 c9 a! T" O$ J/ _6 M! a finish();
/ x" C" \% d; O+ z" v }7 _+ r- I9 ]$ k3 p9 @
});9 X. x9 P. Z# |0 l
mWaypointAdapter.setOnCheckboxCheckedListener(new WaypointAdapter.OnCheckboxCheckedListener() {
) }. _, {) F) q' ? ?; R. C8 ~9 B @Override) e; q# W% S$ W" R. x' ]0 F7 m
public void OnCheckboxChecked(boolean isCheck, int position) {5 m' U1 R" f, s1 ^5 V- O1 }
if (isCheck){. y3 |8 E7 q3 \, B1 ~/ D( N" A4 X
mWaypointId.add(position);4 i T0 C% }7 H( e9 n& y6 ~
}else {
8 `- A, }- E$ F+ k if (mWaypointId.contains(position)){8 A$ p/ H4 L* Y; r
mWaypointId.remove(position);
o# n& R/ ^! J! v4 S }- i; T* U! r* c" f: M
}1 j) l. H( @5 k {! d3 d/ `
}7 i A2 |3 w, L" y
});7 P/ _& b, \/ r3 l
}) r9 d6 ^5 R/ I. k- U" s u
@Override1 o. w4 }9 D: R* _' u( i
protected void requestData() {" q' G! f2 E, H- z3 \3 @: w2 X
}5 m3 {1 }3 L3 S4 E* ?3 n8 A: q6 r
@OnClick({R.id.img_way_choose,R.id.img_way_delete,R.id.img_back})
: u2 ]3 j6 I( h8 D' f. K: t( `- | @Override4 q# F$ a& W7 R
public void onClick(View v) {& K' q8 c" G" c( k& `
switch (v.getId()){
1 F/ A t$ B( v3 M7 i r case R.id.img_way_choose:
/ j. M+ P1 b0 T x7 \: c D/ A8 q if (MyStatic.isChoose){
9 L& ?% H* R! \8 S) y( j0 d, U MyStatic.isChoose = false;- u$ s/ u( D' B9 f* K, l
}else {4 |9 F# \8 E7 |: E5 z4 M/ ]
MyStatic.isChoose = true;( ^8 N/ G' U$ x$ P& t0 }1 F8 S! j
} @, Y2 q+ h+ G
if (mWaypointAdapter!=null){
1 o5 N, l) v6 J9 u mWaypointAdapter.notifyDataSetChanged();
- T7 c7 ~( K1 p! Z V% ?9 H }
]$ b$ u6 E* v0 ^ break;
9 I8 ~* l1 l- U! d+ P) B, p7 T case R.id.img_way_delete:7 S1 ?9 U m# L, D& l
if (mWaypointId.size() > 0){
: b* N/ x, E( C0 t2 k2 e6 G& J: r for (int i = 0; i ",";/ \2 h1 y/ ]/ e4 i) l
}
9 f" f2 ?) s2 O# B/ O+ J5 R k if (!TextUtils.isEmpty(StrId)){
: f% O0 a6 q4 g: P6 o6 D0 ~' ` StrId = StrId.substring(0,StrId.length()-1);
. ~9 I J1 a/ v' z0 l+ _ mSQLiteHelper = new SQLiteHelper(WaypointActivity.this);
# a% V2 H7 \" F; m, O# r+ S! e8 h3 H7 q mSQLiteHelper.doDelete(StrId);- ?: \. l" U0 g& ^2 p
mSQLiteHelper.close();
7 b% P$ R: u( C, b9 c0 i for (int j = 0; j if (mWaypointAdapter!=null){
( d5 Q) Z: v& A3 W# i' c mWaypointId.clear();
" h; w* q b, F; w3 F* O, _* J2 a& _' e MyStatic.isChoose = false;
: @% W" } o: k \ mWaypointAdapter.setNewData(mWaypointInfo); y6 g' m. F6 V/ }5 R- V5 |: f
}9 J+ c- Y* Z* j! e
}
6 Q2 H& D6 ]$ m4 o$ X* x) j. s }else {
) @5 s5 M/ y8 D7 Y$ d, u showToasts("请先选择删除的航线!");3 a( o6 }. h- x$ z. e }
}
0 m4 R0 I' T9 Q | break;+ P/ h) Y% f) ?# d
case R.id.img_back:
# c9 u1 h! |% u9 O1 V0 s Intent intent = new Intent();1 }% t. d) W, T0 D, R( O
intent.putExtra("id", -1);
) d$ t1 h) ^$ h; p' Y3 ]7 w" Z3 D' K setResult(RESULT_OK, intent);
& T9 o6 F% B: d$ { finish();' g- h) D/ l7 U8 @5 e# C
break;
8 I5 g8 F, V8 V& j+ |3 y3 u }
9 `% M) g. s. L5 G" M! o1 A }
" ]& n$ i' \5 q; V+ l以上代码仅供参考,如果想了解更多的大疆无人机二次开发过程可以私信我,源代码因为涉及到商业使用不能给大家共享,有什么问题我可以帮你解决。
8 k5 v" D5 w6 q+ y) F( h
5yks3dvh5by640349811.png
) T! f) ^* R1 v
往期推荐毕业设计So Easy:基于C++实现网络扫描器; i8 L" e2 ?/ |! u+ b4 M: J: G
详解CAN总线:CAN节点硬件构成方案- V6 x( a' f' C
LabVIEW串口通信
! o) f( h1 o. E5 I1 `LabVIEW感兴趣区域分析(实战篇—1)
/ E+ W! o% f3 v9 A) g2 b7 ?" gPython Qt GUI设计:信号与槽的使用方法(基础篇—7)
( @2 G' t( ^, _9 S3 F4 ?和12岁小同志搞创客开发:如何使用继电器?
9 _4 l) Y) \- ]PCB天线无线模组如何布局摆放?( U% N/ p/ ?: Y" x. V4 F* l
芯片内部长啥样?牛人用1500张照片,一层一层放给你看!% E; e& W& ~( z. r$ S' B" x
移柯L620模组使用MQTT协议连接移动OneNet云平台/ x# q% K k, V* t2 I
" U% x$ l h* a* E B
ncztwuyizh2640349911.jpg
5 ]. D' H& ~: d/ A6 ^. W
ga3gen0esyq640350011.gif
& t, D0 F& \$ ]# P. w) e点击阅读原文,更精彩~ |
|