0
$\begingroup$

Rosanswers logo

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())
  {  
    chatter_pub.publish(map);    
    ros::spinOnce();    
    loop_rate.sleep();
  }

below is part of the error:

In static member function ‘static const char* ros::message_traits::MD5Sum::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’


Originally posted by Mudassir Khan on ROS Answers with karma: 1 on 2013-04-02

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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).


Originally posted by Stefan Kohlbrecher with karma: 24361 on 2013-04-02

This answer was ACCEPTED on the original site

Post score: 5


Original comments

Comment by Mudassir Khan on 2013-04-04:
thank you, I converted Eigen::Matrix to std_msgs::Float64MultiArray and published it

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.