skai2 / EDAutopilot

Elite Dangerous computer vision based auto-navigation including long range routing
MIT License
150 stars 66 forks source link

Attempting to Refuel on Non-Scoopable Class T Star #51

Open kbmorris opened 3 years ago

kbmorris commented 3 years ago

So essentially EDAutoPilot parks on this star at Col 285 Sector JX-T d3-76 even though it is Class:T. In the Python debugger the ship() method returns 'star_class': 'M' so is mistaken on the star class. It looks as if the Star Class of the FSDTarget (the next star) is being populated too early for the fuel scoop decision. I need to understand how EDAutoPilot determines star_class in ship() to work on a fix.

ED Log:

{ "timestamp":"2021-01-04T04:39:59Z", "event":"StartJump", "JumpType":"Hyperspace", "StarSystem":"Col 285 Sector JX-T d3-76", "SystemAddress":2621800728931, "StarClass":"TTS" }
{ "timestamp":"2021-01-04T04:40:04Z", "event":"Music", "MusicTrack":"NoTrack" }
{ "timestamp":"2021-01-04T04:40:07Z", "event":"FSDTarget", "Name":"Col 285 Sector NZ-C b14-1", "SystemAddress":2868904273297, "StarClass":"M", "RemainingJumpsInRoute":3 }
{ "timestamp":"2021-01-04T04:40:17Z", "event":"ReceiveText", "From":"", "Message":"$COMMS_entered:#name=Col 285 Sector JX-T d3-76;", "Message_Localised":"Entered Channel: Col 285 Sector JX-T d3-76", "Channel":"npc" }
{ "timestamp":"2021-01-04T04:40:17Z", "event":"FSDJump", "StarSystem":"Col 285 Sector JX-T d3-76", "SystemAddress":2621800728931, "StarPos":[-78.25000,77.12500,-54.15625], "SystemAllegiance":"", "SystemEconomy":"$economy_None;", "SystemEconomy_Localised":"None", "SystemSecondEconomy":"$economy_None;", "SystemSecondEconomy_Localised":"None", "SystemGovernment":"$government_None;", "SystemGovernment_Localised":"None", "SystemSecurity":"$GAlAXY_MAP_INFO_state_anarchy;", "SystemSecurity_Localised":"Anarchy", "Population":0, "Body":"Col 285 Sector JX-T d3-76 A", "BodyID":1, "BodyType":"Star", "JumpDist":19.221, "FuelUsed":4.620865, "FuelLevel":5.408135 }
{ "timestamp":"2021-01-04T04:40:17Z", "event":"Music", "MusicTrack":"Supercruise" }
{ "timestamp":"2021-01-04T04:40:24Z", "event":"Scan", "ScanType":"AutoScan", "BodyName":"Col 285 Sector JX-T d3-76 A A Belt Cluster 5", "BodyID":10, "Parents":[ {"Ring":5}, {"Star":1}, {"Null":0} ], "StarSystem":"Col 285 Sector JX-T d3-76", "SystemAddress":2621800728931, "DistanceFromArrivalLS":5.226392, "WasDiscovered":true, "WasMapped":false }
{ "timestamp":"2021-01-04T04:40:24Z", "event":"Scan", "ScanType":"AutoScan", "BodyName":"Col 285 Sector JX-T d3-76 A", "BodyID":1, "Parents":[ {"Null":0} ], "StarSystem":"Col 285 Sector JX-T d3-76", "SystemAddress":2621800728931, "DistanceFromArrivalLS":0.000000, "StarType":"TTS", "Subclass":2, "StellarMass":0.964844, "Radius":718677632.000000, "AbsoluteMagnitude":5.582504, "Age_MY":48, "SurfaceTemperature":4780.000000, "Luminosity":"Va", "SemiMajorAxis":471539974212.646484, "Eccentricity":0.120456, "OrbitalInclination":23.009228, "Periapsis":213.535804, "OrbitalPeriod":644373738.765717, "RotationPeriod":309500.146263, "AxialTilt":0.000000, "Rings":[ { "Name":"Col 285 Sector JX-T d3-76 A A Belt", "RingClass":"eRingClass_MetalRich", "MassMT":1.4533e+14, "InnerRad":1.1858e+09, "OuterRad":2.6044e+09 } ], "WasDiscovered":true, "WasMapped":false }
{ "timestamp":"2021-01-04T04:40:24Z", "event":"Scan", "ScanType":"AutoScan", "BodyName":"Col 285 Sector JX-T d3-76 A A Belt Cluster 3", "BodyID":8, "Parents":[ {"Ring":5}, {"Star":1}, {"Null":0} ], "StarSystem":"Col 285 Sector JX-T d3-76", "SystemAddress":2621800728931, "DistanceFromArrivalLS":8.481720, "WasDiscovered":true, "WasMapped":false }
{ "timestamp":"2021-01-04T04:40:24Z", "event":"Scan", "ScanType":"AutoScan", "BodyName":"Col 285 Sector JX-T d3-76 A A Belt Cluster 4", "BodyID":9, "Parents":[ {"Ring":5}, {"Star":1}, {"Null":0} ], "StarSystem":"Col 285 Sector JX-T d3-76", "SystemAddress":2621800728931, "DistanceFromArrivalLS":5.205257, "WasDiscovered":true, "WasMapped":false }
{ "timestamp":"2021-01-04T04:40:24Z", "event":"Scan", "ScanType":"AutoScan", "BodyName":"Col 285 Sector JX-T d3-76 A A Belt Cluster 1", "BodyID":6, "Parents":[ {"Ring":5}, {"Star":1}, {"Null":0} ], "StarSystem":"Col 285 Sector JX-T d3-76", "SystemAddress":2621800728931, "DistanceFromArrivalLS":7.940810, "WasDiscovered":true, "WasMapped":false }
{ "timestamp":"2021-01-04T04:40:24Z", "event":"Scan", "ScanType":"AutoScan", "BodyName":"Col 285 Sector JX-T d3-76 A A Belt Cluster 2", "BodyID":7, "Parents":[ {"Ring":5}, {"Star":1}, {"Null":0} ], "StarSystem":"Col 285 Sector JX-T d3-76", "SystemAddress":2621800728931, "DistanceFromArrivalLS":3.995406, "WasDiscovered":true, "WasMapped":false }
{ "timestamp":"2021-01-04T04:43:37Z", "event":"ReservoirReplenished", "FuelMain":4.778135, "FuelReservoir":0.630000 }
{ "timestamp":"2021-01-04T04:49:54Z", "event":"Music", "MusicTrack":"SystemMap" }
{ "timestamp":"2021-01-04T04:50:39Z", "event":"Music", "MusicTrack":"Supercruise" }
{ "timestamp":"2021-01-04T04:51:09Z", "event":"ModuleInfo" }
{ "timestamp":"2021-01-04T04:51:14Z", "event":"Music", "MusicTrack":"SystemMap" }
{ "timestamp":"2021-01-04T04:51:16Z", "event":"Music", "MusicTrack":"Supercruise" }
{ "timestamp":"2021-01-04T04:51:17Z", "event":"Music", "MusicTrack":"GalaxyMap" }
{ "timestamp":"2021-01-04T04:51:51Z", "event":"Music", "MusicTrack":"Supercruise" }
{ "timestamp":"2021-01-04T04:57:54Z", "event":"ReservoirReplenished", "FuelMain":4.148135, "FuelReservoir":0.630000 }

