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

Take initial parameters from parameters yaml files and constructor arguments. #225

Merged
merged 35 commits into from
Aug 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
93b3daf
Add dependency on rcl_yaml_param_parser.
nuclearsandwich Aug 10, 2018
9e31f51
Add rclpy_get_node_parameters function.
nuclearsandwich Aug 14, 2018
799e432
Add initial parameters to Node constructor.
nuclearsandwich Aug 14, 2018
a490fef
Deallocate array after members are deallocated.
nuclearsandwich Aug 17, 2018
595f8e3
Increment references of boolean values.
nuclearsandwich Aug 17, 2018
e80c255
Add much more null checking.
nuclearsandwich Aug 17, 2018
9c5d206
Fix unsafe statement order and don't raise a new exception.
nuclearsandwich Aug 17, 2018
a2218d2
Fix pre-pizza typos.
nuclearsandwich Aug 17, 2018
563b5f8
Set initial parameters cleanly.
nuclearsandwich Aug 17, 2018
14c8a2a
Type on its own line.
nuclearsandwich Aug 17, 2018
b532ef5
Improved NULL checking and DECREFing.
nuclearsandwich Aug 17, 2018
a11ad2b
Restructure the end of the function for better cleanup.
nuclearsandwich Aug 17, 2018
c5452d7
Call fini on the params struct internally.
nuclearsandwich Aug 17, 2018
fa42780
fixup: cpplint.
nuclearsandwich Aug 17, 2018
0191b7c
Set default type_enum_value.
nuclearsandwich Aug 17, 2018
c94f206
fixup: cpplint
nuclearsandwich Aug 20, 2018
f13c33f
Use PyLong_FromLongLong to convert int64_t.
nuclearsandwich Aug 21, 2018
950f1f2
Dereference bool_value.
nuclearsandwich Aug 21, 2018
5ef3ffc
Updated implementation using nested dicts.
nuclearsandwich Aug 22, 2018
10d15fb
Add initial_parameters kwarg to rclpy.create_node.
nuclearsandwich Aug 22, 2018
9dd57d8
typo
wjwwood Aug 23, 2018
14a23d1
fixup: Linters.
nuclearsandwich Aug 24, 2018
edad250
Merge parameters from cli and constructor before setting.
nuclearsandwich Aug 24, 2018
bb68363
python -> Python per feedback.
nuclearsandwich Aug 24, 2018
43db3c2
Reduce nesting with early return.
nuclearsandwich Aug 24, 2018
26243f9
Return a dict of parameter name: parameter instead of a list.
nuclearsandwich Aug 24, 2018
eb092ea
Fix null check and comment styles.
nuclearsandwich Aug 24, 2018
090dcbf
Simplify setting initial params from a dict.
nuclearsandwich Aug 24, 2018
57a9984
Fix docblock (false - >NULL)
nuclearsandwich Aug 24, 2018
655b6cc
More DECREF.
nuclearsandwich Aug 24, 2018
04bfe36
Remove earlier version of parameter setting.
nuclearsandwich Aug 27, 2018
2a60867
Use parameter message type enums instead of hard-coding values.
nuclearsandwich Aug 27, 2018
584d547
Address feedback from Shane.
nuclearsandwich Aug 29, 2018
4726384
Don't set new exception.
nuclearsandwich Aug 29, 2018
6369aac
Merge remote-tracking branch 'ros2/master' into initial-parameters
nuclearsandwich Aug 29, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions rclpy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ endif()
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_python REQUIRED)
find_package(rcl REQUIRED)
find_package(rcl_yaml_param_parser REQUIRED)
find_package(rcutils REQUIRED)
find_package(rmw REQUIRED)
find_package(rmw_implementation_cmake REQUIRED)
Expand Down Expand Up @@ -77,6 +78,7 @@ add_library(
configure_python_c_extension_library(rclpy)
ament_target_dependencies(rclpy
"rcl"
"rcl_yaml_param_parser"
"rcutils"
)

Expand Down
1 change: 1 addition & 0 deletions rclpy/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<depend>rmw_implementation</depend>
<depend>rcl</depend>
<depend>rcl_yaml_param_parser</depend>

<exec_depend>ament_index_python</exec_depend>
<exec_depend>builtin_interfaces</exec_depend>
Expand Down
7 changes: 5 additions & 2 deletions rclpy/rclpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def shutdown():

def create_node(
node_name, *, cli_args=None, namespace=None, use_global_arguments=True,
start_parameter_services=True
start_parameter_services=True, initial_parameters=None
):
"""
Create an instance of :class:`rclpy.node.Node`.
Expand All @@ -60,6 +60,8 @@ def create_node(
:param cli_args: A list of strings of command line args to be used only by this node.
:param namespace: The namespace to which relative topic and service names will be prefixed.
:param use_global_arguments: False if the node should ignore process-wide command line args.
:param start_parameter_services: False if the node should not create parameter services.
:param initial_parameters: A list of rclpy.parameter.Parameters to be set during node creation.
:return: An instance of a node
:rtype: :class:`rclpy.node.Node`
"""
Expand All @@ -68,7 +70,8 @@ def create_node(
return Node(
node_name, cli_args=cli_args, namespace=namespace,
use_global_arguments=use_global_arguments,
start_parameter_services=start_parameter_services)
start_parameter_services=start_parameter_services,
initial_parameters=initial_parameters)


def spin_once(node, *, timeout_sec=None):
Expand Down
9 changes: 8 additions & 1 deletion rclpy/rclpy/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Node:

def __init__(
self, node_name, *, cli_args=None, namespace=None, use_global_arguments=True,
start_parameter_services=True
start_parameter_services=True, initial_parameters=None
):
self._handle = None
self._parameters = {}
Expand Down Expand Up @@ -104,6 +104,13 @@ def __init__(
self._parameter_event_publisher = self.create_publisher(
ParameterEvent, 'parameter_events', qos_profile=qos_profile_parameter_events)

node_parameters = _rclpy.rclpy_get_node_parameters(Parameter, self.handle)
# Combine parameters from params files with those from the node constructor and
# use the set_parameters_atomically API so a parameter event is published.
if initial_parameters is not None:
node_parameters.update({p.name: p for p in initial_parameters})
self.set_parameters_atomically(node_parameters.values())

if start_parameter_services:
self._parameter_service = ParameterService(self)

Expand Down
Loading