大疆社区
标题:
CodeMaster第二次任务 代码分享及交流
[打印本页]
作者:
菜鸟步兵3号
时间:
2019-10-4
标题:
CodeMaster第二次任务 代码分享及交流
本帖最后由 菜鸟步兵3号 于 2019-10-4 19:48 编辑
[{"nameindex":"_1_1","type":1,"url":"","desc":"\u9996\u5148\u6765\u8bb2\u8bb2\u6211\u662f\u600e\u4e48\u8868\u793a\u6bcf\u6b21\u8981\u51fb\u6253\u7684\u6570\u5b57\u3002\u4e91\u53f0\u5355\u4fa7\u76848\u4e2aled\u5355\u72ec\u8868\u793a\u6570\u5b571\uff0c2\uff0c3\uff0c4\uff0c5\uff0c6\uff0c7\uff0c8\u5982\u4e0b\u56fe\u6240\u793a","imgsrc":"static\/image\/text.jpg"},{"nameindex":"_2_588007","type":2,"url":"201910\/04\/193210fgcmh778e978dg98.jpg","desc":"","imgsrc":"201910\/04\/193210fgcmh778e978dg98.jpg"},{"nameindex":"_1_2","type":1,"url":"","desc":"\u4e91\u53f08\u4e2aled\u706f\u5168\u4eae\u52a0\u4e0a\u5e95\u76d8\u53f3\u4fa7\u88c5\u7532\u677fled\u706f\u4eae\u8868\u793a\u6570\u5b579\u3002","imgsrc":"static\/image\/text.jpg"},{"nameindex":"_2_588008","type":2,"url":"201910\/04\/193433gvc1yhmllho0pl9h.jpg","desc":"","imgsrc":"201910\/04\/193433gvc1yhmllho0pl9h.jpg"},{"nameindex":"_1_3","type":1,"url":"","desc":"\u4e91\u53f0\u53f3\u4fa7led\u706f\u5168\u4eae\u52a0\u4e0a\u5e95\u76d8\u53f3\u4fa7\u52a0\u524d\u65b9\u7684\u88c5\u7532\u677fled\u706f\u4eae\u8868\u793a\u6570\u5b570","imgsrc":"static\/image\/text.jpg"},{"nameindex":"_2_588009","type":2,"url":"201910\/04\/193639plffuq4lxddqzjr2.jpg","desc":"","imgsrc":"201910\/04\/193639plffuq4lxddqzjr2.jpg"},{"nameindex":"_1_4","type":1,"url":"","desc":"\u4e0b\u9762\u5c55\u793a\u6700\u7ec8\u7684\u6548\u679c\u89c6\u9891\u3002 \u6211\u5c06100\u5185\u6590\u6ce2\u90a3\u5951\u6570\u5217\u7684\u6240\u6709\u6570\u5b57\u7684\u5341\u4f4d\u548c\u4e2a\u4f4d\u62c6\u5f00\u5e76\u5b58\u5728\u4e00\u4e2a\u5217\u8868\u91cc\u5982\uff1a\u4e00\u4e2a\u6590\u6ce2\u90a3\u5951\u6570\u5217[3\uff0c5\uff0c8\uff0c13\uff0c21\uff0c34\uff0c55\uff0c89]\u62c6\u5206\u6210[3\uff0c5\uff0c8\uff0c1\uff0c3\uff0c2\uff0c1\uff0c3\uff0c4\uff0c5\uff0c5\uff0c8\uff0c9]\u7136\u540e\u6309\u987a\u5e8f\u4f9d\u6b21\u51fb\u6253\u3002\u4e2a\u4f4d\u5341\u4f4d\u91cd\u590d\u7684\u6570\u5219\u51fb\u6253\u4e24\u6b21\u3002\u5982\uff1a55\u5219\u51fb\u6253\u6807\u7b7e5\u4e24\u6b21\u3002\u6bcf\u6b21\u51fb\u6253\u5b8c\u6210\u540e\u4f1a\u63d0\u793a\u97f3\u6548\u3002","imgsrc":"static\/image\/text.jpg"},{"nameindex":"_3_1","type":3,"url":"http:\/\/player.youku.com\/embed\/XNDM4NTMxOTE0MA==","desc":"","imgsrc":"https:\/\/vthumb.ykimg.com\/054206015D96238D000001784208228B"},{"nameindex":"_3_2","type":3,"url":"http:\/\/player.youku.com\/embed\/XNDM4NTMyOTcyOA==","desc":"","imgsrc":"https:\/\/vthumb.ykimg.com\/054204085D961F9D00000147F10927F8"},{"nameindex":"_1_5","type":1,"url":"","desc":"\u6700\u540e\u9644\u4e0a\u4ee3\u7801\uff0c\u6b22\u8fce\u5927\u5bb6\u6765\u4ea4\u6d41\u8ba8\u8bba","imgsrc":"static\/image\/text.jpg"},{"nameindex":"_1_6","type":1,"url":"","desc":"import random\r\nlist_MarkerList = RmList()\r\nFibonacci = [random.randint(1,5), random.randint(1,5)]\r\nnum_List = []\r\npid_Auto_Yaw = rm_ctrl.PIDCtrl()\r\npid_Auto_Pitch = rm_ctrl.PIDCtrl()\r\nvariable_X = 0\r\nvariable_Y = 0\r\nindex = 0\r\ndef System_Init():\r\n led_ctrl.set_top_led(rm_define.armor_top_all, 69, 215, 255, rm_define.effect_always_off)\r\n led_ctrl.set_bottom_led(rm_define.armor_bottom_all, 69, 215, 255, rm_define.effect_always_off)\r\n robot_ctrl.set_mode(rm_define.robot_mode_free)\r\n vision_ctrl.enable_detection(rm_define.vision_detection_marker)\r\n vision_ctrl.set_marker_detection_distance(3)\r\n media_ctrl.zoom_value_update(2)\r\n pid_Auto_Yaw.set_ctrl_params(55,0,10)\r\n pid_Auto_Pitch.set_ctrl_params(35,0,10)\r\n gimbal_ctrl.recenter()\r\n time.sleep(2)\r\ndef Fibonacci_Sequence():\r\n while Fibonacci[len(Fibonacci) - 1] < 100:\r\n Fibonacci.append(Fibonacci[len(Fibonacci) - 1] + Fibonacci[len(Fibonacci) - 2])\r\n del Fibonacci[len(Fibonacci) -1 ]\r\n for i in range(len(Fibonacci)):\r\n if Fibonacci
< 10:\r\n unitPlace = Fibonacci
% 10\r\n num_List.append(unitPlace)\r\n else:\r\n tenPlace = int(Fibonacci
\/ 10 % 10)\r\n num_List.append(tenPlace)\r\n unitPlace = Fibonacci
% 10\r\n num_List.append(unitPlace)\r\ndef Find_Target(num): \r\n global variable_X\r\n global variable_Y\r\n list_MarkerList = RmList(vision_ctrl.get_marker_detection_info())\r\n if list_MarkerList[1] > 1:\r\n for count in range(2,len(list_MarkerList),5):\r\n if list_MarkerList[count] == num + 10:\r\n variable_X = list_MarkerList[count + 1]\r\n variable_Y = list_MarkerList[count + 2]\r\n pid_Auto_Yaw.set_error(variable_X - 0.5)\r\n pid_Auto_Pitch.set_error(0.5 - variable_Y)\r\n gimbal_ctrl.rotate_with_speed(pid_Auto_Yaw.get_output(),pid_Auto_Pitch.get_output())\r\n else:\r\n gimbal_ctrl.rotate_with_speed(0,0)\r\ndef Operation():\r\n global index\r\n if num_List[index] == 0:\r\n led_ctrl.set_top_led(rm_define.armor_top_right, 69, 215, 255, rm_define.effect_always_on)\r\n led_ctrl.set_bottom_led(rm_define.armor_bottom_front, 69, 215, 255, rm_define.effect_always_on)\r\n led_ctrl.set_bottom_led(rm_define.armor_bottom_right, 69, 215, 255, rm_define.effect_always_on)\r\n elif num_List[index] == 9:\r\n led_ctrl.set_top_led(rm_define.armor_top_right, 69, 215, 255, rm_define.effect_always_on)\r\n led_ctrl.set_bottom_led(rm_define.armor_bottom_right, 69, 215, 255, rm_define.effect_always_on)\r\n else:\r\n led_ctrl.set_single_led(rm_define.armor_top_right, num_List[index], rm_define.effect_always_on)\r\n Find_Target(num_List[index])\r\n if abs(variable_X - 0.5) < 0.01 and abs(0.5 - variable_Y) < 0.01:\r\n time.sleep(1)\r\n media_ctrl.play_sound(rm_define.media_sound_shoot)\r\n led_ctrl.set_top_led(rm_define.armor_top_all, 69, 215, 255, rm_define.effect_always_off)\r\n led_ctrl.set_bottom_led(rm_define.armor_bottom_all, 69, 215, 255, rm_define.effect_always_off)\r\n index += 1\r\n if index >= len(num_List):\r\n index = len(num_List)-1\r\ndef start():\r\n System_Init()\r\n Fibonacci_Sequence()\r\n while True:\r\n Operation() ","imgsrc":"static\/image\/text.jpg"}]
作者:
哆来咪
时间:
2019-10-5
学习一下
作者:
王生
时间:
2019-11-11
學習一下, 多謝樓主的分享!!!
欢迎光临 大疆社区 (https://bbs.dji.com/)
Powered by Discuz! X3.2