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

Implement node parameters and parameter services #214

Merged
merged 8 commits into from
Aug 16, 2018

Commits on Aug 16, 2018

  1. Implement parameter services.

    This adds parameter services to rclpy nodes. Like rclcpp nodes, parameter
    services are started by default and can be turned off with the
    create_node/Node constructor kwarg `start_parameter_services=False`.
    
    Parameters are stored on the Node class via a `_parameters` dict
    attribute. The methods following methods have been added to the Node
    API.
    * `get_parameter(name)`
    * `get_parameters(names)`
    * `set_parameters(parameters)`
    * `set_parameters_atomically(parameters)`
    
    A Parameter class provides a python interface to individual parameters
    that is (hopefully) a bit more ergonomic than using the
    Parameter-related message types from rcl_interfaces.
    
    Changes forthcoming in later pull requests:
    - Add the parameters_changed_callback API
    - Take initial parameters from params file argument.
    nuclearsandwich committed Aug 16, 2018
    Configuration menu
    Copy the full SHA
    0f7c170 View commit details
    Browse the repository at this point in the history
  2. Raise TypeErrors instead of asserting types.

    When checking for valid arguments in the parameters API raise TypeErrors
    rather than asserting on failure.
    nuclearsandwich committed Aug 16, 2018
    Configuration menu
    Copy the full SHA
    9dc54a8 View commit details
    Browse the repository at this point in the history
  3. Enforce parameter types.

    This commit adds a Parameter.Type.check method which is used to enforce
    the declared parameter type at runtime.
    nuclearsandwich committed Aug 16, 2018
    Configuration menu
    Copy the full SHA
    1a2a4aa View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    8adc3d6 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    7350e26 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    869db6c View commit details
    Browse the repository at this point in the history
  7. Use type_ for Parameter type attribute.

    Avoids collusion/confusion with type builtin.
    nuclearsandwich committed Aug 16, 2018
    Configuration menu
    Copy the full SHA
    a8231e0 View commit details
    Browse the repository at this point in the history
  8. Destroy nodes after node creation tests.

    The test teardown method is calling rclpy.shutdown() before the nodes
    created here are destroyed. With the inclusion of parameter services
    this is causing the tests to hang after printing the following
    exceptions:
    
        ========================================================================================================================== 7 passed in 0.11 seconds
        Exception ignored in: <bound method Node.__del__ of <rclpy.node.Node object at 0x7fc321e0fd30>>
        Traceback (most recent call last):
          File "/tmp/scree/src/rclpy-mount/rclpy/rclpy/node.py", line 410, in __del__
            self.destroy_node()
          File "/tmp/scree/src/rclpy-mount/rclpy/rclpy/node.py", line 353, in destroy_node
            _rclpy.rclpy_destroy_node_entity(srv.service_handle, self.handle)
        RuntimeError: Failed to fini 'rcl_service_t': rcl node is invalid, rcl instance id does not match, at /tmp/scree/src/ros2/rcl/rcl/src/rcl/node.c:461
        Exception ignored in: <bound method Node.__del__ of <rclpy.node.Node object at 0x7fc320597828>>
        Traceback (most recent call last):
          File "/tmp/scree/src/rclpy-mount/rclpy/rclpy/node.py", line 410, in __del__
            self.destroy_node()
          File "/tmp/scree/src/rclpy-mount/rclpy/rclpy/node.py", line 353, in destroy_node
            _rclpy.rclpy_destroy_node_entity(srv.service_handle, self.handle)
        RuntimeError: Failed to fini 'rcl_service_t': rcl node is invalid, rcl instance id does not match, at /tmp/scree/src/ros2/rcl/rcl/src/rcl/node.c:461
        Exception ignored in: <bound method Node.__del__ of <rclpy.node.Node object at 0x7fc320597b70>>
        Traceback (most recent call last):
          File "/tmp/scree/src/rclpy-mount/rclpy/rclpy/node.py", line 410, in __del__
            self.destroy_node()
          File "/tmp/scree/src/rclpy-mount/rclpy/rclpy/node.py", line 353, in destroy_node
            _rclpy.rclpy_destroy_node_entity(srv.service_handle, self.handle)
        RuntimeError: Failed to fini 'rcl_service_t': rcl node is invalid, rcl instance id does not match, at /tmp/scree/src/ros2/rcl/rcl/src/rcl/node.c:461
    
    Destroying the nodes before the teardown runs resolves both the
    indefinite hang and the exceptions.
    nuclearsandwich committed Aug 16, 2018
    Configuration menu
    Copy the full SHA
    e6c7125 View commit details
    Browse the repository at this point in the history