Skip to content

Commit

Permalink
Merge pull request iris-ua#7 from UbiquityRobotics/hybrid-initialpose
Browse files Browse the repository at this point in the history
Initialpose for hybrid slam
  • Loading branch information
MoffKalast authored Mar 6, 2021
2 parents f39baa1 + d041245 commit 833ae3d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/lama/hybrid_pf_slam2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ class HybridPFSlam2D {

void setPrior(const Pose2D& prior);

void setPose(const Pose2D& prior);

// Tell the slam process to do localization but not the mapping part.
inline void pauseMapping()
{ do_mapping_ = false; }
Expand Down
15 changes: 15 additions & 0 deletions src/hybrid_pf_slam2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,21 @@ void lama::HybridPFSlam2D::setPrior(const Pose2D& prior)
pose_ = prior;
}

void lama::HybridPFSlam2D::setPose(const Pose2D& initialpose)
{
// Get the expected pose of the particle filter
Pose2D pose = getPose();
// We will not be applying the initialpose directly.
// To maintain the distribution of the filter we will be applying
// the offset between the current expected pose and the desired initialpose.
// This will effectively change the expected value to the initialpose.
Pose2D offset = pose - initialpose;

// Apply the offset to all particles.
for (auto& particle : particles_[current_particle_set_])
particle.pose += offset;
}

uint64_t lama::HybridPFSlam2D::getMemoryUsage() const
{
uint64_t total = 0;
Expand Down

0 comments on commit 833ae3d

Please sign in to comment.