Skip to content

Commit

Permalink
Support parameter overrides and remap rules flags on command line (#483)
Browse files Browse the repository at this point in the history
* Support rcl_params_t copies.

Signed-off-by: Michel Hidalgo <[email protected]>

* Parse parameter overrides from command line.

Signed-off-by: Michel Hidalgo <[email protected]>

* Parameter overrides' tests passing.

Signed-off-by: Michel Hidalgo <[email protected]>

* Test rcl_yaml_node_struct_copy() function

Signed-off-by: Michel Hidalgo <[email protected]>

* Export rcl_yaml_param_parser as rcl dependency.

Signed-off-by: Michel Hidalgo <[email protected]>

* Zero initialize parameter overrides before rcl arguments copy.

Signed-off-by: Michel Hidalgo <[email protected]>

* Initialize local variables early enough.

Signed-off-by: Michel Hidalgo <[email protected]>

* Simplify rcl package.xml

Signed-off-by: Michel Hidalgo <[email protected]>

* Assert arguments sanity in rcl args parsing internal functions.

Signed-off-by: Michel Hidalgo <[email protected]>

* Extend rcl_yaml_param_parser tests to all parameter types.

Signed-off-by: Michel Hidalgo <[email protected]>

* Address peer review comments.

Signed-off-by: Michel Hidalgo <[email protected]>

* Support --remap/-r flags.

Signed-off-by: Michel Hidalgo <[email protected]>

* Please cpplint

Signed-off-by: Michel Hidalgo <[email protected]>
  • Loading branch information
hidmic authored Aug 26, 2019
1 parent d070038 commit 6f98943
Show file tree
Hide file tree
Showing 10 changed files with 815 additions and 178 deletions.
3 changes: 3 additions & 0 deletions rcl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ project(rcl)
find_package(ament_cmake_ros REQUIRED)

find_package(rcl_interfaces REQUIRED)
find_package(rcl_yaml_param_parser REQUIRED)
find_package(rcutils REQUIRED)
find_package(rmw REQUIRED)
find_package(rmw_implementation REQUIRED)
Expand Down Expand Up @@ -63,6 +64,7 @@ add_library(${PROJECT_NAME} ${${PROJECT_NAME}_sources})
# specific order: dependents before dependencies
ament_target_dependencies(${PROJECT_NAME}
"rcl_interfaces"
"rcl_yaml_param_parser"
"rmw_implementation"
"rmw"
"rcutils"
Expand Down Expand Up @@ -94,6 +96,7 @@ ament_export_libraries(${PROJECT_NAME})

ament_export_dependencies(ament_cmake)
ament_export_dependencies(rcl_interfaces)
ament_export_dependencies(rcl_yaml_param_parser)
ament_export_dependencies(rmw_implementation)
ament_export_dependencies(rmw)
ament_export_dependencies(rcutils)
Expand Down
30 changes: 30 additions & 0 deletions rcl/include/rcl/arguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "rcl/macros.h"
#include "rcl/types.h"
#include "rcl/visibility_control.h"
#include "rcl_yaml_param_parser/types.h"

#ifdef __cplusplus
extern "C"
Expand All @@ -36,6 +37,10 @@ typedef struct rcl_arguments_t

#define RCL_ROS_ARGS_FLAG "--ros-args"
#define RCL_ROS_ARGS_EXPLICIT_END_TOKEN "--"
#define RCL_PARAM_FLAG "--param"
#define RCL_SHORT_PARAM_FLAG "-p"
#define RCL_REMAP_FLAG "--remap"
#define RCL_SHORT_REMAP_FLAG "-r"

#define RCL_LOG_LEVEL_ARG_RULE "__log_level:="
#define RCL_EXTERNAL_LOG_CONFIG_ARG_RULE "__log_config_file:="
Expand Down Expand Up @@ -254,6 +259,31 @@ rcl_arguments_get_param_files(
rcl_allocator_t allocator,
char *** parameter_files);

/// Return all parameter overrides specified on the command line.
/**
* <hr>
* Attribute | Adherence
* ------------------ | -------------
* Allocates Memory | Yes
* Thread-Safe | No
* Uses Atomics | No
* Lock-Free | Yes
*
* \param[in] arguments An arguments structure that has been parsed.
* \param[out] parameter_overrides Zero or more parameter overrides.
* This structure must be finalized by the caller.
* \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_param_overrides(
const rcl_arguments_t * arguments,
rcl_params_t ** parameter_overrides);

/// Return a list of arguments with ROS-specific arguments removed.
/**
* Some arguments may not have been intended as ROS arguments.
Expand Down
20 changes: 5 additions & 15 deletions rcl/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,13 @@

<build_export_depend>rmw</build_export_depend>

<build_depend>rcl_interfaces</build_depend>
<build_depend>rcutils</build_depend>
<build_depend>rosidl_generator_c</build_depend>
<build_depend>tinydir_vendor</build_depend>

<build_export_depend>rcl_interfaces</build_export_depend>
<build_export_depend>rcutils</build_export_depend>
<build_export_depend>rosidl_generator_c</build_export_depend>
<build_export_depend>tinydir_vendor</build_export_depend>

<exec_depend>rcl_interfaces</exec_depend>
<exec_depend>ament_cmake</exec_depend>
<exec_depend>rcutils</exec_depend>
<exec_depend>rosidl_default_runtime</exec_depend>

<depend>rcl_interfaces</depend>
<depend>rcl_logging_noop</depend> <!-- the default logging impl -->
<depend>rcl_yaml_param_parser</depend>
<depend>rcutils</depend>
<depend>rmw_implementation</depend>
<depend>rosidl_generator_c</depend>
<depend>tinydir_vendor</depend>

<test_depend>ament_cmake_gtest</test_depend>
<test_depend>ament_cmake_pytest</test_depend>
Expand Down
Loading

0 comments on commit 6f98943

Please sign in to comment.