mars-sim / mars-sim

Mars Simulation Project Official Codebase
https://mars-sim.com
GNU General Public License v3.0
107 stars 38 forks source link

Orbit Viewer cannot display from the view point of Mars #387

Closed mokun closed 11 months ago

mokun commented 3 years ago

Describe the bug

Expected behavior

Screenshots image

Desktop (please complete the following information):

Additional context

mokun commented 3 years ago

@larsnaesbye

You are now our astrophysic guru and can you figure out what went wrong with those two comboboxes and how to fix them ?

I don't know how.

mokun commented 3 years ago

This is another spinoff of the original JPL orbit viewer.

mokun commented 3 years ago

JPL also updated their app to be able to load on their website.

bevans2000 commented 3 years ago

I didn't even know the simulation had an OrbitViewer

larsnaesbye commented 3 years ago

@larsnaesbye

You are now our astrophysic guru and can you figure out what went wrong with those two comboboxes and how to fix them ?

I don't know how.

Haha! I'm not an astrophysics guru but just a regular IT guy who happens to work now with satellite data. My colleague's an astrophysicist, though, but I don't think I can bother him with non-work related stuff :-)

larsnaesbye commented 3 years ago

That being said, I'd like to take a look at this problem.

mokun commented 3 years ago

@larsnaesbye You are now our astrophysic guru and can you figure out what went wrong with those two comboboxes and how to fix them ? I don't know how.

Haha! I'm not an astrophysics guru but just a regular IT guy who happens to work now with satellite data. My colleague's an astrophysicist, though, but I don't think I can bother him with non-work related stuff :-)

ok. at least you work with them daily and i imagine their excess expertise would easily spill onto you :D

mokun commented 3 years ago

I didn't even know the simulation had an OrbitViewer

Yea. Clicking the telescope button on the bottom right would open the OrbitViewer as a JInternalFrame inside the main window.

image

larsnaesbye commented 3 years ago

There are some comparisons I don't understand, for example:

                for (int i = 0; i < timeStepCount; i++) {
                    if ((String)(source.getName()) == timeStepLabel[i]) {
                        timeStep = timeStepSpan[i];
                        break;
                    }
                }

In Java, String is an object, so when you compare using == you compare object references, not contents. This is most often not what you want as since two created Strings have different object references even if you give them identical content.

String.equals(String) compares contents instead, and it seems like many of the comparisons in actionPerformed should use it instead. This might populate the location and orbit arrays correctly(?).

larsnaesbye commented 3 years ago

@mokun

ok. at least you work with them daily and i imagine their excess expertise would easily spill onto you :D

I hope so. Right now I'm mostly fixing scripts to process RINEX files and some data extraction.

larsnaesbye commented 3 years ago

Did it work? I must admit I didn't test it myself.

mokun commented 3 years ago

Did it work? I must admit I didn't test it myself.

I wish it did. Now it's throwing NPE

image

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at org.mars_sim.msp.ui.astroarts.OrbitViewer.actionPerformed(OrbitViewer.java:1144)
    at java.desktop/javax.swing.JComboBox.fireActionEvent(JComboBox.java:1264)
    at java.desktop/javax.swing.JComboBox.contentsChanged(JComboBox.java:1337)
    at java.desktop/javax.swing.AbstractListModel.fireContentsChanged(AbstractListModel.java:123)
    at java.desktop/javax.swing.DefaultComboBoxModel.setSelectedItem(DefaultComboBoxModel.java:94)
    at java.desktop/javax.swing.DefaultComboBoxModel.addElement(DefaultComboBoxModel.java:132)
    at java.desktop/javax.swing.JComboBox.addItem(JComboBox.java:716)
    at org.mars_sim.msp.ui.astroarts.OrbitViewer.createGUI(OrbitViewer.java:667)
    at org.mars_sim.msp.ui.astroarts.OrbitViewer.<init>(OrbitViewer.java:279)
    at org.mars_sim.msp.ui.swing.MainWindow.openOrbitViewer(MainWindow.java:794)
    at org.mars_sim.msp.ui.swing.MainWindow$6.actionPerformed(MainWindow.java:825)
    at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
    at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2308)
    at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:405)
    at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
    at com.alee.laf.button.WButtonInputListener.mouseReleased(WButtonInputListener.java:248)
    at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
    at java.desktop/java.awt.Component.processMouseEvent(Component.java:6635)
    at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3342)
    at java.desktop/java.awt.Component.processEvent(Component.java:6400)
    at java.desktop/java.awt.Container.processEvent(Container.java:2263)
    at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5011)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
    at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
    at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
    at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
    at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2772)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4843)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:772)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
    at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
    at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:743)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
