I was trying to make a vizzy program for my upcoming bomber's bomb bay
It is supposed to release a bomb when at a specific location, namely 0,-0.83,-0.92
But it isn't working. Please help!
Tags
Vizzy8 Comments
- Log in to leave a comment
-
10.4k sflanker
So several of the issues I pointed out originally were still relevant, but the solution is obviously quite different then what I described before. To restate the problem: the goal is to activate stages when specific parts (bombs) are in a particular position relative to the craft as they rotate around a central drum. There are several ways to skin this cat: you could check the orientation of the drum itself, you can check the angle between a vector to the bombs and some reference angle, or you can explicitly check the position of the bombs. I elected to check the position because it was the closest to the original and didn't require any complex vector math. The implementation I used was to take the PCI position of the rotating drum (part 162) and subtract it from the PCI position of the bomb to be dropped, which gives us a PCI vector from the COM of the drum to the bomb; then convert that into the craft's local frame of reference (we don't want to use the PCI frame of reference because it would give us different vectors as the craft orientation changed relative to the planet, and we don't want to use the frame of reference of the shaft or anything rotating because that would result in a constant vector, i.e. the bombs are not moving with respect to the drum they're attached to); once we have the craft relative vector from the drum to the bomb we subtract it from the desired position, and if the length of the resulting vector is less than 3mm we activate the stage. I won't write this up in text since you can see it in the screen shot on the craft.
-
-
10.4k sflanker
Oh haha I Completely misinterpreted what you were trying to do. That makes way more sense. I'll take another look now that I understand what you were actually trying to do.
-
15.7k Hylo
@sflanker thank you! I was actually trying to make the bombs detatch when they are at the bottom of the cargo bay, but I’m definitely going to use this!
-
10.4k sflanker
Here's my tweaked version that basically seems to work (only drops the first pair of bombs).
-
10.4k sflanker
The primary issue is that the expression
part [number] |PCI to Local| [pci_vector]
doesn't do what you think it does. First, the vector must be in PCI coordinates and relative to the part, and this instruction will change its orientation into the local coordinate system of the part. What this means is using a fixed vector like(0, -0.83, -0.92)
doesn't make much sense assuming you want to hit a target on the ground. What you will probably want to do is start with a lat/lon/agl position, and convert that to PCI. Additionally you will need to take the difference between the part position and the target position. Second, that expression returns a vector, and you can'twait until
a vector. You need to use that vector in some kind of comparison to make it a boolean value (i.e.true
orfalse
). To do this you will want to define some range limit, and then compare that with the the length of the resulting vector. Lastly you need to account for altitude, since I'm assuming you want to drop ordinance when you are above the target position (as opposed to dropping down to near ground level and dropping ordinance from point blank range). Given all that your instructions might look something like this:> wait until [ [ [ part [322] |PCI to Local| [ [convert [ vec [-0.83], [-0.92], [ altitude |AGL| ] ] to position] - [ part [322] |Position| ] ] ] length ] < 500 ] > activate stage
And you can actually drop the
PCI to Local
entirely because it only affects orientation, and you're just checking length, so:[ [ [ [convert [ vec [-0.83], [-0.92], [ altitude |AGL| ] ] to position] - [ part [322] |Position| ] ] ] length ] < 500
is what you want.
I will leave adding adjustments to compensate for lateral velocity as an exercise to the reader, because if you release your weapons directly above the target while traveling at 200 kph you are probably going to miss the target. If you're lazy you can probably just assume a certain altitude and airspeed and tweak the range accordingly.
-
@sflanker interesting, I always thought that I could just use the vector location to make the activate at a certain point. Thanks for the explanation, and for the help!