CARLA
 
载入中...
搜索中...
未找到
WalkerEvent.cpp
浏览该文件的文档.
1// Copyright (c) 2019 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
11
12namespace carla {
13namespace nav {
14
18
20 // refresh time and check
21 event.time -= _delta;
22 if (event.time <= 0.0)
23 return EventResult::End;
24 else
26 }
27
29 event.time -= _delta;
30 if (event.time <= 0.0) {
32 } else {
33 carla::geom::Location currentUnrealPos;
35 _manager->GetNavigation()->GetWalkerPosition(_id, currentUnrealPos);
36 // check if we need to check for a trafficlight there (only the first time)
37 if (event.check_for_trafficlight) {
38 event.actor = _manager->GetTrafficLightAffecting(currentUnrealPos);
39 event.check_for_trafficlight = false;
40 }
41 // check if we need to wait for a trafficlight
42 if (event.actor) {
43 auto state = event.actor->GetState();
47 }
48 }
50 // calculate the direction to look for vehicles
51 carla::geom::Location crosswalkEnd;
52 _manager->GetWalkerCrosswalkEnd(_id, crosswalkEnd);
53 carla::geom::Location direction;
54 direction.x = crosswalkEnd.x - currentUnrealPos.x;
55 direction.y = crosswalkEnd.y - currentUnrealPos.y;
56 direction.z = crosswalkEnd.z - currentUnrealPos.z;
57 // check if the agent has any vehicle around
58 if (_manager && !(_manager->GetNavigation()->HasVehicleNear(_id, 6.0f, direction))) {
59 return EventResult::End;
60 } else {
62 }
63 }
64 }
65
66} // namespace nav
67} // namespace carla
bool GetWalkerPosition(ActorId id, carla::geom::Location &location)
get the walker current location
void PauseAgent(ActorId id, bool pause)
set an agent as paused for the crowd
bool HasVehicleNear(ActorId id, float distance, carla::geom::Location direction)
return if the agent has a vehicle near (as neighbour)
EventResult operator()(WalkerEventIgnore &event)
bool GetWalkerCrosswalkEnd(ActorId id, carla::geom::Location &location)
get the point in the route that end current crosswalk
Navigation * GetNavigation()
return the navigation object
SharedPtr< carla::client::TrafficLight > GetTrafficLightAffecting(carla::geom::Location UnrealPos, float max_distance=-1.0f)
return the trafficlight affecting that position
EventResult
result of an event
Definition WalkerEvent.h:28
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133
empty event that just ignores
Definition WalkerEvent.h:35
event to pause and check for near vehicles
Definition WalkerEvent.h:45
SharedPtr< carla::client::TrafficLight > actor
Definition WalkerEvent.h:48
event to wait for a while
Definition WalkerEvent.h:39