Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding options to translation averaging to support betweenfactor translation priors #1190

Merged
merged 18 commits into from
May 11, 2022

Conversation

akshay-krishnan
Copy link
Contributor

@akshay-krishnan akshay-krishnan commented May 6, 2022

These Point3 "between translations" (not using the term "relative translations" since this was already used for the direction measurements), can come for other sensors in a SLAM problem.

@dellaert
Copy link
Member

dellaert commented May 6, 2022

Cool. But what's this?
image
Did you not start from develop?

@dellaert
Copy link
Member

dellaert commented May 6, 2022

Two suggestions before I review:

  • CI is failing, see what's up?
  • I suggest you merge in develop

@akshay-krishnan
Copy link
Contributor Author

I created a branch called ta-add-methods, but it looks like there was one already, and I started working on an existing branch. Pulled from develop now.

Copy link
Member

@dellaert dellaert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, BUT, I think the params way is not right. We could have only betweenTranslations.

tests/testTranslationRecovery.cpp Outdated Show resolved Hide resolved
return graph;
}

void TranslationRecovery::addPrior(
const double scale, NonlinearFactorGraph *graph,
const double scale, const boost::shared_ptr<NonlinearFactorGraph> graph,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think * is right. In .i file use @ to indicated an output parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed all shared_ptr back to *, this change was to wrap these methods, but later I decided not to wrap them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works in wrapper... Use @

gtsam/sfm/TranslationRecovery.h Outdated Show resolved Hide resolved
@@ -93,7 +125,8 @@ class TranslationRecovery {
* @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,
void addPrior(const double scale,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should remain *

* @return Key of optimized variable - same as input if it does not have any
* zero-translation edges.
*/
Key getUniqueKey(const Key i) const;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what this does. we can chat about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are multiple input nodes that share the same translation, i.e have a zero unit translation edge between them, only one of them will be added to the factor graph. This function will return the value of the Key that was added to the graph for an input node. If there is no zero-translation edge, the output is the same as input.

It is used each time we add the betweenFactors or any other priors, we need to find that "root" node that was added to the graph. I renamed the method, hopefully its more clear.

gtsam/sfm/sfm.i Outdated
gtsam::Values run(const gtsam::BinaryMeasurementsPoint3& betweenTranslations,
const double scale) const;
// default empty betweenTranslations
// gtsam::Values run(const double scale) const;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dellaert is there a way to wrap the method this way? using the default value of the first betweenTranslations argument?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think run should have both relativeTranslations and betweenTranslations. The constructor should just take parameters, not data, so you can "run" multiple datasets.
If you agree, you could make scale the first argument and provide two declarations in the .i file:

gtsam::Values run(const double scale, const gtsam::BinaryMeasurementsUnit3& relativeTranslations) const;
gtsam::Values run(const double scale, const gtsam::BinaryMeasurementsUnit3& relativeTranslations, const gtsam::BinaryMeasurementsPoint3& betweenTranslations) const;

@akshay-krishnan
Copy link
Contributor Author

That was not as simple as it should have been, due to the handling of nodes with zero-edges between them. But its done now, moved the relativeTranslations to run() .
The handling of zero-edges now completely happens inside run(), using some helper functions that are not class methods.

gtsam/sfm/TranslationRecovery.h Outdated Show resolved Hide resolved

// Add global frame prior and scale (either from betweenTranslations or
// scale).
addPrior(nonzeroRelativeTranslations, scale, nonzeroBetweenTranslations,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, you add even if betweenTranslations is not empty

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do not add the scale prior, only a prior on the first translation to lie at (0, 0, 0). I updated the addPrior documention to be more clear about this.

return initializeRandomly(relativeTranslations, &kRandomNumberGenerator);
}

Values TranslationRecovery::run(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can still fine-tune this API, but let's go with this for now.

@dellaert dellaert merged commit e362906 into develop May 11, 2022
@dellaert dellaert deleted the ta-add-methods branch May 11, 2022 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants