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

Node action failing with some special parameters #12

Closed
ivanpauno opened this issue Apr 11, 2019 · 1 comment
Closed

Node action failing with some special parameters #12

ivanpauno opened this issue Apr 11, 2019 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@ivanpauno
Copy link
Member

Bug report

  • Operating System:
    • Ubuntu 18.04
  • Installation type:
    • From source
  • Version or commit hash:
    • launch_ros(#448846d9361f39bdde94d1a41679abac3a1e124a)
  • DDS implementation:
    • fast-rtps
  • Client library (if applicable):
    • rclcpp

Steps to reproduce issue

This is a modified version of launch_ros/examples/pub_sub_launch.py here.

# 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.

"""Launch a talker and a listener."""

import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))  # noqa
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', 'launch'))  # noqa

from launch import LaunchDescription
from launch import LaunchIntrospector
from launch import LaunchService

from launch_ros import get_default_launch_description
import launch_ros.actions


def main(argv=sys.argv[1:]):
    """Main."""
    ld = LaunchDescription([
        launch_ros.actions.Node(
            package='demo_nodes_cpp', node_executable='talker', output='screen',
            node_name='my_node',
            parameters=[{'a': 1, 'b': 'a', 'c': ['list', 'of', 'stuff']}],
            remappings=[('chatter', 'my_chatter')]),
        launch_ros.actions.Node(
            package='demo_nodes_cpp', node_executable='listener', output='screen',
            remappings=[('chatter', 'my_chatter')]),
    ])

    print('Starting introspection of launch description...')
    print('')

    print(LaunchIntrospector().format_launch_description(ld))

    print('')
    print('Starting launch of launch description...')
    print('')

    # ls = LaunchService(debug=True)
    ls = LaunchService()
    ls.include_launch_description(get_default_launch_description())
    ls.include_launch_description(ld)
    return ls.run()


if __name__ == '__main__':
    main()

I only added:

            node_name='my_node',
            parameters=[{'a': 1, 'b': 'a', 'c': ['list', 'of', 'stuff']}],

Expected behavior

It should work as the original example.

Actual behavior

It fails when loading parameters.

Starting introspection of launch description...

<launch.launch_description.LaunchDescription object at 0x7fe2636a25c0>
├── ExecuteProcess(cmd=[ExecInPkg(pkg='demo_nodes_cpp', exec='talker'), LocalVar('node name'), LocalVar('parameter 1'), LocalVar('remapping 1')], cwd=None, env=None, shell=False)
└── ExecuteProcess(cmd=[ExecInPkg(pkg='demo_nodes_cpp', exec='listener'), LocalVar('remapping 1')], cwd=None, env=None, shell=False)

Starting launch of launch description...

[INFO] [launch]: All log files can be found below /home/ivanpauno/.ros/log/2019-04-11-15-07-37-242126-71c1584df2a2-4887
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [talker-1]: process started with pid [4896]
[INFO] [listener-2]: process started with pid [4897]
[talker-1] terminate called after throwing an instance of 'std::runtime_error'
[talker-1]   what():  Failed to parse parameters from file '/tmp/launch_params_au9d6q_k': Sequence should be of same type. Value type 'bool' do not belong at line_num 8, at /home/ivanpauno/ros2_ws/src/ros2/rcl/rcl_yaml_param_parser/src/parser.c:891
[ERROR] [talker-1]: process has died [pid 4896, exit code -6, cmd '/home/ivanpauno/ros2_ws/install/demo_nodes_cpp/lib/demo_nodes_cpp/talker __node:=my_node __params:=/tmp/launch_params_au9d6q_k chatter:=my_chatter'].

Content of /tmp/launch_params_au9d6q_k

ivanpauno@71c1584df2a2:~/ros2_ws/src/ros2/launch_ros/launch_ros/examples$ cat /tmp/launch_params_au9d6q_k
/:
  my_node:
    ros__parameters:
      a: 1
      b: a
      c: !!python/tuple
      - list
      - of
      - stuff

Additional information

If I change the parameter arg to:

            parameters=[{'a': 1, 'b': 'a', 'c': ['a', 'b', 'c']}],

It works. Generated parameters file:

/:
  my_node:
    ros__parameters:
      a: 1
      b: a
      c: !!python/tuple
      - a
      - b
      - c

Numbers inside the 'c' list also work well, like ['10', '1', '2'].

As far as I've seen, the problem appears when one of the parameters is a list of strings, and one of the list items is more that one character long.

@ivanpauno ivanpauno added the bug Something isn't working label Apr 11, 2019
@ivanpauno ivanpauno self-assigned this Apr 11, 2019
@ivanpauno
Copy link
Member Author

ivanpauno commented Apr 11, 2019

Ok, I saw that the 'of' world is automatically recognized as a bool, and I used it on all my previous tests (super fun).
I think that it shouldn't be recognized like that (yaml boolean).
Also, if any of the yaml boolean keywords is between quotes ('On', 'True', etc), they shouldn't been converted to a bool. Now, the generated yaml file doesn't have quotes, and the rcl parser is still converting it to a bool.

I will open an issue later in rcl. I'm closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant