mars-sim / mars-sim

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

Missions running out of resources, not enough food/water, why not every member join the mission before departure #664

Closed bevans2000 closed 1 year ago

bevans2000 commented 2 years ago

Describe the bug Randomly EVAMissions are running out of resources at the 1st EVA. Sometimes it's Water and sometimes it's Food. I have checked the LoadingController and the resources there look correct. Either the Vehicle is not loading correctly (I doubt this since there are Unit tests) or the Loading is being forcibly aborted or the consumption rates during the Mission are not the same as those used to calculate the resources needed (this was previously a problem a long time ago but I fixed it)

It was working 2 weeks ago when I did my last pull, but now it is not so I suspect a recent commit have be the cause.

mokun commented 2 years ago

Sometimes it's Water and sometimes it's Food

True.

It's very possible that I changed EatDrinkMeta and EatDrink recently as I incorporate the use of leptin and ghrelin that will affect appetite for food and how often they eat.

To satisfy their requirements, the consumption will become frequent.

bevans2000 commented 2 years ago

No it wasn't that. It's even worse after the latest pull. I had Mission that failed after 1KM with not enough water. It looks like there is not enough supplies when the mission starts travelling so either the mission distance estimates are now incorrect or the loading logic has been changed.

mokun commented 2 years ago

Mission that failed after 1KM with not enough water... when the mission starts travelling so either the mission distance estimates are now incorrect ...

Then I'd say the current remaining leg distance method is bad.

There's actually two different version.

You came up with a newer and simplifier version for just the Trade and Delivery mission.

Can you see if it fits for other missions?

mokun commented 2 years ago

or the loading logic has been changed.

In some of those recent cpu util optimization commits, what I did was about removing the need to check for the remaining capacity of a resource/equipment holder before storing an amount resource.

But it's only, say 80%, for good only.

When the holder is full, then it's a good thing we check it initially.

Storing an amount resource seems to be even more of a labor intensive process than just check for whether there is room.

bevans2000 commented 2 years ago

But the remaining leg distance was working so I don't understand why it would now change.

My thoughts are the loading is not completing.

bevans2000 commented 2 years ago

This will needs some detailed investigation as it's not obvious what has been changed. I'm working on #621 at the moment.

mokun commented 2 years ago

But the remaining leg distance was working so I don't understand why it would now change.

The remaining leg distance used to work well.

It seems that ever since we start using EVAMission, some mission would be "completed" with the wrong total distance traveled and wrong remaining distance.

Also, the Mission Tool doesn't report things correctly and/or report different distance values, compared to the Mission tab in Monitor Tool.

At least, that's the story of the recent development.

mokun commented 2 years ago

My thoughts are the loading is not completing.

I haven't thought of that but how do we test if loading is good or not ?

mokun commented 2 years ago

the consumption rates during the Mission are not the same as those used to calculate the resources needed

Let's track how much food each settler eat and water he drinks in a sol.

We could do something similar to tracking sleep and exercise.

mokun commented 2 years ago

Also, I want to define the lunch hour (and breakfast/dinner)) labeled clearly for each settlement and be posted in the Cooking tab or something.

Of course, the settlement lunch hour would be determined primarily by the longitude of a settlement.

If we start tracking the food statistic, we could rack and stack how well each settlement harvest from crop and how much is being cooked into meals to be consumed or made into 'food'.

bevans2000 commented 2 years ago

My thoughts are the loading is not completing.

I haven't thought of that but how do we test if loading is good or not ?

There is a Unit test for the loading controller so I'm confident that the logic is correct. But it could be the Mission moves into the Travelling phase before the loading completes.

bevans2000 commented 2 years ago

Duplicate of #670

bevans2000 commented 2 years ago

@mokun I think I've got to the bottom of this issue. When we calculate the initial resources for loading for some reason the EVA time is not being included in the food calculation. But when checking on route it is so hence there is never enough food initially loaded. Why it is happening I haven't found out yet but there will be a reason.

bevans2000 commented 2 years ago

Scratch that; my debugging missed the vehicle starting to move. The Loading Controller has the correctly calculated values but by the time of the 1st check during Travelling the vehicle inventory has less. It does look like the Vehicle is not fully loading for some reason enough though the loading is complete. Hmmmm.

mokun commented 2 years ago

Yes it's not known as to why there's not enough water.

image

Q1: should the Phase column say more specifically as to why this mission is being aborted ? Also, it's not aborted by user but rather by the mission lead of this mission.

