25 : _simulator(simulator),
27 _server_side(server_side) {
35 auto files =
_simulator.lock()->GetRequiredFiles(
"Nav");
48 if (walkers->empty()) {
53 std::shared_ptr<const EpisodeState> state = episode->GetState();
66 std::vector<Cmd> commands;
67 commands.reserve(walkers->size());
68 for (
auto handle : *walkers) {
72 commands.emplace_back(Cmd::ApplyWalkerState{ handle.walker, trans, speed });
75 _simulator.lock()->ApplyBatchSync(std::move(commands),
false);
79 for (
auto handle : *walkers) {
83 _simulator.lock()->SetActorCollisions(handle.walker,
true);
84 _simulator.lock()->SetActorDead(handle.walker);
88 _simulator.lock()->DestroyActor(handle.controller);
118 std::vector<carla::nav::VehicleCollisionInfo> vehicles;
121 std::shared_ptr<const EpisodeState> state = episode->GetState();
124 for (
auto &&actor : episode->GetActors()) {
126 if (actor.description.id.rfind(
"vehicle.", 0) == 0) {
142 for (
int i = 0; i <
_nav.
GetCrowd()->getAgentCount(); ++i) {
144 const dtCrowdAgent *agent =
_nav.
GetCrowd()->getAgent(i);
145 if (agent && agent->params.useObb) {
148 p1.
x = agent->params.obb[0];
149 p1.
z = agent->params.obb[1];
150 p1.
y = agent->params.obb[2];
151 p2.
x = agent->params.obb[3];
152 p2.
z = agent->params.obb[4];
153 p2.
y = agent->params.obb[5];
154 p3.
x = agent->params.obb[6];
155 p3.
z = agent->params.obb[7];
156 p3.
y = agent->params.obb[8];
157 p4.
x = agent->params.obb[9];
158 p4.
z = agent->params.obb[10];
159 p4.
y = agent->params.obb[11];
165 line1.
color = { 0, 255, 0 };
169 line1.
color = { 255, 0, 0 };
173 line1.
color = { 0, 0, 255 };
177 line1.
color = { 255, 255, 0 };
183 for (
int i = 0; i <
_nav.
GetCrowd()->getAgentCount(); ++i) {
185 const dtCrowdAgent *agent =
_nav.
GetCrowd()->getAgent(i);
189 if (agent->params.userData) {
190 std::ostringstream out;
191 out << *(reinterpret_cast<const float *>(agent->params.userData));
196 text.
color = { 0, 255, 0 };
Represents the state of all the actors of an episode at a given frame.
bool ContainsActorSnapshot(ActorId actor_id) const
unsigned long _next_check_index
void UpdateVehiclesInCrowd(std::shared_ptr< Episode > episode, bool show_debug=false)
add/update/delete all vehicles in crowd
std::weak_ptr< Simulator > _simulator
void Tick(std::shared_ptr< Episode > episode)
void CheckIfWalkerExist(std::vector< WalkerHandle > walkers, const EpisodeState &state)
check a few walkers and if they don't exist then remove from the crowd
WalkerNavigation(std::weak_ptr< Simulator > simulator, bool server_side=false)
void UnregisterWalker(ActorId walker_id, ActorId controller_id)
carla::nav::Navigation _nav
AtomicList< WalkerHandle > _walkers
void UpdateCrowd(const client::detail::EpisodeState &state)
update all walkers in crowd
bool RemoveAgent(ActorId id)
remove an agent
float GetWalkerSpeed(ActorId id)
get the walker current transform
bool Load(const std::string &filename)
load navigation data
bool UpdateVehicles(std::vector< VehicleCollisionInfo > vehicles)
add/update/delete vehicles in crowd
bool GetWalkerTransform(ActorId id, carla::geom::Transform &trans)
get the walker current transform
bool IsWalkerAlive(ActorId id, bool &alive)
return if the agent has been killed by a vehicle
void SetSimulator(std::weak_ptr< carla::client::detail::Simulator > simulator)
reference to the simulator to access API functions
std::variant< Point, Line, Arrow, Box, String > primitive
This file contains definitions of common data structures used in traffic manager.
geom::Transform transform
struct to send info about vehicles to the crowd