SUBSIM Radio Room Forums



SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997

Go Back   SUBSIM Radio Room Forums > Silent Hunter 3 - 4 - 5 > SH5 Mods Workshop
Forget password? Reset here

Reply
 
Thread Tools Display Modes
Old 09-06-12, 05:09 AM   #1
dottore
Seaman
 
Join Date: Mar 2010
Location: Hungary
Posts: 32
Downloads: 138
Uploads: 0
Default Semi-automatic Celestial Navigation

Original don1reed: http://www.subsim.com/radioroom/show...llarium&page=2

Yesterday, based on the original idea of don1reed(Thank you sir!) I began to work on the semi-automatic CelNav to implement this nice function in Silent Hunter 5:

1. phase (Under development):

Using Python script to get the needed data from the only actual CampaignMission.mis file. Push this to the startup.ssc(The new Stellarium script extension) they made a whole new API so I needed to mine deep into.

2. phase (In the very near future):

After I made my celestial body inspects, Stars, Moon, Sun etc. I'd like to calculate my current pos with an application written in C# or B#.


Pros:
. You don't need to know your Current Pos, before you begin to calculate your Current Pos . That was funny .
. If you're not a navigator or a hobby astronomer yet you can enjoy the success with your CelOb inspects.
. You can navigate in bad weather too or even under water, but that's not realistic so not recommended.

Cons:
. You need some software: Stellarium above 0.11.3, The Python interpreter ( Future: automated install with everything, and batch file to execute) and my exe file from 2. phase (Required: Dotnetfx 2.0 or above).
. You need time, patience, and time Interest, if you want to navigate like a real navigator.

I use Python for data mine, because of it's talent in. Visual family from Microsoft is best for object-oriented programming (2. phase).

Software reqs:

.Python

.Stellarium 0.11.3 or above (if they change the programming language in the future, then I need some modification) Important: you need to configure config.ini, change timezone to UTC time and change display settings to best your system is capable.

Last edited by dottore; 09-06-12 at 08:09 PM. Reason: notes
dottore is offline   Reply With Quote
Old 09-06-12, 05:28 AM   #2
flostt
Sonar Guy
 
Join Date: Sep 2010
Location: Switzerland
Posts: 388
Downloads: 86
Uploads: 0
Default

have a look at this thread : http://www.subsim.com/radioroom/showthread.php?t=194033
__________________
Von den 40'000 deutschen U-Boot-Männern des Zweiten Weltkrieges kehrten 30'000 nicht zurück...
40’000 German sailors served on U-boats during World War II – 30’000 never returned home...
flostt is offline   Reply With Quote
Old 09-06-12, 05:52 AM   #3
dottore
Seaman
 
Join Date: Mar 2010
Location: Hungary
Posts: 32
Downloads: 138
Uploads: 0
Default

Thank you Flostt!

I read this thread before, I'm not a modder, but I think I can help Silent Marshal.

I'm eager to do this first written below and I am curious about your opinion. Are you interested? I just want to bring closer this thing to the ordinary people.
dottore is offline   Reply With Quote
Old 09-06-12, 05:30 PM   #4
dottore
Seaman
 
Join Date: Mar 2010
Location: Hungary
Posts: 32
Downloads: 138
Uploads: 0
1. phase

Progress:

Code:
import fileinput,string,sys,csv
def MakeFile(file_name):

     """
        MakeFile(file_name): makes a file.
     """

    temp_path = 'C:\\Python27\\' + file_name
    file = open(temp_path, 'w')
    file.write('')
    file.close()
    print 'Execution completed.'
MakeFile('my.active.uboat.data.txt')
                       #YourUsername                              #Your.ingame.name, Your Campaign date -> You need to modify this onetime per new patrol(working on an automated latest file copy paste)
f=open("C:\\Users\\*.*.*\\Documents\\SH5\\data\\Users\\*.*.*\\Campaign-2012-09-02_1721\\CampaignMission.mis",'r')
lookup = 'Name=U-'                                                              #changes here too
with open("C:\\Users\\*.*.*\\Documents\\SH5\\data\\Users\\*.*.*\\Campaign-2012-09-02_1721\\CampaignMission.mis",'r') as f:
    for num, line in enumerate(f, 1):
        if lookup in line:
                print 'found at line:', num
                nu=num
