139 std::vector<carla::geom::Location> path;
140 std::vector<unsigned char> area;
162 info.
route.reserve(path.size());
164 for (
unsigned int i=0; i<path.size(); ++i) {
183 previous_area = area[i];
264 while (pos < info.
route.size()) {
266 location = info.
route[pos].location;
282 return std::visit(visitor, rp.
event);
286 static bool AlreadyCalculated =
false;
287 if (AlreadyCalculated)
return;
294 for (
auto const &actor : *actors) {
296 if (actor->GetTypeId() ==
"traffic.traffic_light") {
300 auto tl = std::dynamic_pointer_cast<carla::client::TrafficLight>(actor);
303 std::vector<SharedPtr<carla::client::Waypoint>> list = tl->GetStopWaypoints();
304 for (
auto const &way : list) {
311 AlreadyCalculated =
true;
318 float max_distance) {
319 float min_dist = std::numeric_limits<float>::infinity();
323 if (dist < min_dist) {
329 if (max_distance < 0.0f || min_dist <= max_distance * max_distance) {
SharedPtr< ActorList > GetActors() const
Return a list with all the actors currently present in the world.
Manage the pedestrians navigation, using the Recast & Detour library for low level calculations.
bool GetWalkerPosition(ActorId id, carla::geom::Location &location)
get the walker current location
bool SetWalkerDirectTarget(ActorId id, carla::geom::Location to)
void PauseAgent(ActorId id, bool pause)
set an agent as paused for the crowd
bool GetRandomLocation(carla::geom::Location &location, dtQueryFilter *filter=nullptr) const
get a random location for navigation
bool GetAgentRoute(ActorId id, carla::geom::Location from, carla::geom::Location to, std::vector< carla::geom::Location > &path, std::vector< unsigned char > &area)
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
std::weak_ptr< carla::client::detail::Simulator > _simulator
std::unordered_map< ActorId, WalkerInfo > _walkers
void GetAllTrafficLightWaypoints()
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
This file contains definitions of common data structures used in traffic manager.
std::shared_ptr< T > SharedPtr
constexpr auto DistanceSquared(Location loc) const
constexpr float SquaredLength() const
empty event that just ignores
event to pause and check for near vehicles
unsigned int currentIndex
std::vector< WalkerRoutePoint > route
carla::geom::Location from