Skip to content

Commit

Permalink
Issue #144: Fuel use penalty
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark2000 committed Dec 19, 2024
1 parent f45b18c commit 017a2cb
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 45 deletions.
111 changes: 66 additions & 45 deletions examples/continuous_orbit_manuevers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,21 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 6,
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "ImportError",
"evalue": "cannot import name 'FuelPenalty' from 'bsk_rl.data' (/Users/markstephenson/avslab/bsk_rl/src/bsk_rl/data/__init__.py)",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[6], line 9\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mbsk_rl\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mutils\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01morbital\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m relative_to_chief, random_orbit\n\u001b[1;32m 8\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mbsk_rl\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mscene\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m FibonacciSphereRSOPoints\n\u001b[0;32m----> 9\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mbsk_rl\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mdata\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m RSOInspectionReward, FuelPenalty\n\u001b[1;32m 11\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mBasilisk\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01marchitecture\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m bskLogging\n\u001b[1;32m 12\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mBasilisk\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mutilities\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mRigidBodyKinematics\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m MRP2C\n",
"\u001b[0;31mImportError\u001b[0m: cannot import name 'FuelPenalty' from 'bsk_rl.data' (/Users/markstephenson/avslab/bsk_rl/src/bsk_rl/data/__init__.py)"
]
}
],
"source": [
"# %matplotlib qt # Uncomment to use interactive plotting, may need `pip install PyQt5`\n",
"\n",
Expand All @@ -28,7 +40,7 @@
"from bsk_rl.sim import dyn, fsw\n",
"from bsk_rl.utils.orbital import relative_to_chief, random_orbit\n",
"from bsk_rl.scene import FibonacciSphereRSOPoints\n",
"from bsk_rl.data import RSOInspectionReward\n",
"from bsk_rl.data import RSOInspectionReward, FuelPenalty\n",
"\n",
"from Basilisk.architecture import bskLogging\n",
"from Basilisk.utilities.RigidBodyKinematics import MRP2C\n",
Expand All @@ -51,7 +63,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -105,24 +117,17 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[90;3m2024-12-12 10:59:43,536 \u001b[0m\u001b[m \u001b[0m\u001b[93mWARNING \u001b[0m\u001b[93mCreating logger for new env on PID=54499. Old environments in process may now log times incorrectly.\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"{'Tumbler': Discrete(1),\n",
" 'Thrust-1': Box([-100. -100. -100. 0.], [100. 100. 100. inf], (4,), float32)}"
]
},
"execution_count": 13,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -164,7 +169,7 @@
" theta_min=np.radians(30),\n",
" ),\n",
" # communicator=comm.LOSCommunication(),\n",
" rewarder=RSOInspectionReward(),\n",
" rewarder=FuelPenalty(),\n",
" time_limit=5700.0 * 3,\n",
" log_level=\"INFO\",\n",
")\n",
Expand All @@ -182,16 +187,16 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[90;3m2024-12-12 10:59:43,854 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[mResetting environment with seed=281930216\u001b[0m\n",
"\u001b[90;3m2024-12-12 10:59:43,970 \u001b[0m\u001b[36msats.satellite.Thrust-1.FSW \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[m<Basilisk.architecture.messaging.NavTransMsgPayload.NavTransMsg_C; proxy of <Swig Object of type 'NavTransMsg_C *' at 0x32e667330> >\u001b[0m\n",
"\u001b[90;3m2024-12-12 10:59:44,043 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[mEnvironment reset\u001b[0m\n"
"\u001b[90;3m2024-12-19 10:56:56,123 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[mResetting environment with seed=757261176\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:56,287 \u001b[0m\u001b[36msats.satellite.Thrust-1.FSW \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[m<Basilisk.architecture.messaging.NavTransMsgPayload.NavTransMsg_C; proxy of <Swig Object of type 'NavTransMsg_C *' at 0x33b153360> >\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:56,365 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[mEnvironment reset\u001b[0m\n"
]
}
],
Expand All @@ -218,32 +223,49 @@
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[90;3m2024-12-12 10:59:44,049 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[93;1m=== STARTING STEP ===\u001b[0m\n",
"\u001b[90;3m2024-12-12 10:59:44,050 \u001b[0m\u001b[92msats.satellite.Tumbler \u001b[0m\u001b[93mWARNING \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[92mTumbler: \u001b[0m\u001b[93mRequires retasking but received no task.\u001b[0m\n",
"\u001b[90;3m2024-12-12 10:59:44,051 \u001b[0m\u001b[36msats.satellite.Thrust-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[mThrusting with inertial dV [0 0 0] with 1000 second drift.\u001b[0m\n",
"\u001b[90;3m2024-12-12 10:59:44,052 \u001b[0m\u001b[36msats.satellite.Thrust-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[msetting timed terminal event at 1000.0\u001b[0m\n",
"\u001b[90;3m2024-12-12 10:59:44,052 \u001b[0m\u001b[36msats.satellite.Thrust-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[mFSW action action_inspect_rso activated.\u001b[0m\n",
"\u001b[90;3m2024-12-12 10:59:44,311 \u001b[0m\u001b[36msats.satellite.Thrust-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<1000.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[mtimed termination at 1000.0 \u001b[0m\n",
"\u001b[90;3m2024-12-12 10:59:44,959 \u001b[0m\u001b[36msats.satellite.Thrust-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<1000.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[mInspected 44 points this step\u001b[0m\n",
"\u001b[90;3m2024-12-12 10:59:44,959 \u001b[0m\u001b[mdata.base \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<1000.00> \u001b[0m\u001b[mData reward: {}\u001b[0m\n",
"\u001b[90;3m2024-12-12 10:59:44,959 \u001b[0m\u001b[92msats.satellite.Tumbler \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<1000.00> \u001b[0m\u001b[92mTumbler: \u001b[0m\u001b[mSatellite Tumbler requires retasking\u001b[0m\n",
"\u001b[90;3m2024-12-12 10:59:44,960 \u001b[0m\u001b[36msats.satellite.Thrust-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<1000.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[mSatellite Thrust-1 requires retasking\u001b[0m\n",
"\u001b[90;3m2024-12-12 10:59:44,961 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<1000.00> \u001b[0m\u001b[mStep reward: {}\u001b[0m\n"
"\u001b[90;3m2024-12-19 10:56:56,371 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[93;1m=== STARTING STEP ===\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:56,372 \u001b[0m\u001b[92msats.satellite.Tumbler \u001b[0m\u001b[93mWARNING \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[92mTumbler: \u001b[0m\u001b[93mRequires retasking but received no task.\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:56,372 \u001b[0m\u001b[36msats.satellite.Thrust-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[mThrusting with inertial dV [55 0 0] with 1000 second drift.\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:56,373 \u001b[0m\u001b[36msats.satellite.Thrust-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[msetting timed terminal event at 1000.0\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:56,373 \u001b[0m\u001b[36msats.satellite.Thrust-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<0.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[mFSW action action_inspect_rso activated.\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:56,563 \u001b[0m\u001b[36msats.satellite.Thrust-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<1000.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[mtimed termination at 1000.0 \u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:57,223 \u001b[0m\u001b[36msats.satellite.Thrust-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<1000.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[mInspected 40 points this step\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:57,223 \u001b[0m\u001b[mdata.base \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<1000.00> \u001b[0m\u001b[mData reward: {}\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:57,224 \u001b[0m\u001b[92msats.satellite.Tumbler \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<1000.00> \u001b[0m\u001b[92mTumbler: \u001b[0m\u001b[mSatellite Tumbler requires retasking\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:57,224 \u001b[0m\u001b[36msats.satellite.Thrust-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<1000.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[mSatellite Thrust-1 requires retasking\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:57,225 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<1000.00> \u001b[0m\u001b[mStep reward: {}\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:57,226 \u001b[0m\u001b[mgym \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<1000.00> \u001b[0m\u001b[93;1m=== STARTING STEP ===\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:57,226 \u001b[0m\u001b[92msats.satellite.Tumbler \u001b[0m\u001b[93mWARNING \u001b[0m\u001b[33m<1000.00> \u001b[0m\u001b[92mTumbler: \u001b[0m\u001b[93mRequires retasking but received no task.\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:57,227 \u001b[0m\u001b[36msats.satellite.Thrust-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<1000.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[mThrusting with inertial dV [55 0 0] with 1000 second drift.\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:57,227 \u001b[0m\u001b[36msats.satellite.Thrust-1 \u001b[0m\u001b[93mWARNING \u001b[0m\u001b[33m<1000.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[93mManeuver exceeds available Delta V (55.0/<bound method MagicOrbitalManeuverFSWModel.fuel_remaining of <abc.FSW object at 0x33b128580>> m/s).\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:57,228 \u001b[0m\u001b[36msats.satellite.Thrust-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<1000.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[msetting timed terminal event at 2000.0\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:57,228 \u001b[0m\u001b[36msats.satellite.Thrust-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<1000.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[mFSW action action_inspect_rso activated.\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:57,228 \u001b[0m\u001b[36msats.satellite.Thrust-1 \u001b[0m\u001b[93mWARNING \u001b[0m\u001b[33m<1000.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[93mfailed fuel_remaining check\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:57,387 \u001b[0m\u001b[36msats.satellite.Thrust-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<2000.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[mtimed termination at 2000.0 \u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:58,016 \u001b[0m\u001b[36msats.satellite.Thrust-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<2000.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[mInspected 50 points this step\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:58,018 \u001b[0m\u001b[mdata.base \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<2000.00> \u001b[0m\u001b[mData reward: {}\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:58,018 \u001b[0m\u001b[92msats.satellite.Tumbler \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<2000.00> \u001b[0m\u001b[92mTumbler: \u001b[0m\u001b[mSatellite Tumbler requires retasking\u001b[0m\n",
"\u001b[90;3m2024-12-19 10:56:58,018 \u001b[0m\u001b[36msats.satellite.Thrust-1 \u001b[0m\u001b[mINFO \u001b[0m\u001b[33m<2000.00> \u001b[0m\u001b[36mThrust-1: \u001b[0m\u001b[mSatellite Thrust-1 requires retasking\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"[ 3.05834745e+06 6.14678990e+06 -3.30911937e+01]\n",
"[ 3.05846436e+06 6.14688063e+06 -3.30899829e+01]\n"
"ename": "KeyError",
"evalue": "'Thrust-1'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[5], line 15\u001b[0m\n\u001b[1;32m 2\u001b[0m actions \u001b[38;5;241m=\u001b[39m {\n\u001b[1;32m 3\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mThrust-1\u001b[39m\u001b[38;5;124m\"\u001b[39m: np\u001b[38;5;241m.\u001b[39marray([\u001b[38;5;241m55\u001b[39m, \u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m1000\u001b[39m]),\n\u001b[1;32m 4\u001b[0m \u001b[38;5;66;03m# \"Thrust-2\": np.array([0, 0, 0, 1]),\u001b[39;00m\n\u001b[1;32m 5\u001b[0m }\n\u001b[1;32m 6\u001b[0m \u001b[38;5;66;03m# for sat in env.satellites:\u001b[39;00m\n\u001b[1;32m 7\u001b[0m \u001b[38;5;66;03m# if sat.requires_retasking:\u001b[39;00m\n\u001b[1;32m 8\u001b[0m \u001b[38;5;66;03m# if isinstance(sat, TumbleSat):\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[38;5;66;03m# (np.random.uniform(-20, 20, 3), np.random.uniform(0, 200, 1))\u001b[39;00m\n\u001b[1;32m 13\u001b[0m \u001b[38;5;66;03m# )\u001b[39;00m\n\u001b[0;32m---> 15\u001b[0m observation, reward, terminated, truncated, info \u001b[38;5;241m=\u001b[39m \u001b[43menv\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstep\u001b[49m\u001b[43m(\u001b[49m\u001b[43mactions\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 17\u001b[0m \u001b[38;5;66;03m# print(env.satellites[1].data_store.data.point_inspect_status)\u001b[39;00m\n\u001b[1;32m 18\u001b[0m \u001b[38;5;66;03m# print(\"storage:\", observation[\"Thrust-1\"][\"sat_props\"][\"storage_level_fraction\"])\u001b[39;00m\n\u001b[1;32m 20\u001b[0m BN \u001b[38;5;241m=\u001b[39m MRP2C(observation[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mTumbler\u001b[39m\u001b[38;5;124m\"\u001b[39m][\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msat_props\u001b[39m\u001b[38;5;124m\"\u001b[39m][\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124msigma_BN\u001b[39m\u001b[38;5;124m\"\u001b[39m])\n",
"File \u001b[0;32m~/avslab/bsk_rl/src/bsk_rl/gym.py:704\u001b[0m, in \u001b[0;36mConstellationTasking.step\u001b[0;34m(self, actions)\u001b[0m\n\u001b[1;32m 701\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mnewly_dead \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlist\u001b[39m(\u001b[38;5;28mset\u001b[39m(previous_alive) \u001b[38;5;241m-\u001b[39m \u001b[38;5;28mset\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39magents))\n\u001b[1;32m 703\u001b[0m observation \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_get_obs()\n\u001b[0;32m--> 704\u001b[0m reward \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_get_reward\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 705\u001b[0m terminated \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_get_terminated()\n\u001b[1;32m 706\u001b[0m truncated \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_get_truncated()\n",
"File \u001b[0;32m~/avslab/bsk_rl/src/bsk_rl/gym.py:627\u001b[0m, in \u001b[0;36mConstellationTasking._get_reward\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 625\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m agent, satellite \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mzip\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mpossible_agents, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msatellites):\n\u001b[1;32m 626\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m satellite\u001b[38;5;241m.\u001b[39mis_alive():\n\u001b[0;32m--> 627\u001b[0m reward[agent] \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mfailure_penalty\n\u001b[1;32m 629\u001b[0m reward_keys \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mlist\u001b[39m(reward\u001b[38;5;241m.\u001b[39mkeys())\n\u001b[1;32m 630\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m agent \u001b[38;5;129;01min\u001b[39;00m reward_keys:\n",
"\u001b[0;31mKeyError\u001b[0m: 'Thrust-1'"
]
}
],
"source": [
"for _ in range(1):\n",
"for _ in range(2):\n",
" actions = {\n",
" \"Thrust-1\": np.array([0, 0, 0, 1000]),\n",
" \"Thrust-1\": np.array([5, 0, 0, 1000]),\n",
" # \"Thrust-2\": np.array([0, 0, 0, 1]),\n",
" }\n",
" # for sat in env.satellites:\n",
Expand All @@ -260,17 +282,16 @@
" # print(env.satellites[1].data_store.data.point_inspect_status)\n",
" # print(\"storage:\", observation[\"Thrust-1\"][\"sat_props\"][\"storage_level_fraction\"])\n",
"\n",
"BN = MRP2C(observation[\"Tumbler\"][\"sat_props\"][\"sigma_BN\"])\n",
"# BN = MRP2C(observation[\"Tumbler\"][\"sat_props\"][\"sigma_BN\"])\n",
"\n",
"fig, ax = plt.subplots(1, 1, subplot_kw=dict(projection=\"3d\"))\n",
"for point, inspected in env.satellites[1].data_store.data.point_inspect_status.items():\n",
" # print(point, inspected)\n",
" ax.scatter(*(BN.T @ point.r_PB_B), color=\"tab:green\" if inspected else \"tab:red\")\n",
"# fig, ax = plt.subplots(1, 1, subplot_kw=dict(projection=\"3d\"))\n",
"# for point, inspected in env.satellites[1].data_store.data.point_inspect_status.items():\n",
"# ax.scatter(*(BN.T @ point.r_PB_B), color=\"tab:green\" if inspected else \"tab:red\")\n",
"\n",
"# ax.scatter(\n",
"# *observation[\"Thrust-1\"][\"rel_props\"][\"r_DC_N\"], color=\"tab:blue\", marker=\"x\"\n",
"# )\n",
"ax.set_aspect(\"equal\")"
"# # ax.scatter(\n",
"# # *observation[\"Thrust-1\"][\"rel_props\"][\"r_DC_N\"], color=\"tab:blue\", marker=\"x\"\n",
"# # )\n",
"# ax.set_aspect(\"equal\")"
]
}
],
Expand Down
Loading

0 comments on commit 017a2cb

Please sign in to comment.