本文整理汇总了Python中position.Position.fromnp方法的典型用法代码示例。如果您正苦于以下问题:Python Position.fromnp方法的具体用法?Python Position.fromnp怎么用?Python Position.fromnp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类position.Position
的用法示例。
在下文中一共展示了Position.fromnp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: to_screen
# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import fromnp [as 别名]
def to_screen(self, pos):
"""
Does not modify original pos. Converto from field space to screen space.
:param pos: Position or RobotPosition
:return: new Position ready to draw on screen
"""
if pos.__class__.__name__ == "ndarray":
pos = Position.fromnp(pos)
pos = pos.clone()
pos.y = -pos.y
if hasattr(pos, 'theta'):
pos.theta = -pos.theta
pos = pos.move_origin(-75, -65)
pos.x = int(pos.x*self.field_zoom)
pos.y = int(pos.y*self.field_zoom)
return pos
示例2: go_with_trajectory
# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import fromnp [as 别名]
def go_with_trajectory(self, goal, current, points_distance=10.0):
"""
Create a trajectory to go to the desired goal
:param goal: RobotPosition where we want to go
:param current: RobotPosition where we are now
:return: Move
"""
path = self.trajectory_generator.get_trajectory(
goal, current, points_distance)
if path is None:
alternative_angles = range(-180,180, 45)
distances = [abs(normalize(goal.theta-angle)) for angle in alternative_angles]
for dist, angle in sorted(zip(distances, alternative_angles)):
path = self.trajectory_generator.get_trajectory(
RobotPosition(goal.x, goal.y, angle), current, points_distance)
if path is not None:
break
if path is None:
return self.go_to_from(goal, current)
intermediate = Position.fromnp(path[1])
return self.go_to_from(intermediate, current)