00-Adir-01:417.086 (Info) Mission : [Zvezda] Andrei Novikov - Began organizing a Regolith Prospecting #1 mission.
00-Adir-01:417.086 (Info) CollectResourcesMission : Regolith Prospecting totalSiteScore: 200.0   bestScore: 100.0
00-Adir-01:417.086 (Info) CollectResourcesMission : Regolith Prospecting totalSiteScore: 300.0   bestScore: 100.0
00-Adir-01:417.086 (Info) CollectResourcesMission : [Zvezda] Tatishchev - Target amount of resource per site: 1333 kg of regolith.
00-Adir-01:417.086 (Info) VehicleMission : [Zvezda] Tatishchev - Total est remaining distance: 19.794 km   Projected fuel economy: 9.1 km/kg   Margin for fuel: 3.6   Fuel needed: 7.906 kg   Fuel onboard: 0.0 kg
00-Adir-01:417.086 (Info) VehicleMission : [Zvezda] Andrei Novikov - Started mission Regolith Prospecting #1 using Tatishchev
00-Adir-01:417.086 (Info) PlanMission : [Zvezda] Andrei Novikov - Submitted a mission plan for Regolith Prospecting #1.
00-Adir-01:417.232 (Info) Mission : [Zvezda] Andrei Novikov - Serving as the mission lead on Regolith Prospecting #1.
00-Adir-01:417.232 (Info) MissionManager : [Zvezda] Andrei Novikov - Put together a mission plan for Regolith Prospecting #1.
00-Adir-01:417.232 (Config) MissionManager : Added 'Regolith Prospecting #1' **mission.
...
00-Adir-01:531.215 (Info) Walk : [Zvezda - Tatishchev] Musa Orlov - Entered rover Tatishchev inside Garage 1.
00-Adir-01:531.507 (Info) DriveGroundVehicle : [25.9400 N 76.3700 E - Tatishchev] Nadezhda Afanasyev - Took the wheel of the rover.
...
00-Adir-01:533.107 (Info) OperateVehicle : [25.9370 N 76.3909 E] Tatishchev - Case 1: Arriving near 25.9369 N 76.3913 E - 0.023 km away.
00-Adir-01:533.107 (Info) VehicleMission [x2] : [25.9370 N 76.3909 E] Tatishchev - Total est remaining distance: 18.645 km   Projected fuel economy: 9.1 km/kg   Margin for fuel: 1.0   Fuel needed: 2.044 kg   Fuel onboard: 7.892 kg
00-Adir-01:533.107 (Warning) VehicleMission : [25.9370 N 76.3909 E] Tatishchev - Not enough water to continue with Regolith Prospecting #1 - Required: 28.33 kg - Vehicle stored: 24.64 kg
00-Adir-01:533.107 (Warning) VehicleMission : [25.9370 N 76.3909 E] Tatishchev - Emergency encountered. Returning to home settlement (Zvezda) : 1.13 km    Duration : 0.0 sols
bevans2000 commented 2 years ago

There are 2 problem related to this Issue

  1. The loading is not completing before starting the Travelling - account for the lack of resources
  2. End a mission runs out of resources it is a complicated logic path to abort the mission; hence the Abort by User.

The later can be handled by a reworking of the Mission/VehicleMission class to simplify the interaction.

mokun commented 2 years ago
  1. The loading is not completing before starting the Travelling - account for the lack of resources

are there some sort of conditions in which it will automatically quit loading resources onto a vehicle ?

I suppose there isn't any countdown timer or a set deadline for loading.

mokun commented 2 years ago

End a mission runs out of resources it is a complicated logic path to abort the mission; hence the Abort by User.

Yes we could standardize better the path it takes to end a mission.

Say, we can create a method in that 4+ conditions must be satisfied in order to end a mission (in contrast with starting a mission)

  1. The reason(s) of ending a mission
  2. have a vehicle assigned
  3. have members assigned
  4. have mission status
bevans2000 commented 2 years ago

No actually we have to make it generic otherwise it becomes harder for new Missions. Each Mission class can have different specific reasons for failing a Mission. Cleaning this now will help with #625 because the logic will be better isolated.

bevans2000 commented 2 years ago

I can reproduce the loading issue quite easily now but I'm going to fix the mission ending fist. Also change the MissionStatus from an enum to a class to allow extra parameters to be added, e.g. when running out of resource we can tag the status with the resource name. Again trying to go with a "plug and play" design.

mokun commented 2 years ago

@bevans2000

How are you doing with changes in mission related classes ?

bevans2000 commented 2 years ago

Getting there but been busy with work this week. Sorted out the Mission completion so it seems to be working ok now. Investigating the resource issue, it's a puzzling one. Hopefully should have some free time at weekend.

bevans2000 commented 2 years ago

