コード例 #1
0
 def __init__(self,
              primitive_id,
              start_theta_discrete,
              action_cost_multiplier,
              end_cell,
              intermediate_states,
              control_signals=None):
     self._id = primitive_id
     self._start_theta_discrete = start_theta_discrete
     self._action_cost_multiplier = action_cost_multiplier
     self._end_cell = freeze_array(np.array(end_cell))
     self._intermediate_states = freeze_array(np.array(intermediate_states))
     if control_signals is not None:
         control_signals = freeze_array(control_signals.copy())
     self._control_signals = control_signals
コード例 #2
0
ファイル: costmap_2d.py プロジェクト: abhi-iyer/meta-learning
 def from_state(cls, state):
     """
     Deserialize and make a CostMap2D from saved serialized 'state'
     :param state Dict: serialized representation of the costmap
     :return CostMap2D: deserialized costmap
     """
     assert state['version'] == CURRENT_ENCODING_VERSION
     return CostMap2D(
         data=state['data'],
         resolution=state['resolution'],
         origin=freeze_array(state['origin']),
     )
コード例 #3
0
ファイル: costmap_2d.py プロジェクト: abhi-iyer/meta-learning
 def __init__(self, data, resolution, origin):
     """
     :param data: A (width, height) numpy array
     :param resolution: A float, indicating the costmap resolution in meters/pixel.
     :param origin: A 2-element numpy array indicating the position, in meters, of the bottom-left corner of the costmap.
                   (i.e. the position corresponding to data[0, 0])
     """
     self._data = data
     self._resolution = resolution
     # origin has to be a numpy array with float type to avoid constant creation of arrays during perception
     assert origin.dtype == np.float64
     self._origin = freeze_array(origin)
     assert self._origin.dtype == np.float64
     assert not self._origin.flags.writeable
コード例 #4
0
def test_frozen_array():
    a = freeze_array(np.array([0, 1, 2]))
    np.testing.assert_array_equal(a, [0, 1, 2])

    assert a[0] == 0

    with pytest.raises(ValueError):
        a[0] = 3

    b = a[:1]
    assert len(b) == 1
    assert b[0] == 0
    with pytest.raises(ValueError):
        b[0] = 4

    # some slicing operations create a copy that is mutable again,
    # however original array is still immutable
    c = a[[0, 2]]
    np.testing.assert_array_equal(c, [0, 2])
    c[1] = 10
    np.testing.assert_array_equal(a, [0, 1, 2])
    with pytest.raises(ValueError):
        a[0] = 3
コード例 #5
0
ファイル: costmap_2d.py プロジェクト: abhi-iyer/meta-learning
 def __setstate__(self, state):
     self._data = state['_data']
     self._origin = freeze_array(state['_origin'])
     self._resolution = state['_resolution']