(self, world, start_in_autopilot)
| 205 | |
| 206 | class DualControl(object): |
| 207 | def __init__(self, world, start_in_autopilot): |
| 208 | self._autopilot_enabled = start_in_autopilot |
| 209 | if isinstance(world.player, carla.Vehicle): |
| 210 | self._control = carla.VehicleControl() |
| 211 | world.player.set_autopilot(self._autopilot_enabled) |
| 212 | elif isinstance(world.player, carla.Walker): |
| 213 | self._control = carla.WalkerControl() |
| 214 | self._autopilot_enabled = False |
| 215 | self._rotation = world.player.get_transform().rotation |
| 216 | else: |
| 217 | raise NotImplementedError("Actor type not supported") |
| 218 | self._steer_cache = 0.0 |
| 219 | world.hud.notification("Press 'H' or '?' for help.", seconds=4.0) |
| 220 | |
| 221 | # initialize steering wheel |
| 222 | pygame.joystick.init() |
| 223 | |
| 224 | joystick_count = pygame.joystick.get_count() |
| 225 | if joystick_count > 1: |
| 226 | raise ValueError("Please Connect Just One Joystick") |
| 227 | |
| 228 | self._joystick = pygame.joystick.Joystick(0) |
| 229 | self._joystick.init() |
| 230 | |
| 231 | self._parser = ConfigParser() |
| 232 | self._parser.read('wheel_config.ini') |
| 233 | self._steer_idx = int( |
| 234 | self._parser.get('G29 Racing Wheel', 'steering_wheel')) |
| 235 | self._throttle_idx = int( |
| 236 | self._parser.get('G29 Racing Wheel', 'throttle')) |
| 237 | self._brake_idx = int(self._parser.get('G29 Racing Wheel', 'brake')) |
| 238 | self._reverse_idx = int(self._parser.get('G29 Racing Wheel', 'reverse')) |
| 239 | self._handbrake_idx = int( |
| 240 | self._parser.get('G29 Racing Wheel', 'handbrake')) |
| 241 | |
| 242 | def parse_events(self, world, clock): |
| 243 | for event in pygame.event.get(): |
nothing calls this directly
no test coverage detected