ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ROS2 twist sub linker errors

asked 2019-11-16 17:52:41 -0500

neuromancer2701 gravatar image

updated 2019-11-18 02:06:32 -0500

gvdhoorn gravatar image

I am trying to build a node for a motor controller. I have a timer, a pub<custom message> and a sub to twist.
I have added both std_msgs and geometry_msgs to both the package.xml and the cmakelist.txt.

It compiles and links if I comment out the line below:

subscription_ = this->create_subscription<Twist>("cmd_vel", std::bind(&VescNode::twist_callback, this, _1),cmd_vel_qos_profile);

Then that line is added back in I get all sorts of linking errors. Are std_msgs and geometry_msgs conflicting somehow?

Error:

CMakeFiles/vesc_node.dir/vesc_node.cpp.o: In function rclcpp::create_subscription_factory<geometry_msgs::msg::Twist_<std::allocator<void> >, std::_Bind<void (VescNode::*(VescNode*, std::_Placeholder<1>))(std::shared_ptr<geometry_msgs::msg::Twist_<std::allocator<void> > >)>, std::allocator<void>, geometry_msgs::msg::Twist_<std::allocator<void> >, rclcpp::Subscription<geometry_msgs::msg::Twist_<std::allocator<void> >, std::allocator<void> > >(std::_Bind<void (VescNode::*(VescNode*, std::_Placeholder<1>))(std::shared_ptr<geometry_msgs::msg::Twist_<std::allocator<void> > >)>&&, rclcpp::SubscriptionEventCallbacks const&, rclcpp::message_memory_strategy::MessageMemoryStrategy<geometry_msgs::msg::Twist_<std::allocator<void> >, std::allocator<void> >::SharedPtr, std::shared_ptr<std::allocator<void> >)::{lambda(rclcpp::node_interfaces::NodeBaseInterface*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, rcl_subscription_options_t const&)#1}::operator()(rclcpp::node_interfaces::NodeBaseInterface*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, rcl_subscription_options_t const&) const':
vesc_node.cpp:(.text._ZZN6rclcpp27create_subscription_factoryIN13geometry_msgs3msg6Twist_ISaIvEEESt5_BindIFM8VescNodeFvSt10shared_ptrIS5_EEPS7_St12_PlaceholderILi1EEEES4_S5_NS_12SubscriptionIS5_S4_EEEENS_19SubscriptionFactoryEOT0_RKNS_26SubscriptionEventCallbacksENS_23message_memory_strategy21MessageMemoryStrategyIT2_T1_E9SharedPtrES8_ISS_EENKUlPNS_15node_interfaces17NodeBaseInterfaceERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERK26rcl_subscription_options_tE_clESY_S16_S19_[_ZZN6rclcpp27create_subscription_factoryIN13geometry_msgs3msg6Twist_ISaIvEEESt5_BindIFM8VescNodeFvSt10shared_ptrIS5_EEPS7_St12_PlaceholderILi1EEEES4_S5_NS_12SubscriptionIS5_S4_EEEENS_19SubscriptionFactoryEOT0_RKNS_26SubscriptionEventCallbacksENS_23message_memory_strategy21MessageMemoryStrategyIT2_T1_E9SharedPtrES8_ISS_EENKUlPNS_15node_interfaces17NodeBaseInterfaceERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERK26rcl_subscription_options_tE_clESY_S16_S19_]+0x16d): undefined reference to rosidl_message_type_support_t const* rosidl_typesupport_cpp::get_message_type_support_handle<geometry_msgs::msg::Twist_<std::allocator<void> > >()'
collect2: error: ld returned 1 exit status

Code: vesc_node.cpp vesc_node.hpp

edit retag flag offensive close merge delete

Comments

1

Then that line is added back in I get all sorts of linking errors.

You can't expect us to be able to help you if you don't show those errors.

Add that information to your question text by editing it. Use the edit button/link.

Also show your CMakeLists.txt (without all the boilerplate comments).

gvdhoorn gravatar image gvdhoorn  ( 2019-11-17 08:12:36 -0500 )edit

Moreover, they have just Twist so unless they did a typedef / using call, then there's some problem. Moreover if they have multiple Twist messages defined by different packages (which the words here make me suspect) then clearly there will be a conflict.

stevemacenski gravatar image stevemacenski  ( 2019-11-17 13:59:27 -0500 )edit

I did implement the code with using using geometry_msgs::msg::Twist; I just tested it without that and I still get the linker error. Updated the question with more details and links to all the appropriate files.

neuromancer2701 gravatar image neuromancer2701  ( 2019-11-17 16:35:45 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2019-11-17 20:54:34 -0500

neuromancer2701 gravatar image

I figured out the problem. I had added the 'geometry_msgs' to all of the places in package.xml and CMakeLists.txt except for the dependencies line:

ament_target_dependencies(vesc_node rclcpp std_msgs geometry_msgs)

edit flag offensive delete link more

Comments

I added that, and it worked. Thanks!

Fsn9 gravatar image Fsn9  ( 2022-05-14 10:01:11 -0500 )edit

Awsome, you save my ass.

kimbring2 gravatar image kimbring2  ( 2023-02-20 15:12:37 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2019-11-16 17:52:41 -0500

Seen: 1,309 times

Last updated: Nov 18 '19