EDAutoPilot Log:

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---- AUTOPILOT JUMP ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DEBUG:root:jump
DEBUG:root:jump= try:0
DEBUG:root:jump= start fsd
DEBUG:root:send=key:{'pre_key': 'DIK_J', 'key': 36},hold:1,repeat:1,repeat_delay:None,state:None
DEBUG:root:jump= in jump
DEBUG:root:jump= speed 0
DEBUG:root:send=key:{'pre_key': 'DIK_X', 'key': 45},hold:None,repeat:1,repeat_delay:None,state:None
DEBUG:root:jump=complete
INFO:root:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
---- AUTOPILOT REFUEL ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
DEBUG:root:refuel
DEBUG:root:refuel= start refuel
DEBUG:root:send=key:{'pre_key': 'DIK_R', 'key': 19},hold:None,repeat:1,repeat_delay:None,state:None
DEBUG:root:refuel= wait for refuel
DEBUG:root:send=key:{'pre_key': 'DIK_X', 'key': 45},hold:None,repeat:3,repeat_delay:None,state:None

Debug Console:

ship()
{'fuel_capacity': 32.0, 'fuel_level': 5.408135, 'fuel_percent': 17, 'is_scooping': False, 'location': 'Col 285 Sector JX-T d3-76', 'star_class': 'M', 'status': 'in_supercruise', 'target': 'Col 285 Sector NZ-C b14-1', 'time': 663, 'type': 'krait_mkii'}
TomW1605 commented 3 years ago

i think the problem is here: https://github.com/skai2/EDAutopilot/blob/master/dev_autopilot.py#L229 i think it is taking the first instance of StarClass it finds and in this case that is infact the class of the target system not the curent one. it should be easy to add some more conditions to prevent this. i think this has been fixed in one of the forks but need to confirm that.

kbmorris commented 3 years ago

Yes @TomW1605 it appears the reliable message in the ED Journal for StarClass of the current system would be the current "event":"StartJump" event and the current "event":"FSDTarget" event should be ignored for StarClass of the current system.

kbmorris commented 3 years ago

Yes @TomW1605 it appears the reliable message in the ED Journal for StarClass of the current system would be the current "event":"StartJump" event and the current "event":"FSDTarget" event should be ignored for StarClass of the current system.

Should I submit a pull request?

TomW1605 commented 3 years ago

go for it but please test it first

kbmorris commented 3 years ago

This is working for non-scoopable stars now. Simple fix really. I didn't see any testing files in the repo but I did test on a 300LY route through scoopable and non-scoopable stars with no issues. I had the threshold turned up to a fairly high percentage to see plenty of refuel activity. Pull request is inbound.