3D trigonometric question

Andrey

New member
Joined
May 15, 2020
Messages
4
Hello!

Normally I would be able to solve an issue like this myself, but today my brain just isn't having it. This is my first post here, so please remind me if I've forgotten anything.

So, I am building a device to point to a certain position on a board using 2 servos, and arduino and a laser (Small harmless red dot laser). This device will be mounted to the roof of the building and is set "Z" distance away from the wall (This is a constant value that I can edit on the fly in software). The idea is that there are many trays on the wall (28 trays across by 40 down, where the trays are "A" thick and "B" tall. Again, constants that I can edit on the fly in software) and I want to be able to find a trays position.

So far in the software I can locate the tray without issue, but I'm having troubles with the angles. The servo library works only in angles, so I figured it'd be easiest to explain this as a maths question. So, the trays are in a grid, with the top left tray being "0,0" and the bottom right tray being "28,40" where the device in mounted on the roof half way across (So directly ahead and down a bit is trays 14 and 15 across). Getting the X axis is fairly easy as I'm just doing "atan((x_index - 14.5)/Z)". HOWEVER, because the wall is flat, changing the X axis also alters the Y axis, making it so much trickier. Effectively, I presumed that it was all a 2D problem, and because of that my calculation for the Y axis ends up being thrown COMPLETELY off.

I could use 1 of 2 solutions:
- 1: Find how much changing the X position will alter the Y position (Then subtract it from where I want the Y position to be)
- 2: Given all required variables, just find the X angle to drive the servo at.

Attached is some images that (Hopefully) help explain the issue I'm having (Blue boxes are small servos that rotate). I don't quite know how to explain it.

Do note that I use "EEPROM(#)" to specify some values. That's just a fancy way of me saying "This is a constant value that has yet to be defined, but will not change at all". If you want to say something like "variable D = EEPROM(2)" to make it easier, go ahead I don't mind in the slightest.

I'm almost certain I'm close, I've just forgotten something really obvious. Just came home from work (It's 7:30pm here) so like I said, my brain just isn't ready for maths. I wanted to hear your opinions and if you noticed I'd forgotten anything obvious.

Thanking you in advance,
Andrey
 

Attachments

  • 2020-05-15 18_45_08-asm0001.pdf - Adobe Acrobat Reader DC.png
    2020-05-15 18_45_08-asm0001.pdf - Adobe Acrobat Reader DC.png
    27.5 KB · Views: 0
  • 2020-05-15 18_45_23-asm0001.pdf - Adobe Acrobat Reader DC.png
    2020-05-15 18_45_23-asm0001.pdf - Adobe Acrobat Reader DC.png
    17.6 KB · Views: 1
  • asm0001.pdf
    283.3 KB · Views: 0
  • img003.jpg
    img003.jpg
    380.4 KB · Views: 1
Wow, I really must be tired. I just realised the super obvious thing I missed. The calculation for θ 2 should take into account the altered position of the servos (Very simple trig). MEANING, instead of just using "EEPROM(0)", it should use "EEPROM(0)/Cos(θ 1)".

Effectively I was presuming that the length was "EEPROM(0)" for the top of the triangle. But it's not. After you move the X axis, it's the hypotenuse of the triangle where one of the sides is "EEPROM(0)".

I am both glad and annoyed that it was so easy/simple to solve.
 
Top