Added filter by type
This commit is contained in:
parent
b58f86382d
commit
a95d3d74a8
|
@ -174,8 +174,8 @@ namespace client {
|
|||
return _episode.Lock()->GetLevelBBs(queried_tag);
|
||||
}
|
||||
|
||||
std::vector<rpc::EnvironmentObject> World::GetEnvironmentObjects() const {
|
||||
return _episode.Lock()->GetEnvironmentObjects();
|
||||
std::vector<rpc::EnvironmentObject> World::GetEnvironmentObjects(uint8_t queried_tag) const {
|
||||
return _episode.Lock()->GetEnvironmentObjects(queried_tag);
|
||||
}
|
||||
|
||||
void World::EnableEnvironmentObjects(
|
||||
|
|
|
@ -162,7 +162,7 @@ namespace client {
|
|||
/// Returns all the BBs of all the elements of the level
|
||||
std::vector<geom::BoundingBox> GetLevelBBs(uint8_t queried_tag) const;
|
||||
|
||||
std::vector<rpc::EnvironmentObject> GetEnvironmentObjects() const;
|
||||
std::vector<rpc::EnvironmentObject> GetEnvironmentObjects(uint8_t queried_tag) const;
|
||||
|
||||
void EnableEnvironmentObjects(
|
||||
std::vector<uint64_t> env_objects_ids,
|
||||
|
|
|
@ -460,9 +460,9 @@ namespace detail {
|
|||
return _pimpl->CallAndWait<return_t>("get_all_level_BBs", queried_tag);
|
||||
}
|
||||
|
||||
std::vector<rpc::EnvironmentObject> Client::GetEnvironmentObjects() const {
|
||||
std::vector<rpc::EnvironmentObject> Client::GetEnvironmentObjects(uint8_t queried_tag) const {
|
||||
using return_t = std::vector<rpc::EnvironmentObject>;
|
||||
return _pimpl->CallAndWait<return_t>("get_environment_objects");
|
||||
return _pimpl->CallAndWait<return_t>("get_environment_objects", queried_tag);
|
||||
}
|
||||
|
||||
void Client::EnableEnvironmentObjects(
|
||||
|
|
|
@ -298,7 +298,7 @@ namespace detail {
|
|||
/// Returns all the BBs of all the elements of the level
|
||||
std::vector<geom::BoundingBox> GetLevelBBs(uint8_t queried_tag) const;
|
||||
|
||||
std::vector<rpc::EnvironmentObject> GetEnvironmentObjects() const;
|
||||
std::vector<rpc::EnvironmentObject> GetEnvironmentObjects(uint8_t queried_tag) const;
|
||||
|
||||
void EnableEnvironmentObjects(
|
||||
std::vector<uint64_t> env_objects_ids,
|
||||
|
|
|
@ -240,8 +240,8 @@ namespace detail {
|
|||
return _client.GetLevelBBs(queried_tag);
|
||||
}
|
||||
|
||||
std::vector<rpc::EnvironmentObject> GetEnvironmentObjects() const {
|
||||
return _client.GetEnvironmentObjects();
|
||||
std::vector<rpc::EnvironmentObject> GetEnvironmentObjects(uint8_t queried_tag) const {
|
||||
return _client.GetEnvironmentObjects(queried_tag);
|
||||
}
|
||||
|
||||
void EnableEnvironmentObjects(
|
||||
|
|
|
@ -88,9 +88,9 @@ static auto GetLevelBBs(const carla::client::World &self, uint8_t queried_tag) {
|
|||
return result;
|
||||
}
|
||||
|
||||
static auto GetEnvironmentObjects(const carla::client::World &self) {
|
||||
static auto GetEnvironmentObjects(const carla::client::World &self, uint8_t queried_tag) {
|
||||
boost::python::list result;
|
||||
for (const auto &object : self.GetEnvironmentObjects()) {
|
||||
for (const auto &object : self.GetEnvironmentObjects(queried_tag)) {
|
||||
result.append(object);
|
||||
}
|
||||
return result;
|
||||
|
@ -270,8 +270,8 @@ void export_world() {
|
|||
.def("reset_all_traffic_lights", &cc::World::ResetAllTrafficLights)
|
||||
.def("get_lightmanager", CONST_CALL_WITHOUT_GIL(cc::World, GetLightManager))
|
||||
.def("freeze_all_traffic_lights", &cc::World::FreezeAllTrafficLights, (arg("frozen")))
|
||||
.def("get_level_bbs", &GetLevelBBs, (arg("actor_type")=cr::CityObjectLabel::None))
|
||||
.def("get_environment_objects", &GetEnvironmentObjects)
|
||||
.def("get_level_bbs", &GetLevelBBs, (arg("bb_type")=cr::CityObjectLabel::None))
|
||||
.def("get_environment_objects", &GetEnvironmentObjects, (arg("object_type")=cr::CityObjectLabel::None))
|
||||
.def("enable_environment_objects", &EnableEnvironmentObjects, (arg("env_objects_ids"), arg("enable")))
|
||||
.def("cast_ray", CALL_RETURNING_LIST_2(cc::World, CastRay, cg::Location, cg::Location), (arg("initial_location"), arg("final_location")))
|
||||
.def("project_point", CALL_RETURNING_OPTIONAL_3(cc::World, ProjectPoint, cg::Location, cg::Vector3D, float), (arg("location"), arg("direction"), arg("search_distance")=10000.f))
|
||||
|
|
|
@ -57,9 +57,9 @@ public:
|
|||
TArray<FBoundingBox> GetAllBBsOfLevel(uint8 TagQueried = 0);
|
||||
|
||||
UFUNCTION(Category = "Carla Game Mode", BlueprintCallable, CallInEditor, Exec)
|
||||
const TArray<FEnvironmentObject>& GetEnvironmentObjects() const
|
||||
TArray<FEnvironmentObject> GetEnvironmentObjects(uint8 QueriedTag = 0) const
|
||||
{
|
||||
return ObjectRegister->GetEnvironmentObjects();
|
||||
return ObjectRegister->GetEnvironmentObjects(QueriedTag);
|
||||
}
|
||||
|
||||
void EnableEnvironmentObjects(const TSet<uint64>& EnvObjectIds, bool Enable);
|
||||
|
|
|
@ -369,7 +369,7 @@ void FCarlaServer::FPimpl::BindActions()
|
|||
return MakeVectorFromTArray<cg::BoundingBox>(Result);
|
||||
};
|
||||
|
||||
BIND_SYNC(get_environment_objects) << [this]() -> R<std::vector<cr::EnvironmentObject>>
|
||||
BIND_SYNC(get_environment_objects) << [this](uint8 QueriedTag) -> R<std::vector<cr::EnvironmentObject>>
|
||||
{
|
||||
REQUIRE_CARLA_EPISODE();
|
||||
ACarlaGameModeBase* GameMode = UCarlaStatics::GetGameMode(Episode->GetWorld());
|
||||
|
@ -377,7 +377,7 @@ void FCarlaServer::FPimpl::BindActions()
|
|||
{
|
||||
RESPOND_ERROR("unable to find CARLA game mode");
|
||||
}
|
||||
TArray<FEnvironmentObject> Result = GameMode->GetEnvironmentObjects();
|
||||
TArray<FEnvironmentObject> Result = GameMode->GetEnvironmentObjects(QueriedTag);
|
||||
return MakeVectorFromTArray<cr::EnvironmentObject>(Result);
|
||||
};
|
||||
|
||||
|
|
|
@ -16,6 +16,24 @@
|
|||
|
||||
namespace crp = carla::rpc;
|
||||
|
||||
TArray<FEnvironmentObject> UObjectRegister::GetEnvironmentObjects(uint8 InTagQueried) const
|
||||
{
|
||||
TArray<FEnvironmentObject> Result;
|
||||
|
||||
crp::CityObjectLabel TagQueried = (crp::CityObjectLabel)InTagQueried;
|
||||
bool FilterByTagEnabled = (TagQueried != crp::CityObjectLabel::None);
|
||||
|
||||
for(const FEnvironmentObject& It : EnvironmentObjects)
|
||||
{
|
||||
if(!FilterByTagEnabled || (It.ObjectLabel == TagQueried))
|
||||
{
|
||||
Result.Emplace(It);
|
||||
}
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
void UObjectRegister::RegisterObjects(TArray<AActor*> Actors)
|
||||
{
|
||||
// Empties the array but doesn't change memory allocations
|
||||
|
|
|
@ -25,11 +25,8 @@ public:
|
|||
UObjectRegister() {}
|
||||
~UObjectRegister() {}
|
||||
|
||||
UFUNCTION(Category = "Carla Object Register", BlueprintCallable, CallInEditor, Exec)
|
||||
const TArray<FEnvironmentObject>& GetEnvironmentObjects() const
|
||||
{
|
||||
return EnvironmentObjects;
|
||||
}
|
||||
UFUNCTION(Category = "Carla Object Register", BlueprintCallable, CallInEditor)
|
||||
TArray<FEnvironmentObject> GetEnvironmentObjects(uint8 InTagQueried = 0) const;
|
||||
|
||||
UFUNCTION(Category = "Carla Object Register")
|
||||
void RegisterObjects(TArray<AActor*> Actors);
|
||||
|
|
Loading…
Reference in New Issue