83 lines
43 KiB
HTML
83 lines
43 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en-US" dir="ltr">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||
<title>Simulation Logging | micromissiles-unity</title>
|
||
<meta name="description" content="Swarm-on-swarm simulator using micromissiles for point defense">
|
||
<meta name="generator" content="VitePress v1.3.4">
|
||
<link rel="preload stylesheet" href="/micromissiles-unity/assets/style.ByW27x_6.css" as="style">
|
||
|
||
<script type="module" src="/micromissiles-unity/assets/app.CoSPHv2u.js"></script>
|
||
<link rel="preload" href="/micromissiles-unity/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
|
||
<link rel="modulepreload" href="/micromissiles-unity/assets/chunks/theme.ClAeuI5Q.js">
|
||
<link rel="modulepreload" href="/micromissiles-unity/assets/chunks/framework.DYF6f1aH.js">
|
||
<link rel="modulepreload" href="/micromissiles-unity/assets/Simulation_Logging.md.t33KQhfo.lean.js">
|
||
<script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
|
||
<script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
|
||
</head>
|
||
<body>
|
||
<div id="app"><div class="Layout" data-v-5d98c3a5><!--[--><!--]--><!--[--><span tabindex="-1" data-v-0f60ec36></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-0f60ec36> Skip to content </a><!--]--><!----><header class="VPNav" data-v-5d98c3a5 data-v-ae24b3ad><div class="VPNavBar" data-v-ae24b3ad data-v-6aa21345><div class="wrapper" data-v-6aa21345><div class="container" data-v-6aa21345><div class="title" data-v-6aa21345><div class="VPNavBarTitle has-sidebar" data-v-6aa21345 data-v-ab179fa1><a class="title" href="/micromissiles-unity/" data-v-ab179fa1><!--[--><!--]--><!----><span data-v-ab179fa1>micromissiles-unity</span><!--[--><!--]--></a></div></div><div class="content" data-v-6aa21345><div class="content-body" data-v-6aa21345><!--[--><!--]--><div class="VPNavBarSearch search" data-v-6aa21345><!--[--><!----><div id="local-search"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><span class="vp-icon DocSearch-Search-Icon"></span><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-6aa21345 data-v-dc692963><span id="main-nav-aria-label" class="visually-hidden" data-v-dc692963> Main Navigation </span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/micromissiles-unity/" tabindex="0" data-v-dc692963 data-v-9c663999><!--[--><span data-v-9c663999>Home</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/micromissiles-unity/Keybinds_and_Controls.html" tabindex="0" data-v-dc692963 data-v-9c663999><!--[--><span data-v-9c663999>Documentation</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/micromissiles-unity/Development_Guide.html" tabindex="0" data-v-dc692963 data-v-9c663999><!--[--><span data-v-9c663999>Development Guide</span><!--]--></a><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-6aa21345 data-v-6c893767><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-6c893767 data-v-5337faa4 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-5337faa4></span><span class="vpi-moon moon" data-v-5337faa4></span><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-6aa21345 data-v-0394ad82 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://github.com/PisterLab/micromissiles-unity" aria-label="github" target="_blank" rel="noopener" data-v-7bc22406 data-v-eee4e7cb><span class="vpi-social-github" /></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-6aa21345 data-v-bb2aa2f0 data-v-b6c34ac9><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-b6c34ac9><span class="vpi-more-horizontal icon" data-v-b6c34ac9></span></button><div class="menu" data-v-b6c34ac9><div class="VPMenu" data-v-b6c34ac9 data-v-b98bc113><!----><!--[--><!--[--><!----><div class="group" data-v-bb2aa2f0><div class="item appearance" data-v-bb2aa2f0><p class="label" data-v-bb2aa2f0>Appearance</p><div class="appearance-action" data-v-bb2aa2f0><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-bb2aa2f0 data-v-5337faa4 data-v-1d5665e3><span class="check" data-v-1d5665e3><span class="icon" data-v-1d5665e3><!--[--><span class="vpi-sun sun" data-v-5337faa4></span><span class="vpi-moon moon" data-v-5337faa4></span><!--]--></span></span></button></div></div></div><div class="group" data-v-bb2aa2f0><div class="item social-links" data-v-bb2aa2f0><div class="VPSocialLinks social-links-list" data-v-bb2aa2f0 data-v-7bc22406><!--[--><a class="VPSocialLink no-icon" href="https://github.com/PisterLab/micromissiles-unity" aria-label="github" target="_blank" rel="noopener" data-v-7bc22406 data-v-eee4e7cb><span class="vpi-social-github" /></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><!--[--><!--]--><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-6aa21345 data-v-e5dd9c1c><span class="container" data-v-e5dd9c1c><span class="top" data-v-e5dd9c1c></span><span class="middle" data-v-e5dd9c1c></span><span class="bottom" data-v-e5dd9c1c></span></span></button></div></div></div></div><div class="divider" data-v-6aa21345><div class="divider-line" data-v-6aa21345></div></div></div><!----></header><div class="VPLocalNav has-sidebar empty" data-v-5d98c3a5 data-v-a6f0e41e><div class="container" data-v-a6f0e41e><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-a6f0e41e><span class="vpi-align-left menu-icon" data-v-a6f0e41e></span><span class="menu-text" data-v-a6f0e41e>Menu</span></button><div class="VPLocalNavOutlineDropdown" style="--vp-vh:0px;" data-v-a6f0e41e data-v-17a5e62e><button data-v-17a5e62e>Return to top</button><!----></div></div></div><aside class="VPSidebar" data-v-5d98c3a5 data-v-319d5ca6><div class="curtain" data-v-319d5ca6></div><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-319d5ca6><span class="visually-hidden" id="sidebar-aria-label" data-v-319d5ca6> Sidebar Navigation </span><!--[--><!--]--><!--[--><div class="no-transition group" data-v-c40bc020><section class="VPSidebarItem level-0 has-active" data-v-c40bc020 data-v-b7550ba0><div class="item" role="button" tabindex="0" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><h2 class="text" data-v-b7550ba0>Documentation</h2><!----></div><div class="items" data-v-b7550ba0><!--[--><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/micromissiles-unity/Keybinds_and_Controls.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>Keybinds and Controls</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/micromissiles-unity/Simulation_Config_Guide.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>Simulation Configuration Guide</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/micromissiles-unity/Simulation_Logging.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>Simulation Logging</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/micromissiles-unity/coverage/editmode/Report/" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>Coverage Reports</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-b7550ba0 data-v-b7550ba0><div class="item" data-v-b7550ba0><div class="indicator" data-v-b7550ba0></div><a class="VPLink link link" href="/micromissiles-unity/Development_Guide.html" data-v-b7550ba0><!--[--><p class="text" data-v-b7550ba0>Development Guide</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><!--]--><!--[--><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-5d98c3a5 data-v-1428d186><div class="VPDoc has-sidebar has-aside" data-v-1428d186 data-v-39a288b8><!--[--><!--]--><div class="container" data-v-39a288b8><div class="aside" data-v-39a288b8><div class="aside-curtain" data-v-39a288b8></div><div class="aside-container" data-v-39a288b8><div class="aside-content" data-v-39a288b8><div class="VPDocAside" data-v-39a288b8 data-v-3f215769><!--[--><!--]--><!--[--><!--]--><nav aria-labelledby="doc-outline-aria-label" class="VPDocAsideOutline" data-v-3f215769 data-v-a5bbad30><div class="content" data-v-a5bbad30><div class="outline-marker" data-v-a5bbad30></div><div aria-level="2" class="outline-title" id="doc-outline-aria-label" role="heading" data-v-a5bbad30>On this page</div><ul class="VPDocOutlineItem root" data-v-a5bbad30 data-v-b933a997><!--[--><!--]--></ul></div></nav><!--[--><!--]--><div class="spacer" data-v-3f215769></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-39a288b8><div class="content-container" data-v-39a288b8><!--[--><!--]--><main class="main" data-v-39a288b8><div style="position:relative;" class="vp-doc _micromissiles-unity_Simulation_Logging" data-v-39a288b8><div><h1 id="simulation-logging" tabindex="-1">Simulation Logging <a class="header-anchor" href="#simulation-logging" aria-label="Permalink to "Simulation Logging""></a></h1><p>This guide provides instructions on how to access and interpret the simulation logs, how they are structured by the <code>SimMonitor</code> class, and how to utilize the provided <code>visualize_log.py</code> script to analyze simulation data. Additionally, it offers guidance on creating your own scripts for custom analysis.</p><h2 id="overview" tabindex="-1">Overview <a class="header-anchor" href="#overview" aria-label="Permalink to "Overview""></a></h2><p><img src="/micromissiles-unity/assets/sim_visualizer.CwuQ1zYH.png" alt="Python simulation log visualizer"></p><p>Simulation logs capture detailed telemetry and event data from each simulation run. These logs are essential for debugging, performance analysis, and understanding the behavior of agents within the simulation.</p><p>Logs are exported to the <code>Telemetry/Logs</code> folder in your operating system's <a href="https://docs.unity3d.com/ScriptReference/Application-persistentDataPath.html" target="_blank" rel="noreferrer">persistent data path</a>.</p><p>For example, on Windows, the logs are exported to:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>C:\Users\<user>\AppData\LocalLow\BAMLAB\micromissiles\Telemetry\Logs</span></span></code></pre></div><p>On macOS, the logs are exported to:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>~/Library/Application Support/BAMLAB/micromissiles/Telemetry/Logs</span></span></code></pre></div><p><code>visualize_log.py</code> is an example script provided to help visualize and interpret the simulation logs. It is included in the <code>Tools</code> directory of the release download.</p><h2 id="understanding-log-files-and-directory-structure" tabindex="-1">Understanding Log Files and Directory Structure <a class="header-anchor" href="#understanding-log-files-and-directory-structure" aria-label="Permalink to "Understanding Log Files and Directory Structure""></a></h2><h3 id="log-directory-structure" tabindex="-1">Log Directory Structure <a class="header-anchor" href="#log-directory-structure" aria-label="Permalink to "Log Directory Structure""></a></h3><p>Simulation logs are organized into timestamped directories within the <code>Logs</code> folder. Each simulation run generates a new directory named with the timestamp of the run.</p><p>For example:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Telemetry/</span></span>
|
||
<span class="line"><span>└── Logs/</span></span>
|
||
<span class="line"><span> ├── 20241002_101305/</span></span>
|
||
<span class="line"><span> │ ├── sim_telemetry_20241002_101311.csv</span></span>
|
||
<span class="line"><span> │ ├── sim_events_20241002_101311.csv</span></span>
|
||
<span class="line"><span> │ │</span></span>
|
||
<span class="line"><span> │ ├── sim_telemetry_20241002_101306.csv</span></span>
|
||
<span class="line"><span> │ └── sim_events_20241002_101306.csv</span></span>
|
||
<span class="line"><span> ├── 20241002_012122/</span></span>
|
||
<span class="line"><span> │ ├── sim_telemetry_20241002_012122.csv</span></span>
|
||
<span class="line"><span> │ └── sim_events_20241002_012122.csv</span></span>
|
||
<span class="line"><span> └── ...</span></span></code></pre></div><p>Each simulation run produces two main CSV files:</p><ul><li><strong>Telemetry Log (<code>sim_telemetry_*.csv</code>)</strong>: Contains detailed state information for each agent at each time step.</li><li><strong>Event Log (<code>sim_events_*.csv</code>)</strong>: Records significant events such as hits, misses, agent creation, and destruction.</li></ul><h3 id="log-files-generated-by-simmonitor" tabindex="-1">Log Files Generated by <code>SimMonitor</code> <a class="header-anchor" href="#log-files-generated-by-simmonitor" aria-label="Permalink to "Log Files Generated by `SimMonitor`""></a></h3><p>The logging system is managed by the <code>SimMonitor</code> class in the simulation codebase.</p><div class="language-csharp vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">csharp</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">public</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> class</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> SimMonitor</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> : </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">MonoBehaviour</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">{</span></span>
|
||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // Responsible for logging simulation data</span></span>
|
||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> // ...</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><p><strong>Key Responsibilities of <code>SimMonitor</code>:</strong></p><ul><li>Collecting agent state data at each simulation step.</li><li>Writing telemetry data to <code>sim_telemetry_*.csv</code>.</li><li>Recording significant events to <code>sim_events_*.csv</code>.</li><li>Organizing logs into timestamped directories for each simulation run.</li></ul><h3 id="telemetry-log-structure" tabindex="-1">Telemetry Log Structure <a class="header-anchor" href="#telemetry-log-structure" aria-label="Permalink to "Telemetry Log Structure""></a></h3><p>The telemetry log provides a snapshot of the simulation at each time step for every agent. Key columns include:</p><ul><li><strong><code>Time</code></strong>: Simulation time at the log entry.</li><li><strong><code>AgentID</code></strong>: Unique identifier for each agent.</li><li><strong><code>AgentType</code></strong>: Type of the agent (e.g., interceptor, threat).</li><li><strong><code>AgentX</code></strong>, <strong><code>AgentY</code></strong>, <strong><code>AgentZ</code></strong>: Position coordinates of the agent.</li><li><strong><code>AgentVelocityX</code></strong>, <strong><code>AgentVelocityY</code></strong>, <strong><code>AgentVelocityZ</code></strong>: Velocity components.</li><li><strong><code>AgentStatus</code></strong>: Current status of the agent (e.g., active, destroyed).</li></ul><h3 id="event-log-structure" tabindex="-1">Event Log Structure <a class="header-anchor" href="#event-log-structure" aria-label="Permalink to "Event Log Structure""></a></h3><p>The event log records significant occurrences within the simulation. Key columns include:</p><ul><li><strong><code>Time</code></strong>: Time when the event occurred.</li><li><strong><code>PositionX</code></strong>, <strong><code>PositionY</code></strong>, <strong><code>PositionZ</code></strong>: Position where the event occurred.</li><li><strong><code>EventType</code></strong>: Type of event (e.g., <code>HIT</code>, <code>MISS</code>, <code>NEW_THREAT</code>, <code>NEW_INTERCEPTOR</code>).</li><li><strong><code>Details</code></strong>: Additional details about the event.</li></ul><h2 id="running-the-visualize-log-py-script" tabindex="-1">Running the <code>visualize_log.py</code> Script <a class="header-anchor" href="#running-the-visualize-log-py-script" aria-label="Permalink to "Running the `visualize_log.py` Script""></a></h2><p>The <code>visualize_log.py</code> script helps visualize agent trajectories and significant events in a 3D plot.</p><h3 id="locating-the-script" tabindex="-1">Locating the Script <a class="header-anchor" href="#locating-the-script" aria-label="Permalink to "Locating the Script""></a></h3><p>After downloading and extracting the release package, you can find the script at:</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Tools/visualize_log.py</span></span></code></pre></div><p>Make sure you have Python 3 installed on your system, along with the required libraries to run the script.</p><h3 id="required-python-libraries" tabindex="-1">Required Python Libraries <a class="header-anchor" href="#required-python-libraries" aria-label="Permalink to "Required Python Libraries""></a></h3><p>The script depends on the following Python libraries:</p><ul><li><strong><code>pandas</code></strong></li><li><strong><code>matplotlib</code></strong></li><li><strong><code>numpy</code></strong></li></ul><p>You can install them using <code>pip</code>:</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">pip</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> pandas</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> matplotlib</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> numpy</span></span></code></pre></div><h3 id="usage" tabindex="-1">Usage <a class="header-anchor" href="#usage" aria-label="Permalink to "Usage""></a></h3><h4 id="navigate-to-the-tools-directory" tabindex="-1">Navigate to the Tools Directory <a class="header-anchor" href="#navigate-to-the-tools-directory" aria-label="Permalink to "Navigate to the Tools Directory""></a></h4><p>Open a terminal or command prompt and navigate to the <code>Tools</code> directory:</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">cd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> path/to/Tools/</span></span></code></pre></div><h4 id="run-the-script" tabindex="-1">Run the Script <a class="header-anchor" href="#run-the-script" aria-label="Permalink to "Run the Script""></a></h4><p>To visualize the most recent simulation logs:</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">python</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> visualize_log.py</span></span></code></pre></div><p><strong>What the Script Does:</strong></p><ul><li><strong>Automatically Finds the Latest Logs</strong>: If no arguments are provided, it locates the most recent <code>sim_telemetry_*.csv</code> and <code>sim_events_*.csv</code> files.</li><li><strong>Prints a Summary</strong>: Outputs a summary of events, including total counts and timing of hits and misses.</li><li><strong>Generates a 3D Plot</strong>: Displays agent trajectories and marks events such as hits and misses.</li></ul><h4 id="specifying-log-files-manually" tabindex="-1">Specifying Log Files Manually <a class="header-anchor" href="#specifying-log-files-manually" aria-label="Permalink to "Specifying Log Files Manually""></a></h4><p>You can also provide specific file paths as arguments:</p><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">python</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> visualize_log.py</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> path/to/sim_telemetry_file.csv</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> path/to/sim_events_file.csv</span></span></code></pre></div><h3 id="example-output" tabindex="-1">Example Output <a class="header-anchor" href="#example-output" aria-label="Permalink to "Example Output""></a></h3><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>Total number of events: 150</span></span>
|
||
<span class="line"><span></span></span>
|
||
<span class="line"><span>Event Counts:</span></span>
|
||
<span class="line"><span> HIT: 120</span></span>
|
||
<span class="line"><span> MISS: 30</span></span>
|
||
<span class="line"><span></span></span>
|
||
<span class="line"><span>First hit at 5.00 seconds, last hit at 15.00 seconds</span></span>
|
||
<span class="line"><span></span></span>
|
||
<span class="line"><span>[3D plot window opens showing trajectories and events]</span></span></code></pre></div><h3 id="interpreting-the-plot" tabindex="-1">Interpreting the Plot <a class="header-anchor" href="#interpreting-the-plot" aria-label="Permalink to "Interpreting the Plot""></a></h3><p>The 3D plot displays:</p><ul><li><strong>Agent Trajectories</strong>: Lines representing the paths of interceptors and threats. <ul><li><strong>Colors</strong> indicate agent types (e.g., blue for interceptors, red for threats).</li></ul></li><li><strong>Event Markers</strong>: Symbols marking where events occurred. <ul><li><strong>Hits</strong>: Marked with green circles.</li><li><strong>Misses</strong>: Marked with red crosses.</li></ul></li></ul><h3 id="adjusting-the-visualization" tabindex="-1">Adjusting the Visualization <a class="header-anchor" href="#adjusting-the-visualization" aria-label="Permalink to "Adjusting the Visualization""></a></h3><ul><li><strong>View Angle</strong>: You can rotate the 3D plot by clicking and dragging to view the simulation from different perspectives.</li><li><strong>Zoom</strong>: Use the scroll wheel to zoom in and out.</li></ul><h2 id="writing-your-own-scripts" tabindex="-1">Writing Your Own Scripts <a class="header-anchor" href="#writing-your-own-scripts" aria-label="Permalink to "Writing Your Own Scripts""></a></h2><p>The simulation logs are in CSV format, making them accessible for custom analysis and visualization.</p><h3 id="getting-started" tabindex="-1">Getting Started <a class="header-anchor" href="#getting-started" aria-label="Permalink to "Getting Started""></a></h3><ul><li><strong>Choose a Programming Language</strong>: Python or MATLAB are recommended for ease-of-use and data analysis capabilities.</li></ul><p>For example, using Python and the <code>pandas</code> library, you can load the telemetry and event data like this:</p><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> pandas </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">as</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> pd</span></span>
|
||
<span class="line"></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">telemetry_df </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> pd.read_csv(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'path/to/sim_telemetry_*.csv'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">event_df </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> pd.read_csv(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'path/to/sim_events_*.csv'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div><h3 id="visualization" tabindex="-1">Visualization <a class="header-anchor" href="#visualization" aria-label="Permalink to "Visualization""></a></h3><ul><li><strong>2D Plots</strong>: Use <code>matplotlib</code> to create time-series plots:</li></ul><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> matplotlib.pyplot </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">as</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> plt</span></span>
|
||
<span class="line"></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">plt.plot(telemetry_df[</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'Time'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">], telemetry_df[</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'AgentY'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">])</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">plt.xlabel(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'Time (s)'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">plt.ylabel(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'Altitude (m)'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">plt.title(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'Agent Altitude Over Time'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">plt.show()</span></span></code></pre></div><ul><li><strong>3D Plots</strong>: Use <code>mpl_toolkits.mplot3d</code> for 3D trajectory plots.</li></ul><h3 id="sample-script-calculating-miss-distances" tabindex="-1">Sample Script: Calculating Miss Distances <a class="header-anchor" href="#sample-script-calculating-miss-distances" aria-label="Permalink to "Sample Script: Calculating Miss Distances""></a></h3><div class="language-python vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">python</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> pandas </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">as</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> pd</span></span>
|
||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> numpy </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">as</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> np</span></span>
|
||
<span class="line"></span>
|
||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Load telemetry and event data</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">telemetry_df </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> pd.read_csv(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'path/to/sim_telemetry_*.csv'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">event_df </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> pd.read_csv(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'path/to/sim_events_*.csv'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||
<span class="line"></span>
|
||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Filter miss events</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">miss_events </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> event_df[event_df[</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'Event'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> 'MISS'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
|
||
<span class="line"></span>
|
||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Calculate miss distances</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">miss_distances </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> []</span></span>
|
||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> idx, miss </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> miss_events.iterrows():</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> agent_id </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> miss[</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'AgentID'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> time </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> miss[</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'Time'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
|
||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # Get agent position at the time of miss</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> agent_state </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> telemetry_df[(telemetry_df[</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'AgentID'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> agent_id) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (telemetry_df[</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'Time'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">==</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> time)]</span></span>
|
||
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> if</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> not</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> agent_state.empty:</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> x </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> agent_state[</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'AgentX'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">].values[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> y </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> agent_state[</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'AgentY'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">].values[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> z </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> agent_state[</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'AgentZ'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">].values[</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span>
|
||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # Calculate distance to target or predefined point</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> distance </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> np.sqrt(x</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> z</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">**</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> miss_distances.append(distance)</span></span>
|
||
<span class="line"></span>
|
||
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Output average miss distance</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">average_miss_distance </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> np.mean(miss_distances)</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">print</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">'Average Miss Distance: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">average_miss_distance</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">:.2f</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> meters'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></div><h3 id="suggestions-for-analysis" tabindex="-1">Suggestions for Analysis <a class="header-anchor" href="#suggestions-for-analysis" aria-label="Permalink to "Suggestions for Analysis""></a></h3><ul><li><strong>Performance Metrics</strong>: Determine interception success rates, average time to intercept, or hit accuracy.</li><li><strong>Behavioral Analysis</strong>: Examine how changes in simulation configurations affect agent behavior.</li><li><strong>Batch Processing</strong>: Automate analysis over multiple simulation runs to compare different scenarios.</li></ul><h2 id="additional-resources" tabindex="-1">Additional Resources <a class="header-anchor" href="#additional-resources" aria-label="Permalink to "Additional Resources""></a></h2><ul><li><strong>Python Documentation</strong>: <a href="https://pandas.pydata.org/" target="_blank" rel="noreferrer">pandas</a>, <a href="https://matplotlib.org/" target="_blank" rel="noreferrer">matplotlib</a>, <a href="https://numpy.org/" target="_blank" rel="noreferrer">NumPy</a></li></ul></div></div></main><footer class="VPDocFooter" data-v-39a288b8 data-v-e257564d><!--[--><!--]--><!----><nav class="prev-next" aria-labelledby="doc-footer-aria-label" data-v-e257564d><span class="visually-hidden" id="doc-footer-aria-label" data-v-e257564d>Pager</span><div class="pager" data-v-e257564d><a class="VPLink link pager-link prev" href="/micromissiles-unity/Simulation_Config_Guide.html" data-v-e257564d><!--[--><span class="desc" data-v-e257564d>Previous page</span><span class="title" data-v-e257564d>Simulation Configuration Guide</span><!--]--></a></div><div class="pager" data-v-e257564d><a class="VPLink link pager-link next" href="/micromissiles-unity/coverage/editmode/Report/" data-v-e257564d><!--[--><span class="desc" data-v-e257564d>Next page</span><span class="title" data-v-e257564d>Coverage Reports</span><!--]--></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><footer class="VPFooter has-sidebar" data-v-5d98c3a5 data-v-e315a0ad><div class="container" data-v-e315a0ad><p class="message" data-v-e315a0ad>Released under the <a href="https://github.com/PisterLab/micromissiles-unity/blob/main/LICENSE">BSD-3-Clause License</a>.</p><p class="copyright" data-v-e315a0ad>Copyright © 2024-present, The Regents of the University of California (Regents). All Rights Reserved.</p></div></footer><!--[--><!--]--></div></div>
|
||
<script>window.__VP_HASH_MAP__=JSON.parse("{\"development_guide.md\":\"Wx7fNEd3\",\"index.md\":\"CVOWUTll\",\"keybinds_and_controls.md\":\"CAuuuHw7\",\"markdown_examples.md\":\"BJC7tN3K\",\"simulation_config_guide.md\":\"BZQcs5Eb\",\"simulation_logging.md\":\"t33KQhfo\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"micromissiles-unity\",\"description\":\"Swarm-on-swarm simulator using micromissiles for point defense\",\"base\":\"/micromissiles-unity/\",\"head\":[],\"router\":{\"prefetchLinks\":true},\"appearance\":true,\"themeConfig\":{\"nav\":[{\"text\":\"Home\",\"link\":\"/\"},{\"text\":\"Documentation\",\"link\":\"/Keybinds_and_Controls\"},{\"text\":\"Development Guide\",\"link\":\"/Development_Guide\"}],\"sidebar\":[{\"text\":\"Documentation\",\"items\":[{\"text\":\"Keybinds and Controls\",\"link\":\"/Keybinds_and_Controls\"},{\"text\":\"Simulation Configuration Guide\",\"link\":\"/Simulation_Config_Guide\"},{\"text\":\"Simulation Logging\",\"link\":\"/Simulation_Logging\"},{\"text\":\"Coverage Reports\",\"link\":\"/coverage/editmode/Report/\"},{\"text\":\"Development Guide\",\"link\":\"/Development_Guide\"}]}],\"socialLinks\":[{\"icon\":\"github\",\"link\":\"https://github.com/PisterLab/micromissiles-unity\"}],\"search\":{\"provider\":\"local\"},\"footer\":{\"message\":\"Released under the <a href=\\\"https://github.com/PisterLab/micromissiles-unity/blob/main/LICENSE\\\">BSD-3-Clause License</a>.\",\"copyright\":\"Copyright © 2024-present, The Regents of the University of California (Regents). All Rights Reserved.\"}},\"locales\":{},\"scrollOffset\":134,\"cleanUrls\":false}");</script>
|
||
|
||
</body>
|
||
</html> |