One thing that has become apparent is the need to run Missions in UnitTests. The resource problem is due to a previous change I believe which if we had UnitTests on Missions would have trapped it. The addition of the "create mission" console command actually advances this desire because it makes it much easier to create missions. I just need a way to correctly think of how to advance the clock in a UnitTest; obviously we can't run it in a thread. Nevertheless, I plan to fix the resourcing problem first and then tackle that problem. Having UnitTests beforehand will help #625

mokun commented 2 years ago

Sorted out the Mission completion so it seems to be working ok now.

Awesome !

mokun commented 2 years ago

Investigating the resource issue, it's a puzzling one.

I hear that you said it probably came from untested changes.

What method calls do you think would be involved ?

bevans2000 commented 2 years ago

What method calls do you think would be involved ?

Now that is the million dollar question that I've yet to answer....

bevans2000 commented 2 years ago

I've found the problem phew...... The actual problem lies in the LoadingController and what happens when the Person tries to load a very small amount. In this cases it will think that all of the current resource has completed loading; hence creates the under-loading problem. This bug has been there for at least 10 months so why haven't we seen it before? Well it is because of the change to the pulse width applied to Tasks. These recent changes means a different pulse size is being used which is creating more cases of a very small loading amount. I've redone the resource finished logic in the Loading Controller and missions seems to be loading correctly now. However this again show the problems with using double based arithmetic needing these "hacks" for the small amounts; gives more strength to moving to an integer based model of #503

mokun commented 1 year ago

I"m still getting "Not enough ..." once in a while.

00-Adir-01:792.048 (Warning) AbstractVehicleMission : [22.6887 N 134.6749 E] Piaofu - Not enough food to continue with Mineral Exploration #1 - Required: 2.99 kg - Vehicle stored: 0.0 kg
00-Adir-01:792.048 (Info) AbstractVehicleMission : [22.6887 N 134.6749 E] Piaofu - Needs help.
00-Adir-01:792.048 (Info) AbstractVehicleMission : [22.6887 N 134.6749 E] Piaofu - Turned on emergency beacon to request for towing. Status flag(s): Not enough food.
00-Adir-01:792.048 (Info) AbstractVehicleMission : [22.6887 N 134.6749 E] Piaofu - Not enough food

It's good that the Mission Status correctly shows "Not Enough Food" image As a side note, Gen Pun never boarded the vehicle. Even though he was a member of this mission, he couldn't get boarded in time. Why ? Q: should his name be dropped from 'Team Members' table in Mission Tool ? image In Vehicle Window's Crew tab, it correctly shows that Gen Pun was not on board. image

image

image Even though Exploration Site 1 looks only a very short distance as shown in Navpoint tab's map, it's actually 475 km away. image

Despite having turned on emergency beacon, the interesting thing is that this mission is still ongoing, with 70.3 km to the next waypoint and only estimated 307.8 km more to go. image

bevans2000 commented 1 year ago

I've not seen this problem come back however I've been working on a branch and haven't picked up all the changes you've done. I'd be surprised if it is the same problem but will keep an eye open for it.

mokun commented 1 year ago

Another interesting side note is that if I saved that simulation and reloaded it, all of a sudden Gen Pun became boarded once again, according to the Vehicle Window below.

image

As a matter of fact, he was even selected the driver of rover Piaofu.

image

So we do need to find out why and work on this logic.

Q: how should we handle unboarded members ideally speaking ?

bevans2000 commented 1 year ago

Well the logic was previously that the mission phase cannot advance from Embarking unless everyone is on board so I don't know how this situation can occur. Could it be a problem with some of recent small patch of changes that have been done?

mokun commented 1 year ago

Well the logic was previously that the mission phase cannot advance from Embarking unless everyone is on board

hmm. I recalled I asked once or twice about this since I joined this project. So I've seen this from time to time.

But it actually make total sense that if a person who initially signed up for a mission became unavailable (having medical issue, too busy or change his mind), we should allow him to elect to remotely support the expedition "at the home station" instead.

Right now, when a mission is out there, there's virtually no support from the home station.

The concept of Mission Control could come in handy. Will it ?

bevans2000 commented 1 year ago

The medical issue is a different scenario. Once a person has a medical issue they should withdrawn from the Mission if they haven't embarked, i.e. still in the Settlement. Then on the next call of the Mission it will be flagged as all members boarded since the straggler has dropped out.

bevans2000 commented 1 year ago

I would prefer to close this issue because it has quite a bit of history and the original problem is solved. We should create a new one with a better focused description of the problem, e.g does it happen for all Missions?

bevans2000 commented 1 year ago

There may be an issue with Delivery mission and drones not calculating fuel correctly.