CARLA
WalkerEvent.h
Go to the documentation of this file.
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 
7 #pragma once
8 
9 #ifdef _MSC_VER
10 #pragma warning(push)
11 #pragma warning(disable:4583)
12 #pragma warning(disable:4582)
13 #include <boost/variant2/variant.hpp>
14 #pragma warning(pop)
15 #else
16 #include <boost/variant2/variant.hpp>
17 #endif
18 
19 #include "carla/rpc/ActorId.h"
20 
21 namespace carla {
22 namespace nav {
23 
24  class Navigation;
25  class WalkerManager;
26 
27  /// result of an event
28  enum class EventResult : uint8_t {
29  Continue,
30  End,
31  TimeOut
32  };
33 
34  /// empty event that just ignores
36  };
37 
38  /// event to wait for a while
39  struct WalkerEventWait {
40  double time;
41  WalkerEventWait(double duration) : time(duration) {};
42  };
43 
44  /// event to pause and check for near vehicles
46  double time;
49  WalkerEventStopAndCheck(double duration) : time(duration),
50  check_for_trafficlight(true)
51  {};
52  };
53 
54  /// walker event variant
55  using WalkerEvent = boost::variant2::variant<WalkerEventIgnore, WalkerEventWait, WalkerEventStopAndCheck>;
56 
57  /// visitor class
59  public:
60  WalkerEventVisitor(WalkerManager *manager, ActorId id, double delta) : _manager(manager), _id(id), _delta(delta) {};
61  EventResult operator()(WalkerEventIgnore &event);
62  EventResult operator()(WalkerEventWait &event);
63  EventResult operator()(WalkerEventStopAndCheck &event);
64  private:
65  WalkerManager *_manager { nullptr };
66  ActorId _id { 0 };
67  double _delta { 0 };
68  };
69 
70 } // namespace nav
71 } // namespace carla
WalkerEventVisitor(WalkerManager *manager, ActorId id, double delta)
Definition: WalkerEvent.h:60
event to wait for a while
Definition: WalkerEvent.h:39
rpc::ActorId ActorId
Definition: ActorId.h:18
boost::shared_ptr< T > SharedPtr
Use this SharedPtr (boost::shared_ptr) to keep compatibility with boost::python, but it would be nice...
Definition: Memory.h:20
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:133
EventResult
result of an event
Definition: WalkerEvent.h:28
boost::variant2::variant< WalkerEventIgnore, WalkerEventWait, WalkerEventStopAndCheck > WalkerEvent
walker event variant
Definition: WalkerEvent.h:55
event to pause and check for near vehicles
Definition: WalkerEvent.h:45
WalkerEventWait(double duration)
Definition: WalkerEvent.h:41
empty event that just ignores
Definition: WalkerEvent.h:35
WalkerEventStopAndCheck(double duration)
Definition: WalkerEvent.h:49
SharedPtr< carla::client::TrafficLight > actor
Definition: WalkerEvent.h:48