140 std::vector<carla::geom::Location> path;
141 std::vector<unsigned char> area;
154 info.
route.reserve(path.size());
156 for (
unsigned int i=0; i<path.size(); ++i) {
175 previous_area = area[i];
256 while (pos < info.
route.size()) {
258 location = info.
route[pos].location;
274 return boost::variant2::visit(visitor, rp.
event);
278 static bool AlreadyCalculated =
false;
279 if (AlreadyCalculated)
return;
285 std::vector<carla::rpc::Actor> actors =
_simulator.lock()->GetAllTheActorsInTheEpisode();
286 for (
auto actor : actors) {
289 if (actor.description.id ==
"traffic.traffic_light") {
292 boost::static_pointer_cast<carla::client::TrafficLight>(world.
GetActor(actor.id));
294 std::vector<SharedPtr<carla::client::Waypoint>> list = tl->GetStopWaypoints();
295 for (
auto &way : list) {
301 AlreadyCalculated =
true;
308 float max_distance) {
309 float min_dist = std::numeric_limits<float>::infinity();
313 if (dist < min_dist) {
319 if (max_distance < 0.0f || min_dist <= max_distance * max_distance) {
SharedPtr< Actor > GetActor(ActorId id) const
Find actor by id, return nullptr if not found.
auto DistanceSquared(const Location &loc) const
float SquaredLength() const
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.
boost::shared_ptr< T > SharedPtr
Use this SharedPtr (boost::shared_ptr) to keep compatibility with boost::python, but it would be nice...
empty event that just ignores
event to pause and check for near vehicles
unsigned int currentIndex
std::vector< WalkerRoutePoint > route
carla::geom::Location from