Make SharedNoiseModel as optional parameter, remove hardcoded verbosity, and silence test.
parent
0043120a8a
commit
aa67e3c276
|
@ -45,9 +45,8 @@ NonlinearFactorGraph TranslationRecovery::buildGraph() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TranslationRecovery::addPrior(const double scale,
|
void TranslationRecovery::addPrior(const double scale,
|
||||||
NonlinearFactorGraph *graph) const {
|
NonlinearFactorGraph *graph,
|
||||||
//TODO(akshay-krishnan): make this an input argument
|
const SharedNoiseModel &priorNoiseModel) const {
|
||||||
auto priorNoiseModel = noiseModel::Isotropic::Sigma(3, 0.01);
|
|
||||||
auto edge = relativeTranslations_.begin();
|
auto edge = relativeTranslations_.begin();
|
||||||
graph->emplace_shared<PriorFactor<Point3> >(edge->key1(), Point3(0, 0, 0), priorNoiseModel);
|
graph->emplace_shared<PriorFactor<Point3> >(edge->key1(), Point3(0, 0, 0), priorNoiseModel);
|
||||||
graph->emplace_shared<PriorFactor<Point3> >(edge->key2(), scale * edge->measured().point3(),
|
graph->emplace_shared<PriorFactor<Point3> >(edge->key2(), scale * edge->measured().point3(),
|
||||||
|
|
|
@ -68,9 +68,7 @@ class TranslationRecovery {
|
||||||
*/
|
*/
|
||||||
TranslationRecovery(const TranslationEdges &relativeTranslations,
|
TranslationRecovery(const TranslationEdges &relativeTranslations,
|
||||||
const LevenbergMarquardtParams &lmParams = LevenbergMarquardtParams())
|
const LevenbergMarquardtParams &lmParams = LevenbergMarquardtParams())
|
||||||
: relativeTranslations_(relativeTranslations), params_(lmParams) {
|
: relativeTranslations_(relativeTranslations), params_(lmParams) {}
|
||||||
params_.setVerbosityLM("Summary");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Build the factor graph to do the optimization.
|
* @brief Build the factor graph to do the optimization.
|
||||||
|
@ -84,8 +82,11 @@ class TranslationRecovery {
|
||||||
*
|
*
|
||||||
* @param scale scale for first relative translation which fixes gauge.
|
* @param scale scale for first relative translation which fixes gauge.
|
||||||
* @param graph factor graph to which prior is added.
|
* @param graph factor graph to which prior is added.
|
||||||
|
* @param priorNoiseModel the noise model to use with the prior.
|
||||||
*/
|
*/
|
||||||
void addPrior(const double scale, NonlinearFactorGraph *graph) const;
|
void addPrior(const double scale, NonlinearFactorGraph *graph,
|
||||||
|
const SharedNoiseModel &priorNoiseModel =
|
||||||
|
noiseModel::Isotropic::Sigma(3, 0.01)) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Create random initial translations.
|
* @brief Create random initial translations.
|
||||||
|
|
|
@ -40,7 +40,12 @@ class TestTranslationRecovery(unittest.TestCase):
|
||||||
def test_run(self):
|
def test_run(self):
|
||||||
gt_poses = ExampleValues()
|
gt_poses = ExampleValues()
|
||||||
measurements = SimulateMeasurements(gt_poses, [[0, 1], [0, 2], [1, 2]])
|
measurements = SimulateMeasurements(gt_poses, [[0, 1], [0, 2], [1, 2]])
|
||||||
algorithm = gtsam.TranslationRecovery(measurements)
|
|
||||||
|
# Set verbosity to Silent for tests
|
||||||
|
lmParams = gtsam.LevenbergMarquardtParams()
|
||||||
|
lmParams.setVerbosityLM("silent")
|
||||||
|
|
||||||
|
algorithm = gtsam.TranslationRecovery(measurements, lmParams)
|
||||||
scale = 2.0
|
scale = 2.0
|
||||||
result = algorithm.run(scale)
|
result = algorithm.run(scale)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue