title: How to publish/subscribe a python “list of list” as topic in ROS
body: <p>I am new to ROS and rospy, and I am not familiar with non-simple data type as topic.</p>
  
  <p>I want to build a ROS node as both a subscriber and publisher: it receives a topic (a list of two <code>float64</code>), and uses a function (say <code>my_function</code>) which returns a list of lists of <code>float64</code>, then publish this list of list as a topic. </p>
  
  <p>To do this, I built a node as following: </p>
  
  <pre><code>from pymongo import MongoClient
  from myfile import my_function
  import rospy
  import numpy as np
  
  pub = None
  sub = None
  
  def callback(req):
      client = MongoClient()
      db = client.block
      lon = np.float64(req.b)
      lat = np.float64(req.a)
      point_list = my_function(lon, lat, db)
      pub.publish(point_list)
  
  def calculator():
      global sub, pub
      rospy.init_node('calculator', anonymous=True)
      pub = rospy.Publisher('output_data', list)
      # Listen
      sub = rospy.Subscriber('input_data', list, callback)
      print "Calculation finished. \n"
      ros.spin()
  
  if __name__ == '__main__':
      try:
          calculator()
      except rospy.ROSInterruptException:
          pass
  </code></pre>
  
  <p>I know clearly that <code>list</code> in Subscriber and Publisher is not a message data, but I cannot figure out how to fix it since it is not an integer nor list of integer.</p>