Loaded new mass and inertial characteristics into sim, ported sim arch into arduino code
This commit is contained in:
@@ -2189,14 +2189,14 @@
|
||||
"id": "21babeb3",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Now, let's find the equilibrium height for our pod, given mass of 5.8 kg. \n",
|
||||
"### Now, let's find the equilibrium height for our pod, given mass of 9.4 kg. \n",
|
||||
"\n",
|
||||
"5.8 kg * 9.81 $m/s^2$ = 56.898 N"
|
||||
"9.4 kg * 9.81 $m/s^2$ = 56.898 N"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 50,
|
||||
"execution_count": 1,
|
||||
"id": "badbc379",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -2204,23 +2204,27 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Loading maglev model from /Users/adipu/Documents/guadaloop_lev_control/RL Testing/maglev_model.pkl...\n",
|
||||
"Model loaded. Degree: 6\n",
|
||||
"Force R2: 1.0000\n",
|
||||
"Torque R2: 0.9999\n",
|
||||
"======================================================================\n",
|
||||
"EQUILIBRIUM GAP HEIGHT FINDER (Analytical Solution)\n",
|
||||
"======================================================================\n",
|
||||
"Pod mass: 5.8 kg\n",
|
||||
"Total weight: 56.898 N\n",
|
||||
"Target force per yoke: 28.449 N\n",
|
||||
"Pod mass: 9.4 kg\n",
|
||||
"Total weight: 92.214 N\n",
|
||||
"Target force per yoke: 46.107 N\n",
|
||||
"Parameters: currL = 0 A, currR = 0 A, roll = 0°\n",
|
||||
"\n",
|
||||
"using scipy.optimize.fsolve:\n",
|
||||
" Gap: 16.491742 mm → Force: 28.449000 N\n",
|
||||
" Gap: 11.857530 mm → Force: 46.107000 N\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# The following was generated by AI - see [13]\n",
|
||||
"# Find equilibrium gap height for 5.8 kg pod using polynomial root finding\n",
|
||||
"# Find equilibrium gap height for 9.4 kg pod using polynomial root finding\n",
|
||||
"import numpy as np\n",
|
||||
"from maglev_predictor import MaglevPredictor\n",
|
||||
"from scipy.optimize import fsolve\n",
|
||||
@@ -2228,15 +2232,15 @@
|
||||
"# Initialize predictor\n",
|
||||
"predictor = MaglevPredictor()\n",
|
||||
"\n",
|
||||
"# Target force for 5.8 kg pod (total force = weight)\n",
|
||||
"# Target force for 9.4 kg pod (total force = weight)\n",
|
||||
"# Since we have TWO yokes (front and back), each produces this force\n",
|
||||
"target_force_per_yoke = 5.8 * 9.81 / 2 # 28.449 N per yoke\n",
|
||||
"target_force_per_yoke = 9.4 * 9.81 / 2 # 28.449 N per yoke\n",
|
||||
"\n",
|
||||
"print(\"=\" * 70)\n",
|
||||
"print(\"EQUILIBRIUM GAP HEIGHT FINDER (Analytical Solution)\")\n",
|
||||
"print(\"=\" * 70)\n",
|
||||
"print(f\"Pod mass: 5.8 kg\")\n",
|
||||
"print(f\"Total weight: {5.8 * 9.81:.3f} N\")\n",
|
||||
"print(f\"Pod mass: 9.4 kg\")\n",
|
||||
"print(f\"Total weight: {9.4 * 9.81:.3f} N\")\n",
|
||||
"print(f\"Target force per yoke: {target_force_per_yoke:.3f} N\")\n",
|
||||
"print(f\"Parameters: currL = 0 A, currR = 0 A, roll = 0°\")\n",
|
||||
"print()\n",
|
||||
|
||||
@@ -217,7 +217,7 @@ class MaglevStateSpace:
|
||||
"""
|
||||
|
||||
def __init__(self, linearizer,
|
||||
mass=5.8,
|
||||
mass=9.4,
|
||||
I_roll=0.0192942414, # Ixx from pod.xml [kg·m²]
|
||||
I_pitch=0.130582305, # Iyy from pod.xml [kg·m²]
|
||||
coil_R=1.1, # from MagLevCoil in lev_pod_env.py
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -8,7 +8,7 @@ from datetime import datetime
|
||||
from mag_lev_coil import MagLevCoil
|
||||
from maglev_predictor import MaglevPredictor
|
||||
|
||||
TARGET_GAP = 16.491741 / 1000 # target gap height for 5.8 kg pod in meters
|
||||
TARGET_GAP = 11.86 / 1000 # target gap height for 9.4 kg pod in meters
|
||||
|
||||
class LevPodEnv(gym.Env):
|
||||
def __init__(self, use_gui=False, initial_gap_mm=10.0, max_steps=2000, disturbance_force_std=0.0,
|
||||
@@ -385,8 +385,8 @@ class LevPodEnv(gym.Env):
|
||||
obs = self._get_obs()
|
||||
|
||||
# --- 8. Calculate Reward ---
|
||||
# Goal: Hover at target gap (16.5mm), minimize roll/pitch, minimize power
|
||||
target_gap = TARGET_GAP # 16.5mm in meters
|
||||
# Goal: Hover at target gap (11.8mm), minimize roll/pitch, minimize power
|
||||
target_gap = TARGET_GAP # 11.8mm in meters
|
||||
avg_gap = (avg_gap_front + avg_gap_back) / 2
|
||||
|
||||
gap_error = abs(avg_gap - target_gap)
|
||||
@@ -656,7 +656,7 @@ class LevPodEnv(gym.Env):
|
||||
t = {k: np.array(v) for k, v in self._telemetry.items()}
|
||||
time = t['time']
|
||||
target_mm = TARGET_GAP * 1000
|
||||
weight = 5.8 * 9.81 # Pod weight in N
|
||||
weight = 9.4 * 9.81 # Pod weight in N
|
||||
|
||||
fig, axes = plt.subplots(4, 1, figsize=(12, 14), sharex=True)
|
||||
fig.suptitle(f'Simulation Telemetry | gap₀={self.initial_gap_mm}mm target={target_mm:.1f}mm',
|
||||
|
||||
@@ -27,7 +27,7 @@ _SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# Default optimization config: long enough to see late instability (~8s+), not so long that optimizer goes ultra-conservative
|
||||
DEFAULT_MAX_STEPS = 1500
|
||||
DEFAULT_INITIAL_GAPS_MM = [12.0, 18.0] # Two conditions for robustness
|
||||
DEFAULT_INITIAL_GAPS_MM = [8.0, 15.0] # Two conditions for robustness (bracket 11.86mm target)
|
||||
DEFAULT_N_TRIALS = 200
|
||||
DEFAULT_TIMEOUT_S = 3600
|
||||
TARGET_GAP_MM = TARGET_GAP * 1000
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"height_kp": 80.05607483893696,
|
||||
"height_ki": 0,
|
||||
"height_kd": 7.09266287860531,
|
||||
"roll_kp": -0.600856607986966,
|
||||
"roll_ki": 0,
|
||||
"height_kp": 100.962395560374814,
|
||||
"height_ki": 0.0,
|
||||
"height_kd": 8.1738092637166575,
|
||||
"roll_kp": 0.600856607986966,
|
||||
"roll_ki": 0.0,
|
||||
"roll_kd": -0.1,
|
||||
"pitch_kp": 50.3415835489009009,
|
||||
"pitch_ki": 0.02319184022898008,
|
||||
"pitch_kd": 0.017632648760979346
|
||||
"pitch_kp": 50.0114708799258271,
|
||||
"pitch_ki": 0,
|
||||
"pitch_kd": 1.8990306608320433
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"height_kp": 112.05607483893696,
|
||||
"height_ki": 1.3231206601751908,
|
||||
"height_kd": 14.09266287860531,
|
||||
"roll_kp": 3.600856607986966,
|
||||
"roll_ki": 0.10314962498074487,
|
||||
"roll_kd": 0.013792861414632316,
|
||||
"pitch_kp": 0.1415835489009009,
|
||||
"pitch_ki": 0.02319184022898008,
|
||||
"pitch_kd": 0.017632648760979346
|
||||
"height_kp": 61.34660453658844,
|
||||
"height_ki": 5.337339965349835,
|
||||
"height_kd": 12.13071554123404,
|
||||
"roll_kp": 5.838881924776812,
|
||||
"roll_ki": 0.11040111644948386,
|
||||
"roll_kd": 0.0401383180893775,
|
||||
"pitch_kp": 0.10114651080341679,
|
||||
"pitch_ki": 0.06948994902747452,
|
||||
"pitch_kd": 0.16948986671689478
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"height_kp": 7.886377342450826,
|
||||
"height_ki": 0.5011631292801424,
|
||||
"height_kd": 6.281854346104332,
|
||||
"roll_kp": 0.5834114273785317,
|
||||
"roll_ki": 4.958217971237515,
|
||||
"roll_kd": 0.020111264395006163,
|
||||
"pitch_kp": 1.7442062254360877,
|
||||
"pitch_ki": 0.03376218829632256,
|
||||
"pitch_kd": 2.7713413800138587
|
||||
"height_kp": 6.79952358593656,
|
||||
"height_ki": 2.7199339229214856,
|
||||
"height_kd": 12.166576111298163,
|
||||
"roll_kp": 1.7073146141313746,
|
||||
"roll_ki": 0.026221209129363342,
|
||||
"roll_kd": 0.018353603438859525,
|
||||
"pitch_kp": 1.2333241666054757,
|
||||
"pitch_ki": 0.03544610305322942,
|
||||
"pitch_kd": 0.3711162924888727
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"height_kp": 6.387288593598476,
|
||||
"height_ki": 3.8692474098125285,
|
||||
"height_kd": 8.326592570264028,
|
||||
"roll_kp": 2.5896160034319817,
|
||||
"roll_ki": 0.26391970508131646,
|
||||
"roll_kd": 0.10133339760273202,
|
||||
"pitch_kp": 0.5612446354489615,
|
||||
"pitch_ki": 0.014113041384510265,
|
||||
"pitch_kd": 1.100684970603034
|
||||
"height_kp": 5.962395560374814,
|
||||
"height_ki": 0.5381137743695537,
|
||||
"height_kd": 1.1738092637166575,
|
||||
"roll_kp": 0.48249575996443006,
|
||||
"roll_ki": 0.016923890033141546,
|
||||
"roll_kd": 0.013609429509460135,
|
||||
"pitch_kp": 0.10114708799258271,
|
||||
"pitch_ki": 1.906050976563914,
|
||||
"pitch_kd": 1.8990306608320433
|
||||
}
|
||||
@@ -14,7 +14,7 @@ _FF_PWM_LUT = None
|
||||
|
||||
|
||||
def build_feedforward_lut(
|
||||
pod_mass: float = 5.8,
|
||||
pod_mass: float = 9.4,
|
||||
coil_r: float = 1.1,
|
||||
v_supply: float = 12.0,
|
||||
gap_min: float = 3.0,
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
<robot name="lev_pod">
|
||||
<link name="base_link">
|
||||
<inertial>
|
||||
<mass value="5.8"/>
|
||||
<inertia ixx="0.0192942414" ixy="0.0" ixz="0.0" iyy="0.130582305" iyz="0.0" izz="0.13760599326"/>
|
||||
<mass value="9.4"/>
|
||||
<inertia ixx="0.03162537654" ixy="0.0" ixz="0.0" iyy="0.21929017831" iyz="0.0" izz="0.21430205089"/>
|
||||
</inertial>
|
||||
|
||||
<collision>
|
||||
@@ -13,19 +13,19 @@
|
||||
|
||||
Bolts
|
||||
<collision>
|
||||
<origin rpy="0 0 0" xyz="0.285 0.03 0.09585"/>
|
||||
<origin rpy="0 0 0" xyz="0.285 0.03 0.09085"/>
|
||||
<geometry><box size="0.01 0.01 0.01"/></geometry>
|
||||
</collision>
|
||||
<collision>
|
||||
<origin rpy="0 0 0" xyz="0.285 -0.03 0.09585"/>
|
||||
<origin rpy="0 0 0" xyz="0.285 -0.03 0.09085"/>
|
||||
<geometry><box size="0.01 0.01 0.01"/></geometry>
|
||||
</collision>
|
||||
<collision>
|
||||
<origin rpy="0 0 0" xyz="-0.285 0.03 0.09585"/>
|
||||
<origin rpy="0 0 0" xyz="-0.285 0.03 0.09085"/>
|
||||
<geometry><box size="0.01 0.01 0.01"/></geometry>
|
||||
</collision>
|
||||
<collision>
|
||||
<origin rpy="0 0 0" xyz="-0.285 -0.03 0.09585"/>
|
||||
<origin rpy="0 0 0" xyz="-0.285 -0.03 0.09085"/>
|
||||
<geometry><box size="0.01 0.01 0.01"/></geometry>
|
||||
</collision>
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"height_kp": 6.387288593598476,
|
||||
"height_ki": 3.8692474098125285,
|
||||
"height_kd": 8.326592570264028,
|
||||
"roll_kp": 2.5896160034319817,
|
||||
"roll_ki": 0.26391970508131646,
|
||||
"roll_kd": 0.10133339760273202,
|
||||
"pitch_kp": 0.5612446354489615,
|
||||
"pitch_ki": 0.014113041384510265,
|
||||
"pitch_kd": 1.100684970603034
|
||||
"height_kp": 80.05607483893696,
|
||||
"height_ki": 0,
|
||||
"height_kd": 7.09266287860531,
|
||||
"roll_kp": -0.600856607986966,
|
||||
"roll_ki": 0,
|
||||
"roll_kd": -0.1,
|
||||
"pitch_kp": 50.3415835489009009,
|
||||
"pitch_ki": 0.02319184022898008,
|
||||
"pitch_kd": 0.017632648760979346
|
||||
}
|
||||
Reference in New Issue
Block a user