Ask Your Question
2

Better msg implementation for random, complicated shape in 2D

asked 2012-06-07 15:35:30 -0600

130s gravatar image

updated 2012-06-08 06:24:01 -0600

I want to design a .msg that represents a line with irregular shape. What would be the best optimal option especially utilizing existing ROS msg types as much as possible? Example image:

image description(Image obtained from http://www.had2know.com/images/irregshap.jpg)

The line like red curvy one in this figure is my target. For now, whether the line draws a cycle can be ignored for my purpose (to represent non-cyclic line is another design discussion).

My idea is:

geometry_msgs/Point[] dotsOnLine
# The order of Point objects in the array can be determined by certain algorithm. Not a focus in this discussion.

I found sensor_msgs/RegionOfInterest might be a good fit for rectangular/squares, but I guess not for irregular shapes. I'm asking particularly because I'm afraid I might be missing good existing msg types (I've only looked at common_msgs).

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2012-06-07 17:01:38 -0600

Eric Perko gravatar image

I'd say this is exactly what you are looking for: geometry_msgs/PolygonStamped. That contains a standard header as well as a geometry_msgs/Polygon message that is basically the same as yours (but uses 32-bit floats instead of 64-bit doubles).

A bonus to using geometry_msgs/PolygonStamped instead of the non-stamped version or your own message is that you get the RVIZ Polygon display for free :-)

edit flag offensive delete link more

Comments

+1; sounds perfect incl. RViz feature except that I'm not yet sure how the msg type works when the line doesn't go cyclic which I'm trying to figure out now. Also I need to know how sparse the points can become so that ROS detects the line closes its loop.

130s gravatar image130s ( 2012-06-08 14:20:19 -0600 )edit

Take a look at http://www.ros.org/doc/api/geometry_msgs/html/msg/Polygon.html (the embedded Polygon message). It states that the assumption is that the first and last points are connected, so it can't represent non-closed polygons. I don't think there are any sparseness constraints...

Eric Perko gravatar imageEric Perko ( 2012-06-08 19:56:57 -0600 )edit

Yeah I saw that doc too, & I just tested with a simple code out of curiosity (e.g. what error would I get if loop not closed etc.). Turned out to me that ROS compensates the miss-match b/w 2 pts so that the line represented by PolygonStamped always closed-loops. My sample code: http://goo.gl/FKlXX

130s gravatar image130s ( 2012-06-11 07:06:28 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-06-07 15:35:30 -0600

Seen: 824 times

Last updated: Jun 08 '12