CARLA
 
载入中...
搜索中...
未找到
WalkerManager.h
浏览该文件的文档.
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
12#include "carla/client/World.h"
13#include "carla/geom/Location.h"
15#include "carla/rpc/ActorId.h"
17
18namespace carla {
19namespace nav {
20
21 class Navigation;
22
29
36
37 struct WalkerInfo {
40 unsigned int currentIndex { 0 };
42 std::vector<WalkerRoutePoint> route;
43 };
44
45 class WalkerManager : private NonCopyable {
46
47 public:
48
51
52 /// assign the navigation module
53 void SetNav(Navigation *nav);
54
55 /// reference to the simulator to access API functions
56 void SetSimulator(std::weak_ptr<carla::client::detail::Simulator> simulator);
57
58 /// create a new walker route
59 bool AddWalker(ActorId id);
60
61 /// remove a walker route
62 bool RemoveWalker(ActorId id);
63
64 /// update all routes
65 bool Update(double delta);
66
67 /// set a new route from its current position
68 bool SetWalkerRoute(ActorId id);
70
71 /// set the next point in the route
73
74 /// get the next point in the route
76
77 /// get the point in the route that end current crosswalk
79
80 /// return the navigation object
82
83 /// return the trafficlight affecting that position
85
86 private:
87
89
90 EventResult ExecuteEvent(ActorId id, WalkerInfo &info, double delta);
91
92 std::unordered_map<ActorId, WalkerInfo> _walkers;
93 std::vector<std::pair<SharedPtr<carla::client::TrafficLight>, carla::geom::Location>> _traffic_lights;
94 Navigation *_nav { nullptr };
95 std::weak_ptr<carla::client::detail::Simulator> _simulator;
96 };
97
98} // namespace nav
99} // namespace carla
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
bool RemoveWalker(ActorId id)
remove a walker route
std::vector< std::pair< SharedPtr< carla::client::TrafficLight >, carla::geom::Location > > _traffic_lights
bool AddWalker(ActorId id)
create a new walker route
bool GetWalkerCrosswalkEnd(ActorId id, carla::geom::Location &location)
get the point in the route that end current crosswalk
void SetSimulator(std::weak_ptr< carla::client::detail::Simulator > simulator)
reference to the simulator to access API functions
EventResult ExecuteEvent(ActorId id, WalkerInfo &info, double delta)
bool Update(double delta)
update all routes
bool GetWalkerNextPoint(ActorId id, carla::geom::Location &location)
get the next point in the route
bool SetWalkerNextPoint(ActorId id)
set the next point in the route
Navigation * GetNavigation()
return the navigation object
std::weak_ptr< carla::client::detail::Simulator > _simulator
std::unordered_map< ActorId, WalkerInfo > _walkers
SharedPtr< carla::client::TrafficLight > GetTrafficLightAffecting(carla::geom::Location UnrealPos, float max_distance=-1.0f)
return the trafficlight affecting that position
void SetNav(Navigation *nav)
assign the navigation module
bool SetWalkerRoute(ActorId id)
set a new route from its current position
EventResult
result of an event
Definition WalkerEvent.h:28
boost::variant2::variant< WalkerEventIgnore, WalkerEventWait, WalkerEventStopAndCheck > WalkerEvent
walker event variant
Definition WalkerEvent.h:55
This file contains definitions of common data structures used in traffic manager.
Definition Carla.cpp:133
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
rpc::ActorId ActorId
Definition ActorId.h:18
unsigned int currentIndex
std::vector< WalkerRoutePoint > route
carla::geom::Location from
carla::geom::Location to
carla::geom::Location location
WalkerRoutePoint(WalkerEvent ev, carla::geom::Location loc, unsigned char area)