Still set mass/CG even if there is no motor

This commit is contained in:
SiboVG 2023-04-01 12:42:39 +02:00
parent 27a77825be
commit d0102fde0e
3 changed files with 46 additions and 17 deletions

View File

@ -384,7 +384,7 @@ public class RASAeroCommonConstants {
*/ */
public static String OPENROCKET_TO_RASAERO_MOTOR(List<ThrustCurveMotor> motors, Motor ORMotor, MotorConfiguration motorConfig, public static String OPENROCKET_TO_RASAERO_MOTOR(List<ThrustCurveMotor> motors, Motor ORMotor, MotorConfiguration motorConfig,
WarningSet warnings) { WarningSet warnings) {
if (!(ORMotor instanceof ThrustCurveMotor)) { if (!(ORMotor instanceof ThrustCurveMotor) || motorConfig == null) {
return null; return null;
} }

View File

@ -113,6 +113,7 @@ public class SimulationDTO {
* @param rocket the rocket * @param rocket the rocket
* @param simulation the simulation to convert * @param simulation the simulation to convert
* @param mounts a map of stages and their corresponding motor mount (only 1 mount per stage allowed) * @param mounts a map of stages and their corresponding motor mount (only 1 mount per stage allowed)
* if a motor mount is null, it means that stage does not have any motors, but mass/CG export should still take place
* @param motors a list of RASAero motors * @param motors a list of RASAero motors
* @param warnings a list to add export warnings to * @param warnings a list to add export warnings to
* @param errors a list to add export errors to * @param errors a list to add export errors to
@ -132,25 +133,36 @@ public class SimulationDTO {
// Get sustainer motor mass // Get sustainer motor mass
MotorMount sustainerMount = mounts.get((AxialStage) rocket.getChild(0)); MotorMount sustainerMount = mounts.get((AxialStage) rocket.getChild(0));
MotorConfiguration sustainerConfig = sustainerMount.getMotorConfig(fcid); double sustainerMotorMass = 0;
Motor sustainerMotor = sustainerConfig.getMotor(); if (sustainerMount != null) {
double sustainerMotorMass = sustainerMotor != null ? sustainerMotor.getLaunchMass() : 0; MotorConfiguration sustainerConfig = sustainerMount.getMotorConfig(fcid);
Motor sustainerMotor = sustainerConfig.getMotor();
sustainerMotorMass = sustainerMotor != null ? sustainerMotor.getLaunchMass() : 0;
}
for (Map.Entry<AxialStage, MotorMount> mountSet : mounts.entrySet()) { for (Map.Entry<AxialStage, MotorMount> mountSet : mounts.entrySet()) {
AxialStage stage = mountSet.getKey(); AxialStage stage = mountSet.getKey();
MotorMount mount = mountSet.getValue(); MotorMount mount = mountSet.getValue();
if (mount == null || stage == null) { if (stage == null) {
continue; continue;
} }
// Get the motor info for this stage // Get the motor info for this stage
MotorConfiguration motorConfig = mount.getMotorConfig(fcid); MotorConfiguration motorConfig = mount != null ? mount.getMotorConfig(fcid) : null;
Motor motor = motorConfig.getMotor(); Motor motor = null;
double motorMass = motor != null ? motor.getLaunchMass() : 0; StageSeparationConfiguration separationConfig = null;
StageSeparationConfiguration separationConfig = stage.getSeparationConfigurations().get(fcid); double motorMass = 0;
if (motorConfig != null) {
motor = motorConfig.getMotor();
motorMass = motor != null ? motor.getLaunchMass() : 0;
separationConfig = stage.getSeparationConfigurations().get(fcid);
}
int stageNr = rocket.getChildPosition(stage); int stageNr = rocket.getChildPosition(stage);
FlightConfiguration CGCalcConfig = new FlightConfiguration(rocket); FlightConfiguration CGCalcConfig = new FlightConfiguration(rocket);
RigidBody calc;
double ignitionDelay, totalCG, separationDelay;
switch (stageNr) { switch (stageNr) {
// Sustainer // Sustainer
case 0: case 0:
@ -163,7 +175,9 @@ public class SimulationDTO {
double sustainerCG = MassCalculator.calculateStructure(CGCalcConfig).getCM().x; double sustainerCG = MassCalculator.calculateStructure(CGCalcConfig).getCM().x;
setSustainerCG(sustainerCG * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH); setSustainerCG(sustainerCG * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
setSustainerIgnitionDelay(motorConfig.getIgnitionDelay()); // Ignition delay
ignitionDelay = motorConfig != null ? motorConfig.getIgnitionDelay() : 0;
setSustainerIgnitionDelay(ignitionDelay);
break; break;
// Booster 1 // Booster 1
case 1: case 1:
@ -174,19 +188,25 @@ public class SimulationDTO {
for (int i = 1; i <= stage.getStageNumber(); i++) { for (int i = 1; i <= stage.getStageNumber(); i++) {
CGCalcConfig._setStageActive(i, true); CGCalcConfig._setStageActive(i, true);
} }
RigidBody calc = MassCalculator.calculateStructure(CGCalcConfig); calc = MassCalculator.calculateStructure(CGCalcConfig);
// Aggregate mass of sustainer and booster 1 // Aggregate mass of sustainer and booster 1
double booster1Mass = calc.getMass() + motorMass + sustainerMotorMass; double booster1Mass = calc.getMass() + motorMass + sustainerMotorMass;
setBooster1LaunchWt(booster1Mass * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_WEIGHT); setBooster1LaunchWt(booster1Mass * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_WEIGHT);
// CG // CG
double totalCG = calc.getCM().x; totalCG = calc.getCM().x;
setBooster1CG(totalCG * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH); setBooster1CG(totalCG * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
setBooster1IgnitionDelay(motorConfig.getIgnitionDelay()); // Ignition delay
setBooster1SeparationDelay(separationConfig.getSeparationDelay()); // TODO: this could be handled a bit better (look at separation delay, upper stage ignition event etc.) ignitionDelay = motorConfig != null ? motorConfig.getIgnitionDelay() : 0;
setIncludeBooster1(mount.isMotorMount()); setBooster1IgnitionDelay(ignitionDelay);
// Separation delay
separationDelay = separationConfig != null ? separationConfig.getSeparationDelay() : 0;
setBooster1SeparationDelay(separationDelay); // TODO: this could be handled a bit better (look at separation delay, upper stage ignition event etc.)
setIncludeBooster1(mount != null && mount.isMotorMount());
break; break;
// Booster 2 // Booster 2
case 2: case 2:
@ -213,8 +233,11 @@ public class SimulationDTO {
totalCG = calc.getCM().x; totalCG = calc.getCM().x;
setBooster2CG(totalCG * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH); setBooster2CG(totalCG * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
setBooster2Delay(separationConfig.getSeparationDelay()); // TODO: this could be handled a bit better (look at separation delay, upper stage ignition event etc.) // Separation delay
setIncludeBooster2(mount.isMotorMount()); separationDelay = separationConfig != null ? separationConfig.getSeparationDelay() : 0;
setBooster2Delay(separationDelay); // TODO: this could be handled a bit better (look at separation delay, upper stage ignition event etc.)
setIncludeBooster2(mount != null && mount.isMotorMount());
break; break;
// Invalid // Invalid
default: default:

View File

@ -67,6 +67,12 @@ public class SimulationListDTO {
} }
} }
} }
// If at this point, we still don't have a mount, there is probably a mount without a motor.
// In that case, add a null mount, so that mass/CG export happens.
if (!mounts.containsKey(stage)) {
mounts.put(stage, null);
}
} }
// Load all RASAero motors // Load all RASAero motors