Skip to content

Commit 4da825b

Browse files
authored
Implemented possibility to change CARLA's behavior whether the instance segmentation traverses translucent materials or not. (#8909)
DepthCamera and SemanticSegmentationCamera now also use the TaggedSceneProxies instead of the default ones, such that they also benefit from this feature. Users can set the desired behavior via World::SetAnnotationsTraverseTranslucency (C++) and world.set_annotations_traverse_translucency (Python).
1 parent 6fc02a5 commit 4da825b

File tree

22 files changed

+121
-28
lines changed

22 files changed

+121
-28
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
* Set to default Visual Studio 2022 in Windows
3636
* Added env CARLA_CACHE_DIR to be able to set CARLA CACHE location
3737
* Support of masked materials in instance segmentation, resulting in fine-grained annotations on e.g. leaves or fences (as in semantic segmentation)
38+
* Added API function `world.set_annotations_traverse_translucency` and implemented functionality to configure, whether depth and semantic + instance segmentation traverse translucent materials or not.
3839

3940
## CARLA 0.9.15
4041

Docs/python_api.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3837,6 +3837,10 @@ Retrieves an object containing weather parameters currently active in the simula
38373837
- **Setter:** _[carla.World.set_weather](#carla.World.set_weather)_
38383838

38393839
##### Setters
3840+
- <a name="carla.World.set_annotations_traverse_translucency"></a>**<font color="#7fb800">set_annotations_traverse_translucency</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**enable**</font>)
3841+
Sets CARLA's behavior whether the semantic + instance segmentation and depth annotations traverse translucent materials or not. To find the closest obstacle, this should be set to false (default). If you are interested in annotations that detect objects behind windows, this should be enabled.
3842+
- **Parameters:**
3843+
- `enable` (_bool_) - Enables or disables the traversal of translucent materials in semantic, instance and depth annotations. __Default is `False`__.
38403844
- <a name="carla.World.set_pedestrians_cross_factor"></a>**<font color="#7fb800">set_pedestrians_cross_factor</font>**(<font color="#00a6ed">**self**</font>, <font color="#00a6ed">**percentage**</font>)
38413845
- **Parameters:**
38423846
- `percentage` (_float_) - Sets the percentage of pedestrians that can walk on the road or cross at any point on the road. Value should be between `0.0` and `1.0`. For example, a value of `0.1` would allow 10% of pedestrians to walk on the road. __Default is `0.0`__.

LibCarla/source/carla/client/World.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,5 +394,10 @@ namespace client {
394394
}
395395
}
396396

397+
void World::SetAnnotationsTraverseTranslucency(
398+
bool enable) {
399+
_episode.Lock()->SetAnnotationsTraverseTranslucency(enable);
400+
}
401+
397402
} // namespace client
398403
} // namespace carla

LibCarla/source/carla/client/World.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ namespace client {
9696

9797
/// Get Gravity value used for IMUI Sensor accelerometer calculation
9898
float GetIMUISensorGravity() const;
99-
99+
100100
/// Set Gravity value used for IMUI Sensor accelerometer calculation
101101
void SetIMUISensorGravity(float NewIMUISensorGravity);
102102

@@ -237,6 +237,10 @@ namespace client {
237237
const rpc::TextureFloatColor& normal_texture,
238238
const rpc::TextureFloatColor& ao_roughness_metallic_emissive_texture);
239239

240+
/// Enables or disables the traversal of translucent materials in semantic, instance and depth annotations. Defaults to False.
241+
void SetAnnotationsTraverseTranslucency(
242+
bool enable);
243+
240244
std::vector<std::string> GetNamesOfAllObjects() const;
241245

242246
private:

LibCarla/source/carla/client/detail/Client.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,11 @@ namespace detail {
777777
return _pimpl->CallAndWait<return_t>("cast_ray", start_location, end_location);
778778
}
779779

780+
void Client::SetAnnotationsTraverseTranslucency(
781+
bool enable) {
782+
_pimpl->AsyncCall("set_annotations_traverse_translucency", enable);
783+
}
784+
780785
} // namespace detail
781786
} // namespace client
782787
} // namespace carla

LibCarla/source/carla/client/detail/Client.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,8 @@ namespace detail {
480480
std::vector<rpc::LabelledPoint> CastRay(
481481
geom::Location start_location, geom::Location end_location) const;
482482

483+
void SetAnnotationsTraverseTranslucency(
484+
bool enable);
483485
private:
484486

485487
class Pimpl;

LibCarla/source/carla/client/detail/Simulator.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ namespace detail {
300300
return _client.CastRay(start_location, end_location);
301301
}
302302

303+
void SetAnnotationsTraverseTranslucency(
304+
bool enable) {
305+
_client.SetAnnotationsTraverseTranslucency(enable);
306+
}
307+
303308
/// @}
304309
// =========================================================================
305310
/// @name AI

PythonAPI/carla/source/carla/libcarla.pyi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8056,6 +8056,15 @@ class World:
80568056
# endregion
80578057

80588058
# region Setters
8059+
def set_annotations_traverse_translucency(self, enable: bool):
8060+
"""Sets CARLA's behavior whether the semantic + instance segmentation and depth annotations traverse translucent materials or not.
8061+
To find the closest obstacle, this should be set to false (default). If you are interested in annotations that detect objects
8062+
behind windows, this should be enabled.
8063+
8064+
Args:
8065+
`enable (bool)`: Enables or disables the traversal of translucent materials in semantic, instance and depth annotations. Defaults to False.
8066+
"""
8067+
80598068
def set_pedestrians_cross_factor(self, percentage: float):
80608069
"""Sets the percentage of pedestrians that can walk on the road or cross at any point on the road.
80618070

PythonAPI/carla/source/libcarla/World.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ void export_world() {
363363
self.ApplyTexturesToObjects(PythonLitstToVector<std::string>(list), diffuse_texture, emissive_texture, normal_texture, ao_roughness_metallic_emissive_texture);
364364
}, (arg("objects_name_list"), arg("diffuse_texture"), arg("emissive_texture"), arg("normal_texture"), arg("ao_roughness_metallic_emissive_texture")))
365365
.def(self_ns::str(self_ns::self))
366+
.def("set_annotations_traverse_translucency", CALL_WITHOUT_GIL_1(cc::World, SetAnnotationsTraverseTranslucency, bool), (arg("enable")))
366367
;
367368

368369
#undef SPAWN_ACTOR_WITHOUT_GIL

PythonAPI/docs/world.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,15 @@
814814
If the layer is already unloaded the call has no effect.
815815
warning: This only affects "Opt" maps. The minimum layout includes roads, sidewalks, traffic lights and traffic signs.
816816
# --------------------------------------
817+
- def_name: set_annotations_traverse_translucency
818+
params:
819+
- param_name: enable
820+
type: bool
821+
doc: >
822+
Enables or disables the traversal of translucent materials in semantic, instance and depth annotations. __Default is `False`__.
823+
doc: >
824+
Sets CARLA's behavior whether the semantic + instance segmentation and depth annotations traverse translucent materials or not. To find the closest obstacle, this should be set to false (default). If you are interested in annotations that detect objects behind windows, this should be enabled.
825+
# --------------------------------------
817826
- def_name: set_pedestrians_cross_factor
818827
params:
819828
- param_name: percentage

0 commit comments

Comments
 (0)