

Tracking a "U" shape of lights Gordon from Australia [6 posts] 
7 years

I have a rectangular robot with LED strips around three edges. I'm successfully using RoboRealm to isolate the light from the robot in a binary image with an approximate "U" shape. I'm attaching some example images, so you can see what I'm seeing.
What I want is to get the robot's position, angle and bounds for use in a separate application (I'll be reading these variables into my application through the API). I've been messing with various modules, but I can't seem to get a consistent angle measurement. What would you recommend as the best way to track the "U" shape and get an angle of rotation?



Gordon from Australia [6 posts] 
7 years

I've been playing around a bit and found an approach that at first try seems to work okay:
Firstly, I use the Cluster_Points module to generate three points evenly spaced around the inside of the "U" to give me a triangle shape. I then use a blob filter and a basic C script to save the points to variables (is there a better way to do that?). These three points make up a triangle that will end up giving me my orientation.
Secondly, I revert back to the "U" blob and generate four Cluster_Points and save them to variables also.
For the third step, I wrote a custom C script that iterates through the first three points, and figures out which of the three is furthest away from the second set (of four) points. This point is the bottom of the "U" shape.
I then find the midpoint of the line between the two points that aren't the bottom. Using that midpoint, and the point at the bottom of the "U", I calculate my angle.
Attached is an image with a bunch of annotations so I can see what it's doing. The green point is the one calculated to be at the bottom of the "U", red and orange are the other two of the three cluster_points. The blue points are the four cluster_points. The purple diamond is the COG of the "U" blob and the red line is what is used to calculate angle, which is annotated in the topleft corner.
This seems to work well, except there's a little bit of jitter with the Cluster_Points, even on a static image. Does anyone have any idea why this might be?



Anonymous 
7 years

Gordon,
The clustering of points has a random nature to it as the initial point set is split at random. So even on static images you will see a little bit of a wiggle as not exactly the same cluster points will get selected each time. Regardless of what technique you use you will get a little bit of wiggle anyhow. The trick is to find the technique that gives a low enough amount to be acceptable for your application.
What we normally use for these kinds of things is the Geometry statistics module and have a look at how the 3 angle variables it generates function as the object is rotated. If you've not already looked at this module and the 3 angle stats that may be worth a look as they might be more stable than the point clustering.
STeven.



Gordon from Australia [6 posts] 
7 years

I did try the the Geometry Statistics module, but I couldn't make sense of the angles it generated. The hard part for me at the moment is that the robot itself (as well as the camera to track it) is unfinished and offsite, so I've had to make do with taking static images from the camera and experimenting with them for now until I can get full access to the robot and camera (hopefully by the end of this week).
But from the static images I've taken, I can seem to get any consistency from the Geometric statistics' angles. I will definitely try again on a live image from the robot, but for now at least I have something that seems to work okay.
Thanks for your advice Steven, and I'll let you know how it goes.



Anonymous 
7 years

Gordon,
One additional way (just in case you need even more) would be to use the Shape match module which given the shape that you are using should be quite stable. It also has an orientation value that is generated once the shape is matched to that in the database. May offer a different perspective.
http://www.roborealm.com/help/Shape_Match.php
Good luck!
STeven.

