Skip to content

Commit

Permalink
rpo2023 (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsBurgh authored May 6, 2023
2 parents c2ab283 + 4dd527c commit 60e7b1f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/ed/entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ class Entity
has_pose_ = true;
}

inline void removePose() { has_pose_ = false; }

inline bool has_pose() const { return has_pose_; }

inline const tue::config::DataConstPointer& data() const { return config_; }
Expand Down
3 changes: 3 additions & 0 deletions include/ed/update_request.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ class UpdateRequest
std::map<UUID, geo::Pose3D> poses;
void setPose(const UUID& id, const geo::Pose3D& pose) { poses[id] = pose; flagUpdated(id); }

std::vector<UUID> poses_removed;
void removePose(const UUID& id) { poses_removed.push_back(id); flagUpdated(id); }


// RELATIONS

Expand Down
5 changes: 5 additions & 0 deletions src/ed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ bool srvUpdate(ed_msgs::UpdateSrv::Request& req, ed_msgs::UpdateSrv::Response& r
if (r.readGroup("pose"))
{
double x, y, z;
std::string remove;
if (r.readValue("x", x) && r.readValue("y", y) && r.readValue("z", z))
{
geo::Pose3D pose = geo::Pose3D::identity();
Expand All @@ -120,6 +121,10 @@ bool srvUpdate(ed_msgs::UpdateSrv::Request& req, ed_msgs::UpdateSrv::Response& r

update_req.setPose(id, pose);
}
else if(r.readValue("remove", remove) && remove == "true")
{
update_req.removePose(id);
}
else
{
res.response += "For entity '" + id + "': invalid pose (position).\n";
Expand Down
6 changes: 6 additions & 0 deletions src/world_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ void WorldModel::update(const UpdateRequest& req)
e->setPose(it->second);
}

for (const UUID& id : req.poses_removed)
{
EntityPtr e = getOrAddEntity(id, new_entities);
e->removePose();
}

// Update visuals
for(std::map<UUID, geo::ShapeConstPtr>::const_iterator it = req.visuals.begin(); it != req.visuals.end(); ++it)
{
Expand Down

0 comments on commit 60e7b1f

Please sign in to comment.