-
Notifications
You must be signed in to change notification settings - Fork 29
/
onekey.sh
executable file
·1263 lines (1147 loc) · 43.8 KB
/
onekey.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
#=================================================
# System Required: Ubuntu 14.04+
# Description: Install ROS And Spark
# Version: 1.0.21
# Author: J.xiao
# Site: http://www.nxrobo.com/
# SPARK技术讨论与反馈群:8346256
#=================================================
GAME_ENABLE="no"
sh_ver="1.1.0"
filepath=$(cd "$(dirname "$0")"; pwd)
Green_font_prefix="\033[32m" && Red_font_prefix="\033[31m" && Green_background_prefix="\033[42;37m" && Red_background_prefix="\033[41;37m" && Font_color_suffix="\033[0m" && Yellow_font_prefix="\e[1;33m" && Blue_font_prefix="\e[0;34m"
Info="${Green_font_prefix}[信息]${Font_color_suffix}"
Error="${Red_font_prefix}[错误]${Font_color_suffix}"
Warn="${Yellow_font_prefix}[警告]${Font_color_suffix}"
Tip="${Green_font_prefix}[注意]${Font_color_suffix}"
Separator_1="——————————————————————————————"
password="spark"
Version=$(lsb_release -r --short)
Codename=$(lsb_release -c --short)
OSDescription=$(lsb_release -d --short)
OSArch=$(uname -m)
calibra_default="${filepath}/../.ros/camera_info"
calibration="calibration"
color_block="color_block"
#检查系统要求
check_sys(){
if [[ "${Version}" == "14.04" ]]; then
ROS_Ver="indigo"
elif [[ "${Version}" == "16.04" ]]; then
ROS_Ver="kinetic"
elif [[ "${Version}" == "18.04" ]]; then
ROS_Ver="melodic"
else
echo -e "${Error} SPARK不支持当前系统 ${OSDescription} !" && exit 1
fi
}
#检查设备连接
check_dev(){
#检查底盘
if [ ! -n "$(lsusb -d 1a86:7523)" ]; then
echo -e "${Error} 底盘没有正确连接,请确认正确连接!!"
fi
#检查机械臂
if [ -n "$(lsusb -d 2341:0042)" ]; then
echo -e "${Info} 正在使用UARM机械臂"
ARMTYPE="uarm"
elif [ -n "$(lsusb -d 2e88:4603)" ]; then
echo -e "${Info} 正在使用射手座机械臂"
ARMTYPE="sagittarius_arm"
else
echo -e "${Error} 机械臂没有正确连接或未上电,请确认正确连接!!"
ARMTYPE="uarm"
fi
#检查摄像头
check_camera
#检查雷达
check_lidar
}
check_camera_no_print(){
#检查使用哪种设备
if [ -n "$(lsusb -d 2bc5:0403)" ]; then
CAMERATYPE="astrapro"
fi
if [ -n "$(lsusb -d 2bc5:0401)" ]; then
CAMERATYPE="astra"
fi
if [ -n "$(lsusb -d 8086:0b07)" ]; then
CAMERATYPE="d435"
fi
}
#检查摄像头设备
check_camera(){
camera_flag=0
calibra_backup="/opt/nxrobo/camera_info"
#检查使用哪种设备
if [ -n "$(lsusb -d 2bc5:0403)" ]; then
CAMERATYPE="astrapro"
depthtolaser="/camera/depth/image_rect_raw"
camera_flag=$[$camera_flag + 1]
fi
if [ -n "$(lsusb -d 2bc5:0401)" ]; then
CAMERATYPE="astra"
depthtolaser="/camera/depth/image_raw"
camera_flag=$[$camera_flag + 1]
fi
if [ -n "$(lsusb -d 8086:0b07)" ]; then
CAMERATYPE="d435"
depthtolaser="/camera/depth/image_rect_raw"
camera_flag=$[$camera_flag + 1]
fi
if [ $camera_flag -ge 2 ]; then
echo -e "${Warn} 正在使用多个摄像头设备,请退出并拔掉其中一个再使用!"
echo -e "${Warn} 退出请输入:Ctrl + c!"
elif [ $camera_flag -eq 1 ]; then
echo -e "${Info} 正在使用${CAMERATYPE}摄像头"
elif [ $camera_flag -eq 0 ]; then
echo -e "${Error} 没有找到摄像头,请确认摄像头已正确连接!!"
fi
#根据摄像头类型检查标定文件和备份文件
case $CAMERATYPE in
astrapro)
#检查是否有默认文件夹和备份文件夹
if [ ! -d "$calibra_default" ]; then
mkdir -p "$calibra_default"
fi
if [ ! -d "$calibra_backup" ]; then
echo -e "${Info} 创建标定文件备份文件夹..."
sudo mkdir -p "$calibra_backup"
fi
#如果没有就拷贝一份
if [ ! -f "$calibra_backup/camera.yaml" ]||[ ! -f "$calibra_backup/depth_Astra_Orbbec.yaml" ]; then
if [ -f "$calibra_default/camera.yaml" ]&&[ -f "$calibra_default/depth_Astra_Orbbec.yaml" ]; then
echo -e "${Info} 备份标定文件..."
sudo cp -r "$calibra_default/." "$calibra_backup/."
elif [ ! -f "$calibra_default/camera.yaml" ]||[ ! -f "$calibra_default/depth_Astra_Orbbec.yaml" ]; then
echo -e "${Warn} 标定文件缺少其中一个,请确认rgb和depth标定文件都存在"
fi
elif [ -f "$calibra_backup/camera.yaml" ]&&[ -f "$calibra_backup/depth_Astra_Orbbec.yaml" ]; then
if [ ! -f "$calibra_default/camera.yaml" ]; then
echo -e "${Info} 缺少彩色摄像头标定文件,已拷贝"
cp "$calibra_backup/camera.yaml" $calibra_default
fi
if [ ! -f "$calibra_default/depth_Astra_Orbbec.yaml" ]; then
echo -e "${Info} 缺少深度摄像头标定文件,已拷贝"
cp "$calibra_backup/depth_Astra_Orbbec.yaml" $calibra_default
fi
fi
;;
astra)
#astra自带标定文件
#如果检查到有标定文件就删除
if [ -d "$calibra_default" ]; then
rm -rf "$calibra_default"
fi
;;
esac
}
#检查雷达设备
check_lidar(){
BASEPATH=$(cd `dirname $0`; pwd)
TYPE_LIDAR=$(cat /opt/lidar.txt)
if [[ "${TYPE_LIDAR}" == "ydlidar_g6" ]]; then
LIDARTYPE="ydlidar_g6"
rm -f ${BASEPATH}/src/spark_driver/lidar/ydlidar_g6/CATKIN_IGNORE
elif [[ "${TYPE_LIDAR}" == "ydlidar_g2" ]]; then
LIDARTYPE="ydlidar_g2"
touch ${BASEPATH}/src/spark_driver/lidar/ydlidar_g6/CATKIN_IGNORE
elif [[ "${TYPE_LIDAR}" == "3iroboticslidar2" ]]; then
LIDARTYPE="3iroboticslidar2"
touch ${BASEPATH}/src/spark_driver/lidar/ydlidar_g6/CATKIN_IGNORE
else
echo "暂不支持的雷达:${TYPE_LIDAR},使用默认的杉川雷达运行"
LIDARTYPE="3iroboticslidar2"
touch ${BASEPATH}/src/spark_driver/lidar/ydlidar_g6/CATKIN_IGNORE
fi
lidar_flag=0
#检查使用哪种设备
if [ -n "$(lsusb -d 10c4:ea60)" ]; then
lidar_flag=$[$lidar_flag + 1]
fi
if [ $lidar_flag -ge 2 ]; then
echo -e "${Warn} 正在使用多个雷达设备,请退出并拔掉其中一个再使用!"
echo -e "${Warn} 退出请输入:Ctrl + c!"
elif [ $lidar_flag -eq 1 ]; then
echo -e "${Info} 正在使用${LIDARTYPE}雷达"
elif [ $lidar_flag -eq 0 ]; then
echo -e "${Error} 没有找到雷达,请确认雷达已正确连接!!"
fi
}
#安装ROS完整版
install_ros_full(){
sudo sh -c 'echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6'
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt-get update
sudo apt-get install -y ros-${ROS_Ver}-desktop-full
sudo rosdep init
rosdep update
echo "source /opt/ros/${ROS_Ver}/setup.bash" >> ~/.bashrc
source /opt/ros/${ROS_Ver}/setup.bash
sudo apt-get install -y python-rosinstall python-rosinstall-generator python-wstool build-essential
}
#检测是否需要安装完整版
check_install_ros_full(){
if [ -f "/usr/bin/rosversion" ]; then
ROSVER=`/usr/bin/rosversion -d`
if [ $ROSVER ]; then
echo -e "${Tip} 检测到当前系统已安装了ROS的${ROSVER}版本!"
echo && stty erase ^? && read -p "请选择是否继续安装? y/n:" choose
if [[ "${choose}" == "y" ]]; then
echo -e "${Info}准备安装ROS系统!"
else
exit
fi
fi
fi
install_ros_full
}
#安装SPARK依赖库
install_spark_require(){
echo -e "${Info} 准备安装SPARK相关驱动……"
echo 'deb http://realsense-hw-public.s3.amazonaws.com/Debian/apt-repo xenial main' | sudo tee /etc/apt/sources.list.d/realsense-public.list
sudo apt-key adv --keyserver keys.gnupg.net --recv-key 6F3EFCDE
if [[ "${ROS_Ver}" == "kinetic" ]]; then
sudo add-apt-repository "deb http://realsense-hw-public.s3.amazonaws.com/Debian/apt-repo xenial main" -u
elif [[ "${ROS_Ver}" == "melodic" ]]; then
sudo add-apt-repository "deb http://realsense-hw-public.s3.amazonaws.com/Debian/apt-repo bionic main" -u
fi
echo -e "${Info} 设置udev规则……"
BASEPATH=$(cd `dirname $0`; pwd)
sudo cp $BASEPATH/doc/rules/3ilidar-usb-serial.rules /etc/udev/rules.d/
sudo cp $BASEPATH/doc/rules/uarm-usb-serial.rules /etc/udev/rules.d/
sudo cp $BASEPATH/doc/rules/spark-usb-serial.rules /etc/udev/rules.d/
sudo cp $BASEPATH/doc/rules/orbbec-usb.rules /etc/udev/rules.d/556-orbbec-usb.rules
sudo udevadm trigger
echo -e "${Info} 安装所需要的依赖库……"
#sudo sh -c 'echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6'
sudo apt-get update
sudo apt-get install -y ros-${ROS_Ver}-ecl ros-${ROS_Ver}-ecl-threads ros-${ROS_Ver}-rgbd-launch
sudo apt-get install -y ros-${ROS_Ver}-image-common
sudo apt-get install -y ros-${ROS_Ver}-move-base-*
sudo apt-get install -y ros-${ROS_Ver}-serial
sudo apt-get install -y ros-${ROS_Ver}-libuvc-camera
sudo apt-get install -y python-pip python-sklearn libudev-dev
sudo apt-get install -y ros-${ROS_Ver}-depthimage-to-laserscan ros-${ROS_Ver}-map-server ros-${ROS_Ver}-amcl ros-${ROS_Ver}-gmapping ros-${ROS_Ver}-navigation ros-${ROS_Ver}-navigation-stage ros-${ROS_Ver}-navigation-layers ros-${ROS_Ver}-navigation-tutorials
sudo apt-get install -y ros-${ROS_Ver}-hector-mapping
sudo apt-get install -y ros-${ROS_Ver}-frontier-exploration
sudo apt-get install -y ros-${ROS_Ver}-cartographer*
sudo apt-get install -y ros-${ROS_Ver}-rtabmap-ros
sudo apt-get install -y ros-${ROS_Ver}-slam-karto
sudo apt-get install -y librealsense2-dkms librealsense2-utils librealsense2-dev librealsense2-dbg
sudo apt-get install -y ros-${ROS_Ver}-ddynamic-reconfigure
sudo apt-get install -y libasound2-dev mplayer
sudo apt-get install -y ros-${ROS_Ver}-usb-cam ros-${ROS_Ver}-openni2-launch
sudo apt-get install -y python-dev python-virtualenv
echo -e "${Info} 安装tensorflow依赖库……"
sudo apt install python-testresources
pip install setuptools -i https://pypi.douban.com/simple/
sudo pip install --upgrade setuptools -i https://pypi.douban.com/simple/
pip install virtualenv -i https://pypi.douban.com/simple/
sudo pip install --upgrade virtualenv -i https://pypi.douban.com/simple/
virtualenv --system-site-packages $BASEPATH/tensorflow
source $BASEPATH/tensorflow/bin/activate
easy_install -U pip
pip install --upgrade tensorflow==1.5.0 -i https://pypi.douban.com/simple/
source $BASEPATH/tensorflow/bin/activate
echo -e "${Info} 安装语音依赖库……"
sudo apt-get install -y swig portaudio19-dev
#sudo easy_install -U pip
sudo pip install pocketsphinx webrtcvad pyaudio wxpy
echo -e "${Info} 依赖库安装成功……"
}
#安装intel_movidius的相关驱动和程序
install_intel_movidius(){
BASEPATH=$(cd `dirname $0`; pwd)
if [[ ! -d "$BASEPATH/src/3rd_app/intel/ncappzoo" ]] || [[ ! -d "$BASEPATH/src/3rd_app/intel/ros_intel_movidius_ncs" ]] || [[ ! -d "/opt/movidius" ]] ; then
echo && stty erase ^? && read -p "检测到未安装INTEL MOVIDIUS的相关驱动和程序,是否现在安装y/n?" yorn
if [[ "${yorn}" == "y" ]]; then
echo -e "${Info} 准备安装intel movidius的相关驱动和代码…… "
echo -e "${Info} 安装过程中可能会花费挺长时间的。请耐心等待!"
cd $BASEPATH
mkdir $BASEPATH/src/3rd_app/intel
cd $BASEPATH/src/3rd_app/intel
echo -e "${Info} git clone https://github.com/movidius/ncsdk"
git clone https://github.com/movidius/ncsdk
echo -e "${Info} git clone https://github.com/movidius/ncappzoo"
git clone https://github.com/movidius/ncappzoo
echo -e "${Info} git clone https://github.com/intel/object_msgs"
git clone https://github.com/intel/object_msgs
echo -e "${Info} git clone https://github.com/intel/ros_intel_movidius_ncs.git"
git clone https://github.com/intel/ros_intel_movidius_ncs.git
cd $BASEPATH/src/3rd_app/intel/ncsdk
make install
make examples
echo -e "${Info} sudo ln -s $BASEPATH/src/3rd_app/intel/ncappzoo /opt/movidius/ncappzoo"
sudo ln -s $BASEPATH/src/3rd_app/intel/ncappzoo /opt/movidius/ncappzoo
cd $BASEPATH/src/3rd_app/intel/ros_intel_movidius_ncs
git checkout master
cp $BASEPATH/src/3rd_app/intel/ros_intel_movidius_ncs/data/labels/* /opt/movidius/ncappzoo/data/ilsvrc12/
# AlexNet
echo -e "${Info} compile NCS graph--AlexNet"
cd /opt/movidius/ncappzoo/caffe/AlexNet
make
# GoogleNet
echo -e "${Info} compile NCS graph--GoogleNet"
cd /opt/movidius/ncappzoo/caffe/GoogLeNet
make
# SqueezeNet
echo -e "${Info} compile NCS graph--SqueezeNet"
cd /opt/movidius/ncappzoo/caffe/SqueezeNet
make
# Inception_V1
echo -e "${Info} compile NCS graph--Inception_V1"
cd /opt/movidius/ncappzoo/tensorflow/inception_v1/
make
# Inception_V2
echo -e "${Info} compile NCS graph--Inception_V2"
cd /opt/movidius/ncappzoo/tensorflow/inception_v2/
make
# Inception_V3
echo -e "${Info} compile NCS graph--Inception_V3"
cd /opt/movidius/ncappzoo/tensorflow/inception_v3/
make
# Inception_V4
echo -e "${Info} compile NCS graph--Inception_V4"
cd /opt/movidius/ncappzoo/tensorflow/inception_v4/
make
# MobileNet
echo -e "${Info} compile NCS graph--MobileNet"
cd /opt/movidius/ncappzoo/tensorflow/mobilenets/
make
# MobileNet_SSD
echo -e "${Info} compile NCS graph--MobileNet_SSD"
cd /opt/movidius/ncappzoo/caffe/SSD_MobileNet
make
# TinyYolo
echo -e "${Info} compile NCS graph--TinyYolo"
cd /opt/movidius/ncappzoo/caffe/TinyYolo
make
echo -e "${Info} finish compiling..."
echo -e "${Info} start to catkin_make..."
cd $BASEPATH
catkin_make
echo -e "${Info} finsh catkin_make..."
else
echo -e "${Info} 取消安装."
exit
fi
fi
}
#编译SPARK
install_spark(){
if [[ "${Version}" == "18.04" ]]; then
git checkout melodic-devel
fi
source /opt/ros/${ROS_Ver}/setup.bash
catkin_make
#catkin_make install
}
#完全安装
install_all(){
check_install_ros_full
install_spark_require
install_spark
}
#远程设置
master_uri_setup(){
eth_ip=`/sbin/ifconfig eth0|grep inet|awk '{print $2}'|awk -F: '{print $2}'`
wlp1s_ip=`/sbin/ifconfig wlp1s0|grep inet|awk '{print $2}'|awk -F: '{print $2}'`
wlp2s_ip=`/sbin/ifconfig wlp2s0|grep inet|awk '{print $2}'|awk -F: '{print $2}'`
wlan_ip=`/sbin/ifconfig wlan0|grep inet|awk '{print $2}'|awk -F: '{print $2}'`
enp3s_ip=`/sbin/ifconfig enp3s0|grep inet|awk '{print $2}'|awk -F: '{print $2}'`
wlp0s_ip=`/sbin/ifconfig wlp0s20f3|grep inet|awk '{print $2}'|awk -F: '{print $2}'`
if [ $eth_ip ]; then
echo -e "${Info}使用有线网络eth0"
local_ip=$eth_ip
elif [ $wlp1s_ip ]; then
echo -e "${Info}使用无线网络wlp1s0"
local_ip=$wlp1s_ip
elif [ $wlp2s_ip ]; then
echo -e "${Info}使用无线网络wlp2s0"
local_ip=$wlp2s_ip
elif [ $wlan_ip ]; then
echo -e "${Info}使用无线网络wlan0"
local_ip=$wlan_ip
elif [ $enp3s_ip ]; then
echo -e "${Info}使用无线网络enp3s0"
local_ip=$enp3s_ip
elif [ $wlp0s_ip ]; then
echo -e "${Info}使用无线网络wlp0s20f3"
local_ip=$wlp0s_ip
fi
export ROS_HOSTNAME=$local_ip
export ROS_MASTER_URI="http://${local_ip}:11311"
echo -e "${Info}Using ROS MASTER at ${Red_font_prefix}$ROS_MASTER_URI${Font_color_suffix} from ${Red_font_prefix}$ROS_HOSTNAME${Font_color_suffix}"
}
#让机器人动起来
let_robot_go(){
echo -e "${Info}"
echo -e "${Info} 让机器人动起来"
PROJECTPATH=$(cd `dirname $0`; pwd)
source ${PROJECTPATH}/devel/setup.bash
echo -e "${Info}"
echo -e "${Info} 请在新的终端窗口操作"
echo -e "${Info}键盘“wsad”分别对应“前后左右”"
echo -e "${Info} "
echo -e "${Info} w前进 "
echo -e "${Info} a左转 d右转 "
echo -e "${Info} s后退 "
echo -e "${Info} "
echo -e "${Info} 退出请输入:Ctrl + c "
echo && stty erase ^? && read -p "按回车键(Enter)开始:"
roslaunch spark_teleop teleop.launch camera_type_tel:=${CAMERATYPE} lidar_type_tel:=${LIDARTYPE} arm_type_tel:=${ARMTYPE} enable_arm_tel:="false"
}
#远程(手机APP)控制SPARK
remote_control_robot(){
master_uri_setup
PROJECTPATH=$(cd `dirname $0`; pwd)
source ${PROJECTPATH}/devel/setup.bash
echo -e "${Info} "
echo -e "${Info} 远程(手机APP)控制SPARK"
echo -e "${Info}"
echo -e "${Info}远程控制的APP地址:${Yellow_font_prefix}https://raw.githubusercontent.com/iamzhuang/RobotCA/kinetic/Release/control_app-debug.apk"${Font_color_suffix}
echo -e "${Info}下载安装完成后,打开app,设置Master URI:${Red_font_prefix}http://${local_ip}:11311${Font_color_suffix}"
echo -e "${Info}接着就可以开始远程控制机器人了"
echo -e "${Info}退出请输入:Ctrl + c"
echo -e "${Info}"
echo && stty erase ^? && read -p "按回车键(Enter)开始:"
roslaunch spark_teleop app_op.launch camera_type_tel:=${CAMERATYPE} lidar_type_tel:=${LIDARTYPE}
}
#让SPARK跟着你走
people_follow(){
echo -e "${Info} "
echo -e "${Info}让SPARK跟着你走"
PROJECTPATH=$(cd `dirname $0`; pwd)
source ${PROJECTPATH}/devel/setup.bash
echo -e "${Info} "
echo -e "${Info}请站在SPARK的正前方,与SPARK保持一米左右的距离,然后走动"
echo -e "${Info} "
echo -e "${Info}退出请输入:Ctrl + c "
echo -e "${Info}"
echo && stty erase ^? && read -p "按回车键(Enter)开始:"
roslaunch spark_follower bringup.launch camera_type_tel:=${CAMERATYPE}
}
#语音控制SPARK移动
voice_nav(){
echo -e "${Info}"
echo -e "${Info}语音控制SPARK移动"
echo -e "${Info}"
echo -e "${Info}请选择语音的方式:
${Green_font_prefix}1.${Font_color_suffix} 本地语音识别(识别准确度低,已不推荐使用,仅支持英文)
${Green_font_prefix}2.${Font_color_suffix} 在线语音识别(需要互联网连接,只支持中文)
${Green_font_prefix}3.${Font_color_suffix} 退出请输入:Ctrl + c"
echo && stty erase ^? && read -p "请输入数字 [1-3]:" asrnum
case "$asrnum" in
1)
ASRTYPE="voice_nav.launch"
;;
2)
ASRTYPE="baidu_nav.launch"
;;
*)
echo -e "${Error} 错误,默认使用在线方式"
ASRTYPE="baidu_nav.launch"
;;
esac
PROJECTPATH=$(cd `dirname $0`; pwd)
source ${PROJECTPATH}/devel/setup.bash
echo -e "${Info} "
echo -e "${Info}请确认连接线并设定正确的默认麦克风"
echo -e "${Info} "
echo -e "${Info}退出请输入:Ctrl + c "
echo -e "${Info}"
echo && stty erase ^? && read -p "按回车键(Enter)开始:"
roslaunch spark_voice ${ASRTYPE} camera_type_tel:=${CAMERATYPE}
}
#机械臂与摄像头匹对标定
cal_camera_arm(){
echo -e "${Info}"
echo -e "${Info}机械臂与摄像头匹对标定"
ROSVER=`/usr/bin/rosversion -d`
PROJECTPATH=$(cd `dirname $0`; pwd)
source ${PROJECTPATH}/devel/setup.bash
echo -e "${Info}"
echo -e "${Info}请确定:"
echo -e "${Info} A.摄像头已反向向下安装好。机械臂正常上电。"
echo -e "${Info} B.${Red_font_prefix}红色${Font_color_suffix}标定物已贴好在吸盘固定头正上方。"
echo -e "${Info} C.机械臂正常上电。"
echo -e "${Info}退出请输入:Ctrl + c "
echo -e "${Info}"
echo && stty erase ^? && read -p "按回车键(Enter)开始:"
if [ $ROSVER = "kinetic" ]; then
echo -e "${Info}It is kinetic."
roslaunch spark_carry_object spark_carry_cal_cv3.launch camera_type_tel:=${CAMERATYPE} lidar_type_tel:=${LIDARTYPE}
elif [ $ROSVER = "indigo" ]; then
echo -e "${Info}It is indigo."
roslaunch spark_carry_object spark_carry_cal_cv2.launch camera_type_tel:=${CAMERATYPE} lidar_type_tel:=${LIDARTYPE}
elif [ $ROSVER = "melodic" ]; then
echo -e "${Info}It is melodic."
roslaunch spark_carry_object spark_carry_cal_cv3.launch camera_type_tel:=${CAMERATYPE} lidar_type_tel:=${LIDARTYPE}
fi
}
#让SPARK使用激光雷达进行导航
spark_navigation_2d(){
echo -e "${Info}"
echo -e "${Info}让SPARK使用激光雷达进行导航"
PROJECTPATH=$(cd `dirname $0`; pwd)
source ${PROJECTPATH}/devel/setup.bash
echo -e "${Info}"
echo -e "${Info}请注意:"
echo -e "${Info} A.激光雷达已上电连接"
echo -e "${Info} B.导航正常启动后,点击‘2D Pose Estimate’后在地图上进行手动定位。"
echo -e "${Info} C.手动定位成功后,点击‘2D Nav Goal’后在地图上指定导航的目标点,机器人将进入自主导航。"
echo -e "${Info}退出请输入:Ctrl + c "
echo -e "${Info}"
echo && stty erase '^H' && read -p "按回车键(Enter)开始:"
roslaunch spark_navigation amcl_demo_lidar_rviz.launch camera_type_tel:=${CAMERATYPE} lidar_type_tel:=${LIDARTYPE}
}
#让SPARK使用深度摄像头进行导航
spark_navigation_3d(){
echo -e "${Info}"
echo -e "${Info}让SPARK使用深度摄像头进行导航"
PROJECTPATH=$(cd `dirname $0`; pwd)
source ${PROJECTPATH}/devel/setup.bash
echo -e "${Info}请选择导航方式:"
echo -e "${Info}1.使用2D地图"
echo -e "${Info}2.使用rtab_map地图"
echo && stty erase ^? && read -p "请输入数字 [1-2]:" slamnum
echo -e "${Info}"
echo -e "${Info}请注意:"
echo -e "${Info}A.摄像头已连接"
case "$slamnum" in
1)
SLAMTYPE="2d"
echo -e "${Info}B.导航正常启动后,点击‘2D Pose Estimate’后在地图上进行手动定位。"
;;
2)
SLAMTYPE="rtab_map"
echo -e "${Info}B.把机器人放到原来建图的原点。导航正常启动后,如需查看原来建立的3D地图,点击rviz的Display->Rtabmap cloud->Download map加载3D地图。"
;;
*)
echo -e "${Error} 错误,默认使用2D地图"
SLAMTYPE="2d"
echo -e "${Info}B.导航正常启动后,点击‘2D Pose Estimate’后在地图上进行手动定位。"
;;
esac
echo -e "${Info}C.手动定位成功后,点击‘2D Nav Goal’后在地图上指定导航的目标点,机器人将进入自主导航。"
echo -e "${Info}退出请输入:Ctrl + c "
echo -e "${Info}"
echo && stty erase ^? && read -p "按回车键(Enter)开始:"
if [[ "${SLAMTYPE}" == "2d" ]]; then
roslaunch spark_navigation amcl_demo_rviz.launch camera_type_tel:=${CAMERATYPE} depthtolaser:=${depthtolaser}
else
roslaunch spark_rtabmap spark_rtabmap_nav.launch camera_type_tel:=${CAMERATYPE} depthtolaser:=${depthtolaser}
fi
}
#深度学习
spark_DeepLearn(){
PROJECTPATH=$(cd `dirname $0`; pwd)
source ${PROJECTPATH}/tensorflow/bin/activate
source ${PROJECTPATH}/devel/setup.bash
echo -e "${Info}运行深度学习的方式:
1.软件tensorflow
2.硬件计算棒(需将intel movidius接在spark的${Blue_font_prefix}蓝色${Font_color_suffix}的USB3.0上)"
echo && stty erase ^? && read -p "请选择 1 或 2 :" chnum
case "$chnum" in
1)
roslaunch tensorflow_object_detector object_detect.launch camera_type_tel:=${CAMERATYPE}
;;
2)
spark_intel_movidius
;;
*)
echo -e "${Error} 错误,将运行默认的软件tensorflow"
roslaunch tensorflow_object_detector object_detect.launch camera_type_tel:=${CAMERATYPE}
;;
esac
}
#intel_movidius的功能列表
intel_movidius_list(){
echo -e "
请根据右侧的功能说明选择相应的序号。
${Green_font_prefix} NO.${Font_color_suffix} | CNN Model | Framework |
${Green_font_prefix} 1.${Font_color_suffix} | AlexNet | Caffe |
${Green_font_prefix} 2.${Font_color_suffix} | GoogleNet | Caffe |
${Green_font_prefix} 3.${Font_color_suffix} | SqueezeNet | Caffe |
${Green_font_prefix} 4.${Font_color_suffix} | Inception_v1 | tensorflow |
${Green_font_prefix} 5.${Font_color_suffix} | Inception_v2 | tensorflow |
${Green_font_prefix} 6.${Font_color_suffix} | Inception_v3 | tensorflow |
${Green_font_prefix} 7.${Font_color_suffix} | Inception_v4 | tensorflow |
${Green_font_prefix} 8.${Font_color_suffix} | MobileNet | tensorflow |
${Green_font_prefix} 9.${Font_color_suffix} | MobileNetSSD | Caffe |
${Green_font_prefix} 10.${Font_color_suffix} | TinyYolo | Caffe |"
}
#运行intel_movidius的相关功能
spark_intel_movidius(){
intel_device=`/usr/bin/lsusb |grep 03e7:|awk '{print $6}'`
if [ $intel_device ]; then
echo -e "${Info}检测到INTEL MOVIDIUS神经计算棒设备,请确定该设备已插入到SPARK主机的USB3.0的接口(${Blue_font_prefix}蓝色${Font_color_suffix}USB接口)。"
install_intel_movidius
echo -e "${Info}请选择下表的相关功能:"
intel_movidius_list
echo && stty erase ^? && read -p "请输入数字 [1-10]:" chnum
case "$chnum" in
1)
roslaunch app_shell intel_movidius_classification.launch cnn_model:=alexnet
;;
2)
roslaunch app_shell intel_movidius_classification.launch cnn_model:=googlenet
;;
3)
roslaunch app_shell intel_movidius_classification.launch cnn_model:=squeezenet
;;
4)
roslaunch app_shell intel_movidius_classification.launch cnn_model:=inception_v1
;;
5)
roslaunch app_shell intel_movidius_classification.launch cnn_model:=inception_v2
;;
6)
roslaunch app_shell intel_movidius_classification.launch cnn_model:=inception_v3
;;
7)
roslaunch app_shell intel_movidius_classification.launch cnn_model:=inception_v4
;;
8)
roslaunch app_shell intel_movidius_classification.launch cnn_model:=mobilenet
;;
9)
roslaunch app_shell intel_movidius_detection.launch cnn_model:=mobilenetssd
;;
10)
roslaunch app_shell intel_movidius_detection.launch cnn_model:=tinyyolo_v1
;;
*)
echo -e "${Error} 错误,将运行默认的mobilenetssd功能"
roslaunch app_shell intel_movidius_detection.launch cnn_model:=mobilenetssd
;;
esac
else
echo -e "${Info}没检测到已插入intel movidius神经计算棒。请先插入相关设备到${Blue_font_prefix}蓝色${Font_color_suffix}的USB3.0接口。"
exit
fi
}
#spark_test_mode
spark_test_mode(){
PROJECTPATH=$(cd `dirname $0`; pwd)
source ${PROJECTPATH}/tensorflow/bin/activate
source ${PROJECTPATH}/devel/setup.bash
echo -e "${Info}老化测试程序,请将机器人放在一个50X50CM的方格中间进行测试,请选择:
1.执行5分钟的检测功能;
2.执行老化检测功能,直至断电。"
echo -e "${Info}退出请输入:Ctrl + c "
echo && stty erase ^? && read -p "请选择 1 或 2 :" chnum
case "$chnum" in
1)
roslaunch spark_test all_run_test_st.launch camera_type_tel:=${CAMERATYPE}
;;
2)
roslaunch spark_test all_run_test.launch camera_type_tel:=${CAMERATYPE}
;;
*)
echo -e "${Error} 退出!"
;;
esac
}
#让SPARK通过机械臂进行视觉抓取
spark_carry_obj(){
echo -e "${Info}"
echo -e "${Info}让SPARK通过机械臂进行视觉抓取"
ROSVER=`/usr/bin/rosversion -d`
PROJECTPATH=$(cd `dirname $0`; pwd)
source ${PROJECTPATH}/devel/setup.bash
echo -e "${Info}请选择移动的方式:
${Green_font_prefix}1.${Font_color_suffix} 固定位置移动
${Green_font_prefix}2.${Font_color_suffix} 手动地图指定位置导航(未完成。。)
${Green_font_prefix}3.${Font_color_suffix} 退出请输入:Ctrl + c"
echo && stty erase ^? && read -p "请输入数字 [1-2]:" armnum
case "$armnum" in
1)
MOVETYPE="fix"
;;
2)
MOVETYPE="slam"
;;
*)
echo -e "${Error} 错误,默认使用固定位置移动"
MOVETYPE="fix"
;;
esac
echo -e "${Info}"
echo -e "${Info}请确定:"
echo -e "${Info} A.摄像头已反向向下安装好。机械臂正常上电。"
echo -e "${Info} B.机械臂正常上电。"
echo -e "${Info} C.准备好可吸附的${Blue_font_prefix}蓝色${Font_color_suffix}物品。"
echo -e "${Info}退出请输入:Ctrl + c "
echo -e "${Info}"
echo && stty erase ^? && read -p "按回车键(Enter)开始:"
if [ $ROSVER = "kinetic" ]; then
echo -e "${Info}It is kinetic."
roslaunch spark_carry_object spark_carry_object_only_cv3.launch camera_type_tel:=${CAMERATYPE} lidar_type_tel:=${LIDARTYPE}
elif [ $ROSVER = "indigo" ]; then
echo -e "${Info}It is indigo."
roslaunch spark_carry_object spark_carry_object_only_cv2.launch camera_type_tel:=${CAMERATYPE} lidar_type_tel:=${LIDARTYPE}
elif [ $ROSVER = "melodic" ]; then
echo -e "${Info}It is melodic."
roslaunch spark_carry_object spark_carry_object_only_cv3.launch camera_type_tel:=${CAMERATYPE} lidar_type_tel:=${LIDARTYPE}
fi
}
#让SPARK使用激光雷达绘制地图(gmapping)
spark_build_map_2d(){
echo -e "${Info}"
echo -e "${Info}让SPARK使用激光雷达绘制地图"
echo -e "${Info}"
echo -e "${Info}请选择SLAM的方式:
${Green_font_prefix}1.${Font_color_suffix} gmapping
${Green_font_prefix}2.${Font_color_suffix} hector
${Green_font_prefix}3.${Font_color_suffix} frontier_exploration
${Green_font_prefix}4.${Font_color_suffix} karto
${Green_font_prefix}5.${Font_color_suffix} 退出请输入:Ctrl + c"
echo && stty erase ^? && read -p "请输入数字 [1-4]:" slamnum
case "$slamnum" in
1)
SLAMTYPE="gmapping"
;;
2)
SLAMTYPE="hector"
;;
3)
SLAMTYPE="frontier_exploration"
;;
4)
SLAMTYPE="karto"
;;
*)
echo -e "${Error} 错误,默认使用gmapping"
SLAMTYPE="gmapping"
;;
esac
PROJECTPATH=$(cd `dirname $0`; pwd)
source ${PROJECTPATH}/devel/setup.bash
echo -e "${Info}"
echo -e "${Info} 请在新的终端窗口操作"
echo -e "${Info}键盘“wsad”分别对应“前后左右”"
echo -e "${Info} "
echo -e "${Info} w前进 "
echo -e "${Info} a左转 d右转 "
echo -e "${Info} s后退 "
echo -e "${Info} "
echo -e "${Info}退出请输入:Ctrl + c "
echo -e "${Info}"
echo && stty erase ^? && read -p "按回车键(Enter)开始:"
echo -e "roslaunch spark_slam 2d_slam_teleop.launch slam_methods_tel:=${SLAMTYPE} camera_type_tel:=${CAMERATYPE} lidar_type_tel:=${LIDARTYPE}"
roslaunch spark_slam 2d_slam_teleop.launch slam_methods_tel:=${SLAMTYPE} camera_type_tel:=${CAMERATYPE} lidar_type_tel:=${LIDARTYPE}
}
#让SPARK去充电
spark_dock(){
echo -e "${Info}"
echo -e "${Info} 让SPARK去充电。注:只适用于带充电座的SPARK使用!"
echo -e "${Info} 退出请输入:Ctrl + c "
PROJECTPATH=$(cd `dirname $0`; pwd)
source ${PROJECTPATH}/devel/setup.bash
echo && stty erase ^? && read -p "按回车键(Enter)继续:"
echo && stty erase ^? && read -p "请再次确定是否有带充电座 y/n:" choose
if [[ "${choose}" == "y" ]]; then
roslaunch spark_test go2dock.launch
else
return
fi
}
spark_test(){
echo -e "${Info}"
echo -e "${Info} SPARK test"
PROJECTPATH=$(cd `dirname $0`; pwd)
source ${PROJECTPATH}/devel/setup.bash
echo && stty erase ^? && read -p "按回车键(Enter)开始:"
roslaunch spark_test turn_test.launch
}
#让SPARK使用深度摄像头绘制地图
spark_build_map_3d(){
echo -e "${Info}"
echo -e "${Info}让SPARK使用深度摄像头绘制地图"
echo -e "${Info}"
echo -e "${Info}请选择SLAM的方式:
${Green_font_prefix}1.${Font_color_suffix} gmapping
${Green_font_prefix}2.${Font_color_suffix} hector
${Green_font_prefix}3.${Font_color_suffix} frontier_exploration
${Green_font_prefix}4.${Font_color_suffix} karto
${Green_font_prefix}5.${Font_color_suffix} rtab_map
${Green_font_prefix}6.${Font_color_suffix} 退出请输入:Ctrl + c"
echo && stty erase ^? && read -p "请输入数字 [1-5]:" slamnum
case "$slamnum" in
1)
SLAMTYPE="gmapping"
;;
2)
SLAMTYPE="hector"
;;
3)
SLAMTYPE="frontier_exploration"
;;
4)
SLAMTYPE="karto"
;;
5)
SLAMTYPE="rtab_map"
;;
*)
echo -e "${Error} 错误,默认使用gmapping"
SLAMTYPE="gmapping"
;;
esac
PROJECTPATH=$(cd `dirname $0`; pwd)
source ${PROJECTPATH}/devel/setup.bash
echo -e "${Info}"
echo -e "${Info} 请在新的终端窗口操作"
echo -e "${Info}键盘“wsad”分别对应“前后左右”"
echo -e "${Info} "
echo -e "${Info} w前进 "
echo -e "${Info} a左转 d右转 "
echo -e "${Info} s后退 "
echo -e "${Info} "
echo -e "${Info}退出请输入:Ctrl + c "
echo -e "${Info}"
echo && stty erase ^? && read -p "按回车键(Enter)开始:"
if [[ "${SLAMTYPE}" == "rtab_map" ]]; then
echo -e "${Tip}"
echo -e "${Tip}现在使用rtab_map建图,将会删除之前保存的地图,选择‘y’继续建图,其它键直接退出。"
echo -e "${Tip}"
echo && stty erase ^? && read -p "请选择是否继续y/n:" choose
if [[ "${choose}" == "y" ]]; then
roslaunch spark_rtabmap spark_rtabmap_teleop.launch camera_type_tel:=${CAMERATYPE} depthtolaser:=${depthtolaser}
else
return
fi
else
roslaunch spark_slam depth_slam_teleop.launch slam_methods_tel:=${SLAMTYPE} camera_type_tel:=${CAMERATYPE} depthtolaser:=${depthtolaser}
fi
}
#给摄像机做标定
calibrate_camera(){
echo -e "${Info} "
echo -e "${Info}给摄像头做标定"
echo -e "${Info} "
echo -e "${Info}请选择:
${Green_font_prefix}1.${Font_color_suffix} 彩色(rgb)摄像头标定
${Green_font_prefix}2.${Font_color_suffix} 深度(depth/ir)摄像头标定
${Green_font_prefix}3.${Font_color_suffix} 退出请输入:Ctrl + c"
echo && stty erase ^? && read -p "请输入数字 [1-2]:" calinum
case "$calinum" in
1)
CALIBRATETYPE="rgb"
;;
2)
CALIBRATETYPE="depth"
;;
*)
echo -e "${Error} 错误,退出" && exit
;;
esac
echo -e "${Info}"
echo -e "${Info}标定步骤 "
echo -e "${Info}1.准备格子大小为20x20mm的9x7的黑白棋盘(在doc文件夹中可以找到) "
echo -e "${Info} "
echo -e "${Info}2.倾斜或移动棋盘格子使X,Y,Size,Skew指标变成${Green_font_prefix}绿色 "
echo -e "${Info} "
echo -e "${Info}3.点击窗口中的CALIBRATE进行标定 "
echo -e "${Info}${Yellow_font_prefix}注意:${Font_color_suffix}点击后图像窗口将会卡顿!请耐心等候至新终端窗口出现标定矩阵数据! "
echo -e "${Info} "
echo -e "${Info}4.点击SAVE按钮保存标定文件 "
echo -e "${Info} "
echo -e "${Info}标定文件储存在/tmp/calibrationdata.tar.gz中 "
echo -e "${Info}请把压缩文件中的yaml格式文件拷贝至/home/spark/.ros/camera_info中 "
echo -e "${Info} "
echo -e "${Info}${Yellow_font_prefix}注意:${Font_color_suffix}请把yaml文件命名为当以下两种"
echo -e "${Info}rgb标定:camera.yaml depth标定:depth_Astra_Orbbec.yaml"
echo -e "${Info} "
echo -e "${Info}退出请输入:Ctrl + c "
echo -e "${Info} "
echo && stty erase ^? && read -p "按回车键(Enter)开始:"
PROJECTPATH=$(cd `dirname $0`; pwd)
source ${PROJECTPATH}/devel/setup.bash
roslaunch camera_calibrator camera_calibrate.launch calibrate_type:=${CALIBRATETYPE} camera_type_tel:=${CAMERATYPE}
}
#hsv范围值查找
spark_hsv_detection(){
echo -e "${Info}"
echo -e "${Info}hsv值自动查找"
ROSVER=`/usr/bin/rosversion -d`
PROJECTPATH=$(cd `dirname $0`; pwd)
source ${PROJECTPATH}/devel/setup.bash
echo -e "${Info}"
echo -e "${Info}请确定:"
echo -e "${Info} A.摄像头已反向向下安装好。机械臂正常上电。"
echo -e "${Info} B.${Red_font_prefix}红色${Font_color_suffix}标定物已贴好在吸盘固定头正上方。"
echo -e "${Info} C.机械臂正常上电。"
echo -e "${Info}退出请输入:Ctrl + c "
echo -e "${Info}"
echo -e "${Info}请选择比赛方式:
${Green_font_prefix}1.${Font_color_suffix} 获取吸盘上方hsv值
${Green_font_prefix}2.${Font_color_suffix} 获取颜色块hsv值,需要将颜色块放在图像的矩形框中
${Green_font_prefix}3.${Font_color_suffix} 退出请输入:Ctrl + c"
echo && stty erase ^? && read -p "请输入数字 [1-2]:" armnum
case "$armnum" in
1)
roslaunch spark_carry_object hsv_detection.launch camera_type_tel:=${CAMERATYPE} color:=${calibration}
;;
2)
roslaunch spark_carry_object hsv_detection.launch camera_type_tel:=${CAMERATYPE} color:=${color_block}
;;
*)
echo -e "${Error} 错误,请填入正确的数字"
;;
esac
}
#让SPARK夺宝奇兵比赛用示例程序
spark_carry_game(){
echo -e "${Info}"