CARLA
WalkerManager.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 #include "carla/NonCopyable.h"
10 
11 #include "carla/geom/Location.h"
12 #include "carla/nav/WalkerEvent.h"
13 #include "carla/rpc/ActorId.h"
14 
15 namespace carla {
16 namespace nav {
17 
18  class Navigation;
19 
20  enum WalkerState {
25  };
26 
30  unsigned char areaType;
31  WalkerRoutePoint(WalkerEvent ev, carla::geom::Location loc, unsigned char area) : event(ev), location(loc), areaType(area) {};
32  };
33 
34  struct WalkerInfo {
37  unsigned int currentIndex { 0 };
39  std::vector<WalkerRoutePoint> route;
40  };
41 
42  class WalkerManager : private NonCopyable {
43 
44  public:
45 
46  WalkerManager();
47  ~WalkerManager();
48 
49  /// assign the navigation module
50  void SetNav(Navigation *nav) { _nav = nav; };
51 
52  /// create a new walker route
53  bool AddWalker(ActorId id);
54 
55  /// remove a walker route
56  bool RemoveWalker(ActorId id);
57 
58  /// update all routes
59  bool Update(double delta);
60 
61  /// set a new route from its current position
62  bool SetWalkerRoute(ActorId id);
63  bool SetWalkerRoute(ActorId id, carla::geom::Location to);
64 
65  /// set the next point in the route
66  bool SetWalkerNextPoint(ActorId id);
67 
68  /// get the next point in the route
69  bool GetWalkerNextPoint(ActorId id, carla::geom::Location &location);
70 
71  /// get the point in the route that end current crosswalk
72  bool GetWalkerCrosswalkEnd(ActorId id, carla::geom::Location &location);
73 
74  /// return the navigation object
75  Navigation *GetNavigation() { return _nav; };
76 
77  private:
78 
79  EventResult ExecuteEvent(ActorId id, WalkerInfo &info, double delta);
80 
81  std::unordered_map<ActorId, WalkerInfo> _walkers;
82  Navigation *_nav { nullptr };
83  };
84 
85 } // namespace nav
86 } // namespace carla
std::vector< WalkerRoutePoint > route
Definition: WalkerManager.h:39
void SetNav(Navigation *nav)
assign the navigation module
Definition: WalkerManager.h:50
boost::variant< WalkerEventIgnore, WalkerEventWait, WalkerEventStopAndCheck > WalkerEvent
walker event variant
Definition: WalkerEvent.h:43
rpc::ActorId ActorId
Definition: ActorId.h:18
WalkerRoutePoint(WalkerEvent ev, carla::geom::Location loc, unsigned char area)
Definition: WalkerManager.h:31
This file contains definitions of common data structures used in traffic manager. ...
Definition: Carla.cpp:99
EventResult
result of an event
Definition: WalkerEvent.h:20
Navigation * GetNavigation()
return the navigation object
Definition: WalkerManager.h:75
carla::geom::Location from
Definition: WalkerManager.h:35
std::unordered_map< ActorId, WalkerInfo > _walkers
Definition: WalkerManager.h:81
carla::geom::Location location
Definition: WalkerManager.h:29
carla::geom::Location to
Definition: WalkerManager.h:36
Inherit (privately) to suppress copy/move construction and assignment.
Manage the pedestrians navigation, using the Recast & Detour library for low level calculations...
Definition: Navigation.h:57