f.close()                                                                     #changes here too
with open("C:\\Users\\*.*.*\\Documents\\SH5\\data\\Users\\*.*.*\\Campaign-2012-09-02_1721\\CampaignMission.mis",'r') as f:
        g=open("c:\\Python27\\my.active.uboat.data.txt",'w')
        lines=f.readlines()
        for i in range(nu-1,nu+45):
                line = lines[i]
                line2 = g.writelines(line)
f.close()
g.close()
# longitude grab
lookup2 = 'Long='
with open("c:\\Python27\\my.active.uboat.data.txt",'r') as h:
        for long, line in enumerate(h, 1):
                if lookup2 in line:
                        long2=line
h.close()                        
long2.split('=')
longitude = long2.split('=')[1]
print longitude
# latitude grab
lookup3 = 'Lat='
with open("c:\\Python27\\my.active.uboat.data.txt",'r') as h:
        for long, line in enumerate(h, 1):
                if lookup3 in line:
                        lat2=line
h.close()                        
lat2.split('=')
latitude = lat2.split('=')[1]
print latitude

#stella=open("C:\\Program Files\\Stellarium\\scripts\\startup.ssc" ,'w') 
#stella.write("date utc "+date+"T"+time+":00\n")
#stella.write("moveto lon "+str(longi2)+"\n")
#stella.write("moveto lat "+str(lati2)+"\n")
#stella.write("script action end\n")
#stella.close()
With this initiation we can reduce our big CampaignMission.mis to show only the U-** data. This is essential, because we get rid of needless navigational data.

Everybody can use this script, because it finds the Uboat data ergo the Unit 1.

Results:

my.active.uboat.data.txt content:

Code:
Name=U-33
Class=SSTypeVIIA
Type=200
Origin=German
LayerOperation=0
Side=2
Commander=1
CargoExt=-1
CargoInt=-1
Doctrine=0
CfgDate=19400313
MainEquipment=1
SecondaryEquipment=1
DeleteOnLastWaypoint=false
DockedShip=false
IsEscort=false
GameEntryDate=19380101
GameEntryTime=0
GameExitDate=19451231
GameExitTime=0
EvolveFromEntryDate=false
Long=1322261.310968
Lat=6550443.292625
Height=-3.870683
IsFromSingleMis=true
Heading=69.006813
Speed=0.000000
CrewRating=3
DelayMin=0
ReportPosMin=-1
ReportPosProbability=100
SecondsUntilReport=-40100.000000
HighPrioContact=false
RandStartRadius=0.000000
In3D=true
TacticalUnit=false
AvailStartDate=19380101
AvailEndDate=19451231
TempHeading=0.000000
TempNextWP=0
CombatSubmarine2D=false
CombatRadius2D=30.000000
CommandedSpeed2D=0.000000
Num2DCombatKills=0
Intercept2DCooldown=6.000000
NextWP=1000000
Yes, I know we can grab the important data without this step, but this is double proof safety. You don't want to get an another unit's position only your boat.

Changes:
.Added code snippet so we have our latitude and longitude in decimal using the my.active.uboat.data.txt file.

Last edited by dottore; 09-06-12 at 07:26 PM. Reason: changes 1.2
dottore is offline   Reply With Quote
Old 09-06-12, 10:53 PM   #5
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

The ScriptManager exposes a function that one can call to get the player's position at anytime There's no need to do what you are doing...
TheDarkWraith is offline   Reply With Quote
Old 09-07-12, 10:03 AM   #6
dottore
Seaman
 
Join Date: Mar 2010
Location: Hungary
Posts: 32
Downloads: 138
Uploads: 0
Default

Thank you for your guide. That makes everything simpler.
dottore is offline   Reply With Quote
Old 09-08-12, 03:55 AM   #7
CaliEs
Loader
 
Join Date: Oct 2011
Posts: 89
Downloads: 27
Uploads: 0
Default

