ros2 / ros2cli

ROS 2 command line interface tools
Apache License 2.0
166 stars 159 forks source link

Cannot change log level on ros2 component load command (galactic) #699

Open Nir-Az opened 2 years ago

Nir-Az commented 2 years ago

Bug report

Required Info:

Steps to reproduce issue

Try to change log level on ros2 component load command

Expected behavior

Node loaded with requested log level

Actual behavior

Error from the command

Additional information

$ ros2 component load /ComponentManager camera camera::NodeFactory --log-level WARN Traceback (most recent call last): File "/opt/ros/galactic/bin/ros2", line 11, in load_entry_point('ros2cli==0.13.1', 'console_scripts', 'ros2')() File "/opt/ros/galactic/lib/python3.8/site-packages/ros2cli/cli.py", line 67, in main rc = extension.main(parser=parser, args=args) File "/opt/ros/galactic/lib/python3.8/site-packages/ros2component/command/component.py", line 37, in main return extension.main(args=args) File "/opt/ros/galactic/lib/python3.8/site-packages/ros2component/verb/load.py", line 49, in main component_uid, component_name = load_component_into_container( File "/opt/ros/galactic/lib/python3.8/site-packages/ros2component/api/init.py", line 257, in load_component_into_container request.log_level = log_level File "/opt/ros/galactic/lib/python3.8/site-packages/composition_interfaces/srv/_load_node.py", line 217, in log_level assert \ AssertionError: The 'log_level' field must be of type 'int'

fujitatomoya commented 2 years ago

according to the following experience, we would need to support

any comments and thoughts?

# ros2 run rclcpp_components component_container --ros-args --log-level debug

this works but all nodes will set the same log level with container.

# ros2 component load /ComponentManager composition composition::Talker --ros-args --log-level debug
usage: ros2 [-h] [--use-python-default-buffering] Call `ros2 <command> -h` for more detailed usage. ...
ros2: error: unrecognized arguments: --ros-args

expected this would work, but it does not support --ros-args option.

# ros2 component load /ComponentManager composition composition::Talker --log-level warn
Traceback (most recent call last):
  File "/root/ros2_ws/colcon_ws/install/ros2cli/bin/ros2", line 33, in <module>
    sys.exit(load_entry_point('ros2cli', 'console_scripts', 'ros2')())
  File "/root/ros2_ws/colcon_ws/build/ros2cli/ros2cli/cli.py", line 89, in main
    rc = extension.main(parser=parser, args=args)
  File "/root/ros2_ws/colcon_ws/build/ros2component/ros2component/command/component.py", line 37, in main
    return extension.main(args=args)
  File "/root/ros2_ws/colcon_ws/build/ros2component/ros2component/verb/load.py", line 49, in main
    component_uid, component_name = load_component_into_container(
  File "/root/ros2_ws/colcon_ws/build/ros2component/ros2component/api/__init__.py", line 229, in load_component_into_container
    request.log_level = log_level
  File "/root/ros2_ws/colcon_ws/install/composition_interfaces/lib/python3.8/site-packages/composition_interfaces/srv/_load_node.py", line 219, in log_level
    assert \
AssertionError: The 'log_level' field must be of type 'int'

problem can be observed in mainline.

Nir-Az commented 2 years ago

I think the best way to go is to align to the ros2 run command syntax.

I wouldn't open it as a BUG if it wasn't listed in the command help syntax.. I spend 2 hours trying to understand what am I doing wrong, because if it listed in the help it should work :)

ros2 component load --help
usage: ros2 component load [-h] [--spin-time SPIN_TIME] [-s] [--no-daemon]
                           [-n NODE_NAME] [--node-namespace NODE_NAMESPACE]
                           [--log-level LOG_LEVEL] [-r REMAP_RULES]
                           [-p PARAMETERS] [-e EXTRA_ARGUMENTS] [-q]
                           container_node_name package_name plugin_name
fujitatomoya commented 2 years ago

@Nir-Az okay it seems that already have an option for log level, but it does not work. (i misunderstood.) this behavior is the same with mainline.

root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 component load --log-level debug /ComponentManager composition composition::Talker
Traceback (most recent call last):
  File "/root/ros2_ws/colcon_ws/install/ros2cli/bin/ros2", line 33, in <module>
    sys.exit(load_entry_point('ros2cli', 'console_scripts', 'ros2')())
  File "/root/ros2_ws/colcon_ws/build/ros2cli/ros2cli/cli.py", line 89, in main
    rc = extension.main(parser=parser, args=args)
  File "/root/ros2_ws/colcon_ws/build/ros2component/ros2component/command/component.py", line 37, in main
    return extension.main(args=args)
  File "/root/ros2_ws/colcon_ws/build/ros2component/ros2component/verb/load.py", line 49, in main
    component_uid, component_name = load_component_into_container(
  File "/root/ros2_ws/colcon_ws/build/ros2component/ros2component/api/__init__.py", line 229, in load_component_into_container
    request.log_level = log_level
  File "/root/ros2_ws/colcon_ws/install/composition_interfaces/lib/python3.8/site-packages/composition_interfaces/srv/_load_node.py", line 219, in log_level
    assert \
AssertionError: The 'log_level' field must be of type 'int'