(self, action, speed)
| 108 | self.noise_being_set = noise_exist |
| 109 | |
| 110 | def compute_noise(self, action, speed): |
| 111 | |
| 112 | # noisy_action = action |
| 113 | if self.noise_type == 'None': |
| 114 | return action, False, False |
| 115 | |
| 116 | if self.noise_type == 'Spike': |
| 117 | |
| 118 | if self.is_time_for_noise(action.steer): |
| 119 | steer = action.steer |
| 120 | |
| 121 | if self.remove_noise: |
| 122 | steer_noisy = max( |
| 123 | min(steer + self.get_noise_removing() * (25 / (2.3 * speed + 5)), 1), -1) |
| 124 | |
| 125 | else: |
| 126 | steer_noisy = max(min(steer + self.get_noise() * (25 / (2.3 * speed + 5)), 1), |
| 127 | -1) |
| 128 | |
| 129 | noisy_action = action |
| 130 | |
| 131 | noisy_action.steer = steer_noisy |
| 132 | |
| 133 | return noisy_action, False, not self.remove_noise |
| 134 | |
| 135 | else: |
| 136 | return action, False, False |
| 137 | |
| 138 | if self.noise_type == 'Throttle': |
| 139 | if self.is_time_for_noise(action.throttle): |
| 140 | throttle_noisy = action.throttle |
| 141 | brake_noisy = action.brake |
| 142 | |
| 143 | if self.remove_noise: |
| 144 | # print(" Throttle noise removing", self.get_noise_removing()) |
| 145 | noise = self.get_noise_removing() |
| 146 | if noise > 0: |
| 147 | throttle_noisy = max(min(throttle_noisy + noise, 1), 0) |
| 148 | else: |
| 149 | brake_noisy = max(min(brake_noisy + -noise, 1), 0) |
| 150 | |
| 151 | else: |
| 152 | |
| 153 | # print(" Throttle noise ", self.get_noise()) |
| 154 | noise = self.get_noise() |
| 155 | if noise > 0: |
| 156 | throttle_noisy = max(min(throttle_noisy + noise, 1), 0) |
| 157 | else: |
| 158 | brake_noisy = max(min(brake_noisy + -noise, 1), 0) |
| 159 | |
| 160 | noisy_action = action |
| 161 | noisy_action.throttle = throttle_noisy |
| 162 | noisy_action.brake = brake_noisy |
| 163 | |
| 164 | # print 'timefornosie' |
| 165 | return noisy_action, False, not self.remove_noise |
| 166 | else: |
| 167 | return action, False, False |
nothing calls this directly
no test coverage detected