import time
import numpy as np
from robomaster import robot
ep_robot = robot.Robot()
ep_robot.initialize(conn_type="ap")
ep_gimbal = ep_robot.gimbal
ep_sensor = ep_robot.sensor
ep_robot.set_robot_mode(mode='free')
dd=[]
aa=[]
def sub_data_handler(sub_info):
d = sub_info
dd.append(d[0])
# print(d)
def sub_angle_handler(angle_info):
pitch_angle, yaw_angle, pitch_ground_angle, yaw_ground_angle = angle_info
a=-yaw_ground_angle/180*np.pi
aa.append(a)
# print("gimbal angle: pitch_angle:{0}, yaw_angle:{1}, pitch_ground_angle:{2}, yaw_ground_angle:{3}".format(
# pitch_angle, yaw_angle, pitch_ground_angle, yaw_ground_angle))
ep_gimbal.moveto(pitch=0, yaw=-180).wait_for_completed()
ep_sensor.sub_distance(freq=10, callback=sub_data_handler)
ep_gimbal.sub_angle(freq=10, callback=sub_angle_handler)
ep_gimbal.moveto(pitch=0, yaw=180, yaw_speed=10).wait_for_completed()
ep_gimbal.unsub_angle()
ep_sensor.unsub_distance()
ep_gimbal.moveto(pitch=0, yaw=0).wait_for_completed()
ll=min(len(aa), len(dd))
ll
import matplotlib.pyplot as plt
plt.polar(aa[:ll], dd[:ll], 'b+')
ax = plt.gca() # gets the active axis
ax.set_rmax(700)
ax.set_aspect(1)
plt.savefig('polar.png', dpi=300)
plt.show()
herrDeng網內搜尋
自訂搜尋
Ads
2022年11月20日 星期日
Robomaster SDK紅外線感測器測距 python pyplot.polar畫地圖
訂閱:
張貼留言 (Atom)
熱門文章
-
產生50個元素的陣列並排序
-
11!=?
-
請輸出如下 * ** *** **** ***** ******
-
借錢500萬,年利18%,每月複利計算,請問連本帶利的金額 5, 10, 15, 20, 25, 30, 35, 40, 45, 50年的金額。並比較公式: A*exp(0.18n) A*(1+0.18/12)^(12*n), n=年數, A=本金 hint: math.h, p...
-
計算你上學期加權平均
-
計算你的BMI
-
請用CPU-Z軟體檢測Cache & Memory 註:快取(L1-L3: SRAM) 第一級快取(L1)–通常存取只需要幾個週期,通常是幾十個KB。 第二級快取(L2)–比L1約有2到10倍較高延遲性,通常是幾百個KB或更多。 第三級快取(L3)(不...
-
寫一個是否上學期成績2/3的程式
-
金鑰總數159*10^18 億=10^8 兆=10^12 京=10^16 垓=10^20 秭=10^24 穣=10^28 溝=10^32 澗=10^36 正=10^40 載=10^44 極=10^48 恆河沙=10^52 阿僧祇=10^56 那由...
沒有留言:
張貼留言