Skip to content

Commit

Permalink
methods to anchor first pose
Browse files Browse the repository at this point in the history
  • Loading branch information
yuluntian committed Feb 10, 2023
1 parent 0af66a3 commit 1b07169
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/DPGO/PGOAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,11 @@ class PGOAgent {
* @brief Return the number of currently active robots
*/
size_t numActiveRobots() const;
/**
* @brief Add a prior to the first pose of this robot
*/
bool anchorFirstPose();
bool anchorFirstPose(const LiftedPose &prior);

private:
// Stores the auxiliary variables from neighbors (only used in acceleration)
Expand Down
26 changes: 26 additions & 0 deletions src/PGOAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,14 @@ void PGOAgent::initializeInGlobalFrame(const Pose &T_world_robot) {
initializeRobustOptimization();
}

// For robot 0, anchor its first pose to fix the global frame
if (getID() == 0) {
LiftedPose prior(relaxation_rank(), dimension());
prior.rotation() = YLift.value();
prior.translation() = Vector::Zero(r);
anchorFirstPose(prior);
}

// Initialize auxiliary variables
if (mParams.acceleration) {
initializeAcceleration();
Expand Down Expand Up @@ -1175,4 +1183,22 @@ size_t PGOAgent::numActiveRobots() const {
return num_active;
}

bool PGOAgent::anchorFirstPose() {
if (num_poses() > 0) {
LiftedPose prior(relaxation_rank(), dimension());
prior.setData(X.pose(0));
mPoseGraph->setPrior(0, prior);
} else {
return false;
}
return true;
}

bool PGOAgent::anchorFirstPose(const LiftedPose &prior) {
CHECK_EQ(prior.d(), dimension());
CHECK_EQ(prior.r(), relaxation_rank());
mPoseGraph->setPrior(0, prior);
return true;
}

} // namespace DPGO

0 comments on commit 1b07169

Please sign in to comment.