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

error in publishing an Eigen::Matrix using rostopic

asked 2013-04-02 01:20:56 -0500

Mudassir Khan gravatar image

updated 2013-04-02 01:56:47 -0500

I have this 2D Eigen Matrix called map and I wish to publish it using a rostopic but it gives some unkown error. Here is my code.

  ros::Publisher chatter_pub = n.advertise<Eigen::MatrixXd>("topic_map_info", 1000);    
  ros::Rate loop_rate(0.1);    
  MatrixXd map = MatrixXd::Random(10,10);

  while (ros::ok())

below is part of the error:

In static member function ‘static const char* ros::message_traits::MD5Sum<m>::value(const M&) [with M = Eigen::Matrix<double, -0x00000000000000001,="" -0x00000000000000001>]’:="" opt="" ros="" fuerte="" include="" ros="" message_traits.h:255:104:="" instantiated="" from="" ‘const="" char*="" ros::message_traits::md5sum(const="" m&)="" [with="" m="Eigen::Matrix<double," -0x00000000000000001,="" -0x00000000000000001>]’="" opt="" ros="" fuerte="" include="" ros="" publisher.h:112:7:="" instantiated="" from="" ‘void="" ros::publisher::publish(const="" m&)="" const="" [with="" m="Eigen::Matrix<double," -0x00000000000000001,="" -0x00000000000000001>]’="" home="" khan="" fuerte_workspace="" sandbox="" lawn_mover="" src="" node_map.cpp:98:28:="" instantiated="" from="" here="" opt="" ros="" fuerte="" include="" ros="" message_traits.h:126:34:="" error:="" ‘const="" class="" eigen::matrix<double,="" -0x00000000000000001,="" -0x00000000000000001>’="" has="" no="" member="" named="" ‘__getmd5sum’<="" p="">

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2013-04-02 01:38:33 -0500

You cannot publish arbitrary C++ objects to ROS topics, but only those for which a msg definition has been generated. See the tutorials on msg/srv. Some conversions between Eigen and corresponding msg types are available in the eigen_conversions package. See also the code API. Also included is a conversion from Eigen Matrix to Float64MultiArray (but not the other way around for some reason).

edit flag offensive delete link more


thank you, I converted Eigen::Matrix to std_msgs::Float64MultiArray and published it

Mudassir Khan gravatar image Mudassir Khan  ( 2013-04-04 00:39:30 -0500 )edit

Question Tools


Asked: 2013-04-02 01:20:56 -0500

Seen: 3,055 times

Last updated: Apr 02 '13