云飞行编码比赛 - 火星漫游者
做火星漫游者编码问题,并且陷入了2级。试图调试,但我看不到它,它不会让我进步直到当前级别完成。
问题描述如下:
以一定的转向角度驾驶一定距离后,计算漫游者的位置和方向。
输入:轴距,距离,方向盘(2个小数小数) 输出:X,Y,新界面角
示例: 在:1.00 1.00 30.00 出局:0.24 0.96 28.65
有人知道某些步行,解决方案等的任何链接还是更多示例?
底部有一个指向编码问题的图像链接,
请感谢
## Level 1 - calculate the turn radius ##
## level1 2 - calculate new position and angle
import math
## solution works for this data
WHEELBASE = 1.00
DISTANCE = 1.00
STEERINGANGLE = 30.00
#WHEELBASE = 1.75
#DISTANCE = 3.14
#STEERINGANGLE = -23.00
def calculateTurnRadius(wheelbase, steeringangle):
return round(wheelbase / math.sin(math.radians(steeringangle)), 2)
def calculateNewDirection(wheelbase, steeringangle, distance):
turnRadius = calculateTurnRadius(wheelbase, steeringangle)
theta = distance / turnRadius
#brings theta to within a 180 arc
while theta >= math.pi * 2:
theta -= math.pi * 2
while theta < 0:
theta += math.pi * 2
# calculate theta with basic sin and cos trig
x = turnRadius - (math.cos(theta) * turnRadius)
y = math.sin(theta) * turnRadius
x = abs(round(x, 2))
y = round(y, 2)
theta = math.degrees(theta)
theta = round(theta, 2)
return x, y, theta
print(f"Turn Radius = {calculateTurnRadius(WHEELBASE, STEERINGANGLE)}")
print(f"{calculateNewDirection(WHEELBASE, STEERINGANGLE, DISTANCE)}")
Turn Radius = 2.0
(0.24, 0.96, 28.65)
[1]: https://i.sstatic.net/tDY2u.jpg
Doing the Mars Rover coding problem and am stuck at level 2. Trying to debug but I just can't see it and it wont let me progress until current level is finished.
Problem Description as follows:
Calculate the position and the direction of the rover after driving a certain distance with a certain steering angle.
Input: WheelBase, Distance, SteeringAngle (2 decimal floats)
Output: X, Y, NewDirection Angle
Example:
In: 1.00 1.00 30.00
Out: 0.24 0.96 28.65
Anybody know of any links to some walk throughs, solutions etc or more examples?
There is an image link to the coding problem at the bottom
Thanks
https://catcoder.codingcontest.org/training/1212/play
## Level 1 - calculate the turn radius ##
## level1 2 - calculate new position and angle
import math
## solution works for this data
WHEELBASE = 1.00
DISTANCE = 1.00
STEERINGANGLE = 30.00
#WHEELBASE = 1.75
#DISTANCE = 3.14
#STEERINGANGLE = -23.00
def calculateTurnRadius(wheelbase, steeringangle):
return round(wheelbase / math.sin(math.radians(steeringangle)), 2)
def calculateNewDirection(wheelbase, steeringangle, distance):
turnRadius = calculateTurnRadius(wheelbase, steeringangle)
theta = distance / turnRadius
#brings theta to within a 180 arc
while theta >= math.pi * 2:
theta -= math.pi * 2
while theta < 0:
theta += math.pi * 2
# calculate theta with basic sin and cos trig
x = turnRadius - (math.cos(theta) * turnRadius)
y = math.sin(theta) * turnRadius
x = abs(round(x, 2))
y = round(y, 2)
theta = math.degrees(theta)
theta = round(theta, 2)
return x, y, theta
print(f"Turn Radius = {calculateTurnRadius(WHEELBASE, STEERINGANGLE)}")
print(f"{calculateNewDirection(WHEELBASE, STEERINGANGLE, DISTANCE)}")
Turn Radius = 2.0
(0.24, 0.96, 28.65)
[1]: https://i.sstatic.net/tDY2u.jpg
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我并没有真正看过您的代码,但是我从1级到4的解决方案都得到了解决方案。因此,这是我的2级代码。
I haven't really looked at your code, but I got the solutions from level 1 to 4. So here's my code for level 2.
我也卡住了,但是到目前为止,我对前两个输入有效:
I'm also stuck, but what I have so far works for the first 2 inputs: