Skip to content

Commit

Permalink
Do not update weight if robot status outdated
Browse files Browse the repository at this point in the history
  • Loading branch information
yuluntian committed Jan 18, 2023
1 parent d6409e6 commit 3b74c20
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/DPGO/PGOAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,9 @@ class PGOAgent {
// Current global iteration counter (this is only meaningful in synchronous mode)
unsigned mIterationNumber;

// Iteration number of the latest weight update
unsigned mLatestWeightUpdateIteration;

// Number of inner iterations performed for robust optimization
int mRobustOptInnerIter;

Expand Down
10 changes: 10 additions & 0 deletions src/PGOAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ PGOAgent::PGOAgent(unsigned ID, const PGOAgentParameters &params)
mPoseGraph(std::make_shared<PoseGraph>(mID, r, d)),
mInstanceNumber(0),
mIterationNumber(0),
mLatestWeightUpdateIteration(0),
mRobustOptInnerIter(0),
mWeightUpdateCount(0),
mTrajectoryResetCount(0),
Expand Down Expand Up @@ -432,6 +433,7 @@ void PGOAgent::reset() {

mInstanceNumber++;
mIterationNumber = 0;
mLatestWeightUpdateIteration = 0;
mRobustOptInnerIter = 0;
mWeightUpdateCount = 0;
mTrajectoryResetCount = 0;
Expand Down Expand Up @@ -999,6 +1001,11 @@ bool PGOAgent::shouldUpdateMeasurementWeights() const {
}
const auto &robot_status = it->second;
CHECK_EQ(robot_status.agentID, robot_id);
// return false if robot status is outdated
if (robot_status.iterationNumber < mLatestWeightUpdateIteration) {
should_update = false;
break;
}
if (robot_status.state != PGOAgentState::INITIALIZED) {
should_update = false;
break;
Expand Down Expand Up @@ -1089,10 +1096,13 @@ void PGOAgent::updateMeasurementWeights() {
}
}
mWeightUpdateCount++;
mLatestWeightUpdateIteration = iteration_number();
mRobustOptInnerIter = 0;
mPoseGraph->clearDataMatrices();
mRobustCost.update();
mTeamStatus.clear();
mStatus.readyToTerminate = false;
mStatus.relativeChange = 0;

// Reset trajectory estimate to initial guess
// after the first round of GNC variable update
Expand Down

0 comments on commit 3b74c20

Please sign in to comment.