Skip to content

Commit 01d26eb

Browse files
authored
Add flag to disable ignoring entities in lidar link (#39)
1 parent 3449ff7 commit 01d26eb

File tree

5 files changed

+30
-10
lines changed

5 files changed

+30
-10
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,15 @@ RGLServerPlugin contains two plugins: `RGLServerPluginManager` and `RGLServerPlu
8686

8787
## How to include RGLServerPluginManager in your sdf:
8888
```xml
89-
<plugin filename="RGLServerPluginManager" name="rgl::RGLServerPluginManager"></plugin>
89+
<plugin name='rgl::RGLServerPluginManager' filename='RGLServerPluginManager'>
90+
<do_ignore_entities_in_lidar_link>true</do_ignore_entities_in_lidar_link>
91+
</plugin>
9092
```
93+
94+
### Parameters description:
95+
- **do_ignore_entities_in_lidar_link** - if enabled, all entities attached to the same \<link\> as lidar will be ignored from raycasting. It could be useful when a visual representation of the sensor is added. (optional, default: true) \
96+
*Note: It has been noticed that when the lidar link is chained to another link with a joint component, the entity tree is simplified and the parent link becomes the lidar link. In such case, the whole robot could be ignored from raycasting. Yet to be resolved.*
97+
9198
This is a global plugin and should be included only once per sdf, preferably inside the world entity. RGLServerPluginManager is responsible for synchronizing the scene between Gazebo and GPU (CUDA). At the moment manager handles all primitive geometry types (Box, Capsule, Cylinder, Ellipsoid, Sphere), planes, meshes and submeshes.
9299

93100
![](docs/images/RGLServerPluginManager.png)
@@ -109,7 +116,6 @@ Inside the link entity in your model, add a custom sensor:
109116
</plugin>
110117
</sensor>
111118
```
112-
*Note: All entities attached to the same \<link\> as lidar will be ignored from raycasting. This enables an adding visual representation of the sensor.*
113119

114120
### Parameters description:
115121
- **range** - the minimum and maximum range that the hits will be registered (in meters).

RGLServerPlugin/include/RGLServerPluginManager.hh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ private:
6060
// contains pointers to all entities that were loaded to rgl (as well as to their meshes)
6161
std::unordered_map<gz::sim::Entity, std::pair<rgl_entity_t, rgl_mesh_t>> entitiesInRgl;
6262

63+
// whether to ignore entities attached to the same link as the lidar
64+
bool doIgnoreEntitiesInLidarLink{true};
65+
6366
// the entity ids, that the lidars are attached to
6467
std::unordered_set<gz::sim::Entity> lidarEntities;
6568

RGLServerPlugin/src/RGLServerPluginManager.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "RGLServerPluginManager.hh"
1919

20+
#define PARAM_DO_IGNORE_ENTITIES_IN_LIDAR_LINK_ID "do_ignore_entities_in_lidar_link"
2021

2122
GZ_ADD_PLUGIN(
2223
rgl::RGLServerPluginManager,
@@ -32,14 +33,18 @@ namespace rgl
3233

3334
void RGLServerPluginManager::Configure(
3435
const gz::sim::Entity& entity,
35-
const std::shared_ptr<const sdf::Element>&,
36+
const std::shared_ptr<const sdf::Element>& sdf,
3637
gz::sim::EntityComponentManager& ecm,
3738
gz::sim::EventManager& evm)
3839
{
3940
ValidateRGLVersion();
4041
if (!CheckRGL(rgl_configure_logging(RGL_LOG_LEVEL_ERROR, nullptr, true))) {
4142
gzerr << "Failed to configure RGL logging.\n";
4243
}
44+
45+
if (sdf->HasElement(PARAM_DO_IGNORE_ENTITIES_IN_LIDAR_LINK_ID)) {
46+
doIgnoreEntitiesInLidarLink = sdf->Get<bool>(PARAM_DO_IGNORE_ENTITIES_IN_LIDAR_LINK_ID);
47+
}
4348
}
4449

4550
void RGLServerPluginManager::PostUpdate(

RGLServerPlugin/src/Scene.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ bool RGLServerPluginManager::RegisterNewLidarCb(
4646
for (const auto& plugin : plugins) {
4747
if (plugin.name() == RGL_INSTANCE) {
4848
lidarEntities.insert(entity);
49-
for (auto descendant: ecm.Descendants(entity)) {
50-
entitiesToIgnore.insert(descendant);
49+
if (doIgnoreEntitiesInLidarLink) {
50+
for (auto descendant: ecm.Descendants(entity)) {
51+
entitiesToIgnore.insert(descendant);
52+
}
5153
}
5254
}
5355
}
@@ -57,10 +59,12 @@ bool RGLServerPluginManager::RegisterNewLidarCb(
5759
return true;
5860
}
5961

60-
// Ignore all entities in link associated with RGL lidar
61-
// Link could contain visual representation of the lidar
62-
for (auto entityInParentLink : GetEntitiesInParentLink(entity, ecm)) {
63-
entitiesToIgnore.insert(entityInParentLink);
62+
if (doIgnoreEntitiesInLidarLink) {
63+
// Ignore all entities in link associated with RGL lidar
64+
// Link could contain visual representation of the lidar
65+
for (auto entityInParentLink : GetEntitiesInParentLink(entity, ecm)) {
66+
entitiesToIgnore.insert(entityInParentLink);
67+
}
6468
}
6569

6670
return true;

test_world/rgl_playground.sdf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
<world name='rgl_playground'>
33

44
<!-- Global RGL scene manager required to upload meshes to GPU -->
5-
<plugin name='rgl::RGLServerPluginManager' filename='RGLServerPluginManager'/>
5+
<plugin name='rgl::RGLServerPluginManager' filename='RGLServerPluginManager'>
6+
<do_ignore_entities_in_lidar_link>true</do_ignore_entities_in_lidar_link>
7+
</plugin>
68

79
<physics name='1ms' type='ignored'>
810
<max_step_size>0.001</max_step_size>

0 commit comments

Comments
 (0)