Quote:
Originally Posted by dottore View Post

2. phase (In the very near future):

After I made my celestial body inspects, Stars, Moon, Sun etc.
How do you "inspects" the celestial body in stellarium without getting pinpoint accuracy of the star's position? That is the most important question.
__________________
Dietrich von Carlewitz, 2nd Lt.
U-29
CaliEs is offline   Reply With Quote
Old 09-08-12, 04:32 PM   #8
dottore
Seaman
 
Join Date: Mar 2010
Location: Hungary
Posts: 32
Downloads: 138
Uploads: 0
Default

Maybe I used the "inspect", because of my limited English. I meant to click on the stars and write down the needed data.

If I correctly understand your question, I don't think about hardening the way to get star position. In this first step, I want it to work.

Your job is reduced to choose your navigation object's, note the needed data, give this to the app. I think about triangulation and square operation in this start. If you make more triangulation you get more precise position.

I think, but don't know, in IRL they used actual navigation star data books based on the latitudes, almanacs, sun moon charts. They calculated position's with boards. Today we use math based apps to get this job done.
-
We can limit our options in Stellarium if somebody understand the Stellarium programming language. But if you limit, you need a tool to extract this data.

Last edited by dottore; 09-08-12 at 07:49 PM. Reason: correction
dottore is offline   Reply With Quote
Old 09-08-12, 08:25 PM   #9
CaliEs
Loader
 
Join Date: Oct 2011
Posts: 89
Downloads: 27
Uploads: 0
Default

Quote:
Originally Posted by dottore View Post
Today we use math based apps to get this job done.
-
We can limit our options in Stellarium if somebody understand the Stellarium programming language. But if you limit, you need a tool to extract this data.
Tool for free the celestial navigator for android-handys.
Almanacs 39-45 and sight reduction tables are also availeable for free.

An option in stellarium could be:
if act wind_sh5 = 1 then FOView_Stellarium = max 80
if act wind_sh5 = 3 then FOView_Stellarium = max 75
if act wind_Sh5 = 6 then FOView_Stellarium = max 65
etc.
FOV-values in stellar. make the star-positioning more difficult/inaccurater
__________________
Dietrich von Carlewitz, 2nd Lt.
U-29
CaliEs is offline   Reply With Quote
Old 09-09-12, 02:15 AM   #10
dottore
Seaman
 
Join Date: Mar 2010
Location: Hungary
Posts: 32
Downloads: 138
Uploads: 0
Default 1. phase is done, but this is not the correct way...

Thank you CaliEs!

This will be very useful to refine the Stellarium options. Please note CaliEs' modifications one below to make the navigation more difficult.
-
Stellarium will show your ingame sky always as you execute, correct dates(read below).
Script is working, but read the information below. The script carries the navdata(your location, time) from mission files into the Stellarium's startup file automatically without user input.
You need to run the batch file, when you would like to see your sky in Stellarium.

If you feel lost, don't hesitate to contact me.

Download:
http://www.mediafire.com/?9swhqak15l9a502
Alt.download:
http://www.sendspace.com/file/i22sa1 (Click on below "Click here to start download from...")

Warning:
This is not the final scipt, because it needs user friendly modifications and using needless methods to get the navdata.

-

I don't know the game programming architecture so I need to study Ironpython to make navigational data pick the correct way from the game itself instead of using mission files and avoid text manipulation. So there will be an other script and this will be trashed.

The script is using brute string manipulations to make the job so I apologize.

It prints values, but don't need them. Their purpose is testing the success of data mine. It doesn't change any file in your install or in your user folder only grabbing data to the 2 txt files it creates.(date.txt, my.active.uboat.data.txt) If you want Backup your mission file, but the script only reads it.

