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);
279 static bool AlreadyCalculated =
false;
280 if (AlreadyCalculated)
return;
286 std::vector<carla::rpc::Actor> actors =
_simulator.lock()->GetAllTheActorsInTheEpisode();
287 for (
auto actor : actors) {
290 if (actor.description.id ==
"traffic.traffic_light") {
293 boost::static_pointer_cast<carla::client::TrafficLight>(world.
GetActor(actor.id));
295 std::vector<SharedPtr<carla::client::Waypoint>> list = tl->GetStopWaypoints();
296 for (
auto &way : list) {
302 AlreadyCalculated =
true;
309 float max_distance) {
310 float min_dist = std::numeric_limits<float>::infinity();
314 if (dist < min_dist) {
320 if (max_distance < 0.0f || min_dist <= max_distance * max_distance) {
SharedPtr< Actor > GetActor(ActorId id) const
根据id查找actor,如果没有找到则返回nullptr。 通过传入的ActorId参数,在当前模拟世界中查找对应的参与者对象,方便快速定位特定的实体, 比如查找某一辆特定编号的车辆或者某个行人等。
auto DistanceSquared(const Location &loc) const
float SquaredLength() const
管理行人导航,使用 Recast & Detour 库进行低层计算。
bool GetWalkerPosition(ActorId id, carla::geom::Location &location)
获取行人的当前位置
bool SetWalkerDirectTarget(ActorId id, carla::geom::Location to)
void PauseAgent(ActorId id, bool pause)
将人群中的代理设置为暂停
bool GetRandomLocation(carla::geom::Location &location, dtQueryFilter *filter=nullptr) const
获取导航的随机位置
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)
std::vector< std::pair< SharedPtr< carla::client::TrafficLight >, carla::geom::Location > > _traffic_lights
bool AddWalker(ActorId id)
bool GetWalkerCrosswalkEnd(ActorId id, carla::geom::Location &location)
void SetSimulator(std::weak_ptr< carla::client::detail::Simulator > simulator)
EventResult ExecuteEvent(ActorId id, WalkerInfo &info, double delta)
bool Update(double delta)
bool GetWalkerNextPoint(ActorId id, carla::geom::Location &location)
bool SetWalkerNextPoint(ActorId id)
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)
void SetNav(Navigation *nav)
bool SetWalkerRoute(ActorId id)
boost::shared_ptr< T > SharedPtr
使用这个SharedPtr(boost::shared_ptr)以保持与boost::python的兼容性, 但未来如果可能的话,我们希望能为std::shared_ptr制作一个Python适配器。
unsigned int currentIndex
std::vector< WalkerRoutePoint > route
carla::geom::Location from