Skip to content

Commit

Permalink
Fix progress change updates
Browse files Browse the repository at this point in the history
Signed-off-by: Michael X. Grey <[email protected]>
  • Loading branch information
mxgrey committed Nov 16, 2023
1 parent a5e475d commit c95a491
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
3 changes: 3 additions & 0 deletions rmf_traffic/include/rmf_traffic/schedule/Participant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ class Participant
// TODO(MXG): This function needs to be unit tested.
ItineraryVersion version() const;

/// Get the current progress version for this participant.
ProgressVersion progress_version() const;

/// Get the description of this participant.
const ParticipantDescription& description() const;

Expand Down
31 changes: 16 additions & 15 deletions rmf_traffic/src/rmf_traffic/schedule/Database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1488,10 +1488,10 @@ auto Database::changes(
}

std::vector<Patch::Participant> part_patches;
for (const auto& p : changes)
for (const auto p : _pimpl->participant_ids)
{
const auto& changeset = p.second;
const auto& state = _pimpl->states.at(p.first);
const auto& changeset = changes[p];
const auto& state = _pimpl->states.at(p);

std::vector<Change::Delay> delays;
for (const auto& d : changeset.delays)
Expand All @@ -1502,15 +1502,6 @@ auto Database::changes(
});
}

if (changeset.erasures.empty()
&& delays.empty()
&& changeset.additions.empty())
{
// There aren't actually any changes for this participant, so we will
// leave it out of the patch.
continue;
}

std::optional<Change::Progress> progress;
if (state.schedule_version_of_progress.has_value())
{
Expand All @@ -1522,13 +1513,23 @@ auto Database::changes(
}
}

if (changeset.erasures.empty()
&& delays.empty()
&& changeset.additions.empty()
&& !progress.has_value())
{
// There aren't actually any changes for this participant, so we will
// leave it out of the patch.
continue;
}

part_patches.emplace_back(
Patch::Participant{
p.first,
p,
state.tracker->last_known_version(),
Change::Erase(std::move(p.second.erasures)),
Change::Erase(std::move(changeset.erasures)),
std::move(delays),
Change::Add(state.latest_plan_id, std::move(p.second.additions)),
Change::Add(state.latest_plan_id, std::move(changeset.additions)),
std::move(progress)
});
}
Expand Down
6 changes: 6 additions & 0 deletions rmf_traffic/src/rmf_traffic/schedule/Participant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,12 @@ ItineraryVersion Participant::version() const
return _pimpl->_shared->_version;
}

//==============================================================================
ProgressVersion Participant::progress_version() const
{
return _pimpl->_shared->_progress.version;
}

//==============================================================================
const ParticipantDescription& Participant::description() const
{
Expand Down

0 comments on commit c95a491

Please sign in to comment.