Thanks Ken for the suggestion. I made a custom message type generator similar to rospy/numpy_msg.py called numpy_nd_msg.py in the attachment. Hopefully it will be useful. When running as an standalone script, it is a self-talking node publishing and subscribing /mytopic with random 2x3 numpy arrays as type Float32MultiArray. To test (some sense of) compatibility, one can run the following command to bounce the message rostopic echo /mytopic | rostopic pub /mytopic std_msgs/Float32MultiArray -Tingfan PhD Student Machine Perception Laboratory UC San Diego On Mon, Aug 22, 2011 at 9:29 AM, Ken Conley wrote: > Hi Tingfan, > > rospy allows you to substitute  your own message > serializer/deserializers as you please.  The proposal you suggest > would require custom messages as the generators have no knowledge of > MultiArrayLayouts. > > cheers, > Ken > > On Mon, Aug 22, 2011 at 9:09 AM, Tingfan Wu (UCSD) wrote: >> Hi, >> Sorry for replying an old message. But I am also interested in >> multidimensional numpy array msg. >> My proposal is to initialize the layout of a *MultiArray msg from the >> incoming numpy.ndarray information. >> >> Take Float32MultiArray for an example, the current method of >> numpy_serialization in Float32MultiArray.numpy_serialization leaves >> the layout untouched. And in the numpy_msg tutorial, the layout seems >> to be None through out the example, which seems awkward. Therefore, I >> propose to initialize the layout size and stride using the buff when >> layout is None. This can be done with a numpy specific __init__() or >> just add few lines into numpy_serialization()). Similarly, in the >> Float32MultiArray.numpy_deserialization, reshape the array according >> to the layout information. >> >> This shouldn't break cross-language compatibility  as the lowlevel >> data is still transferred using the "tostring()" mechanism as 1D >> arrays but makes the numpy users' life much easier. >> >> >> -Tingfan >> PhD Student >> Machine Perception Laboratory >> UC San Diego >> >> >> >> >> >> >> On Mon, Jun 14, 2010 at 3:27 PM, Ken Conley wrote: >>> The ROS msg IDL only supports 1D arrays. The reshape approach is the correct >>> approach to ensure compatibility in multiple languages. >>> >>>  - Ken >>> >>> On Mon, Jun 14, 2010 at 3:23 PM, Floris van Breugel >>> wrote: >>>> >>>> Hi folks, >>>> >>>> Is there a way to publish 2D numpy arrays as messages (using python)? I >>>> went through the numpy tutorial for rospy but it seems to only work for 1D >>>> arrays. I suppose one could reshape the 2D array to be 1D, and pass the >>>> shape as another message, and then reconstruct it on the other side, but >>>> maybe there's a more efficient way to do it? Or that functionality could be >>>> added to numpy_msg.py? >>>> http://www.ros.org/wiki/rospy_tutorials/Tutorials/numpy >>>> >>>> Thanks! >>>> >>>> - Floris >>>> >>>> >>>> >>>> -- >>>> Floris van Breugel >>>> Caltech Graduate Student >>>> Control and Dynamical Systems >>>> (925) 963 8280 >>>> >>>> Wildlife and Landscape Photographer >>>> Galleries: http://www.ArtInNaturePhotography.com/ >>>> Blog: http://www.ArtInNaturePhotography.com/wordpress/ >>>> 2010 CALENDARS! Now available on my website! >>>> >>>> >>>> _______________________________________________ >>>> ros-users mailing list >>>> ros-users@code.ros.org >>>> https://code.ros.org/mailman/listinfo/ros-users >>>> >>> >>> >>> _______________________________________________ >>> ros-users mailing list >>> ros-users@code.ros.org >>> https://code.ros.org/mailman/listinfo/ros-users >>> >>> >> _______________________________________________ >> ros-users mailing list >> ros-users@code.ros.org >> https://code.ros.org/mailman/listinfo/ros-users >> > _______________________________________________ > ros-users mailing list > ros-users@code.ros.org > https://code.ros.org/mailman/listinfo/ros-users >