大疆社区

标题: CodeMaster第2次任务--用语音报数实现 [打印本页]

作者: 总督    时间: 2019-9-28
标题: CodeMaster第2次任务--用语音报数实现
本帖最后由 总督 于 2019-9-28 23:57 编辑

[{"nameindex":"_1_1","type":1,"url":"","desc":"       \u7b2c\u4e8c\u6b21\u4efb\u52a1\u76f8\u5bf9\u6bd4\u8f83\u6613\u4e8e\u5b9e\u73b0\uff0c\u5404\u4f4d\u673a\u7532\u5927\u5e08\u4eec\u5df2\u7ecf\u5f88\u5feb\u5f88\u597d\u7684\u5b9e\u73b0\u4e86\u6590\u6ce2\u90a3\u5951\u6570\u5217\u7684\u751f\u6210\u3001\u8bc6\u522b\u548c\u6253\u5370\uff0c\u81ea\u5df1\u4e5f\u5c31\u4e0d\u5728\u91cd\u590d\u4e86\u3002\r\n       \u672c\u7740\u5927\u7586\u673a\u7532\u5927\u5e08\u201c\u73a9\u51fa\u540d\u5802\u201d\u7684\u521d\u8877\uff0c\u6211\u8003\u8651\u5230\u80fd\u4e0d\u80fd\u628a\u751f\u6210\u7684\u6bcf\u4e2a\u6570\u5b57\u8bfb\u51fa\u6765\u5462\uff1f\u7ecf\u8fc7\u4e00\u756a\u6298\u817e\uff0c\u57fa\u672c\u4e0a\u5b9e\u73b0\u4e86\u8bed\u97f3\u62a5\u6570\u3002\u4ee5\u4e0b\u5206\u6b65\u9aa4\u8fdb\u884c\u8be6\u7ec6\u89e3\u91ca\uff0c\u8fd8\u771f\u5fc3\u5e0c\u671b\u5c0f\u4f19\u4f34\u4eec\u4e0d\u541d\u6307\u51fa\u5b58\u5728\u7684\u4e0d\u8db3\u3001\u9519\u8bef\u4ee5\u53ca\u53ef\u4ee5\u8fdb\u4e00\u6b65\u5b8c\u5584\u63d0\u9ad8\u7684\u5730\u65b9\uff0c\u5728\u6b64\u5148\u8868\u793a\u611f\u8c22\u4e86\uff01\r\n\r\n\u4e00\u3001\u4efb\u52a1\u4e8c\u4ecb\u7ecd\r\n    1.\u968f\u673a\u751f\u6210\u201c1\u30012\u30013\u30014\u30015\u201d\u4e2d\u7684\u4efb\u610f\u4e24\u4e2a\u6570\u5b57\uff0c\u4f5c\u4e3a\u6590\u6ce2\u90a3\u5951\u6570\u5217\u7684\u524d\u4e24\u9879\uff08\u6590\u6ce2\u90a3\u5951\u6570\u5217\uff1a\u4ece\u7b2c\u4e09\u9879\u5f00\u59cb\uff0c\u5f53\u524d\u9879\u4e3a\u524d\u4e24\u9879\u6570\u5b57\u4e4b\u548c\uff0c\u5373F(n)=F(n-1)+F(n-2)\uff09\u3002\u8981\u6c42\uff1a\u751f\u6210\u7684\u4e24\u4e2a\u521d\u59cb\u968f\u673a\u6570\u9700\u8981\u6709\u660e\u663e\u7684\u6307\u793a\u4fe1\u53f7\uff08\u706f\u5149\u95ea\u70c1\u6216\u8005\u4e91\u53f0\u6446\u52a8\u7b49\uff09\u63d0\u793a\u6570\u503c\u662f\u591a\u5c11\u3002\r\n    2.\u6839\u636e\u4e0a\u9762\u4ea7\u751f\u7684\u524d\u4e24\u9879\u751f\u6210\u6590\u6ce2\u90a3\u5951\u6570\u5217\uff0c\u8981\u6c42\u6700\u540e\u4e00\u9879\u5c0f\u4e8e100\u3002\r\n    3.\u6309\u7167\u4e0b\u56fe\uff0c\u4ee5\u4ea7\u751f\u7684\u4e24\u4e2a\u6570\u5b57\u4e2d\u8f83\u5c0f\u7684\u4e00\u4e2a\uff0c\u4f5c\u4e3aS1\u673a\u5668\u4eba\u7684\u7b2c\u4e00\u4e2a\u51fb\u6253\u76ee\u6807\uff0c\u8f83\u5927\u7684\u4f5c\u4e3a\u7b2c\u4e8c\u4e2a\u51fb\u6253\u76ee\u6807\uff0c\u4e24\u4e2a\u6570\u7684\u548c\u4f5c\u4e3a\u7b2c\u4e09\u4e2a\u51fb\u6253\u76ee\u6807\uff0c\u6b64\u540e\u7684\u51fb\u6253\u76ee\u6807\u6309\u7167\u7c7b\u4f3c\u6590\u6ce2\u90a3\u5951\u6570\u5217\u7684\u89c4\u5f8b\u8fdb\u884c\u8ba1\u7b97\u3002\u4e3e\u4e2a\u6817\u5b50\uff0c\u5982\u679c\u521d\u59cb\u7684\u4e24\u4e2a\u6570\u5206\u522b\u662f2\u548c3\uff0c\u5219\u4ee52\u4f5c\u4e3a\u7b2c\u4e00\u4e2a\u51fb\u6253\u76ee\u6807\uff0c\u7b2c\u4e8c\u4e2a\u51fb\u6253\u76ee\u6807\u4e3a3\uff0c2+3 =5\u4f5c\u4e3a\u7b2c\u4e09\u4e2a\u51fb\u6253\u76ee\u6807\uff0c3+5 = 8\u4f5c\u4e3a\u7b2c\u56db\u4e2a\u51fb\u6253\u76ee\u6807\uff0c\u4ee5\u6b64\u7c7b\u63a8\u3002\u5927\u4e8e10\u7684\u51fb\u6253\u76ee\u6807\u6570\u5b57\uff0c\u4ee5\u5206\u522b\u51fb\u6253\uff08\u5341\u4f4d\u548c\u4e2a\u4f4d\uff09\u4e24\u4e2a\u6570\u5b57\u8fdb\u884c\u7ec4\u5408\u5b8c\u6210\u3002\u4f8b\u5982\uff0c\u6570\u5b5734\uff0c\u5219\u5148\u51fb\u62533\u540e\u7d27\u63a5\u7740\u51fb\u62534\u5b8c\u6210\uff08*\u8bf7\u6ce8\u610f\uff0c\u6b64\u5904\u6709\u5148\u540e\u987a\u5e8f\uff09\uff1b\u6570\u5b5755\uff0c\u5219\u8fde\u7eed\u51fb\u62535\u4e24\u6b21\u3002\u6bcf\u5b8c\u6210\u51fb\u6253\u4e00\u4e2a\u6570\u5b57\uff0c\u9700\u8981\u6709\u660e\u663e\u7684\u63d0\u793a\u4fe1\u53f7\uff08\u53ef\u81ea\u5b9a\u4e49\uff09\u3002\r\n    4.\u53c2\u7167\u6590\u6ce2\u90a3\u5951\u6570\u5217\u7684\u89c4\u5f8b\uff0c\u4f9d\u6b21\u51fb\u6253\u5b8c\u6210100\u4ee5\u5185\u7684\u6570\u5b57\uff0c\u5373\u88ab\u8ba4\u4e3a\u5b8c\u6210\u7f16\u7a0b\u4efb\u52a1\uff0c\u5b8c\u6210\u4efb\u52a1\u8005\u52a05\u5206\u3002\r\n     \u9644\uff1a\u6570\u5b57\u89c6\u89c9\u6807\u7b7e\u4e0b\u8f7d\u5730\u5740\uff0c[url]https:\/\/dl.djicdn.com\/downloads\/robomaster-s1\/20190620\/RoboMaster_S1_Vision_Markers_44pcs_15_15cm_upda[\/url]\r\nted.pdf","imgsrc":"static\/image\/text.jpg"},{"nameindex":"_2_587146","type":2,"url":"201909\/28\/173729xw22x2m5xrybbyxg.png","desc":"\u7528\u6253\u5370\u51fa\u6765\u7684\u56fe\u7247\u7531\u4e8e\u53cd\u5149\u5c11\uff0cS1\u8bc6\u522b\u6548\u679c\u66f4\u597d","imgsrc":"201909\/28\/173729xw22x2m5xrybbyxg.png"},{"nameindex":"_1_2","type":1,"url":"","desc":"\u4e8c\u3001\u8ba9\u673a\u7532\u5927\u5e08\u64ad\u653e\u81ea\u5b9a\u4e49\u7684\u58f0\u97f3\r\n     S1\u5e76\u6ca1\u6709\u5f00\u53d1\u81ea\u5b9a\u4e49\u58f0\u97f3\u7684\u64ad\u653e\u529f\u80fd\uff0c\u53ea\u80fd\u81ea\u5df1\u60f3\u529e\u6cd5\u4e86\uff01\u80fd\u4e0d\u80fd\u628a S1\u7684\u626c\u58f0\u5668\u63a5\u5230\u6811\u8393\u6d3e\u3001arduino\u7b49\u5916\u56f4\u667a\u80fd\u8bbe\u5907\u64ad\u653e\u5462\uff1f.\r\n      \u5148\u62ff\u624b\u673a\u8bd5\u9a8c\u4e00\u4e0b\u2026\u2026\r\n     S1\u7684\u626c\u58f0\u5668\u63a5\u53e3\u662f2.5mm\u7684\uff0c\u9700\u8981\u4e00\u4e2a2.5\u52303.5mm\u7684\u8f6c\u6362\u63a5\u5934\uff0c\u7f51\u4e0a\u51e0\u5757\u94b1\u4e00\u4e2a\uff0c\u4e70\u6765\u63a5\u4e0a\u624b\u673a\u64ad\u653e\u97f3\u4e50\u57fa\u672c\u542c\u4e0d\u5230\u58f0\u97f3\uff01\uff01\uff01\u5e94\u8be5\u662f\u8f93\u51fa\u529f\u7387\u5c0f\u4e86\uff0c\u518d\u627e\u4e00\u4e2aPAM8403\u8d85\u5fae\u578b\u6570\u5b57\u529f\u653e\u677f(3W)\u8fdb\u884c\u653e\u5927\uff0c\u7f51\u4e0a\u51e0\u5757\u94b1\u4e00\u4e2a\uff0c\u710a\u63a5\u3001\u8fde\u63a5\u540e\u5982\u4e0b\u56fe\u3002\u6ce8\u610f\uff0cS1\u76842.5mm\u63a5\u5934\u4e0d\u80fd\u5168\u90e8\u63d2\u5230\u5e95\uff0c\u5426\u5219\u58f0\u97f3\u6548\u679c\u4e0d\u597d\uff0c\u53ef\u80fd\u662f\u5de6\u53f3\u58f0\u9053\u7684\u539f\u56e0\uff0c\u5177\u4f53\u4e5f\u6ca1\u641e\u6e05\u695a\uff0c\u8fd8\u8bf7\u4e0d\u541d\u8d50\u6559\u554a\u3002\r\n      \u52a0\u4e0a\u653e\u5927\u5668\u540e\uff0c\u628a3.5mm\u63a5\u5934\u63d2\u5165\u6811\u8393\u6d3e\uff0c\u5219\u53ef\u4ee5\u7528\u6811\u8393\u6d3e\u968f\u610f\u5927\u58f0\u64ad\u653e\u4e86\uff01\r\n      \u5982\u4f55\u8ba9S1\u63a7\u5236\u6811\u8393\u6d3e\u64ad\u653e\u7279\u5b9a\u58f0\u97f3\u5462\uff1f\r\n      1.\u901a\u4fe1\uff0c\u6ca1\u6709\u5f00\u653e\uff01\uff01pwm\u5f00\u653e\u4e86\uff0c\u90a3\u4e48\u53ef\u4ee5\u8ba9\u6811\u8393\u6d3eGPIO\u53e3\u68c0\u6d4b\u673a\u7532\u5927\u5e08\u7684pwm\u53e3\u7684\u9ad8\u4f4e\u7535\u5e73\u5b9e\u73b0\u7b80\u5355\u7684S1\u5230\u6811\u8393\u6d3e\u7684\u5355\u5411\u901a\u4fe1\u3002\u5229\u75285\u4e2apwm\u7684\u9ad8\u4f4e\u7535\u5e73\u5b9e\u73b02\u76845\u6b21\u517132\u79cd\u4fe1\u53f7\uff0c\u6811\u8393\u6d3e\u6839\u636e\u4e0d\u540c\u7684\u4fe1\u53f7\u64ad\u653e\u4e0d\u540c\u7684\u58f0\u97f3\uff0c\u4ece\u800c\u5b9e\u73b0\u8bed\u97f3\u64ad\u62a5\u6590\u6ce2\u90a3\u5951\u6570\u5217\u3002\r\n      2.\u5177\u4f53\u662f\u901a\u8fc7\u6811\u8393\u6d3e3b+\u7684BCM\u6a21\u5f0f\u7684\u7b2c20\/21\/23\/24\/25\u53f7GPIO\u53e3\u8fde\u63a5pwm1-5\uff0c\u6bcf\u79d2\u68c0\u6d4b\u4e00\u6b21\u5404\u7aef\u53e3\u7684\u7535\u5e73\u72b6\u6001\u3002\u7a0b\u5e8f\u5982\u4e0b\uff1a","imgsrc":"static\/image\/text.jpg"},{"nameindex":"_1_3","type":1,"url":"","desc":"\uff081)\u6811\u8393\u6d3e\u6bb5\u7a0b\u5e8f\u5982\u4e0b\uff08\u914d\u5957\u7684\u58f0\u97f3\u6587\u4ef6\u53ef\u4ee5\u81ea\u5df1\u5f55\u5236\uff0c\u53ea\u8981\u662fMP3\u683c\u5f0f\u5c31\u884c\uff0c\u4e5f\u53ef\u4ee5\u5fae\u4fe1\u627e\u6211\u8981\uff09\uff1a\r\nimport RPi.GPIO as GPIO\r\nimport time\r\nimport os\r\n\r\nGPIO.setmode(GPIO.BCM)\r\nGPIO.setwarnings(False)\r\nGPIO.setup(20,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)\r\nGPIO.setup(21,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)\r\nGPIO.setup(23,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)\r\nGPIO.setup(24,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)\r\nGPIO.setup(25,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)\r\ntime.sleep(0.5)\r\n\r\nwhile True:   \r\n    a=GPIO.input(20)\r\n    b=GPIO.input(21)\r\n    c=GPIO.input(23)\r\n    d=GPIO.input(24)\r\n    e=GPIO.input(25)    \r\n    \r\n    if a==1 and b==0 and c==0 and d==0 and e==0:\r\n        os.system('mpg321 .\/peiyin\/1.mp3 &')\r\n    elif a==0 and b==1 and c==0 and d==0 and e==0:\r\n        os.system('mpg321 .\/peiyin\/2.mp3 &')\r\n    elif a==1 and b==1 and c==0 and d==0 and e==0:\r\n        os.system('mpg321 .\/peiyin\/3.mp3 &')\r\n    elif a==0 and b==0 and c==1 and d==0 and e==0:\r\n        os.system('mpg321 .\/peiyin\/4.mp3 &')\r\n    elif a==1 and b==0 and c==1 and d==0 and e==0:\r\n        os.system('mpg321 .\/peiyin\/5.mp3 &')   \r\n    elif a==0 and b==1 and c==1 and d==0 and e==0:\r\n        os.system('mpg321 .\/peiyin\/6.mp3 &')   \r\n    elif a==1 and b==1 and c==1 and d==0 and e==0:\r\n        os.system('mpg321 .\/peiyin\/7.mp3 &')   \r\n    elif a==0 and b==0 and c==0 and d==1 and e==0:\r\n        os.system('mpg321 .\/peiyin\/8.mp3 &')   \r\n    elif a==1 and b==0 and c==0 and d==1 and e==0:\r\n        os.system('mpg321 .\/peiyin\/9.mp3 &')   \r\n    elif a==0 and b==1 and c==0 and d==1 and e==0:\r\n        os.system('mpg321 .\/peiyin\/start.mp3 &')\r\n    elif a==1 and b==1 and c==0 and d==1 and e==0:\r\n        os.system('mpg321 .\/peiyin\/feibo.mp3 &') \r\n    elif a==0 and b==0 and c==1 and d==1 and e==0:\r\n        os.system('mpg321 .\/peiyin\/end.mp3 &') \r\n    elif a==1 and b==0 and c==0 and d==0 and e==1:\r\n        os.system('mpg321 .\/peiyin\/10.mp3 &')\r\n    elif a==0 and b==1 and c==0 and d==0 and e==1:\r\n        os.system('mpg321 .\/peiyin\/20.mp3 &')\r\n    elif a==1 and b==1 and c==0 and d==0 and e==1:\r\n        os.system('mpg321 .\/peiyin\/30.mp3 &')\r\n    elif a==0 and b==0 and c==1 and d==0 and e==1:\r\n        os.system('mpg321 .\/peiyin\/40.mp3 &')\r\n    elif a==1 and b==0 and c==1 and d==0 and e==1:\r\n        os.system('mpg321 .\/peiyin\/50.mp3 &')   \r\n    elif a==0 and b==1 and c==1 and d==0 and e==1:\r\n        os.system('mpg321 .\/peiyin\/60.mp3 &')   \r\n    elif a==1 and b==1 and c==1 and d==0 and e==1:\r\n        os.system('mpg321 .\/peiyin\/70.mp3 &')   \r\n    elif a==0 and b==0 and c==0 and d==1 and e==1:\r\n        os.system('mpg321 .\/peiyin\/80.mp3 &')   \r\n    elif a==1 and b==0 and c==0 and d==1 and e==1:\r\n        os.system('mpg321 .\/peiyin\/90.mp3 &')\r\n    else:\r\n        pass\r\n    \r\n    time.sleep(1)\r\n\uff082\uff09\u673a\u7532\u5927\u5e08\u7aef\u7a0b\u5e8f\u89c1\u540e\u7eed\u4ecb\u7ecd\r\n","imgsrc":"static\/image\/text.jpg"},{"nameindex":"_2_587148","type":2,"url":"201909\/28\/175135wsrtw6cxsxx93618.jpg","desc":"\u673a\u7532\u5927\u5e08\u626c\u58f0\u5668-2.5\u4e4b3.5mm\u8f6c\u63a5\u5934-3w\u529f\u653e\u8fde\u63a5\u56fe","imgsrc":"201909\/28\/175135wsrtw6cxsxx93618.jpg"},{"nameindex":"_1_4","type":1,"url":"","desc":"\u4e09\u3001 \u4efb\u52a1\u5b9e\u73b0\r\n1.\u63a7\u52361-5\u53f7pwm\u8f93\u51fa\u4e0d\u540c\u7684\u9ad8\u4f4e\u7535\u5e73\uff0c\u5b9e\u73b0\u4e0e\u6811\u8393\u6d3e\u7684\u5355\u5411\u901a\u4fe1\r\n2.\u751f\u6210\u6590\u6ce2\u90a3\u5951\u6570\u5217\uff0c\u6700\u5927\u4e0d\u8d85\u8fc7100\u3002\r\n3.\u8bc6\u522b0-9\u5341\u4e2a\u6807\u7b7e\uff0c\u8bb0\u5f55\u5404\u6807\u7b7e\u7684\u4f4d\u7f6e\uff08\u4f7f\u7528\u4e86\u4e24\u79cd\u65b9\u6cd5\uff1a\u4e00\u662f\u4f7f\u7528\u8bc6\u522b\u5e76\u7784\u51c6\u51fd\u6570\uff0c\u8fd9\u79cd\u65b9\u6cd5\u5bf9\u6807\u7b7e\u7684\u8d28\u91cf\u8981\u6c42\u8f83\u4f4e\uff0c\u540c\u7b49\u6761\u4ef6\u4e0b\u53ef\u8bc6\u522b\u7684\u6807\u7b7e\u5728\u7b2c\u4e8c\u79cd\u65b9\u6cd5\u4e2d\u5374\u4e0d\u80fd\u88ab\u8bc6\u522b\uff0c\u7f3a\u70b9\u662f\u901f\u5ea6\u6162\uff1b\u4e8c\u662f\u83b7\u53d6\u6574\u4f53\u8bc6\u522b\u5230\u7684\u89c6\u89c9\u6807\u7b7e\u4fe1\u606f\uff0c\u4f18\u70b9\u662f\u901f\u5ea6\u5feb\uff0c\u7f3a\u70b9\u662f\u9700\u8981\u5c06\u8bc6\u522b\u8ddd\u79bb\u8c03\u4e3a3m\uff0c\u6839\u636e\u5149\u7167\u6761\u4ef6\u9002\u5f53\u8c03\u6574\u66dd\u5149\u503c\u4e3a\u5927\u6216\u5c0f\uff0c\u6211\u5728\u5ba4\u5185\u706f\u5149\u6761\u4ef6\u4e0b\uff0c\u8bbe\u7f6e\u4e3a\u5927\u66dd\u5149\u503c\uff0c\u8c03\u6574\u673a\u7532\u5927\u5e08\u7684\u89d2\u5ea6\u9632\u6b62\u6807\u7b7e\u6b63\u597d\u5728\u53cd\u5149\u7684\u4f4d\u7f6e\u5b9e\u73b0\u4e8610\u4e2a\u6807\u7b7e\u7684\u4e00\u6b21\u8bc6\u522b\uff09\u3002\u7136\u540e\u5c06\u6807\u7b7e\u7684x\u3001y\u503c\u8f6c\u6362\u4e3a\u4e91\u53f0\u7684\u822a\u5411\u3001\u4fef\u4ef0\u89d2\uff0c\u4ece0-9\u5b58\u50a8\u5230angleList\u5217\u8868\u4e2d\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\u5bf9\u6807\u7b7e\u4fe1\u606f\u5217\u8868\uff0c\u901a\u8fc7index\u51fd\u6570\u5206\u522b\u627e\u5230id\u4e3a10-19\u7684\u7d22\u5f15\u4f4d\u7f6e\uff0c\u5c06\u4f1a\u4e0e\u7b2c\u4e00\u4e2a10\u91cd\u590d\uff0c\u9700\u8981\u5148\u628a\u7b2c\u4e00\u4e2a10\u503cpop\u6389\u3002\r\n4.\u5c04\u51fb\u51fd\u6570\uff0c\u4ece\u6590\u6ce2\u90a3\u5951\u6570\u5217\u4e2d\u4f9d\u6b21\u62ff\u51fa\u4e00\u9879\uff0c\u5c0f\u4e8e10\u65f6\u76f4\u63a5\u53d6\u51faangleList\u4e2d\u5b58\u50a8\u7684\u822a\u5411\u3001\u4fef\u4ef0\u89d2\uff0c\u5c06\u4e91\u53f0\u8c03\u6574\u5230\u8fd9\u4e2a\u4f4d\u7f6e\u5373\u53ef\uff1b\u5927\u4e8e10\u65f6\u901a\u8fc7\u6574\u53d6\u3001\u53d6\u4f59\u5206\u522b\u53d6\u51fa\u5341\u4f4d\u3001\u4e2a\u4f4d\u6309\u524d\u65b9\u6cd5\u8c03\u6574\u4e91\u53f0\u4f4d\u7f6e\u5373\u53ef\u3002\u8fd9\u91cc\u53d6\u4f59\u65f6\u6709\u4e2aBUG:\u5343\u4e07\u4e0d\u8981\u7528%\u53d6\u4f59\u7b26\u53f7\uff0c\u6709%\u7b26\u53f7\u5c06\u5bfc\u81f4\u5b58\u50a8\u7684\u7a0b\u5e8f\u518d\u6b21\u6253\u5f00\u65f6\u5c31\u7a7a\u767d\u4e86\uff0c\u65e0\u8bba\u662f\u5b58\u5230\u4e91\u4e0a\u8fd8\u662f\u672c\u5730\u3001\u6216\u662f\u751f\u6210\u4e86dsp\u6587\u4ef6\uff0c\u7edf\u7edf\u4e0d\u884c\uff01\uff01\u53ef\u7528\u4ee5\u4e0b\u53d8\u901a\u65b9\u6cd5\u8fdb\u884c\u53d6\u4f59\uff1aindex01=b\/\/10\uff1bindex02=b-index01*10\r\n","imgsrc":"static\/image\/text.jpg"},{"nameindex":"_2_587173","type":2,"url":"201909\/28\/214051gzn3hfhh2c9e7e2w.jpg","desc":"1-5#pwm\u3001\u5730\u7ebf\u63a5\u51fa\u56fe","imgsrc":"201909\/28\/214051gzn3hfhh2c9e7e2w.jpg"},{"nameindex":"_2_587175","type":2,"url":"201909\/28\/214109nnmua2n11dzaznzd.jpg","desc":"pwm\u4e0e\u6811\u8393\u6d3egpio\u3001\u5730\u7ebf\u8fde\u63a5\u56fe","imgsrc":"201909\/28\/214109nnmua2n11dzaznzd.jpg"},{"nameindex":"_2_587176","type":2,"url":"201909\/28\/214122d3bwwnf94n6443wz.jpg","desc":"\u8fd0\u884c\u65f6\u7684\u63a5\u7ebf\u56fe","imgsrc":"201909\/28\/214122d3bwwnf94n6443wz.jpg"},{"nameindex":"_3_1","type":3,"url":"http:\/\/v.qq.com\/iframe\/player.html?vid=z3002te7lnk&tiny=0&auto=0","desc":"FPV\u673a\u7532\u5927\u5e08\u81ea\u5e26\u5f55\u50cf\u7684\u8fd0\u884c\u6210\u529f","imgsrc":"static\/image\/video.jpg"},{"nameindex":"_3_2","type":3,"url":"http:\/\/v.qq.com\/iframe\/player.html?vid=g30022nzx69&tiny=0&auto=0","desc":"\u8fd0\u884c\u4e2d\u673a\u7532\u5927\u5e08\u72b6\u6001\u5f55\u50cf","imgsrc":"static\/image\/video.jpg"},{"nameindex":"_3_3","type":3,"url":"http:\/\/v.qq.com\/iframe\/player.html?vid=n300200f7j5&tiny=0&auto=0","desc":"app\u8c03\u8bd5\u622a\u5c4f\u5f55\u50cf\uff0c\u5173\u952e\u770b\u8c03\u8bd5\u8f93\u51fa\uff08\u6ce8\uff1a\u4e0e\u4e0a\u9762\u4e0d\u662f\u540c\u4e00\u6b21\u8fd0\u884c\uff0c\u6590\u6ce2\u90a3\u5951\u6570\u5217\u4e0d\u76f8\u540c\uff09","imgsrc":"static\/image\/video.jpg"},{"nameindex":"_1_5","type":1,"url":"","desc":"import random\r\nangleList=RmList()\r\nfeiboList=RmList()\r\ninfoList=RmList()\r\n\r\n#pwm\u8f93\u51fa\u540c\u6811\u8393\u6d3e\u901a\u4fe1\u51fd\u6570\r\ndef output_Pwm(num=0,flag=0):\r\n    if num==0:\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm1,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm2,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm3,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm4,0)\r\n        if flag==0:\r\n            chassis_ctrl.set_pwm_value(rm_define.pwm5,0)\r\n        else:\r\n            chassis_ctrl.set_pwm_value(rm_define.pwm5,100)\r\n    elif num==1:\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm1,100)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm2,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm3,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm4,0)\r\n        if flag==0:\r\n            chassis_ctrl.set_pwm_value(rm_define.pwm5,0)\r\n        else:\r\n            chassis_ctrl.set_pwm_value(rm_define.pwm5,100)\r\n    elif num==2:\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm1,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm2,100)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm3,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm4,0)\r\n        if flag==0:\r\n            chassis_ctrl.set_pwm_value(rm_define.pwm5,0)\r\n        else:\r\n            chassis_ctrl.set_pwm_value(rm_define.pwm5,100)\r\n    elif num==3:\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm1,100)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm2,100)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm3,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm4,0)\r\n        if flag==0:\r\n            chassis_ctrl.set_pwm_value(rm_define.pwm5,0)\r\n        else:\r\n            chassis_ctrl.set_pwm_value(rm_define.pwm5,100)\r\n    elif num==4:\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm1,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm2,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm3,100)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm4,0)\r\n        if flag==0:\r\n            chassis_ctrl.set_pwm_value(rm_define.pwm5,0)\r\n        else:\r\n            chassis_ctrl.set_pwm_value(rm_define.pwm5,100)\r\n    elif num==5:\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm1,100)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm2,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm3,100)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm4,0)\r\n        if flag==0:\r\n            chassis_ctrl.set_pwm_value(rm_define.pwm5,0)\r\n        else:\r\n            chassis_ctrl.set_pwm_value(rm_define.pwm5,100)\r\n    elif num==6:\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm1,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm2,100)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm3,100)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm4,0)\r\n        if flag==0:\r\n            chassis_ctrl.set_pwm_value(rm_define.pwm5,0)\r\n        else:\r\n            chassis_ctrl.set_pwm_value(rm_define.pwm5,100)\r\n    elif num==7:\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm1,100)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm2,100)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm3,100)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm4,0)\r\n        if flag==0:\r\n            chassis_ctrl.set_pwm_value(rm_define.pwm5,0)\r\n        else:\r\n            chassis_ctrl.set_pwm_value(rm_define.pwm5,100)\r\n    elif num==8:\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm1,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm2,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm3,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm4,100)\r\n        if flag==0:\r\n            chassis_ctrl.set_pwm_value(rm_define.pwm5,0)\r\n        else:\r\n            chassis_ctrl.set_pwm_value(rm_define.pwm5,100)\r\n    elif num==9:\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm1,100)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm2,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm3,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm4,100)\r\n        if flag==0:\r\n            chassis_ctrl.set_pwm_value(rm_define.pwm5,0)\r\n        else:\r\n            chassis_ctrl.set_pwm_value(rm_define.pwm5,100) \r\n    elif num==10:\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm1,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm2,100)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm3,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm4,100)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm5,0)\r\n    elif num==11:\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm1,100)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm2,100)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm3,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm4,100)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm5,0)\r\n    elif num==12:\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm1,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm2,0)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm3,100)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm4,100)\r\n        chassis_ctrl.set_pwm_value(rm_define.pwm5,0)\r\n    else:\r\n        pass\r\n \r\n#\u751f\u6210\u6590\u6ce2\u90a3\u5951\u6570\u5217\r\ndef make_Feibo():\r\n    global feiboList\r\n    feiboList.append(random.randint(1,5))\r\n    feiboList.append(random.randint(1,5))\r\n    output_Pwm(10,0)\r\n    time.sleep(1)\r\n    output_Pwm(0,0)\r\n    time.sleep(2)\r\n    output_Pwm(feiboList[1],0)\r\n    time.sleep(1)\r\n    output_Pwm(feiboList[2],0)\r\n    time.sleep(1)\r\n    output_Pwm(0,0)\r\n    for i in range(3,12):\r\n        a=feiboList[i-1]+feiboList[i-2]\r\n        if a>100:break\r\n        feiboList.append(a)\r\n        \r\n#\u5b58\u50a8\u4e91\u53f0\u822a\u5411\u3001\u4fef\u4ef0\u89d2\u51fd\u6570\r\ndef storage_Angle():\r\n    global angleList\r\n    angleList.append(gimbal_ctrl.get_axis_angle(rm_define.gimbal_axis_yaw))\r\n    angleList.append(gimbal_ctrl.get_axis_angle(rm_define.gimbal_axis_pitch))\r\n    \r\n#\u65b9\u6cd5\u4e00\uff1a\u901a\u8fc7\u8bc6\u522b\u5e76\u7784\u51c6\u51fd\u6570\u83b7\u53d60-9\u6807\u7b7e\u4f4d\u7f6e\u4fe1\u606f\u7684\u51fd\u6570\r\ndef detect_Marker_0to9_by_aim():\r\n    vision_ctrl.enable_detection(rm_define.vision_detection_marker)\r\n    vision_ctrl.set_marker_detection_distance(2)\r\n    gimbal_ctrl.set_rotate_speed(180)\r\n    #try to use the number of enum\r\n    '''for i in range(10,20):\r\n        vision_ctrl.detect_marker_and_aim(i)\r\n        time.sleep(0.2)\r\n        storage_Angle()\r\n        gimbal_ctrl.angle_ctrl(0,0)'''\r\n    vision_ctrl.detect_marker_and_aim(rm_define.marker_number_zero)\r\n    time.sleep(0.2)\r\n    storage_Angle()\r\n    gimbal_ctrl.angle_ctrl(0,0)\r\n    vision_ctrl.detect_marker_and_aim(rm_define.marker_number_one)\r\n    time.sleep(0.2)\r\n    storage_Angle()\r\n    gimbal_ctrl.angle_ctrl(0,0)\r\n    vision_ctrl.detect_marker_and_aim(rm_define.marker_number_two)\r\n    time.sleep(0.2)\r\n    storage_Angle()\r\n    gimbal_ctrl.angle_ctrl(0,0)\r\n    vision_ctrl.detect_marker_and_aim(rm_define.marker_number_three)\r\n    time.sleep(0.2)\r\n    storage_Angle()\r\n    gimbal_ctrl.angle_ctrl(0,0)\r\n    vision_ctrl.detect_marker_and_aim(rm_define.marker_number_four)\r\n    time.sleep(0.2)\r\n    storage_Angle()\r\n    gimbal_ctrl.angle_ctrl(0,0)\r\n    vision_ctrl.detect_marker_and_aim(rm_define.marker_number_five)\r\n    time.sleep(0.2)\r\n    storage_Angle()\r\n    gimbal_ctrl.angle_ctrl(0,0)\r\n    vision_ctrl.detect_marker_and_aim(rm_define.marker_number_six)\r\n    time.sleep(0.2)\r\n    storage_Angle()\r\n    gimbal_ctrl.angle_ctrl(0,0)\r\n    vision_ctrl.detect_marker_and_aim(rm_define.marker_number_seven)\r\n    time.sleep(0.2)\r\n    storage_Angle()\r\n    gimbal_ctrl.angle_ctrl(0,0)\r\n    vision_ctrl.detect_marker_and_aim(rm_define.marker_number_eight)\r\n    time.sleep(0.2)\r\n    storage_Angle()\r\n    gimbal_ctrl.angle_ctrl(0,0)\r\n    vision_ctrl.detect_marker_and_aim(rm_define.marker_number_nine)\r\n    time.sleep(0.2)\r\n    storage_Angle()\r\n    gimbal_ctrl.angle_ctrl(0,0)\r\n\r\n#\u65b9\u6cd5\u4e8c\uff1a\u901a\u8fc7\u4e00\u6b21\u6574\u4f53\u8bc6\u522b\u51fd\u6570\u83b7\u53d60-9\u6807\u7b7e\u4f4d\u7f6e\u4fe1\u606f\u7684\u51fd\u6570    \r\ndef detect_Marker_0to9_by_info():\r\n    global infoList\r\n    global angleList\r\n    vision_ctrl.enable_detection(rm_define.vision_detection_marker)\r\n    vision_ctrl.set_marker_detection_distance(3)\r\n    media_ctrl.exposure_value_update(rm_define.exposure_value_large)\r\n    time.sleep(2)\r\n    while len(infoList)!=51:\r\n        infoList=RmList(vision_ctrl.get_marker_detection_info())\r\n        time.sleep(1)\r\n        media_ctrl.play_sound(rm_define.media_sound_scanning)        \r\n    if len(infoList)==51:\r\n        infoList.pop(1)\r\n        for i in range(10,20):\r\n            indexofi=infoList.index(i)\r\n            angleList.append((infoList[indexofi+1]-0.5)*96)\r\n            angleList.append((0.5-infoList[indexofi+2])*54)            \r\n\r\n#\u5c04\u51fb\u51fd\u6570  \r\ndef shoot():\r\n    global feiboList\r\n    global angleList\r\n    global infoList\r\n    \r\n    output_Pwm(11,0)\r\n    time.sleep(1)\r\n    output_Pwm(0,0)\r\n    time.sleep(2)\r\n    for i in range(1,len(feiboList)+1):\r\n        b=feiboList[ i ]        \r\n        print(b)\r\n        time.sleep(2)\r\n        if b<10:\r\n            gimbal_ctrl.angle_ctrl(angleList[b*2+1],angleList[b*2+2])\r\n            led_ctrl.gun_led_on()\r\n            output_Pwm(b,0)\r\n            time.sleep(1)\r\n            output_Pwm(0,0)\r\n            led_ctrl.gun_led_off()\r\n        else:\r\n            index01=int(b\/\/10)\r\n            index02=b-index01*10\r\n            gimbal_ctrl.angle_ctrl(angleList[index01*2+1],angleList[index01*2+2])\r\n            output_Pwm(index01,1)\r\n            led_ctrl.gun_led_on()\r\n            time.sleep(1)\r\n            output_Pwm(0,0)\r\n            led_ctrl.gun_led_off()\r\n            gimbal_ctrl.angle_ctrl(angleList[index02*2+1],angleList[index02*2+2])\r\n            output_Pwm(index02,0)\r\n            led_ctrl.gun_led_on()\r\n            time.sleep(1)\r\n            output_Pwm(0,0)\r\n            led_ctrl.gun_led_off()\r\n            \r\ndef start():\r\n    global feiboList\r\n    global angleList\r\n    global infoList   \r\n    \r\n    media_ctrl.record(1)\r\n    robot_ctrl.set_mode(rm_define.robot_mode_free)\r\n    make_Feibo()\r\n    print(feiboList)\r\n    time.sleep(1)\r\n    #detect_Marker_0to9_by_aim()\r\n    detect_Marker_0to9_by_info()\r\n    print(angleList)\r\n    time.sleep(1)\r\n    shoot()\r\n    output_Pwm(12,0)\r\n    time.sleep(1)\r\n    output_Pwm(0,0)\r\n    time.sleep(2)\r\n    media_ctrl.record(0)","imgsrc":"static\/image\/text.jpg"},{"nameindex":"_1_6","type":1,"url":"","desc":"\u603b\u7ed3\uff1a\u57fa\u672c\u5b9e\u73b0\u4e86\u9884\u671f\u6548\u679c\uff0c\u4f46\u6709\u4e24\u65b9\u9762\u7684\u7f3a\u70b9\uff1a\u4e00\u662f\u4e3a\u7b49\u5f85\u6811\u8393\u6d3e\u8bfb\u6570\uff0c\u4e3b\u7a0b\u5e8f\u5fc5\u987b\u52a0sleep\u51fd\u6570\u7b49\u5f85\uff0c\u9020\u6210\u6574\u4f53\u770b\u6765\u6bd4\u8f83\u8fdf\u949d\uff1b\u4e8c\u662fpwm\u8f93\u51fa\u548c\u6811\u8393\u6d3e\u7684\u8f93\u5165\u4e0d\u5341\u5206\u7a33\u5b9a\uff0c\u867d\u7136\u8bbe\u7f6e\u4e86\u4e0b\u62c9\u7535\u963b\uff0c\u4f46\u65f6\u4e0d\u65f6\u7684\u4f1a\u6709\u4e2a\u522b\u610f\u5916\u7684\u4fe1\u53f7\u88ab\u6355\u6349\u5230\uff0c\u5c1a\u9700\u6539\u8fdb\u3002\r\n\u4e0d\u8db3\u4e4b\u5904\u6b22\u8fce\u6279\u8bc4\u6307\u6b63,\u4ea4\u6d41\u5b66\u4e60\uff01\uff01\uff01\u5fae\u4fe1\u53f7:cumtzd","imgsrc":"static\/image\/text.jpg"}]
作者: benq    时间: 2019-9-28
学习了
作者: boolrobot    时间: 2019-9-28
大神
作者: CPYCPY    时间: 2019-9-28

作者: bakedkids    时间: 2019-9-28
多面大神!
作者: Alfred888    时间: 2019-9-29
这个很有意思
作者: g1107    时间: 2019-9-29
厉害
作者: scratch    时间: 2019-9-29
是矿大的同学吗?
作者: 总督    时间: 2019-9-29
scratch9-29 09:33
是矿大的同学吗?
是啊02级的
作者: 哆来咪    时间: 2019-10-5
高阶玩家




欢迎光临 大疆社区 (https://bbs.dji.com/) Powered by Discuz! X3.2