Openrocket: Adding a simulation listener= ?????

The Rocketry Forum

Help Support The Rocketry Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

surfinbird

Member
Joined
Mar 3, 2013
Messages
14
Reaction score
0
How does one add a simulation listener? Do you need to compile the project entirely? (What main class does it use? Eclipse is a nightmare)

The wiki says nothing

Using simulation listeners requires basic (HAAAHAHAH) Java knowledge and knowing how to use the command line. (Wich one? Windows command line? what do you write in it?)

Implement the simulation listener in Java. (writing it)
Compile the Java class file. (the simulation listener? the net.sf.openrocket.simulation.listeners.example? into a .jar file? a runnable jar file?)
Start OpenRocket and include the class file in the classpath. (What classpath? How do you load a class into openrocket's file?)
Add the simulation listener to a simulation and run the simulation. (might as well be the moon)

Java is just horrible.

BTW:
https://openrocket.svn.sourceforge....listeners/SimulationListener.java?view=markup
Its broken
 
Last edited:
I haven't done it myself so far, but the instructions in the Wiki look like a good start to me (disclaimer: I know next to nothing about Java).

First, I assume you have already read this:
https://sourceforge.net/apps/mediawiki/openrocket/index.php?title=Simulation_Listeners

If you haven't already installed the Java JDK (not just the JRE), install it. I believe it is either advisable or even necessary to use the x86 version (but I could be wrong). Restart the computer for the path changes to take effect (logout and login should work too).


How does one add a simulation listener? Do you need to compile the project entirely? (What main class does it use? Eclipse is a nightmare)
According to the instructions, you don't need to compile OR, only the listener. You don't need Eclipse for this either. A text editor is sufficient (I like to use notepad++ for little tasks that don't warrant an IDE).

The wiki says nothing
Pretty much everything I write here, is at least partly based on the wiki. ;-)

(Wich one? Windows command line? what do you write in it?)
Windows command line. See the examples in the wiki. The two commands starting with "java" or "javac".

Start OpenRocket and include the class file in the classpath. (What classpath? How do you load a class into openrocket's file?)
Just use the commands as described in the wiki. If you want to learn more, google will give you lots of results when you look for "java classpath".

Add the simulation listener to a simulation and run the simulation. (might as well be the moon)
Set the instructions further down in the wiki.

Java is just horrible. As if the syntax was not bad enough; the entire way it works is a nightmare.
We could discuss what the the best programming language is, but I'm afraid that this is not possible on TRF as long as the "no religion" rule is in effect. ;-)

Here you go:
https://openrocket.svn.sourceforge....listeners/SimulationListener.java?view=markup


Reinhard
 
Hi,

Like Reinhard already pointed out, the basics are in the wiki. If there's something unclear in specific, we can hopefully clarify that in the wiki.

I definitely admit that the simulation listeners are currently not very user-friendly, and you need some Java knowledge and an understanding of the classpath and how to set it. I'm hoping on making simulation listeners easier to use in the future when I get a plugin system into OR. It won't make them dramatically simpler to write, but easier to install and use. At some point bindings to scripting languages might be implemented as well, allowing you to write simulation listeners within OR.

As a point of example, I've simulated our active roll control system in OR, first having the whole logic in Java, and later so that it fed the measurement readings over a serial link to the actual flight computer, which sent servo commands back into the simulation. (And I found several critical bugs in the controller code in the process.)

However if you're simulating fin control, be warned that the fin cant aerodynamic computations in OR are not designed for such a purpose and may in some cases be considerably off (even by a factor of 2 or more). You can probably get ball-park estimations, but for proper simulation you should figure out the aerodynamic properties of your control fins and plug that in directly as corrections to the aerodynamic computation, instead of changing the fin cant and relying on OR to compute the correct aerodynamics. If you need I can provide some references to such material.

Cheers,
Sampo N.
 
Hello!
Wow thank you a lot for the feedback. Yes, i am a bit biased against Java for now; i've ran into it in minecraft first now this; i can't say i like how it's designed. But that's just a personal distaste. I have no Java experience but as a rocksim addict ever wanting more i began to seriously look into modifying OR to have it able to simulate guided rockets. I will definitely look into a simpler java project to gain experience then collaborate. But i've managed to frankenstein the roll control to a level where i want to test it. I really have no idea what i'm doing regarding Java; perhaps i will look into a bridge to a python code much like the offboard flight computer.

... i also see i might have overlooked a few important lines. Damnit. Thank you very much for the information Sampo, this is a great project by the way and in no way should my criticism of java be equated to criticism of OR; i think it is a great program. Your experience is pretty interesting. I will try my code (wich is very ugly, basically a reworked roll control) and see what kind of control i get. I think the ballpark estimates for a generally pleasing result should be correct; once the basic control is implemented more accurate force control can be replaced. I will look into this and i would appreciate those references, please do!

Basically my ideal would be an OR where one could stick a control mechanism to any rocket and have a simple scripting language controlling an autopilot. An option would make it simple to switch between a simple java autopilot or an offboard serially/IPC controlled one. As well as other modes of control besides fins such as RCS and thrust vectoring (just throwing ideas out here). Basically make it compete with RocksimPro and able to simulate to a satisfactory level anything from a 3in model rocket to a Satellite Launch Vehicle or a jet-powered drone. Buyer beware that a free java program made for a PC might not be the best platform for a super-accurate supersonic/hypersonic research/design flight simulation; that's pretty obvious. But it is still very entertaining.

Thank you immensely.

Edit: Sooo i can't create the class of my listener because of 31 errors i don't understand. It's... ugh. Maybe ill just pastebin what i have. It's a stupidly simple pitch control i intend just for testing. https://pastebin.com/MgTvGb4s Eclipse gives me no java errors; i really have no idea what is wrong, what i am doing, or the reason behind having to learn classpaths. I just want to make openrocket see the file and include it in the simulator.. Im getting an error in command line anyway

C:\Users\REN\Downloads>java -cp OpenRocket-1.1.6.jar:. net.sf.openrocket.startup.Startup
Error: Could not find or load main class net.sf.openrocket.startup.Startup

I am clearly not qualified for this...
 
Last edited:
Hi,

I quickly checked your code and updated it. It also seems that the documentation is a bit out-of-date, sorry about that. I recommend using version 12.03 (available https://sourceforge.net/projects/openrocket/files/openrocket/12.03/)

The new version is here: https://pastebin.com/ag2r9zzZ

Compiling and running:

javac -cp OpenRocket-12.03.jar PitchYawControlListener.java
java -cp OpenRocket-12.03.jar:. net.sf.openrocket.startup.Startup

Then add "PitchYawControlListener" in the Simulation options tab. I didn't have time to test the controller itself.

If you're serious in aerodynamics, I recommend Hoerner's Fluid-Dynamic Drag and Fluid-Dynamic Lift. They're compendia gathering all known aerodynamic experimental data along with theory and experimental equations for them. Though published half a decade ago, there is little basic aerodynamics that hadn't been studied by then. For example in our latest roll control experiment we had a control flap which was a portion of one of the main fins. There's direct data on what the lift due to the flap is relative to the lift of the entire fin, based on the relative size of the flap.

Cheers,
Sampo N.

(I'll be away for the weekend and may not be able to respond during that time.)
 
Last edited:
Alright; i have tried and now the command line works! Everything compiles sucessfully. However openrocket dosen't ever see the class/listener; whatever i put in the "enter listener class name" box wether it be the name, the path to it, anything; always a ClassNotFoundException after a long list of every possible combination of names and locations.

I will check the compendia you're talking about and try to acquire it. I will also try and figure out what i forgot this time.

Cheers
 
Hi,

Make sure you've got OpenRocket-12.03.jar and PitchYawControlListener.class in your current directory, and make sure you have the -cp parameter correct when starting OR. (The significant part is :. which tells it to look for class files in the current directory as well as the JAR file.)

Cheers,
Sampo N.
 
If you're using Windows, use a semicolon instead of a colon as the path separator in the classpath. (':' if you're using Linux/Mac OSX)

java -cp OpenRocket-12.03.jar;. net.sf.openrocket.startup.Startup

Doug
 
YES! THANK YOU DOUG! That was the problem!! Now i can really get to the interesting part.
 
Sorry for the double post; but
I'm trying to find out how to get these parameters
//// Orientation (This is Pitch and Yaw in other words?)
//// Vertical orientation (zenith)
public static final FlightDataType TYPE_ORIENTATION_THETA = newType(trans.get("FlightDataType.TYPE_ORIENTATION_THETA"), "\u0398", UnitGroup.UNITS_ANGLE, 106);
//// Lateral orientation (azimuth)
public static final FlightDataType TYPE_ORIENTATION_PHI = newType(trans.get("FlightDataType.TYPE_ORIENTATION_PHI"), "\u03a6", UnitGroup.UNITS_ANGLE, 107);

to reference them like this; so i can use it for the PID. FlightConditions has a getPitchRate function.. but no getPitch function. I have looked in every file imported but i have found nothing referencing pitch and yaw; where do these end up? Where is the pitchrate added to the pitch? It's VERY deep hidden
@Override
public FlightConditions postFlightConditions(SimulationStatus status, FlightConditions flightConditions) {
// Store the current pitch rate for later use
pitchrate = flightConditions.getPitchRate();
return null;
}
I understand i'm in uncharted territory so yeah.
Thanks a lot.

On the side; why dosen't OR have it's own forum? It certainly deserves one.
 
Last edited:
Hi,

I concur that you're in uncharted territory...

The FlightConditions object contains the momentary state of a rocket, as used in aerodynamic computations. It doesn't contain the whole rocket state such as position or acceleration, since those don't have any effect on the momentary aerodynamics.

The orientation of the rocket is not stored as Euler angles (pitch/yaw/roll) during simulation since those have singularity points that are computationally problematic. Instead the orientation is stored as a unit quaternion in SimulationStatus.getRocketOrientationQuaternion(). For more information on the internals, refer to the technical documentation on the web site.

That said, the Euler angles are computed from the quaternion for each simulation time step and stored in the results. You can access this from a simulation listener using SimulationStatus.getFlightData().get(FlightDataType.TYPE_ORIENTATION_THETA) (zenith angle) and TYPE_ORIENTATION_PHI (azimuth angle). They're named zenith/azimuth since there's no universally acknowledged / user-understandable Euler angles for rockets.

Alternatively you can convert from the quaternion yourself. The code that does that is in RK4SimulationStepper.storeData.


This is an interesting project, so let us know how it progresses. The long-term goal is to make simulation listeners more accessible to advanced rocketeers, so it's good to get feedback on the good and bad things. But there's still a long way to go...


Cheers,
Sampo N.
 
Thank you very much! I have looked at Quaternions and hoped to find another way, it's very advanced math. I will try and implement SimulationStatus.getFlightData().get(FlightDataTyp e.TYPE_ORIENTATION_THETA) (zenith angle) and TYPE_ORIENTATION_PHI (azimuth angle) to have knowledge of the pitch for the autopilot.

But i have done many tests, reviewed the documentation as well as the code, and i think i have hit a problem. Pitching forces due to fins are not simulated. I have found also through simulation that deflecting the fins in parallel at maximum angle does not do a Newton of force on the rocket as compared to if the fins weren't canted.
 
Back
Top