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
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