ROS2 Launch Error: InvalidLaunchFileError - Missing 'exec' Attribute
The following is an output from a ROS2 launch command, indicating an error while launching a launch file:
ros2 launch /home/ubuntu/lslidar_ws/install/pe_ars408_ros/share/pe_ars408_ros/launch/continental_ars408_socket_can.launch.xml
[INFO] [launch]: All log files can be found below /home/ubuntu/.ros/log/2023-04-14-09-07-34-866162-THNCHL-1-3513
[INFO] [launch]: Default logging verbosity is set to INFO
Task exception was never retrieved
future: <Task finished name='Task-2' coro=<LaunchService._process_one_event() done, defined at /opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py:226> exception=InvalidLaunchFileError('xml')>
Traceback (most recent call last):
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_sources/any_launch_file_utilities.py", line 53, in get_launch_description_from_any_launch_file
return loader(launch_file_path)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_sources/frontend_launch_file_utilities.py", line 35, in get_launch_description_from_frontend_launch_file
return parser.parse_description(root_entity)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/frontend/parser.py", line 106, in parse_description
actions = [self.parse_action(child) for child in entity.children]
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/frontend/parser.py", line 106, in <listcomp>
actions = [self.parse_action(child) for child in entity.children]
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/frontend/parser.py", line 83, in parse_action
return instantiate_action(entity, self)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/frontend/expose.py", line 39, in instantiate_action
action_type, kwargs = action_parse_methods[entity.type_name](entity, parser)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/frontend/expose.py", line 105, in wrapper
ret = found_parse_method(entity, parser)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch_ros/actions/node.py", line 303, in parse
kwargs['executable'] = parser.parse_substitution(entity.get_attr('exec'))
File "/opt/ros/foxy/lib/python3.8/site-packages/launch_xml/entity.py", line 119, in get_attr
raise attr_error
AttributeError: Attribute exec of type <class 'str'> not found in Entity node
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 228, in _process_one_event
await self.__process_event(next_event)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py", line 248, in __process_event
visit_all_entities_and_collect_futures(entity, self.__context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 38, in visit_all_entities_and_collect_futures
sub_entities = entity.visit(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/action.py", line 108, in visit
return self.execute(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/actions/include_launch_description.py", line 130, in execute
launch_description = self.__launch_description_source.get_launch_description(context)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_source.py", line 84, in get_launch_description
self._get_launch_description(self.__expanded_location)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_sources/any_launch_description_source.py", line 53, in _get_launch_description
return get_launch_description_from_any_launch_file(location)
File "/opt/ros/foxy/lib/python3.8/site-packages/launch/launch_description_sources/any_launch_file_utilities.py", line 56, in get_launch_description_from_any_launch_file
raise InvalidLaunchFileError(extension, likely_errors=exceptions)
launch.invalid_launch_file_error.InvalidLaunchFileError: Caught exception when trying to load file of format [xml]: Attribute exec of type <class 'str'> not found in Entity node
This error, 'InvalidLaunchFileError', indicates that the launch file (XML format) is missing the 'exec' attribute within the node entity. The 'exec' attribute specifies the executable file for the ROS node defined in the launch file. The error message clearly points to a missing 'exec' attribute of type string within the Node entity of the launch file.
To resolve this error, you need to ensure the 'exec' attribute is present and correctly set within the Node entity in your launch file. The 'exec' attribute should contain the full path to the executable file of the ROS node you want to run. Make sure the path to the executable file is correct and that the node is properly installed and available on your system.
Once you have corrected the launch file and added the 'exec' attribute, you should be able to run the launch file successfully without encountering the 'InvalidLaunchFileError'.
This issue is a common error in ROS2 development, and understanding the error message and the cause is crucial for effective troubleshooting. By addressing the missing 'exec' attribute, you can ensure the proper execution of your ROS nodes within your launch file.
原文地址: https://www.cveoy.top/t/topic/jDx6 著作权归作者所有。请勿转载和采集!