当前位置: 首页>>代码示例>>Python>>正文


Python Move.initial_pos方法代码示例

本文整理汇总了Python中Move.Move.initial_pos方法的典型用法代码示例。如果您正苦于以下问题:Python Move.initial_pos方法的具体用法?Python Move.initial_pos怎么用?Python Move.initial_pos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Move.Move的用法示例。


在下文中一共展示了Move.initial_pos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: explore

# 需要导入模块: from Move import Move [as 别名]
# 或者: from Move.Move import initial_pos [as 别名]
def explore(room):  # Move to a new area, returns area object

    # initialize room.current_area if it does not exsist
    if not room.current_area:
        room.current_area = Area()

    # Test output
    print "Exploring (moving to a new location) ..."

    # Beep to indicate begining of explore step
    buzzer = Buzzer()
    buzzer.play(5)

    # Create new area and move objects
    new_area = Area()
    move = Move()

    # Make sure move is set as a real move (performed by robot)
    move.type = "Real"

    # Link it to the previous object
    new_area.previous.append(room.current_area.name)

    # Initial position set to position of previous area
    move.initial_pos = room.current_area.pos

    # Vector of movement used
    move = get_move_vector(move)

    # Break down movement vector into motion primitives that robot can execute
    move.getMotionPlan()

    for (direction, amount) in move.primitives:
        print "Moving " + str(direction) + " " + str(amount)
        # moveBot(direction, amount, params.p['MOTOR_PWR'])

    # Get final position by summing initial position and delta
    move.final_pos = [init + delt for init, delt in zip(move.initial_pos, move.delta)]

    # TODO: put a kalman filter on the movement. Use camera and sonar as
    # truth? Not sure here

    # # Test print
    # print "Describing move in explore function"
    move.describe()

    # Update location of new area to final position of move
    new_area.pos = move.final_pos

    # Add move to new area's dictionary of moves
    new_area.moves_performed[room.current_area.name] = move

    # Redirect current area to this new_area
    room.current_area = new_area

    # Localize bot in new area
    # new_area.localize

    # # Test print
    # print "Describing new_area in explore function"
    # new_area.describe()

    # Append new_area to room
    room.areas.append(new_area)

    # Return updated room object
    return room
开发者ID:HugoCMU,项目名称:SolarTree,代码行数:69,代码来源:navigation.py


注:本文中的Move.Move.initial_pos方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。