Skip to content

Commit 0b918f5

Browse files
authored
Create per-instance copy of quadrotor randomization attributes (#202)
1 parent 7733238 commit 0b918f5

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

safe_control_gym/envs/gym_pybullet_drones/quadrotor.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Quadrotor(BaseAviary):
4242
}
4343
}
4444

45-
INERTIAL_PROP_RAND_INFO = {
45+
BASE_INERTIAL_PROP_RAND_INFO = {
4646
'M': { # Nominal: 0.027
4747
'distrib': 'uniform',
4848
'low': 0.022,
@@ -65,7 +65,7 @@ class Quadrotor(BaseAviary):
6565
}
6666
}
6767

68-
INIT_STATE_RAND_INFO = {
68+
BASE_INIT_STATE_RAND_INFO = {
6969
'init_x': {
7070
'distrib': 'uniform',
7171
'low': -0.5,
@@ -205,6 +205,7 @@ def __init__(self,
205205
super().__init__(init_state=init_state, inertial_prop=inertial_prop, **kwargs)
206206

207207
# Store initial state info.
208+
self.INIT_STATE_RAND_INFO = deepcopy(self.BASE_INIT_STATE_RAND_INFO)
208209
self.INIT_STATE_LABELS = {
209210
QuadType.ONE_D: ['init_x', 'init_x_dot'],
210211
QuadType.TWO_D: ['init_x', 'init_x_dot', 'init_z', 'init_z_dot', 'init_theta', 'init_theta_dot'],
@@ -229,6 +230,7 @@ def __init__(self,
229230
if init_name not in self.INIT_STATE_LABELS[self.QUAD_TYPE]:
230231
self.INIT_STATE_RAND_INFO.pop(init_name, None)
231232
# Remove randomization info of inertial components inconsistent with quad type.
233+
self.INERTIAL_PROP_RAND_INFO = deepcopy(self.BASE_INERTIAL_PROP_RAND_INFO)
232234
if self.QUAD_TYPE == QuadType.ONE_D:
233235
# Do NOT randomize J for the 1D quadrotor.
234236
self.INERTIAL_PROP_RAND_INFO.pop('Ixx', None)

0 commit comments

Comments
 (0)