-
Notifications
You must be signed in to change notification settings - Fork 181
Command line static remapping (ROS1 compatible syntax + nodename prefix) #217
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
Merged
Merged
Changes from all commits
Commits
Show all changes
85 commits
Select commit
Hold shift + click to select a range
3f68319
rcl_node_namespace() implemented
sloretz d77489f
Committing whatever is there, todo rewrite history
sloretz d160ca6
INIT_GLOBAL_ARGS test macro
sloretz 949feee
rcl_remap_namespace -> rcl_remap_node_namespace
sloretz cbea457
Test local arguments used for namespace replacement
sloretz 6f22ea3
Split topic and service remapping functions
sloretz 896af8b
Test topic remap using local arugments
sloretz f50dde1
Terminate copied string with \0. Add service remap tests
sloretz 55b17e6
Refactored remap rule parsing and application
sloretz 5bd5106
Nodename replacement tests with validation fix
sloretz 4a0ed73
Tests for rules with node-name prefixes
sloretz f4a23d0
Support remap rules with relative names
sloretz bbf2b15
Remove comment
sloretz b811a4f
Check allocator before using it
sloretz f12280d
uncrustify
sloretz 4db3285
Remove out of date TODO
sloretz e21795a
rcl_node_init remaps node name
sloretz 9c03f7a
Namespace remapping works. Fix logger name not being remapped
sloretz ad7790a
Node name and namespace obeys use_global_arguments
sloretz 342c36a
rcl_node_init remaps using arguments supplied to options
sloretz 0f2e2f2
Added failing tests for publisher topic remapping
sloretz f324e45
Publisher topic name can be remapped
sloretz f8bfd8e
Add tests for subscriber
sloretz 1fa0f74
Subscription obeys remap rules
sloretz 6e445fd
Client service name can be remapped
sloretz aecfb79
Service service can now be remapped
sloretz 7b95137
Fix crash on invalid namespace
sloretz 0484332
Fix leaks reported by ASAN
sloretz 8023a33
Shorten sentence
sloretz 21d0311
Shorten sentence
sloretz f04ed71
wrong param documentation
sloretz 39214bd
Expand field documentation in node_options
sloretz d661f36
Fix parameter documentation
sloretz bd0b481
null local arguments and use_global_options false is invalid
sloretz f146ae9
Function documentation
sloretz ea03e51
RCL_LOCAL
sloretz 0355ff5
RCL_LOCAL + documentation
sloretz de189e1
Doc + exit early if colon in replacement
sloretz 3852c82
Comment
sloretz f86af0e
Swap lhs and rhs in comparison
sloretz 25d5340
Add functions to get unparsed arguments
sloretz 62c8154
Fix validation of match and replacement, test unparsed args functions
sloretz d74e537
Check that colon is not NULL
sloretz 1b6cb90
consolidate tests for arguments
sloretz d971b01
Fix '/' not seen as a valid namespace
sloretz 582ff8d
Change comparision
sloretz d2c2d68
Better cleanup in failure cases
sloretz a8528f2
Fix comment
sloretz 6a59c19
fix leak in fini
sloretz 97f68b4
Smarter arg macros
sloretz c7c52e7
Split remapping tests
sloretz 65273b1
Fix windows error array of len 0
sloretz f5618ca
style
sloretz 09dd51f
fix windows warning about strncpy
sloretz 49fcf13
Fix windows warnings about data loss
sloretz b9c64fb
Remove memory_tools
sloretz 2083bf3
Shorten test code
sloretz 0f7c344
Rename fixture
sloretz b76273c
blank lines
sloretz b9f0108
Document arguments_impl
sloretz b6c056e
Remove memorytools
sloretz 60d7747
style
sloretz 51df697
Style
sloretz 7963397
Consistent punctuation in comments
sloretz a98baf2
indentation and vertical whitespace
sloretz a78266c
Make name argument more specific
sloretz 6ac891f
remap rules and arguments store allocator, and fini fixes
sloretz 6dbab0f
Declaritive \brief
sloretz 015bff1
Add method to get global CLI args
sloretz 0ad0f63
Rename two functions to start with rcl_arguments_
sloretz 129aeb7
-1 if args is NULL or zero initialized
sloretz d08034b
Sorted includes
sloretz b52bb8b
are -> as
sloretz 0b465df
remap functions accept global args instead of bool
sloretz 21b9806
use rcutils_reallocf
sloretz 42ea8df
Print error message if fini fails in error handling
sloretz 12e5f59
Improved error messages in _rcl_parse_remap_rule
sloretz 21227ca
Remove out of date comment
sloretz a58b71f
const argv
sloretz c04c2eb
expand docs on remapping and argument parsing
sloretz 1925221
Use rmw_validate_node_name_with_size
sloretz 4f5180f
Better error messages for arg parsing
sloretz 8cbe7f8
Flatten logic and better error handling while remapping
sloretz 3aa044a
Merge branch 'master' into impl_static_remapping
sloretz 6f39edf
use rcl_validate_topic_name_with_size
sloretz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,187 @@ | ||
| // Copyright 2018 Open Source Robotics Foundation, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| #ifndef RCL__ARGUMENTS_H_ | ||
| #define RCL__ARGUMENTS_H_ | ||
|
|
||
| #include "rcl/allocator.h" | ||
| #include "rcl/macros.h" | ||
| #include "rcl/types.h" | ||
| #include "rcl/visibility_control.h" | ||
|
|
||
| #if __cplusplus | ||
| extern "C" | ||
| { | ||
| #endif | ||
|
|
||
| struct rcl_arguments_impl_t; | ||
|
|
||
| /// Hold output of parsing command line arguments. | ||
| typedef struct rcl_arguments_t | ||
| { | ||
| /// Private implementation pointer. | ||
| struct rcl_arguments_impl_t * impl; | ||
| } rcl_arguments_t; | ||
|
|
||
| /// Return a rcl_node_t struct with members initialized to `NULL`. | ||
| RCL_PUBLIC | ||
| RCL_WARN_UNUSED | ||
| rcl_arguments_t | ||
| rcl_get_zero_initialized_arguments(void); | ||
|
|
||
| /// Parse command line arguments into a structure usable by code. | ||
| /** | ||
| * If an argument does not appear to be a valid ROS argument then it is skipped and parsing | ||
| * continues with the next argument in `argv`. | ||
| * \sa rcl_arguments_get_count_unparsed() | ||
| * \sa rcl_arguments_get_unparsed() | ||
| * | ||
| * Successfully parsed remap rules are stored in the order they were given in `argv`. | ||
| * If given arguments `{"__ns:=/foo", "__ns:=/bar"}` then the namespace used by nodes in this | ||
| * process will be `/foo` and not `/bar`. | ||
| * \sa rcl_remap_topic_name() | ||
| * \sa rcl_remap_service_name() | ||
| * \sa rcl_remap_node_name() | ||
| * \sa rcl_remap_node_namespace() | ||
| * | ||
| * <hr> | ||
| * Attribute | Adherence | ||
| * ------------------ | ------------- | ||
| * Allocates Memory | Yes | ||
| * Thread-Safe | Yes | ||
| * Uses Atomics | No | ||
| * Lock-Free | Yes | ||
| * | ||
| * \param[in] argc The number of arguments in argv. | ||
| * \param[in] argv Whe values of the arguments. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spelling:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 74b042b |
||
| * \param[in] allocator A valid allocator. | ||
| * \param[out] args_output A structure that will contain the result of parsing. | ||
| * \return `RCL_RET_OK` if the arguments were parsed successfully, or | ||
| * \return `RCL_RET_INVALID_ARGUMENT` if any function arguments are invalid, or | ||
| * \return `RCL_RET_BAD_ALLOC` if allocating memory failed, or | ||
| * \return `RCL_RET_ERROR` if an unspecified error occurs. | ||
| */ | ||
| RCL_PUBLIC | ||
| RCL_WARN_UNUSED | ||
| rcl_ret_t | ||
| rcl_parse_arguments( | ||
| int argc, | ||
| const char * const argv[], | ||
| rcl_allocator_t allocator, | ||
| rcl_arguments_t * args_output); | ||
|
|
||
| /// Return the number of arguments that were not successfully parsed. | ||
| /** | ||
| * <hr> | ||
| * Attribute | Adherence | ||
| * ------------------ | ------------- | ||
| * Allocates Memory | No | ||
| * Thread-Safe | Yes | ||
| * Uses Atomics | No | ||
| * Lock-Free | Yes | ||
| * | ||
| * \param[in] args An arguments structure that has been parsed. | ||
| * \return number of unparsed arguments, or | ||
| * \return -1 if args is `NULL` or zero initialized. | ||
| */ | ||
| RCL_PUBLIC | ||
| RCL_WARN_UNUSED | ||
| int | ||
| rcl_arguments_get_count_unparsed( | ||
| rcl_arguments_t * args); | ||
|
|
||
| /// Return a list of indexes that weren't successfully parsed. | ||
| /** | ||
| * Some arguments may not have been successfully parsed, or were not intended as ROS arguments. | ||
| * This function populates an array of indexes to these arguments in the original argv array. | ||
| * Since the first argument is always assumed to be a process name, the list will always contain | ||
| * the index 0. | ||
| * | ||
| * <hr> | ||
| * Attribute | Adherence | ||
| * ------------------ | ------------- | ||
| * Allocates Memory | Yes | ||
| * Thread-Safe | Yes | ||
| * Uses Atomics | No | ||
| * Lock-Free | Yes | ||
| * | ||
| * \param[in] args An arguments structure that has been parsed. | ||
| * \param[in] allocator A valid allocator. | ||
| * \param[out] output_unparsed_indices An allocated array of indices into the original argv array. | ||
| * This array must be deallocated by the caller using the given allocator. | ||
| * If there are no unparsed args then the output will be set to NULL. | ||
| * \return `RCL_RET_OK` if everything goes correctly, or | ||
| * \return `RCL_RET_INVALID_ARGUMENT` if any function arguments are invalid, or | ||
| * \return `RCL_RET_BAD_ALLOC` if allocating memory failed, or | ||
| * \return `RCL_RET_ERROR` if an unspecified error occurs. | ||
| */ | ||
| RCL_PUBLIC | ||
| RCL_WARN_UNUSED | ||
| rcl_ret_t | ||
| rcl_arguments_get_unparsed( | ||
| rcl_arguments_t * args, | ||
| rcl_allocator_t allocator, | ||
| int ** output_unparsed_indices); | ||
|
|
||
| /// Reclaim resources held inside rcl_arguments_t structure. | ||
| /** | ||
| * <hr> | ||
| * Attribute | Adherence | ||
| * ------------------ | ------------- | ||
| * Allocates Memory | No | ||
| * Thread-Safe | Yes | ||
| * Uses Atomics | No | ||
| * Lock-Free | Yes | ||
| * | ||
| * \param[in] args The structure to be deallocated. | ||
| * \param[in] allocator A valid allocator. | ||
| * \return `RCL_RET_OK` if the memory was successfully freed, or | ||
| * \return `RCL_RET_INVALID_ARGUMENT` if any function arguments are invalid, or | ||
| * \return `RCL_RET_ERROR` if an unspecified error occurs. | ||
| */ | ||
| RCL_PUBLIC | ||
| RCL_WARN_UNUSED | ||
| rcl_ret_t | ||
| rcl_arguments_fini( | ||
| rcl_arguments_t * args); | ||
|
|
||
| /// Get a global instance of command line arguments. | ||
| /** | ||
| * \sa rcl_init(int, char **, rcl_allocator_t) | ||
| * \sa rcl_shutdown() | ||
| * This returns parsed command line arguments that were passed to `rcl_init()`. | ||
| * The value returned by this function is undefined before `rcl_init()` is called and after | ||
| * `rcl_shutdown()` is called. | ||
| * The return value must not be finalized. | ||
| * | ||
| * <hr> | ||
| * Attribute | Adherence | ||
| * ------------------ | ------------- | ||
| * Allocates Memory | No | ||
| * Thread-Safe | Yes | ||
| * Uses Atomics | No | ||
| * Lock-Free | Yes | ||
| * | ||
| * \return a global instance of parsed command line arguments. | ||
| */ | ||
| RCL_PUBLIC | ||
| RCL_WARN_UNUSED | ||
| rcl_arguments_t * | ||
| rcl_get_global_arguments(); | ||
|
|
||
| #if __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif // RCL__ARGUMENTS_H_ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
A general comment here, is that
argumentsmight be a bit ambiguous, but the only alternative I can think of is pretty verbose incommand line arguments, which is the terminology the spec uses (e.g. http://en.cppreference.com/w/cpp/language/main_function).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.
rcl_command_line_arguments_tis a pretty long name. How aboutrcl_cli_arguments_t?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.
rcl_cli_arguments_tsounds great to me, but after thinking about it, I'm not really concerned about the name. I think in context it will be relatively clear. So I'll leave it up to you to decide what to do about it.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'll leave this as is because I think the name is clear enough, but I'm open to changing it in another PR.