Requirements:
Important install information:
You need to write your file paths, directory paths into the script before running it(don't use "find and replace" because script using \\ to describe paths). I marked the needed modifications. You need to do this only once except your mission file. If you go to a new patrol, you need to change it to point the new file.(This will be fixed later, to auto find your paths). If you make a new profile in the game, you have new folder, new mission file, so you must show the script the new file.

Needed applications:
Python 2.7 default paths in script: C:\Python27
Stellarium 0.11.4 or above (older Stellarium uses other language, so "no go!") default paths in script: C:\Program Files\Stellarium

Default path for .mis file:
C:\Users\This.is.your.name\Documents\SH5\data\User s\This.is.your.in.game.name\Campaign-This.is.your.date\CampaignMission.mis

Important changes in Stellarium config.ini:

Default path: C:\Users\This.is.your.name\AppData\Roaming\Stellar ium
Backup your config.ini.

Use your resolution from ingame in Stellarium, change the values:
[localization]
...
...
time_zone = GMT
.
Note: this is a req, without this your Stellarium will apply your GMT shift and mess up date.

[video]
...
...
screen_h = (Example: 1080)
screen_w = (Example: 1920)
.

You need the script and the python.exe in one folder, you run the whole with a batch file.

This is not difficult but not user-friendly. If you aligned everything you need only change your .mis file location occasionally.

I really much appreciate if you try this script and beta test for me. If this works to you I can step forward.

Last edited by dottore; 09-09-12 at 11:25 AM. Reason: corrections: links
dottore is offline   Reply With Quote
Old 09-09-12, 08:07 AM   #11
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

If not user-friendly then many people will not try/use it. That's just the way it is

I have no need for your idea as I have a working real navigation in my UIs mod (thus no need to test it). I do feel you are overcomplicating things. I would suggest you learn the game's architecture (what functions the scriptmanager exposes and how to use them) first. It will make things so much easier for you/everyone else

You'll also probably get a much better response/feedback if this was originally posted in the SH5 Mods forum.
TheDarkWraith is offline   Reply With Quote
Old 09-09-12, 08:14 AM   #12
dottore
Seaman
 
Join Date: Mar 2010
Location: Hungary
Posts: 32
Downloads: 138
Uploads: 0
Default

Yes, I know but invested too much time in it to trash out the whole thing. That's why I posted. I need time to learn game architecture.

Next time, I will post in the SH5 mods topic.
dottore is offline   Reply With Quote
Old 09-09-12, 08:26 AM   #13
TheDarkWraith
Black Magic
 
Join Date: Jun 2007
Posts: 11,962
Downloads: 147
Uploads: 5


Default

Quote:
Originally Posted by dottore View Post
Yes, I know but invested too much time in it to trash out the whole thing. That's why I posted. I need time to learn game architecture.

Next time, I will post in the SH5 mods topic.
You can always ask a moderator to move your thread to another forum. Contact CCIP or Webster
TheDarkWraith is offline   Reply With Quote
Old 09-09-12, 08:30 AM   #14
dottore
Seaman
 
Join Date: Mar 2010
Location: Hungary
Posts: 32
Downloads: 138
Uploads: 0
Default

Thank you! I felt we misunderstood each other. I really like your Real Navigation, just hard to calculate position in game, the way it meant.

Mod: I started IronPython to make the new script .

First experience: Moon is a problem in game so I can see 1 hour shift of the Moon from GMT.

Last edited by dottore; 09-09-12 at 11:45 AM.
dottore is offline   Reply With Quote
Old 09-09-12, 07:13 PM   #15
CaliEs
Loader
 
Join Date: Oct 2011
Posts: 89
Downloads: 27
Uploads: 0
Default

Quote:
Originally Posted by dottore View Post
Error:
Code:
Traceback(most recent call last):
File "sacn.0.09.beta.py", line 13, in (module) MakeFile("my.active.uboat.data.txt')

File "sacn.0.09.beta.py", line 9, in (module) file = open(temp_path, 'w')

IOError: [Errno 2] No such file or directory 'C:\\Python27\\my.active.uboat.data.txt'
__________________
Dietrich von Carlewitz, 2nd Lt.
U-29
CaliEs is offline   Reply With Quote
Reply

Tags
bad weather, celestial navigation, position, script, stellarium


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 01:41 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 1995- 2024 Subsim®
"Subsim" is a registered trademark, all rights reserved.