【发布时间】:2021-08-07 23:38:53
【问题描述】:
我正在尝试使用正弦波函数进行导航。 我的主要代码中有两个函数:
def stop():
steering = 1024
throttle = 1024
return steering, throttle
def case2():
steering = []
vector = np.vectorize(np.int)
time_interval = 5
samples = 50
t = np.linspace(0, time_interval, samples)
time_req = 5.0
A = 900
vec_steering = A*np.sin(2*(np.pi)*t/time_req) + 1024
vec_steering = vector(vec_steering)
throttle = 1050
for steering in vec_steering:
steering, throttle = steering, throttle
return steering, throttle
函数stop()返回给我规定的油门、转向值,但函数case2()只返回给我:(1023, 1050)
'case2()' 函数的预期正弦输出是这样的:
(1024, 1050)
(1139, 1050)
(1252, 1050)
(1361, 1050)
(1465, 1050)
(1562, 1050)
(1650, 1050)
(1727, 1050)
(1793, 1050)
(1846, 1050)
(1886, 1050)
(1912, 1050)
(1923, 1050)
(1919, 1050)
(1901, 1050)
(1868, 1050)
(1821, 1050)
(1762, 1050)
(1690, 1050)
(1607, 1050)
(1514, 1050)
(1414, 1050)
(1307, 1050)
(1196, 1050)
(1081, 1050)
(966, 1050)
(851, 1050)
(740, 1050)
(633, 1050)
(533, 1050)
(440, 1050)
(357, 1050)
(285, 1050)
(226, 1050)
(179, 1050)
(146, 1050)
(128, 1050)
(124, 1050)
(135, 1050)
(161, 1050)
(201, 1050)
(254, 1050)
(320, 1050)
(397, 1050)
(485, 1050)
(582, 1050)
(686, 1050)
(795, 1050)
(908, 1050)
(1023, 1050)
谁能告诉我我哪里做错了?
【问题讨论】:
标签: python numpy for-loop return trigonometry