[ros-users] 2d numpy arr msgs?

Floris van Breugel florisvb at gmail.com
Mon Jun 14 22:59:08 UTC 2010


Thanks for the ideas!

the cvbridge approach is pretty clever.. nice!

- Floris


On Mon, Jun 14, 2010 at 3:57 PM, Stuart Glaser <sglaser at willowgarage.com>wrote:

> Hi,
>
> I'd suggest the Float64MultiArray message (in std_msgs).  I don't know
> of any conversion function that exists for Python yet.
>
> -Stu
>
> On Mon, Jun 14, 2010 at 3:52 PM, James Bowman <jamesb at willowgarage.com>
> wrote:
> > You can turn the numpy array into a single-channel CV image, then use
> > cv_bridge to turn it into a message:
> >
> > msg = CvBridge().cv_to_imgmsg(cv.fromarray(a))
> >
> > and:
> >
> > a = numpy.fromarray(CvBridge().imgmsg_to_cv(msg))
> >
> >
> > On Mon, Jun 14, 2010 at 3:27 PM, Ken Conley <kwc at willowgarage.com>
> 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 <florisvb at gmail.com
> >
> >> 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 at code.ros.org
> >>> https://code.ros.org/mailman/listinfo/ros-users
> >>>
> >>
> >>
> >> _______________________________________________
> >> ros-users mailing list
> >> ros-users at code.ros.org
> >> https://code.ros.org/mailman/listinfo/ros-users
> >>
> >
> >
> >
> > --
> > J.
> >
> >
> > _______________________________________________
> > ros-users mailing list
> > ros-users at code.ros.org
> > https://code.ros.org/mailman/listinfo/ros-users
> >
> >
>
>
>
> --
> Stuart Glaser
> sglaser -at- willowgarage -dot- com
> www.willowgarage.com
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users
>



-- 
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!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20100614/5a084a1e/attachment-0003.html>


More information about the ros-users mailing list