The sensor scans to find each the angle on each side of the object; then the base servo for the arm moves to the average of those two angles. So if the robot started its scan(from right to left) and picked up an object at let’s say at servo position -1500. The bot would then scan again(from left to right this time)and find the other side of the object at servo position 1000. Then the baseangle is simply (-1500+1000)/2. If you wanted to know the object width in centimeters or inches then you could use the difference between the two angles in a trigonometry equation of some sort. Right now though, I don’t really have any need to find the exact width of the objects I need to pick up since I’m only working with one kind of object.(small lincoln log) Later on I want to get the bot to be able to handle several different sizes of objects so something like that might be a future add on to the code.
Good start!
Alan KM6VV