27 auto files =
_simulator.lock()->GetRequiredFiles(
"Nav");
35 if (walkers->empty()) {
40 std::shared_ptr<const EpisodeState> state = episode->GetState();
53 std::vector<Cmd> commands;
54 commands.reserve(walkers->size());
55 for (
auto handle : *walkers) {
59 commands.emplace_back(Cmd::ApplyWalkerState{ handle.walker, trans, speed });
62 _simulator.lock()->ApplyBatchSync(std::move(commands),
false);
66 for (
auto handle : *walkers) {
70 _simulator.lock()->SetActorCollisions(handle.walker,
true);
71 _simulator.lock()->SetActorDead(handle.walker);
75 _simulator.lock()->DestroyActor(handle.controller);
94 _simulator.lock()->DestroyActor(walkers[_next_check_index].controller);
96 UnregisterWalker(walkers[_next_check_index].walker, walkers[_next_check_index].controller);
105 std::vector<carla::nav::VehicleCollisionInfo> vehicles;
108 std::shared_ptr<const EpisodeState> state = episode->GetState();
111 for (
auto &&actor : episode->GetActors()) {
113 if (actor.description.id.rfind(
"vehicle.", 0) == 0) {
129 for (
int i = 0; i <
_nav.
GetCrowd()->getAgentCount(); ++i) {
131 const dtCrowdAgent *agent =
_nav.
GetCrowd()->getAgent(i);
132 if (agent && agent->params.useObb) {
135 p1.
x = agent->params.obb[0];
136 p1.
z = agent->params.obb[1];
137 p1.
y = agent->params.obb[2];
138 p2.
x = agent->params.obb[3];
139 p2.
z = agent->params.obb[4];
140 p2.
y = agent->params.obb[5];
141 p3.
x = agent->params.obb[6];
142 p3.
z = agent->params.obb[7];
143 p3.
y = agent->params.obb[8];
144 p4.
x = agent->params.obb[9];
145 p4.
z = agent->params.obb[10];
146 p4.
y = agent->params.obb[11];
152 line1.
color = { 0, 255, 0 };
156 line1.
color = { 255, 0, 0 };
160 line1.
color = { 0, 0, 255 };
164 line1.
color = { 255, 255, 0 };
170 for (
int i = 0; i <
_nav.
GetCrowd()->getAgentCount(); ++i) {
172 const dtCrowdAgent *agent =
_nav.
GetCrowd()->getAgent(i);
176 if (agent->params.userData) {
177 std::ostringstream out;
178 out << *(reinterpret_cast<const float *>(agent->params.userData));
183 text.
color = { 0, 255, 0 };
void SetSimulator(std::weak_ptr< carla::client::detail::Simulator > simulator)
reference to the simulator to access API functions
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 RemoveAgent(ActorId id)
remove an agent
unsigned long _next_check_index
This file contains definitions of common data structures used in traffic manager. ...
AtomicList< WalkerHandle > _walkers
Represents the state of all the actors of an episode at a given frame.
carla::nav::Navigation _nav
bool ContainsActorSnapshot(ActorId actor_id) const
void UpdateVehiclesInCrowd(std::shared_ptr< Episode > episode, bool show_debug=false)
add/update/delete all vehicles in crowd
void UpdateCrowd(const client::detail::EpisodeState &state)
update all walkers in crowd
geom::Transform transform
void Tick(std::shared_ptr< Episode > episode)
bool GetWalkerTransform(ActorId id, carla::geom::Transform &trans)
get the walker current transform
void UnregisterWalker(ActorId walker_id, ActorId controller_id)
float GetWalkerSpeed(ActorId id)
get the walker current transform
struct to send info about vehicles to the crowd
bool IsWalkerAlive(ActorId id, bool &alive)
return if the agent has been killed by a vehicle
std::weak_ptr< Simulator > _simulator
boost::variant2::variant< Point, Line, Arrow, Box, String > primitive
bool Load(const std::string &filename)
load navigation data
bool UpdateVehicles(std::vector< VehicleCollisionInfo > vehicles)
add/update/delete vehicles in crowd