Skip to content

Commit

Permalink
feat: remove DELETED entity type by using internal id
Browse files Browse the repository at this point in the history
  • Loading branch information
f0reachARR committed Oct 4, 2023
1 parent ddd4f62 commit e070986
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ namespace entity
class DeletedEntity : public EntityBase
{
public:
// Dummy ID for internal use
static constexpr uint8_t ENTITY_TYPE_ID = 0xFF;

explicit DeletedEntity(
const std::string & name, const CanonicalizedEntityStatus &,
const std::shared_ptr<hdmap_utils::HdMapUtils> &);
Expand All @@ -40,7 +43,7 @@ class DeletedEntity : public EntityBase
auto getEntityType() const -> const traffic_simulator_msgs::msg::EntityType & override
{
static traffic_simulator_msgs::msg::EntityType type;
type.type = traffic_simulator_msgs::msg::EntityType::DELETED;
type.type = ENTITY_TYPE_ID; // Dummy ID for internal use
return type;
}

Expand Down
6 changes: 5 additions & 1 deletion simulation/traffic_simulator/src/entity/entity_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ auto EntityManager::getEntityTypeList() const
{
std::unordered_map<std::string, traffic_simulator_msgs::msg::EntityType> ret;
for (auto && [name, entity] : entities_) {
ret.emplace(name, getEntityType(name));
auto type = getEntityType(name);
if (type.type == DeletedEntity::ENTITY_TYPE_ID) {
continue;
}
ret.emplace(name, type);
}
return ret;
}
Expand Down
1 change: 0 additions & 1 deletion simulation/traffic_simulator_msgs/msg/EntityType.msg
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ uint8 EGO = 0
uint8 VEHICLE = 1
uint8 PEDESTRIAN = 2
uint8 MISC_OBJECT = 3
uint8 DELETED = 255
uint8 type

0 comments on commit e070986

Please sign in to comment.