(
self, centerx: float, centery: float,
yaw: float, speed: float, accel: float
)
| 249 | # entry control mode and control vehicles |
| 250 | # used for real-time simulation mode. |
| 251 | def controlSelf( |
| 252 | self, centerx: float, centery: float, |
| 253 | yaw: float, speed: float, accel: float |
| 254 | ): |
| 255 | x = centerx + (self.length / 2) * cos(yaw) |
| 256 | y = centery + (self.length / 2) * sin(yaw) |
| 257 | # x, y = centerx, centery |
| 258 | angle = (pi / 2 - yaw) * 180 / pi |
| 259 | if self._iscontroled: |
| 260 | traci.vehicle.moveToXY(self.id, '', -1, x, y, |
| 261 | angle=angle, keepRoute=2) |
| 262 | traci.vehicle.setSpeed(self.id, speed) |
| 263 | if accel >= 0: |
| 264 | traci.vehicle.setAccel(self.id, accel) |
| 265 | traci.vehicle.setDecel(self.id, self.maxDecel) |
| 266 | else: |
| 267 | traci.vehicle.setAccel(self.id, self.maxAccel) |
| 268 | traci.vehicle.setDecel(self.id, -accel) |
| 269 | else: |
| 270 | traci.vehicle.setLaneChangeMode(self.id, 0) |
| 271 | traci.vehicle.setSpeedMode(self.id, 0) |
| 272 | traci.vehicle.moveToXY(self.id, '', -1, x, y, |
| 273 | angle=angle, keepRoute=2) |
| 274 | traci.vehicle.setSpeed(self.id, speed) |
| 275 | if accel >= 0: |
| 276 | traci.vehicle.setAccel(self.id, accel) |
| 277 | traci.vehicle.setDecel(self.id, self.maxDecel) |
| 278 | else: |
| 279 | traci.vehicle.setAccel(self.id, self.maxAccel) |
| 280 | traci.vehicle.setDecel(self.id, -accel) |
| 281 | self._iscontroled = 1 |
| 282 | |
| 283 | # exit control mode and set self.iscontroled = 0 |
| 284 | def exitControlMode(self): |
no outgoing calls
no test coverage detected