Merge with commit f8cfebe from kruland2607/openrocket
This commit is contained in:
parent
206214e47a
commit
513e74fd15
@ -192,27 +192,27 @@ public class BarrowmanCalculator extends AbstractAerodynamicCalculator {
|
||||
// With the implementation of ParallelStages and Pods, this is no longer true. -Daniel Williams
|
||||
//
|
||||
// // Check for discontinuities
|
||||
// if (component instanceof SymmetricComponent) {
|
||||
// SymmetricComponent sym = (SymmetricComponent) component;
|
||||
// // TODO:LOW: Ignores other cluster components (not clusterable)
|
||||
// double x = component.toAbsolute(Coordinate.NUL)[0].x;
|
||||
//
|
||||
// // Check for lengthwise discontinuity
|
||||
// if (x > componentX + 0.0001) {
|
||||
// if (!MathUtil.equals(radius, 0)) {
|
||||
// warnings.add(Warning.DISCONTINUITY);
|
||||
// radius = 0;
|
||||
// }
|
||||
// }
|
||||
// componentX = component.toAbsolute(new Coordinate(component.getLength()))[0].x;
|
||||
//
|
||||
// // Check for radius discontinuity
|
||||
// if (!MathUtil.equals(sym.getForeRadius(), radius)) {
|
||||
// warnings.add(Warning.DISCONTINUITY);
|
||||
// // TODO: MEDIUM: Apply correction to values to cp and to map
|
||||
// }
|
||||
// radius = sym.getAftRadius();
|
||||
// }
|
||||
if (component instanceof SymmetricComponent) {
|
||||
SymmetricComponent sym = (SymmetricComponent) component;
|
||||
// TODO:LOW: Ignores other cluster components (not clusterable)
|
||||
double x = component.toAbsolute(Coordinate.NUL)[0].x;
|
||||
|
||||
// Check for lengthwise discontinuity
|
||||
if (x > componentX + 0.0001) {
|
||||
if (!MathUtil.equals(radius, 0)) {
|
||||
warnings.add(Warning.DISCONTINUITY);
|
||||
radius = 0;
|
||||
}
|
||||
}
|
||||
componentX = component.toAbsolute(new Coordinate(component.getLength()))[0].x;
|
||||
|
||||
// Check for radius discontinuity
|
||||
if (!MathUtil.equals(sym.getForeRadius(), radius)) {
|
||||
warnings.add(Warning.DISCONTINUITY);
|
||||
// TODO: MEDIUM: Apply correction to values to cp and to map
|
||||
}
|
||||
radius = sym.getAftRadius();
|
||||
}
|
||||
|
||||
// Call calculation method
|
||||
forces.zero();
|
||||
|
||||
@ -28,6 +28,7 @@ public class MassCalculator implements Monitorable {
|
||||
public Coordinate getCG(Motor motor) {
|
||||
return Coordinate.NUL;
|
||||
}
|
||||
|
||||
},
|
||||
LAUNCH_MASS {
|
||||
@Override
|
||||
@ -43,6 +44,25 @@ public class MassCalculator implements Monitorable {
|
||||
};
|
||||
|
||||
public abstract Coordinate getCG(Motor motor);
|
||||
|
||||
/**
|
||||
* Compute the cg contribution of the motor relative to the rocket's coordinates
|
||||
*
|
||||
* @param motorConfig
|
||||
* @return
|
||||
*/
|
||||
public Coordinate getCG(MotorConfiguration motorConfig) {
|
||||
Coordinate cg = getCG(motorConfig.getMotor());
|
||||
cg = cg.add(motorConfig.getPosition());
|
||||
|
||||
RocketComponent motorMount = (RocketComponent) motorConfig.getMount();
|
||||
Coordinate totalCG = new Coordinate();
|
||||
for (Coordinate cord : motorMount.toAbsolute(cg) ) {
|
||||
totalCG = totalCG.average(cord);
|
||||
}
|
||||
|
||||
return totalCG;
|
||||
}
|
||||
}
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MassCalculator.class);
|
||||
@ -152,6 +172,12 @@ public class MassCalculator implements Monitorable {
|
||||
// a *bit* hacky :P
|
||||
Coordinate curMotorCM = localCM.setX( localCM.x + locations[0].x + motorXPosition );
|
||||
|
||||
// alternate version:
|
||||
// double Ir = inst.getRotationalInertia();
|
||||
// double It = inst.getLongitudinalInertia();
|
||||
// +
|
||||
// + Coordinate curMotorCM = type.getCG(inst);
|
||||
|
||||
double motorMass = curMotorCM.weight;
|
||||
double Ir_single = mtrConfig.getUnitRotationalInertia()*motorMass;
|
||||
double It_single = mtrConfig.getUnitLongitudinalInertia()*motorMass;
|
||||
|
||||
@ -23,7 +23,6 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
|
||||
protected boolean ignitionOveride = false;
|
||||
protected double ignitionDelay = 0.0;
|
||||
protected IgnitionEvent ignitionEvent = IgnitionEvent.NEVER;
|
||||
protected double ignitionTime = 0.0;
|
||||
|
||||
protected int modID = 0;
|
||||
|
||||
@ -43,13 +42,11 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
|
||||
public MotorState getSimulationState() {
|
||||
MotorState state = motor.getNewInstance();
|
||||
if( ignitionOveride ) {
|
||||
state.setIgnitionTime( this.ignitionTime );
|
||||
state.setIgnitionEvent( this.ignitionEvent );
|
||||
state.setIgnitionDelay( this.ignitionDelay );
|
||||
state.setEjectionDelay( this.ejectionDelay );
|
||||
} else {
|
||||
MotorConfiguration defInstance = mount.getDefaultMotorInstance();
|
||||
state.setIgnitionTime( defInstance.ignitionTime );
|
||||
state.setIgnitionEvent( defInstance.ignitionEvent );
|
||||
state.setIgnitionDelay( defInstance.ignitionDelay );
|
||||
state.setEjectionDelay( defInstance.ejectionDelay );
|
||||
@ -110,20 +107,10 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
|
||||
return mount.getLength() - motor.getLength() + mount.getMotorOverhang();
|
||||
}
|
||||
|
||||
public double getIgnitionTime() {
|
||||
return this.ignitionTime;
|
||||
}
|
||||
|
||||
public void useDefaultIgnition() {
|
||||
this.ignitionOveride = false;
|
||||
}
|
||||
|
||||
public void setIgnitionTime(double _time) {
|
||||
this.ignitionTime = _time;
|
||||
this.ignitionOveride = true;
|
||||
modID++;
|
||||
}
|
||||
|
||||
public double getIgnitionDelay() {
|
||||
return this.ignitionDelay;
|
||||
}
|
||||
@ -212,7 +199,6 @@ public class MotorConfiguration implements FlightConfigurableParameter<MotorConf
|
||||
clone.ignitionOveride = this.ignitionOveride;
|
||||
clone.ignitionDelay = this.ignitionDelay;
|
||||
clone.ignitionEvent = this.ignitionEvent;
|
||||
clone.ignitionTime = this.ignitionTime;
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
||||
@ -164,6 +164,7 @@ public class FlightEvent implements Comparable<FlightEvent> {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "FlightEvent[type=" + type.name() + ",time=" + time + ",source=" + source + "]";
|
||||
return "FlightEvent[type=" + type.name() + ",time=" + time + ",source=" + source + ",data=" + String.valueOf(data) + "]";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -432,23 +432,6 @@ public class TestRockets {
|
||||
return rocket;
|
||||
}
|
||||
|
||||
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
||||
public static final MotorConfiguration getTestD12Motor() {
|
||||
// Estes D12:
|
||||
// http://nar.org/SandT/pdf/Estes/D12.pdf
|
||||
ThrustCurveMotor motor = new ThrustCurveMotor(
|
||||
Manufacturer.getManufacturer("Estes"),
|
||||
"D12-X", "Test Motor", Motor.Type.SINGLE, new double[] {0,3,5,7},
|
||||
0.024, 0.07, new double[] { 0, 1, 2 }, new double[] { 0, 10.2, 0 },
|
||||
new Coordinate[] { new Coordinate(0.0035,0,0,44.0),
|
||||
new Coordinate(0.0035,0,0,30.0),
|
||||
new Coordinate(0.0035,0,0,21.0)},
|
||||
"digest_D12");
|
||||
MotorConfiguration inst = new MotorConfiguration(motor);
|
||||
inst.setEjectionDelay(5);
|
||||
return inst;
|
||||
}
|
||||
|
||||
public static Rocket makeSmallFlyable() {
|
||||
double noseconeLength = 0.10, noseconeRadius = 0.01;
|
||||
double bodytubeLength = 0.20, bodytubeRadius = 0.01, bodytubeThickness = 0.001;
|
||||
|
||||
@ -11,11 +11,8 @@ import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
|
||||
import net.sf.openrocket.ServicesForTesting;
|
||||
import net.sf.openrocket.motor.MotorConfiguration;
|
||||
import net.sf.openrocket.plugin.PluginModule;
|
||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||
import net.sf.openrocket.rocketcomponent.InnerTube;
|
||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
@ -64,16 +61,10 @@ public class BarrowmanCalculatorTest {
|
||||
public void testCPSimpleWithMotor() {
|
||||
Rocket rkt = TestRockets.makeEstesAlphaIII();
|
||||
FlightConfiguration config = rkt.getSelectedConfiguration();
|
||||
FlightConfigurationId fcid = config.getFlightConfigurationID();
|
||||
AerodynamicCalculator calc = new BarrowmanCalculator();
|
||||
FlightConditions conditions = new FlightConditions(config);
|
||||
WarningSet warnings = new WarningSet();
|
||||
|
||||
MotorConfiguration inst = TestRockets.getTestD12Motor();
|
||||
InnerTube motorTube = (InnerTube)rkt.getChild(0).getChild(1).getChild(1);
|
||||
motorTube.setMotorInstance(fcid, inst);
|
||||
motorTube.setMotorMount(true);
|
||||
motorTube.setMotorOverhang(0.005);
|
||||
|
||||
// calculated from OpenRocket 15.03
|
||||
double expCPx = 0.225; // cm
|
||||
|
||||
@ -55,9 +55,10 @@ import net.sf.openrocket.gui.util.GUIUtil;
|
||||
import net.sf.openrocket.l10n.Translator;
|
||||
import net.sf.openrocket.masscalc.MassCalculator;
|
||||
import net.sf.openrocket.masscalc.MassCalculator.MassCalcType;
|
||||
import net.sf.openrocket.motor.MotorConfiguration;
|
||||
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||
import net.sf.openrocket.rocketcomponent.FinSet;
|
||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
@ -85,11 +86,10 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
||||
private final ColumnTableModel dragTableModel;
|
||||
private final ColumnTableModel rollTableModel;
|
||||
|
||||
private final JList warningList;
|
||||
private final JList<Object> warningList;
|
||||
|
||||
|
||||
private final List<AerodynamicForces> cpData = new ArrayList<AerodynamicForces>();
|
||||
private final List<Coordinate> cgData = new ArrayList<Coordinate>();
|
||||
private final List<Object[]> cgData = new ArrayList<Object[]>();
|
||||
private final List<AerodynamicForces> dragData = new ArrayList<AerodynamicForces>();
|
||||
private double totalCD = 0;
|
||||
private final List<AerodynamicForces> rollData = new ArrayList<AerodynamicForces>();
|
||||
@ -102,7 +102,7 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
||||
|
||||
JTable table;
|
||||
|
||||
JPanel panel = new JPanel(new MigLayout("fill", "[][35lp::][fill][fill]"));
|
||||
JPanel panel = new JPanel(new MigLayout("fill"));
|
||||
add(panel);
|
||||
|
||||
this.configuration = rocketPanel.getConfiguration();
|
||||
@ -144,7 +144,7 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
||||
panel.add(worstToggle, "");
|
||||
|
||||
|
||||
warningList = new JList();
|
||||
warningList = new JList<>();
|
||||
JScrollPane scrollPane = new JScrollPane(warningList);
|
||||
////Warnings:
|
||||
scrollPane.setBorder(BorderFactory.createTitledBorder(trans.get("componentanalysisdlg.TitledBorder.warnings")));
|
||||
@ -164,7 +164,7 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
||||
panel.add(new JLabel(trans.get("componentanalysisdlg.lbl.rollrate")), "width 120lp!");
|
||||
panel.add(new UnitSelector(roll, true), "width 50lp!");
|
||||
panel.add(new BasicSlider(roll.getSliderModel(-20 * 2 * Math.PI, 20 * 2 * Math.PI)),
|
||||
"growx, wrap paragraph");
|
||||
"growx, wrap");
|
||||
|
||||
|
||||
// Stage and motor selection:
|
||||
@ -194,7 +194,7 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
||||
new Column(trans.get("componentanalysisdlg.TabStability.Col.Component")) {
|
||||
@Override
|
||||
public Object getValueAt(int row) {
|
||||
RocketComponent c = cpData.get(row).getComponent();
|
||||
Object c = cgData.get(row)[0];
|
||||
if (c instanceof Rocket) {
|
||||
return trans.get("componentanalysisdlg.TOTAL");
|
||||
}
|
||||
@ -211,7 +211,11 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int row) {
|
||||
return unit.toString(cgData.get(row).x);
|
||||
Coordinate cg = (Coordinate) cgData.get(row)[1];
|
||||
if ( cg == null ) {
|
||||
return null;
|
||||
}
|
||||
return unit.toString(cg.x);
|
||||
}
|
||||
},
|
||||
new Column(trans.get("componentanalysisdlg.TabStability.Col.Mass") + " / " + UnitGroup.UNITS_MASS.getDefaultUnit().getUnit()) {
|
||||
@ -219,7 +223,11 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int row) {
|
||||
return unit.toString(cgData.get(row).weight);
|
||||
Coordinate cg = (Coordinate) cgData.get(row)[1];
|
||||
if ( cg == null ) {
|
||||
return null;
|
||||
}
|
||||
return unit.toString(cg.weight);
|
||||
}
|
||||
},
|
||||
new Column(trans.get("componentanalysisdlg.TabStability.Col.CP") + " / " + UnitGroup.UNITS_LENGTH.getDefaultUnit().getUnit()) {
|
||||
@ -227,22 +235,36 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int row) {
|
||||
return unit.toString(cpData.get(row).getCP().x);
|
||||
AerodynamicForces forces = (AerodynamicForces) cgData.get(row)[2];
|
||||
if ( forces == null ) {
|
||||
return null;
|
||||
}
|
||||
return unit.toString(forces.getCP().x);
|
||||
}
|
||||
},
|
||||
new Column("<html>C<sub>N<sub>" + ALPHA + "</sub></sub>") {
|
||||
@Override
|
||||
public Object getValueAt(int row) {
|
||||
return NOUNIT.toString(cpData.get(row).getCP().weight);
|
||||
AerodynamicForces forces = (AerodynamicForces) cgData.get(row)[2];
|
||||
if ( forces == null ) {
|
||||
return null;
|
||||
}
|
||||
return NOUNIT.toString(forces.getCP().weight);
|
||||
}
|
||||
}
|
||||
|
||||
) {
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return cpData.size();
|
||||
}
|
||||
};
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return cgData.size();
|
||||
}
|
||||
};
|
||||
|
||||
table = new ColumnTable(cpTableModel);
|
||||
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
@ -310,11 +332,16 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
||||
}
|
||||
}
|
||||
) {
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return dragData.size();
|
||||
}
|
||||
};
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return dragData.size();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
table = new JTable(dragTableModel);
|
||||
@ -372,18 +399,23 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
||||
}
|
||||
}
|
||||
) {
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return rollData.size();
|
||||
}
|
||||
};
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return rollData.size();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
table = new JTable(rollTableModel);
|
||||
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
||||
table.setSelectionBackground(Color.LIGHT_GRAY);
|
||||
table.setSelectionForeground(Color.BLACK);
|
||||
rollTableModel.setColumnWidths(table.getColumnModel());
|
||||
table.setDefaultRenderer(Object.class, new CustomCellRenderer());
|
||||
|
||||
scrollpane = new JScrollPane(table);
|
||||
scrollpane.setPreferredSize(new Dimension(600, 200));
|
||||
@ -467,7 +499,7 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
||||
ComponentAnalysisDialog.this.dispose();
|
||||
}
|
||||
});
|
||||
panel.add(button, "span, split, tag cancel");
|
||||
panel.add(button, "span, tag cancel");
|
||||
|
||||
|
||||
this.setLocationByPlatform(true);
|
||||
@ -508,20 +540,28 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
||||
massCalculator.getCGAnalysis(configuration, MassCalcType.LAUNCH_MASS);
|
||||
|
||||
|
||||
cpData.clear();
|
||||
cgData.clear();
|
||||
dragData.clear();
|
||||
rollData.clear();
|
||||
for (RocketComponent c : configuration.getActiveComponents()) {
|
||||
forces = aeroData.get(c);
|
||||
Coordinate cg = massData.get(c);
|
||||
|
||||
if (forces == null)
|
||||
if ( c instanceof AxialStage ) {
|
||||
continue;
|
||||
if (forces.getCP() != null) {
|
||||
cpData.add(forces);
|
||||
cgData.add(cg);
|
||||
}
|
||||
Object[] data = new Object[3];
|
||||
cgData.add(data);
|
||||
data[0] = c;
|
||||
|
||||
Coordinate cg = massData.get(c);
|
||||
data[1] = cg;
|
||||
|
||||
forces = aeroData.get(c);
|
||||
if (forces == null) {
|
||||
continue;
|
||||
}
|
||||
if (forces.getCP() != null) {
|
||||
data[2] = forces;
|
||||
}
|
||||
|
||||
if (!Double.isNaN(forces.getCD())) {
|
||||
dragData.add(forces);
|
||||
}
|
||||
@ -529,10 +569,23 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
||||
rollData.add(forces);
|
||||
}
|
||||
}
|
||||
|
||||
for ( MotorConfiguration motorConfig : configuration.getActiveMotors()) {
|
||||
|
||||
Object [] data = new Object[3];
|
||||
cgData.add(data);
|
||||
|
||||
data[0] = motorConfig.getMotor().getDesignation();
|
||||
data[1] = MassCalcType.LAUNCH_MASS.getCG(motorConfig);
|
||||
}
|
||||
|
||||
forces = aeroData.get(configuration.getRocket());
|
||||
if (forces != null) {
|
||||
cpData.add(forces);
|
||||
cgData.add(massData.get(configuration.getRocket()));
|
||||
Object[] data = new Object[3];
|
||||
cgData.add(data);
|
||||
data[0] = configuration.getRocket();
|
||||
data[1] = massData.get(configuration.getRocket());
|
||||
data[2] = forces;
|
||||
dragData.add(forces);
|
||||
rollData.add(forces);
|
||||
totalCD = forces.getCD();
|
||||
@ -556,6 +609,10 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
||||
|
||||
|
||||
private class CustomCellRenderer extends JLabel implements TableCellRenderer {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final Font normalFont;
|
||||
private final Font boldFont;
|
||||
|
||||
@ -569,12 +626,12 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
||||
public Component getTableCellRendererComponent(JTable table, Object value,
|
||||
boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
|
||||
this.setText(value.toString());
|
||||
this.setText(value == null ? null : value.toString());
|
||||
|
||||
if ((row < 0) || (row >= cpData.size()))
|
||||
if ((row < 0) || (row >= cgData.size()))
|
||||
return this;
|
||||
|
||||
if (cpData.get(row).getComponent() instanceof Rocket) {
|
||||
if (cgData.get(row)[0] instanceof Rocket) {
|
||||
this.setFont(boldFont);
|
||||
} else {
|
||||
this.setFont(normalFont);
|
||||
@ -586,6 +643,10 @@ public class ComponentAnalysisDialog extends JDialog implements StateChangeListe
|
||||
|
||||
|
||||
private class DragCellRenderer extends JLabel implements TableCellRenderer {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final Font normalFont;
|
||||
private final Font boldFont;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user