TF2 throws rclcpp::exceptions::RCLInvalidROSArgsError when Pytorch libraries are linked
I've been trying to integrate pytorch into my ROS 2 galactic node but have encountered an issue. When the executable gets to this line in my code:
_tf_buffer = std::make_unique<tf2_ros::Buffer>(this->get_clock());
_transform_listener = std::make_shared<tf2_ros::TransformListener>(*_tf_buffer); # specifically this line
It throws a run time error:
what(): failed to parse arguments: Couldn't parse remap rule: '-r __node:=transform_listener_impl_563,a2c,cfa,cc0'. Error: Expected lexeme type (1) not found, search ended at index 35, at /tmp/binarydeb/ros-galactic-rcl-3.1.3/src/rcl/lexer_lookahead.c:233, at /tmp/binarydeb/ros-galactic-rcl-3.1.3/src/rcl/arguments.c:371
I did a test where I added these lines to CMakeLists.txt to another package utilizing TF2:
find_package(Torch REQUIRED)
target_link_libraries(${PROJECT_NAME} ${TORCH_LIBRARIES})
and the same error message appeared. I didn't change the package source files except modifying the CMakeLists.txt file.
For some reason, the act of linking pytorch libraries breaks TF2. I don't understand what the error message means so I'm not sure how to proceed.
Here's something resembling a stack trace. Nothing stands out to me for what could cause this message:
geometry2/tf2_ros/src/transform_listener.cpp
54 rclcpp::Node::make_shared()
rclcpp/rclcpp/src/rclcpp/node.cpp
143 Node::Node
151 get_rcl_node_options()
rclcpp/rclcpp/src/rclcpp/node_options.cpp
94 get_rcl_node_options
120 rcl_parse_arguments()
rcl/rcl/src/rcl/arguments.c
248 rcl_parse_arguments
363 _rcl_parse_remap_rule()
1827 _rcl_parse_remap_rule
1850 _rcl_parse_remap_begin_remap_rule()
1618 _rcl_parse_remap_begin_remap_rule
1666 rcl_lexer_lookahead2_expect()
rcl/rcl/src/rcl/lexer_lookahead.c
222 rcl_lexer_lookahead2_expect
233 rcl_lexer_lookahead2_peek()