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

Add alternativeName() for symbols #572

Merged
merged 3 commits into from
Oct 24, 2020
Merged

Conversation

jlblancoc
Copy link
Member

What do you think of this feature?

It allows writing code with symbol named according to their physical meaning. Check the example in the new unit test.

Of course, the default KeyFormatter would still return the underlying one-character symbol name, but if someone want to have custom names printed, a custom KeyFormatter would be required.

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.

That's cool. But it took a while before I figured out what was going on :-) I think a functor might be easier to grok than a function producing a function. E.g.

gtsam:SymbolGenerator Z('x'), DZ('v'), DDZ('a');

implemented like

class SymbolGenerator {
const char c_;
public:
SymbolGenerator(const char c) c_(c) {} 
Symbol operator()(const std::uint64_t j) const { return Symbol(c_, j); }
};

What do you think?

@jlblancoc
Copy link
Member Author

Updated!
One remaining doubt: what would be better, gtsam::symbol_shorthand::SymbolGenerator or gtsam::SymbolGenerator ?

@jlblancoc
Copy link
Member Author

PS: If it's the shorter gtsam:SymbolGenerator, you could merge straight away.

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!

@dellaert dellaert merged commit 0857dd1 into develop Oct 24, 2020
@dellaert dellaert deleted the feature/symbol-alternative-names branch October 24, 2020 14:13
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.

2 participants