Thanks for the ideas!<br><br>the cvbridge approach is pretty clever.. nice!<br><br>- Floris<br><br><br><div class="gmail_quote">On Mon, Jun 14, 2010 at 3:57 PM, Stuart Glaser <span dir="ltr"><<a href="mailto:sglaser@willowgarage.com">sglaser@willowgarage.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi,<br>
<br>
I'd suggest the Float64MultiArray message (in std_msgs).  I don't know<br>
of any conversion function that exists for Python yet.<br>
<br>
-Stu<br>
<div><div></div><div class="h5"><br>
On Mon, Jun 14, 2010 at 3:52 PM, James Bowman <<a href="mailto:jamesb@willowgarage.com">jamesb@willowgarage.com</a>> wrote:<br>
> You can turn the numpy array into a single-channel CV image, then use<br>
> cv_bridge to turn it into a message:<br>
><br>
> msg = CvBridge().cv_to_imgmsg(cv.fromarray(a))<br>
><br>
> and:<br>
><br>
> a = numpy.fromarray(CvBridge().imgmsg_to_cv(msg))<br>
><br>
><br>
> On Mon, Jun 14, 2010 at 3:27 PM, Ken Conley <<a href="mailto:kwc@willowgarage.com">kwc@willowgarage.com</a>> wrote:<br>
>><br>
>> The ROS msg IDL only supports 1D arrays. The reshape approach is the<br>
>> correct approach to ensure compatibility in multiple languages.<br>
>><br>
>>  - Ken<br>
>><br>
>> On Mon, Jun 14, 2010 at 3:23 PM, Floris van Breugel <<a href="mailto:florisvb@gmail.com">florisvb@gmail.com</a>><br>
>> wrote:<br>
>>><br>
>>> Hi folks,<br>
>>><br>
>>> Is there a way to publish 2D numpy arrays as messages (using python)? I<br>
>>> went through the numpy tutorial for rospy but it seems to only work for 1D<br>
>>> arrays. I suppose one could reshape the 2D array to be 1D, and pass the<br>
>>> shape as another message, and then reconstruct it on the other side, but<br>
>>> maybe there's a more efficient way to do it? Or that functionality could be<br>
>>> added to numpy_msg.py?<br>
>>> <a href="http://www.ros.org/wiki/rospy_tutorials/Tutorials/numpy" target="_blank">http://www.ros.org/wiki/rospy_tutorials/Tutorials/numpy</a><br>
>>><br>
>>> Thanks!<br>
>>><br>
>>> - Floris<br>
>>><br>
>>><br>
>>><br>
>>> --<br>
>>> Floris van Breugel<br>
>>> Caltech Graduate Student<br>
>>> Control and Dynamical Systems<br>
>>> (925) 963 8280<br>
>>><br>
>>> Wildlife and Landscape Photographer<br>
>>> Galleries: <a href="http://www.ArtInNaturePhotography.com/" target="_blank">http://www.ArtInNaturePhotography.com/</a><br>
>>> Blog: <a href="http://www.ArtInNaturePhotography.com/wordpress/" target="_blank">http://www.ArtInNaturePhotography.com/wordpress/</a><br>
>>> 2010 CALENDARS! Now available on my website!<br>
>>><br>
>>><br>
>>> _______________________________________________<br>
>>> ros-users mailing list<br>
>>> <a href="mailto:ros-users@code.ros.org">ros-users@code.ros.org</a><br>
>>> <a href="https://code.ros.org/mailman/listinfo/ros-users" target="_blank">https://code.ros.org/mailman/listinfo/ros-users</a><br>
>>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> ros-users mailing list<br>
>> <a href="mailto:ros-users@code.ros.org">ros-users@code.ros.org</a><br>
>> <a href="https://code.ros.org/mailman/listinfo/ros-users" target="_blank">https://code.ros.org/mailman/listinfo/ros-users</a><br>
>><br>
><br>
><br>
><br>
> --<br>
> J.<br>
><br>
><br>
> _______________________________________________<br>
> ros-users mailing list<br>
> <a href="mailto:ros-users@code.ros.org">ros-users@code.ros.org</a><br>
> <a href="https://code.ros.org/mailman/listinfo/ros-users" target="_blank">https://code.ros.org/mailman/listinfo/ros-users</a><br>
><br>
><br>
<br>
<br>
<br>
</div></div><font color="#888888">--<br>
Stuart Glaser<br>
sglaser -at- willowgarage -dot- com<br>
<a href="http://www.willowgarage.com" target="_blank">www.willowgarage.com</a><br>
</font><div><div></div><div class="h5">_______________________________________________<br>
ros-users mailing list<br>
<a href="mailto:ros-users@code.ros.org">ros-users@code.ros.org</a><br>
<a href="https://code.ros.org/mailman/listinfo/ros-users" target="_blank">https://code.ros.org/mailman/listinfo/ros-users</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Floris van Breugel<br>Caltech Graduate Student<br>Control and Dynamical Systems<br>(925) 963 8280<br><br>Wildlife and Landscape Photographer<br>Galleries: <a href="http://www.ArtInNaturePhotography.com/">http://www.ArtInNaturePhotography.com/</a><br>
Blog: <a href="http://www.ArtInNaturePhotography.com/wordpress/">http://www.ArtInNaturePhotography.com/wordpress/</a><br>2010 CALENDARS! Now available on my website!<br><br>