Beispiel #1
0
def test_analzyer_on_field_model():
    """
    Create a model of the field, then ask the laser to compute
    the range for sweep.  Then move the robot and ask again.
    """
    robot = Robot()
    field = FieldModel()
    tower_range = field.tower_range_from_origin()
    rotation = FakeRotation(field, robot)
    heading, sweep_range = Analyzer.range_at_heading(rotation.polar_data(), (-10,11))

    #  closest point should be dead ahead
    assert heading == 0
    assert sweep_range == tower_range

    movement = 100
    robot.move(movement)
    rotation = FakeRotation(field, robot)
    heading, sweep_range = Analyzer.range_at_heading(rotation.polar_data(), (-10,11))

    #  closest point should be dead ahead
    assert heading == 0
    assert sweep_range == (tower_range - movement)
Beispiel #2
0
    avg_dist = avg_distance(cart_data)
    print("Average distance: {:.1f}\n".format(avg_dist))

    # plot any calculated markers in their specified color
    #lidar_viewer.plot_markers(r2_markers, 'g')

    lidar_viewer.plot_polar_markers(find_wall_markers, 'r')

    #wall_markers = [max_start, max_end]
    #lidar_viewer.plot_markers(wall_markers, 'b')


if __name__ == '__main__':

    # put robot at the origin
    robot = Robot((0,0), 0)
    field_model = FieldModel()
    lidar_viewer = LidarViewer()
    factor = 4
        
    while True:
        text = raw_input("Enter command (mOVE,tURN,sHOW,iNFO,0(origin),hELP or qQUIT): ")
        cmd  = text.split(" ")[0]
        
        #If we see a quit command, well, quit
        if cmd == "q":
            break
            
        #Reset robot to the origin with 0 turn
        if cmd == "0":
            robot = Robot((0,0), 0)