larsnaesbye commented 3 years ago

I can't even open the OrbitViewer by pressing the icon. Nothing happens.

mokun commented 3 years ago

I can't even open the OrbitViewer by pressing the icon. Nothing happens.

I suppose you use linux. Wonder why it behaves this way.

So far, I only tested it on Windows OS.

Next I'll test it in macOS to see what happens.

mokun commented 3 years ago

@larsnaesbye

I just figured out why the comboboxes don't work.

I have wanted to see what the orbit looks like from Mars perspective. But the way the code does is simply moving the planet of choice to (0,0,0) and that' it.

Doing the commit now.

mokun commented 3 years ago

@larsnaesbye , @bevans2000

Can we discuss how we may use this orbit viewer for something more practical in mars-sim ?

I still have a high hope for making use of this orbit viewer.

May be we can use the orbit viewer in the Resupply Tool to decide how long and how much distance a resupply mission will need ?

Visualizing the orbital picture of the trajectory of incoming settlers or any departing settlers to return home and etc. for sure very nice addition.

We sure need more good looking front end UI elements for player to react with the simulation.

mokun commented 3 years ago

@larsnaesbye. Please see this NASA webpage.

https://www.nasa.gov/feature/jpl/nasa-study-highlights-importance-of-surface-shadows-in-moon-water-puzzle

On the third picture box, there's this draggable 3D moon and with lines or orbits. It would be cool for us to visualize things like this.

I know it's hard to do anything with Swing. This makes me think of wanting to try JavaFX again in mars-sim, or embedding Javascript in mars-sim.

Thought, we did come up with a JavaFX 3D Mars Globe main menu in the past, the fusion of Swing and JavaFX had been proven quite difficult.

larsnaesbye commented 3 years ago

For orbits we just need the orbital parameters. Trajectories....hmmm... do we want to simulate a spinning Earth, a spinning Mars and then make advanced calculations of a supply mission launched from a particular place on Earth (Baikonur, Kourou, Cape Canaveral...) towards a designated landing spot on Mars? That is complex.

mokun commented 3 years ago

For orbits we just need the orbital parameters. Trajectories....hmmm... do we want to simulate a spinning Earth, a spinning Mars and then make advanced calculations of a supply mission launched from a particular place on Earth (Baikonur, Kourou, Cape Canaveral...) towards a designated landing spot on Mars? That is complex.

Yes I'd love to but one step at a time no doubt :).

I'm closing this thread now. We can start a new thread in future for a spinning Mars. And we would need to switch back to JavaFX in order to implement it.

Hope the old JavaFX we used to have had been resolved after they open sourced it.

mokun commented 1 year ago

I've just rearranged the control buttons to look better.

Also, I've made the zoom level to go to the level in which the space between the orbit of Mars and the orbit of Earth is clearly shown. See below :

image

If we put in some more work, in future, we should be able to plot out the trajectories of any space vehicles between Earth and Mars.

mokun commented 1 year ago

@larsnaesbye @Urwumpe @bevans2000

Note that the mouse scroll is now working to zoom in and out of the solar system.

The left/right button dragging is working but there's a chance that when I drag too much and too fast in flipping it upsides down and downside up many times, it can crash. I haven't figured out a way to recover it when that happens.

Any suggestions on how to prevent that from happening ?

mokun commented 1 year ago

Just rework the DateDialog to improve clarity as follows :

image

mokun commented 11 months ago

So far, the solar system is still drawn with our Sun at the center.

At least we've fixed some major lingering bugs and enable a closed up view of Mars on an orbit around the sun. . It may be difficult to change the reference frame to having Mars at the center since it will involve retrograde movements of earth and other planets.

Closing this thread now. Over and out.