# Cylinder of unknown radius resting in a V-notch

• So, this is one of those trig problems that has me thinking, "I used to know how to do this, dangit!".

The basic problem is that I need to use a robot-carried sensor to find the highest point of a cylinder lying horizontally in a V-notch, like so:

And from that single-point touch, determine the radius of the cylinder and the vertical distance between the the bottom of the notch and the centerline of the cylinder. So my sensor will touch off the intersection of the dotted line with the top of the cylinder. The radius of the cylinder is unknown, and the interior angle of the V-notch will be known but may not be a nice clean 90deg (still waiting on the mechanical designers, but the V-notch is driven by other parts of the design, so we robot programmers will have to make do with whatever it ends up being).

Obviously, the centerline of the cylinder, the bottom of the notch, and the point of tangent contact against the side of the notch will always make a right triangle (with the right angle at the tangent point of contact). There should be a means to extract the data I want (the cylinder radius, and the distance from the bottom center of the notch to the centerline of the cylinder) using trigonometry, but my trig skills are rusty enough that I'm not finding it so far.

• A formal trig solution still evades me, but I have found that, for a given internal angle of V-notch, there is a constant ratio between the cylinder diameter and the distance between the cylinder centerline and the bottom of the V-notch.

Oddly enough, for a V_notch with a 60deg internal angle, that ratio is 1:1, and for a 90deg notch the ratio is .7071 (the sine and cosine of 45deg). For a 120deg internal angle, the ratio changes to 0.577.

So it looks like there's a non-trigonometric solution, if I still can't work out the correct formalism.

• h=r*(1+sqrt(2))

or simply h = r * 2.41421356237309

of if you know h, r is easy to calculate.

and if you know h and r, low point is simply h-2r

2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

• just a small correction:

sqrt(2) = 1.4142135623730950488016887242097

and plus 1 = 2.4142135623730950488016887242097

(my mistake)

• one approach is to create set of equations and find solution that satisfies them all

we are looking at the profile of the cylinder which is a circle and general equation for circle is

(x-x0)^2+(y-y0)^2=r^2

so to find r for example, we need to express everything else in that equation as some function of r, then you get quadratic equation of form and this is easy to compute. that includes getting rid of or substituting x, x0, y, y0 with something that is known (angle, measured height...)

since center of the cylinder is always on Y axis, we already get x0=0.

this means we get simplified equation

x^2+(y-y0)^2=r^2

also y0 is obtained from the height measurement

y0 = h-r

the next thing is the line which is a tangent on the circle.

we can write this as

y=mx+b

where m=tan(angle)

note that this angle is a complementary angle of the vAngle/2

y=tan(90-vAngle/2)*x+b

and since line goes through origin, intercept b is always zero (b=0) so we get

y=x*tan(90-vAngle/2)

so the last piece of puzzle is how to transform x as a function of r.

looking at contact point of the cylinder and the tangent we can write

x=r*cos(angle)=r*cos(90-vAngle/2)

so combining them all should create simple quadratic equation of only one variable (r). to compute that, rearrange equation into conventional form:

a*r^2+b*r+c=0 ; here the variable is r instead of usual x

then

r1,r2= (-b+/-sqrt(b^2-4*a*c)/(2*a)

2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

• So, r=h/(1+sqrt(2)). This appears to work for a 90deg notch, but not other angles.

Hm... sqrt(2) = 2*sin(90/2). But I don't seem to find any similar ratios that work for my 30deg and 120deg test cases.

Not to mention, the mechanical designers got back to me and apparently the V-notch fixture is going to be nearly flat, with an internal angle of 160deg (each "slope" 10deg above horizontal).

we are looking at the profile of the cylinder which is a circle and general equation for circle is

(x-x0)^2+(y-y0)^2=r^2

Yeah, I remember that one from some other work, and it was one of my first thoughts. But I think I'm going to have to avoid the time cost of hitting 3 points around the upper circumference if at all possible. The cylinder diameters are also going to vary widely, from ~50mm up to ~400mm.

• how are you detecting top side? what sensor?

why 3 points? single measurement should be enough if the part is placed correcly. if the gravity is not enough to put the cylinder square into the the V-slot, then 160deg is probably too wide.

2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

• Hm... sqrt(2) = 2*sin(90/2). But I don't seem to find any similar ratios that work for my 30deg and 120deg test cases.

because equation involves not only sums but product and ratio of SIN and COS. for example TAN is SIN/COS and if i recall there should be product involving SIN*TAN which is same as SIN^2 / COS....

for 45deg SIN and COS values are the same and may cancel out. for other angles that is not the case.

2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

Hello,

The following explanation assumes you have or you can create a frame at the V-notch tip with the Z axis pointing up.

z - is your sensor measurement in the vertical direction relative to the above frame;

R - is the radius of the cylinder;

H - is the distance from the tip of the V-notch to the center line of the cylinder;

a - is the half angle of the V-notch (e.g. 90/2, 30/2, 120/2);

(1): z = R + H

(2): R = H*sin(a)

Substitute (2) in (1):

z = H*sin(a) + H

Then:

H = z/(1 + sin(a))

From (1):

R = z - H

I have a picture for it, if you need it please let me know where would you like me to upload it to.

• H = z/(1 + sin(a))

That works perfectly across all my test cases, with different cylinder sizes and notch angles! Thank you!

• i like it, so much simpler...

2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly