[RESOLVED] Satellite Lua Generation BUG in Pro Version 2 (and CMO) (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Tech Support



Message


jkgarner -> [RESOLVED] Satellite Lua Generation BUG in Pro Version 2 (and CMO) (10/14/2021 12:03:20 PM)

Greeting, and Salutations!

I have been successfully creating satellites under Pro version 1.15.5 with no issues. As we upgraded to the Pro version 2, my satellite generation code stopped working.

For example, say I wish to create a SAR Satellite using TOPAZ (dbid 95) as a template and match it to a TLE that I pulled from the Internet:

In version 1.15.5 I would execute code like the following snippet:
ScenEdit_AddUnit({type='Satellite', side='US', guid='18957U', 
                  dbid=95 name='COSMOS 1932', Latitude='0',Longitude='0'})
local satU = ScenEdit.GetUnit({side='US', name='COSMOS 1932'})
local newTLE = 'COSMOS 1932\n'..
               '1 18957U 88019A   20179.87780374 -.00000067  00000-0  19462-4 0  9999\n'..
               '2 18957  65.0451 329.9962 0059909 254.4223 105.0217 13.79684050628349'
satU:updateorbit({TLE=newTLE})
And it worked like a charm.

In version 2, it returns an error from the ScenEdit_AddUnit:
Script:
ScenEdit_AddUnit({type='Satellite', side='US', dbid=95 name='COSMOS 1932', Latitude=0,Longitude=0})
Result:
ScenEdit_AddUnit 0 : ,Unable to create new unit. Reason: Object reference not set to an instance of an object.
So further testing shows that if you pass the number 1 to the guid AND the orbit, the satellite creates successfully. This is in keeping with what KnightHawk75 was describing in in his post https://www.matrixgames.com/forums/tm.asp?m=4843765&mpage=1&key=Satellite where he discusses a problem with AddUnit in relation to Satellites introduced into CMO a while back.

This represents a severe limitation as to what can be created using Lua to generate Satellites. Basically if it does not already exist in the database, you can't create it. This renders Satellites unusable for Lua generation.

The following code shows that a satellite can be created IF the orbit number is 1 and the GUID is 1. If you need more than 1 satellite, then it will not work. (The guids will collide!):
--local newTLE = 'COSMOS 1932\n1 18957U 88019A   20179.87780374 -.00000067  00000-0  19462-4 0  9999\n'..
                 '2 18957  65.0451 329.9962 0059909 254.4223 105.0217 13.79684050628349'

local newTLE = {}
newTLE[1] = 'TEST SAT #1\n1 18957U 88019A   20179.87780374 -.00000067  00000-0  19462-4 0  9999\n'..
            '2 18957  65.0451 169.9962 0059909 254.4223 105.0217 13.79684050628349'
newTLE[2] = 'TEST SAT #2\n1 18957U 88019A   20179.87780374 -.00000067  00000-0  19462-4 0  9999\n'..
            '2 18957  65.0451 189.9962 0059909 254.4223 105.0217 13.79684050628349'
newTLE[3] = 'TEST SAT #3\n1 18957U 88019A   20179.87780374 -.00000067  00000-0  19462-4 0  9999\n'..
            '2 18957  65.0451 209.9962 0059909 254.4223 105.0217 13.79684050628349'
newTLE[4] = 'TEST SAT #4\n1 18957U 88019A   20179.87780374 -.00000067  00000-0  19462-4 0  9999\n'..
            '2 18957  65.0451 229.9962 0059909 254.4223 105.0217 13.79684050628349'
newTLE[5] = 'TEST SAT #5\n1 18957U 88019A   20179.87780374 -.00000067  00000-0  19462-4 0  9999\n'..
            '2 18957  65.0451 249.9962 0059909 254.4223 105.0217 13.79684050628349'
newTLE[6] = 'TEST SAT #6\n1 18957U 88019A   20179.87780374 -.00000067  00000-0  19462-4 0  9999\n'..
            '2 18957  65.0451 269.9962 0059909 254.4223 105.0217 13.79684050628349'
newTLE[7] = 'TEST SAT #7\n1 18957U 88019A   20179.87780374 -.00000067  00000-0  19462-4 0  9999\n'..
            '2 18957  65.0451 289.9962 0059909 254.4223 105.0217 13.79684050628349'
newTLE[8] = 'TEST SAT #8\n1 18957U 88019A   20179.87780374 -.00000067  00000-0  19462-4 0  9999\n'..
            '2 18957  65.0451 309.9962 0059909 254.4223 105.0217 13.79684050628349'
newTLE[9] = 'TEST SAT #9\n1 18957U 88019A   20179.87780374 -.00000067  00000-0  19462-4 0  9999\n'..
            '2 18957  65.0451 329.9962 0059909 254.4223 105.0217 13.79684050628349'
newTLE[10] = 'TEST SAT #10\n1 18957U 88019A   20179.87780374 -.00000067  00000-0  19462-4 0  9999\n'..
            '2 18957  65.0451 349.9962 0059909 254.4223 105.0217 13.79684050628349'
local satData = {}
local i = 0
while i < 10 do
    i = i + 1
	local offset = -5
    local satName = 'TEST SAT #'..i
    print('creating satellite: '..satName)
    local e,p = pcall(ScenEdit_AddUnit,{type='Satellite', side='US', 
                                        guid=i+offset, dbid=95, orbit=i+offset, 
                                        name=satName, Latitude='0',Longitude='0'})
	if e == true then
		local satU = ScenEdit_GetUnit({name=satName, side='US'})
		satU:updateorbit({TLE=newTLE[i]})
		satData[i] = satU.guid
		print('created satellite #'..i)
	else
		print('error generated by call #'..i..'.  Message follows:')
		print(p)
		print('')
	end	
end
local i =0
while i < 10 do
	i = i + 1
	if satData[i] ~= nil then
		print('Satellite GUID = '..satData[i])
	end
end
In this test code, change the offset value to the negative of the desired satellite to select which satellite in the array will create, but only 1 will create.

It is possible that with a different satellite dbid that additional orbits are defined, say 1 through 3, in which case, 3 satellites would be created, but only those three whose orbits matched pre-existing orbits would create. Since this value is NOT visible through the GUI database viewer, it would be like a crap-shoot trying to figure out which satellite template would have orbits defined above orbit 1 and would successfully generate. This means in a practical sense, I can generate exactly 1 satellite through Lua. This is unacceptable.

Pro version 1.15.5 did not have this limitation. We were able to set specific string GUID when creating the satellite, then use the updateorbit function in the unit wrapper to adjust the orbit. This combination worked. (As a note: Being able to pass in a TLE through the add unit function when creating a satellite would be nice, but as we can use the updateorbit function, it is not necessary. Creation is absolutely necessary.)

As I said, this limitation was documented in the forums by KnightHawk75 as a problem existing in CMO.

Thanks for all your work on the simulation.




Dimitris -> RE: Satellite Lua Generation BUG in Pro Version 2 (and CMO) (11/2/2021 5:46:23 PM)

This is being handled through the pro support channels.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
2.203125