Skip to content

Commit

Permalink
update cameras list on sensor removal
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 committed Nov 12, 2021
1 parent 14d78f3 commit 8a6552e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/systems/sensors/Sensors.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class ignition::gazebo::systems::SensorsPrivate
/// \brief Keep track of cameras, in case we need to handle stereo cameras.
/// Key: Camera's parent scoped name
/// Value: Pointer to camera
// TODO(anyone) Remove element when sensor is deleted
public: std::map<std::string, sensors::CameraSensor *> cameras;

/// \brief Maps gazebo entity to its matching sensor ID
Expand Down Expand Up @@ -361,6 +360,17 @@ void Sensors::RemoveSensor(const Entity &_entity)
this->dataPtr->activeSensors.erase(activeSensorIt);
}
}

// update cameras list
for (auto &it : this->dataPtr->cameras)
{
if (it.second->Id() == idIter->second)
{
this->dataPtr->cameras.erase(it.first);
break;
}
}

this->dataPtr->sensorIds.erase(idIter->second);
this->dataPtr->sensorManager.Remove(idIter->second);
this->dataPtr->entityToIdMap.erase(idIter);
Expand Down

0 comments on commit 8a6552e

Please sign in to comment.