21#include <recast/Recast.h>
25#include <recast/DetourCrowd.h>
27#include <recast/DetourNavMesh.h>
29#include <recast/DetourNavMeshBuilder.h>
31#include <recast/DetourNavMeshQuery.h>
33#include <recast/DetourCommon.h>
94 bool Load(
const std::string &filename);
96 bool Load(std::vector<uint8_t> content);
115 std::vector<carla::geom::Location> &path, std::vector<unsigned char> &area);
137 std::vector<carla::geom::Location> &path, std::vector<unsigned char> &area);
140 void SetSimulator(std::weak_ptr<carla::client::detail::Simulator> simulator);
142 void SetSeed(
unsigned int seed);
管理行人导航,使用 Recast & Detour 库进行低层计算。
bool SetWalkerMaxSpeed(ActorId id, float max_speed)
设置新的最大速度
void UpdateCrowd(const client::detail::EpisodeState &state)
更新人群中的所有步行者
bool GetPath(carla::geom::Location from, carla::geom::Location to, dtQueryFilter *filter, std::vector< carla::geom::Location > &path, std::vector< unsigned char > &area)
返回从一个位置到另一个位置的路径点
void SetAgentFilter(int agent_index, int filter_index)
为代理分配过滤索引
std::unordered_map< ActorId, int > _mapped_vehicles_id
std::unordered_map< ActorId, int > _mapped_walkers_id
mapping Id
bool RemoveAgent(ActorId id)
移除代理
std::weak_ptr< carla::client::detail::Simulator > _simulator
bool GetWalkerPosition(ActorId id, carla::geom::Location &location)
获取行人的当前位置
float GetWalkerSpeed(ActorId id)
获取步行人速度
bool Load(const std::string &filename)
从磁盘中加载导航数据
bool SetWalkerTarget(ActorId id, carla::geom::Location to)
设置新的目标点以通过有事件的路线
void SetSeed(unsigned int seed)
设置随机数种子
bool UpdateVehicles(std::vector< VehicleCollisionInfo > vehicles)
在人群中添加/更新/删除车辆
std::unordered_map< int, ActorId > _mapped_by_index
bool SetWalkerDirectTarget(ActorId id, carla::geom::Location to)
bool SetWalkerLookAt(ActorId id, carla::geom::Location location)
让代理查看某个位置
void PauseAgent(ActorId id, bool pause)
将人群中的代理设置为暂停
bool HasVehicleNear(ActorId id, float distance, carla::geom::Location direction)
如果代理在附近有车辆(作为邻居),则返回
bool GetWalkerTransform(ActorId id, carla::geom::Transform &trans)
获取步行人当前变换
bool GetRandomLocation(carla::geom::Location &location, dtQueryFilter *filter=nullptr) const
获取导航的随机位置
bool IsWalkerAlive(ActorId id, bool &alive)
如果行人代理被车辆撞死,则返回
WalkerManager _walker_manager
行人管理器负责带事件的路线规划
bool GetAgentRoute(ActorId id, carla::geom::Location from, carla::geom::Location to, std::vector< carla::geom::Location > &path, std::vector< unsigned char > &area)
void SetPedestriansCrossFactor(float percentage)
设置行人代理在路径跟随过程中穿过马路的概率
std::unordered_map< ActorId, float > _yaw_walkers
存储上一个节拍的行人偏航角
bool AddWalker(ActorId id, carla::geom::Location from)
创建新的行人
std::vector< uint8_t > _binary_mesh
double GetDeltaSeconds()
返回最后增量秒数
bool SetWalkerDirectTargetIndex(int index, carla::geom::Location to)
void SetSimulator(std::weak_ptr< carla::client::detail::Simulator > simulator)
引用模拟器来访问API函数
dtNavMeshQuery * _nav_query
void CreateCrowd(void)
创建人群对象
bool AddOrUpdateVehicle(VehicleCollisionInfo &vehicle)
在人群中创造一辆新的车辆,让行人避开
float _probability_crossing
std::unordered_map< int, carla::geom::Vector3D > _walkers_blocked_position
每隔一段时间保存每个参与者的位置,并检查是否有参与者被阻挡
carla::geom::BoundingBox bounding
carla::geom::Transform transform