-
Notifications
You must be signed in to change notification settings - Fork 195
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
More Intuitive CLI for Static Transform Publisher #392
Conversation
2b28c36
to
df2315b
Compare
RPY now supported, but need to add |
std::unordered_map<std::string, std::string> ret; | ||
/* collect from [exe] --option1 value --option2 value ... --optionN value */ | ||
for (size_t x = 1; x < args.size(); x += 2) { | ||
ret.emplace(std::move(args[x]), std::move(args[x + 1])); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens here if the user passes an incorrect command line, like:
--x --y 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's a good catch. Would likely crash.
rotation = _get_rotation(arg_map); | ||
translation = _get_translation(arg_map); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the user supplies arguments that we don't understand, like --foo
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is actually immune to that. It should set to the identity transform.
That said, it should probably error, since that's not a valid argument.
For simplicity I'd suggest that instead of adding a bunch of extra logic to this command line parsing that we consider making a new executable with a new name which can take the new argument styles. This will ensure that we maintain the existing CLI and we can just reuse the existing implementation with a new command line parsing. One simple alternative that gives a lot of power would be to actually make this into a python tool that has all the bells and whistles turned on, that then executes the less user friendly one under the hood. This would make the command line parsing much less error prone. And users who don't want python on their system can still use the less user friendly C++ version. |
The thing is, we still need most of the logic to parse the command-line anyway. Adding a second executable only removes the backwards compatibility logic, and I don't expect that to be a whole lot of code anyway. To me, the benefit of keeping the current executable name, and being able to (eventually) remove the old arguments outweighs the downside of carrying a bit of extra logic around. I guess the command-line parsing becomes much easier if we switch the whole thing to Python. But the thing is that we've gone a long way towards separating C++ and Python packages in geometry2, and I'd like to not go back on that. So we'd have to move the new executable to TLDR: my opinion is that we should continue down the path of parsing the command-line arguments in the current executable, and add (just a small bit more) logic to deal with the backwards-compatible arguments. |
Ok, If we were to switch it to be python based it would likely move to tf2_tools or the like to avoid the dependency. |
Yes, that's a good point. It seems to me that we have 3 options here:
Option 3 is the least disruptive to users; option 1 is easier long-term maintenance (2 seems to be the worst of both worlds, so I won't consider it further). Hard to choose :). @allenh1 You are the one actually working on this, so any thoughts from you on this? |
Hm. I think @tfoote makes a really good point here. I am not opposed to option 1 here at all. I'm really not a fan of option 2. I can see that being a real maintenance headache in the future where we have the component version, the standalone executable, and the other standalone executable for the same thing. That's probably overkill, imo. As for option 3, it's definitely a lot of code for setting arguments, but I'm much faster with my C++ than my Python to be honest. And I feel like after printing the deprecation warning for the old style in Galactic, it can be removed completely in H-turtle. So my preference is definitely 3, but probably just because it's all C++. I am fine with 1 if that's what we want instead. |
@allenh1 I'll leave the final decision to you. I'm slightly more in favor of 3 than 1, just because of the relative ease of transition. Tully seems to be more in favor of 1 than 3, because of the maintenance. You are doing the work, so you can do what you feel is best and be the tie-breaker :). If you do decide to go with 1, remember that in addition to the new Python executable we'll want a small update to the existing static_transform_broadcaster_program to say |
Do you mean 1? Just to be clear... |
Yes! Sorry. Will update the comment. |
df2315b
to
d45244f
Compare
@allenh1 I spent a bit of time here and reimplemented this to take care of all of the issues earlier identified, as well as adding support for both new-style and old-style arguments (the latter print a warning). I think this now fulfills all of the requirements we were looking for; can you take a look at the code and let me know what you think about it? |
@clalancette looks good to me. Thanks for finishing this up for me. |
@ahcorde When you get a chance, can you do a review of this? Thanks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, but since I rewrote substantial portions of it I'll wait on @ahcorde before merging it. I'll run CI on it in the meantime.
9cf4e53
to
c38fab3
Compare
c38fab3
to
eca4cf4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a mirnor style comment, otherwise LGTM
Signed-off-by: Hunter L. Allen <hunter.allen@ghostrobotics.io>
In this approach, we still allow the old command-line style, but it prints a warning and is deprecated. The new style is to use flags (like --x, --qx, etc), so that it is clear to the user which axes they are overriding. Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
eca4cf4
to
e2d83c2
Compare
Signed-off-by: Chris Lalancette <clalancette@openrobotics.org>
Opening for visibility. Few TODO's left in line that I'll get to in a bit, but this fixes #295.
Signed-off-by: Hunter L. Allen hunter.allen@ghostrobotics.io