| 567 | return np.rad2deg(math.atan2(next_pos.y - pos.y, next_pos.x - pos.x)) |
| 568 | |
| 569 | class Agent(object): |
| 570 | def __init__(self, actor, type_tag, path, preferred_speed, steer_angle_range=0.0, rand=0): |
| 571 | self.actor = actor |
| 572 | self.type_tag = type_tag |
| 573 | self.path = path |
| 574 | self.preferred_speed = preferred_speed |
| 575 | self.stuck_time = None |
| 576 | self.control_velocity = carla.Vector2D(0, 0) |
| 577 | self.steer_angle_range = steer_angle_range |
| 578 | self.behavior_type = self.rand_agent_behavior_type(rand) |
| 579 | |
| 580 | def rand_agent_behavior_type(self, prob): |
| 581 | prob_gamma_agent = 1.0 |
| 582 | prob_simplified_gamma_agent = 0.0 |
| 583 | prob_ttc_agent = 0.0 |
| 584 | |
| 585 | if prob <= prob_gamma_agent: |
| 586 | return carla.AgentBehaviorType.Gamma |
| 587 | elif prob <= prob_gamma_agent + prob_simplified_gamma_agent: |
| 588 | return carla.AgentBehaviorType.SimplifiedGamma |
| 589 | else: |
| 590 | return -1 |
| 591 | |
| 592 | |
| 593 | class Context(object): |