Update recovery device placement rules
This commit is contained in:
parent
2dc4a0fd39
commit
6c02ad0b91
@ -188,8 +188,14 @@ public class RecoveryHandler extends AbstractElementHandler {
|
|||||||
/**
|
/**
|
||||||
* RASAero does not specify where recovery devices are located.
|
* RASAero does not specify where recovery devices are located.
|
||||||
* We will use the following (arbitrary, but logical) rule to add the recovery device to the rocket:
|
* We will use the following (arbitrary, but logical) rule to add the recovery device to the rocket:
|
||||||
* put recovery device 1 in the first sustainer body tube just below the nosecone (about 1.125 calibers below
|
* 1. If the sustainer consists of two body tubes then Recovery Device 2 (deployment as set altitude) is positioned
|
||||||
* the top of the body tube).
|
* near the top (about 1.125 calibers) of the upper body tube with Recovery Device 1 (deployment at apogee)
|
||||||
|
* positioned near the top (about 1.125 calibers) of the second body tube down.
|
||||||
|
* 2. If the sustainer consists of three or more body tubes then Recovery Device 2 (deployment as set altitude) is
|
||||||
|
* positioned near the top (about 1.125 calibers) of the upper body tube with Recovery Device 1 (deployment at apogee)
|
||||||
|
* positioned near the top (about 1.125 calibers) of the third body tube down.
|
||||||
|
* 3. In all other cases: put recovery device 1 in the first sustainer body tube just below the nosecone
|
||||||
|
* (about 1.125 calibers below the top of the body tube).
|
||||||
* @param recoveryDevice the recovery device to add
|
* @param recoveryDevice the recovery device to add
|
||||||
* @param warnings the warning set to add import warnings to
|
* @param warnings the warning set to add import warnings to
|
||||||
*/
|
*/
|
||||||
@ -199,11 +205,39 @@ public class RecoveryHandler extends AbstractElementHandler {
|
|||||||
warnings.add("No sustainer body tube found." + recoveryDevice.getName() + " will not be added to the rocket.");
|
warnings.add("No sustainer body tube found." + recoveryDevice.getName() + " will not be added to the rocket.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BodyTube bodyTube = (BodyTube) sustainer.getChild(1);
|
|
||||||
bodyTube.addChild(recoveryDevice);
|
final BodyTube parentBodyTube;
|
||||||
|
|
||||||
|
// If there is a recovery device 2, then we will use special rules
|
||||||
|
if (event[1] && !"None".equals(eventType[1])) {
|
||||||
|
List<BodyTube> bodyTubes = getBodyTubesInStage(sustainer);
|
||||||
|
int nrOfTubes = bodyTubes.size();
|
||||||
|
|
||||||
|
// Rule 1: Two body tubes => add to second tube
|
||||||
|
if (nrOfTubes == 2) {
|
||||||
|
parentBodyTube = bodyTubes.get(1);
|
||||||
|
parentBodyTube.addChild(recoveryDevice);
|
||||||
|
}
|
||||||
|
// Rule 2: Three or more body tubes => add to third tube
|
||||||
|
else if (nrOfTubes >= 3) {
|
||||||
|
parentBodyTube = bodyTubes.get(2);
|
||||||
|
parentBodyTube.addChild(recoveryDevice);
|
||||||
|
}
|
||||||
|
// Rule 3: Less than two body tubes => add to first tube
|
||||||
|
else {
|
||||||
|
parentBodyTube = (BodyTube) sustainer.getChild(1);
|
||||||
|
parentBodyTube.addChild(recoveryDevice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Rule 3: Add to the first tube
|
||||||
|
else {
|
||||||
|
parentBodyTube = (BodyTube) sustainer.getChild(1);
|
||||||
|
parentBodyTube.addChild(recoveryDevice);
|
||||||
|
}
|
||||||
|
|
||||||
recoveryDevice.setAxialMethod(AxialMethod.TOP);
|
recoveryDevice.setAxialMethod(AxialMethod.TOP);
|
||||||
double offset = bodyTube.getOuterRadius() * 1.125;
|
double offset = parentBodyTube.getOuterRadius() * 1.125;
|
||||||
if (offset + recoveryDevice.getLength() > bodyTube.getLength()) {
|
if (offset + recoveryDevice.getLength() > parentBodyTube.getLength()) {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
}
|
}
|
||||||
recoveryDevice.setAxialOffset(offset);
|
recoveryDevice.setAxialOffset(offset);
|
||||||
@ -215,9 +249,9 @@ public class RecoveryHandler extends AbstractElementHandler {
|
|||||||
* 1. If the airframe has only 1 body tube:
|
* 1. If the airframe has only 1 body tube:
|
||||||
* put recovery device 2 in the first body tube just below recovery device 1.
|
* put recovery device 2 in the first body tube just below recovery device 1.
|
||||||
* 2. If the airframe has two body tubes:
|
* 2. If the airframe has two body tubes:
|
||||||
* put recovery device 2 in the second body tube (about 1.125 calibers below the top of the second body tube).
|
* put recovery device 2 in the first body tube (about 1.125 calibers below the top of the first body tube).
|
||||||
* 3. If the airframe has three or more body tubes:
|
* 3. If the airframe has three or more body tubes:
|
||||||
* put recovery device 2 in the third body tube (about 1.125 calibers below the top of the third body tube).
|
* put recovery device 2 in the first body tube (about 1.125 calibers below the top of the first body tube).
|
||||||
* @param recoveryDevice the recovery device to add
|
* @param recoveryDevice the recovery device to add
|
||||||
* @param warnings the warning set to add import warnings to
|
* @param warnings the warning set to add import warnings to
|
||||||
*/
|
*/
|
||||||
@ -226,33 +260,21 @@ public class RecoveryHandler extends AbstractElementHandler {
|
|||||||
double offset;
|
double offset;
|
||||||
|
|
||||||
AxialStage sustainer = rocket.getStage(0);
|
AxialStage sustainer = rocket.getStage(0);
|
||||||
|
List<BodyTube> bodyTubes = getBodyTubesInStage(sustainer);
|
||||||
// Get all body tubes
|
|
||||||
List<BodyTube> bodyTubes = new ArrayList<>();
|
|
||||||
for (int i = 0; i < sustainer.getChildCount(); i++) {
|
|
||||||
if (sustainer.getChild(i) instanceof BodyTube) {
|
|
||||||
bodyTubes.add((BodyTube) sustainer.getChild(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (bodyTubes.size()) {
|
switch (bodyTubes.size()) {
|
||||||
case 0:
|
case 0:
|
||||||
warnings.add("No sustainer body tube found." + recoveryDevice.getName() + " will not be added to the rocket.");
|
warnings.add("No sustainer body tube found." + recoveryDevice.getName() + " will not be added to the rocket.");
|
||||||
return;
|
return;
|
||||||
case 1:
|
case 1:
|
||||||
// If there is only one body tube, add the recovery device to the first body tube, after recovery device 1
|
// Rule 1: If there is only one body tube, add the recovery device to the first body tube, after recovery device 1
|
||||||
bodyTube = bodyTubes.get(0);
|
bodyTube = bodyTubes.get(0);
|
||||||
offset = bodyTube.getOuterRadius() * 1.125;
|
offset = bodyTube.getOuterRadius() * 1.125;
|
||||||
offset += recoveryDevice.getLength() * 1.05; // = equivalent to adding after recovery device 1
|
offset += recoveryDevice.getLength() * 1.05; // = equivalent to adding after recovery device 1
|
||||||
break;
|
break;
|
||||||
case 2:
|
|
||||||
// If there are two body tubes, add the recovery device to the second body tube
|
|
||||||
bodyTube = bodyTubes.get(1);
|
|
||||||
offset = bodyTube.getOuterRadius() * 1.125;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
// If there are three or more body tubes, add the recovery device to the third body tube
|
// Rule 2 & 3: If there are two, three or more body tubes, add the recovery device to the first body tube
|
||||||
bodyTube = bodyTubes.get(2);
|
bodyTube = bodyTubes.get(0);
|
||||||
offset = bodyTube.getOuterRadius() * 1.125;
|
offset = bodyTube.getOuterRadius() * 1.125;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -265,4 +287,16 @@ public class RecoveryHandler extends AbstractElementHandler {
|
|||||||
}
|
}
|
||||||
recoveryDevice.setAxialOffset(offset);
|
recoveryDevice.setAxialOffset(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<BodyTube> getBodyTubesInStage(AxialStage stage) {
|
||||||
|
// Get all body tubes
|
||||||
|
List<BodyTube> bodyTubes = new ArrayList<>();
|
||||||
|
for (int i = 0; i < stage.getChildCount(); i++) {
|
||||||
|
if (stage.getChild(i) instanceof BodyTube) {
|
||||||
|
bodyTubes.add((BodyTube) stage.getChild(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bodyTubes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user