[Solved] Problem with calculating angle between ROSbot and wall

Hi,

I have a problem with determining the angle between ROSbot and the wall. I’m trying to find a formula for this angle and I can’t do it. Could someone help me with this task? So far I found this formula:

def calculate_angle(l, l1, alfa):
angle = atan(l1 * cos(radians(alfa)) - l) / (l1 * sin(radians(alfa)))
return degrees(angle)

where l is ray that is perpendicular to ROSbot side, which is set toward the wall, l1 is a ray that is shifted by alfa degrees from l.

I found the error, I am ashamed :frowning: . Should be:

def calculate_angle(l, l1, alfa):
angle = atan((l1 * cos(radians(alfa)) - l) / (l1 * sin(radians(alfa))))
return degrees(angle)