diff --git a/.github/workflows/API.yml b/.github/workflows/API.yml
deleted file mode 100644
index b25d4c7810..0000000000
--- a/.github/workflows/API.yml
+++ /dev/null
@@ -1,44 +0,0 @@
-name: API
-
-on:
- workflow_dispatch: {}
- push:
- branches: [ master, dev ]
- pull_request:
- branches: [ master, dev ]
-
-jobs:
- buildApiSolution:
- name: Build API
- runs-on: ubuntu-latest
- steps:
- - name: Checkout Repository & Submodules
- uses: actions/checkout@v2
- with:
- submodules: recursive
- - name: Install Protoc
- uses: arduino/setup-protoc@v2
- with:
- version: "23.3"
- - name: Generate Protobuf Files
- run: |
- cd protocols/
- bash ./proto_compile.sh
- cd ..
- - name: Setup .NET Core
- uses: actions/setup-dotnet@v3
- with:
- dotnet-version: 7.0.x
- - name: Install API Dependencies
- run: dotnet restore api/api.sln
- - name: Build API Solution
- run: dotnet build api/api.sln --configuration Release --no-restore
- - name: Test API Solution
- run: dotnet test api/api.sln --no-restore --verbosity normal
-
-# - name: Install Module Dependencies
-# run: dotnet restore modules/modules.sln
-# - name: Build Module Solution
-# run: dotnet build modules/modules.sln --configuration Release --no-restore
-# - name: Test Module Solution
-# run: dotnet test modules/modules.sln --no-restore --verbosity normal
diff --git a/.github/workflows/BlackFormat.yml b/.github/workflows/BlackFormat.yml
index 2f258aab79..151d49269e 100644
--- a/.github/workflows/BlackFormat.yml
+++ b/.github/workflows/BlackFormat.yml
@@ -1,4 +1,4 @@
-name: Format Validation (Black)
+name: Fusion - Black Format Validation
on:
workflow_dispatch: {}
diff --git a/.github/workflows/ClangFormat.yml b/.github/workflows/ClangFormat.yml
deleted file mode 100644
index e1a612599f..0000000000
--- a/.github/workflows/ClangFormat.yml
+++ /dev/null
@@ -1,38 +0,0 @@
-name: Format Validation (Clang)
-
-on:
- workflow_dispatch: {}
- push:
- branches: [ master, dev ]
- pull_request:
- branches: [ master, dev ]
-
-jobs:
- runFormatValidationScript:
- name: Run Clang Format Validation Script
- runs-on: ubuntu-latest
- steps:
- - name: Get Clang Format 16
- run: |
- sudo wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
- sudo add-apt-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main"
- sudo apt-get update
- sudo apt-get install -y clang-format-16
- - name: Checkout Code
- uses: actions/checkout@v2
- - name: Python Setup
- uses: actions/setup-python@v2
- with:
- python-version: '3.9'
- - name: Run Script
- run: python3 scripts/format/format_validation.py
- id: format-validation
- continue-on-error: true
- - name: Check Success
- run: |
- if [ ${{ steps.format-validation.outcome }} == "success" ]; then
- echo "Format Validation Passed"
- else
- echo "Format Validation Failed"
- exit 1
- fi
diff --git a/.github/workflows/Engine.yml b/.github/workflows/Engine.yml
deleted file mode 100644
index cf43ef76ec..0000000000
--- a/.github/workflows/Engine.yml
+++ /dev/null
@@ -1,59 +0,0 @@
-name: Engine
-
-on:
- workflow_dispatch: {}
- push: { branches: [master] }
-
-jobs:
- buildForSomePlatforms:
- name: Build for ${{ matrix.targetPlatform }} on version ${{ matrix.unityVersion }}
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
- matrix:
- projectPath:
- - engine/
- unityVersion:
- - 2022.3.2f1
- targetPlatform:
- - StandaloneWindows64
- - StandaloneLinux64
- - StandaloneOSX
- steps:
- - name: Checkout Repository & Submodules
- uses: actions/checkout@v2
- with:
- submodules: recursive
- - uses: actions/cache@v1.1.0
- with:
- path: ${{ matrix.projectPath }}/Library
- key: Library-${{ matrix.projectPath }}-${{ matrix.targetPlatform }}
- restore-keys: |
- Library-${{ matrix.projectPath }}-
- Library-
- - name: Install Protoc
- uses: arduino/setup-protoc@v2
- with:
- version: "23.3"
- - name: Setup .NET Core
- uses: actions/setup-dotnet@v3
- with:
- dotnet-version: 7.0.x
- - name: Setup Dependencies
- run: |
- bash ./init.sh
- bash ./init.sh
- - name: Build Unity
- uses: game-ci/unity-builder@v2
- env:
- UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
- UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
- UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
- with:
- targetPlatform: ${{ matrix.targetPlatform }}
- projectPath: ${{ matrix.projectPath }}
- allowDirtyBuild: true
- - uses: actions/upload-artifact@v1
- with:
- name: Synthesis-${{ matrix.targetPlatform }}
- path: build
diff --git a/.github/workflows/FissionESLintFormat.yml b/.github/workflows/FissionESLintFormat.yml
index 85e76190be..43a165119f 100644
--- a/.github/workflows/FissionESLintFormat.yml
+++ b/.github/workflows/FissionESLintFormat.yml
@@ -1,4 +1,4 @@
-name: Fission - ES Lint Format
+name: Fission - ES Lint Format Validation
on:
workflow_dispatch: {}
diff --git a/README.md b/README.md
index 87d5c0cc62..6859991690 100644
--- a/README.md
+++ b/README.md
@@ -1,111 +1,72 @@
-![Synthesis: An Autodesk Technology](/engine/Assets/Resources/Branding/Synthesis/Synthesis-An-Autodesk-Technology-2023-lockup-Blk-OL-No-Year-stacked.png#gh-light-mode-only)
-![Synthesis: An Autodesk Technology](/engine/Assets/Resources/Branding/Synthesis/Synthesis-An-Autodesk-Technology-2023-lockup-Wht-OL-No-Year-stacked.png#gh-dark-mode-only)
+![Synthesis: An Autodesk Technology](/fission/res/branding/Synthesis-An-Autodesk-Technology-2023-lockup-Blk-OL-No-Year-stacked.svg#gh-light-mode-only)
+![Synthesis: An Autodesk Technology](/fission/res/branding/Synthesis-An-Autodesk-Technology-2023-lockup-Wht-OL-No-Year-stacked.svg#gh-dark-mode-only)
-[![Engine](https://github.com/Autodesk/synthesis/actions/workflows/Engine.yml/badge.svg?branch=master)](https://github.com/Autodesk/synthesis/actions/workflows/Engine.yml)
-[![API](https://github.com/Autodesk/synthesis/actions/workflows/API.yml/badge.svg?branch=master)](https://github.com/Autodesk/synthesis/actions/workflows/API.yml)
-[![Clang Format](https://github.com/Autodesk/synthesis/actions/workflows/ClangFormat.yml/badge.svg?branch=master)](https://github.com/Autodesk/synthesis/actions/workflows/ClangFormat.yml)
-[![Black Format](https://github.com/Autodesk/synthesis/actions/workflows/BlackFormat.yml/badge.svg?branch=master)](https://github.com/Autodesk/synthesis/actions/workflows/BlackFormat.yml)
+[![Fission - Unit Test](https://github.com/Autodesk/synthesis/actions/workflows/FissionUnitTest.yml/badge.svg?branch=master)](https://github.com/Autodesk/synthesis/actions/workflows/FissionUnitTest.yml)
+[![Fission - Packaging](https://github.com/Autodesk/synthesis/actions/workflows/FissionPackage.yml/badge.svg?branch=master)](https://github.com/Autodesk/synthesis/actions/workflows/FissionPackage.yml)
+[![Fission - Lint/Format](https://github.com/Autodesk/synthesis/actions/workflows/FissionESLintFormat.yml/badge.svg?branch=master)](https://github.com/Autodesk/synthesis/actions/workflows/FissionESLintFormat.yml)
+[![Fusion - Format](https://github.com/Autodesk/synthesis/actions/workflows/BlackFormat.yml/badge.svg?branch=master)](https://github.com/Autodesk/synthesis/actions/workflows/BlackFormat.yml)
-Synthesis is a robotics simulator designed by and for FIRST robotics students to help teams design, strategize, test and practice. Teams have the ability to import their own robots and fields using our [Fusion 360 Exporter](/exporter/) or use the pre-packaged ones that come included with every release of Synthesis.
+Synthesis is a robotics simulator designed by and for [FIRST®](https://www.firstinspires.org/) robotics students to help teams design, strategize, test and practice. Teams have the ability to import their own robots and fields using our [Fusion Exporter](/exporter/) or use the pre-made ones available within Synthesis.
For more information on the product itself or the team, visit [http://synthesis.autodesk.com](http://synthesis.autodesk.com/).
## Goals
-Synthesis is built with a direct focus on the FIRST community. Every single one of our developers is a FIRST student. We've also made the project completely open source in order to better involve the community. This way contributors can help make Synthesis better or modify Synthesis to better suit their team’s needs.
+Synthesis is built with a direct focus on the FIRST® community. Every single one of our developers is a FIRST® student. We've also made the project completely open source in order to better involve the community. This way contributors can help make Synthesis better or modify Synthesis to better suit their team’s needs.
Here are some of our primary goals for Synthesis:
-- **Ease of Use**: It's important for us that Synthesis is out of the box ready for teams to use. We want to make sure that teams can get up and running with Synthesis as quickly as possible. To that end, every release of Synthesis comes pre-packaged with a variety of robots and fields; in addition to the ability to export and import your own.
+- **Ease of Use**: It's important for us that Synthesis is out of the box ready for teams to use. We want to make sure that teams can get up and running with Synthesis as quickly as possible. To that end, Synthesis comes ready with a variety of robots and fields; in addition to the ability to export and import your own.
- **Testing Robot Designs**: Synthesis is designed to be a tool for teams to quickly test their robot designs in a semi-realistic environment. Are you a builder who wants to use some crazy virtual four-bar linkage and your team says it's a waste of time? Well now you can prove them wrong by testing it in Synthesis!
-- **Exploring the Field Environment**: Every year on kickoff, for both FTC and FRC FIRST competitions, Synthesis has a new release with the brand new field for that year included. This allows teams to explore the field through a 3D model, drive a robot around, and begin to strategize for the upcoming season's game.
+- **Exploring the Field Environment**: Every year on kickoff, for both FTC and FRC FIRST® competitions, Synthesis has the newest field available immediately. This allows teams to explore the field through a 3D model, drive a robot around, and begin to strategize for the upcoming season's game.
- **Driver Practice & Strategy**: Not getting enough driver practice or don't have a full field available to you? Synthesis has you covered with the ability to drive your robot around with a gamepad from a first-person view at the driver station; allowing you to get a feel for potential control scheme layouts and any line-of-sight challenges that may arise. This also allows the drive team and the programmers to communicate about what control layouts work best for each driver.
## Getting Started
If you are a FIRST robotics student who just wants to use Synthesis, you *don't* need this repo. Simply **install the latest release of Synthesis from [synthesis.autodesk.com/download](https://synthesis.autodesk.com/download.html)**.
+> [!IMPORTANT]
+> Moving to [synthesis.autodesk.com]
+
If you're a developer who wants to contribute to Synthesis, you're in the right place. Synthesis is comprised of 3 main components that can be developed separately. These components include:
-- [Synthesis API](/api/)
-- [Simulation Engine](/engine/)
-- [Fusion Robot Exporter (Fusion 360 Plugin)](/exporter/)
+- [Fission (Core Web App)](/fission/README.md)
+- [Fusion Exporter (Fusion exporter to Mirabuf file format)](/exporter/SynthesisFusionAddin/README.md)
+- [Installers](/installer/)
-Each of this components can be manually compiled separately, but this is not recommended. Instead, we recommend using the *init* scripts provided (`init.bat` & `init.sh`) to build and link each component together (excluding the Fusion Robot Exporter).
+Follow the above links to the respective READMEs on how to build and run each component.
### Compatibility Notes
-As Fusion 360 is not supported on linux the linux installer does not come with the Fusion 360 Addin for exporting robots and fields.
-
-Also note that the linux installer is tailored for Debian based distributions. Synthesis can be installed and ran on other distros but the installer is not guaranteed for your operating system.
-
-### Dependencies
+As Fusion is not supported on linux, the linux installer does not come with the Fusion Addin for exporting robots and fields.
-Synthesis Version `6.0.0` has the following dependencies:
-
-- [.NET Standard 2.0](https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-1-0)
-- [.NET 7.0](https://dotnet.microsoft.com/en-us/download/dotnet/7.0)
-- [Protobuf 23.3](https://github.com/protocolbuffers/protobuf/releases/tag/v23.3)
-- Unity Version 2022.3.2f1 (d74737c6db50)
-
-These dependencies need to be satisfied before attempting to build Synthesis with unity. You can either install these dependencies manually or use the *resolve dependencies* scripts (`scripts/win/resolve_deps.bat` & `scripts/osx/resolve_deps.sh`) to install some of them for you.
+## Contributing
-To automatically install .NET and Protobuf run the following script depending on your operating system:
-- Windows: `scripts/win/resolve_deps.bat`
-- MacOS & Linux: `scripts/osx/resolve_deps.sh`
+This project welcomes community suggestions and contributions. Synthesis is nearly 100% open source and relies on the FIRST® community to help make it better. The [Synthesis Contribution Guide](/CONTRIBUTING.md) suggests ways in which you can get involved through development and non-development avenues.
-Dependency Notes:
+Before you contribute to this repository, please first discuss the change you wish to make via a GitHub issue, email us ([frc@autodesk.com](mailto:frc@autodesk.com)), or reach out through our [community discord](https://www.discord.gg/hHcF9AVgZA). This way we can ensure that there is no overlap between outside contributors and internal development work.
-- The windows script requires admin privileges to install .NET and Protobuf to the system PATH. For this reason it is not included by default in `init.bat` unlike how `init.sh` includes `resolve_deps.sh`.
-- Unity must be installed manually through the Unity Hub app which can be downloaded from [https://unity.com/download](https://unity.com/download).
+When ready to contribute, fork the synthesis repository, make your changes, and submit a pull request. Be sure to fill out the template accordingly to make reviewing your work as smooth as possible. Feel free to check out our [contributing guidelines](/CONTRIBUTING.md) to learn more.
-### How To Build Synthesis Using An `init` Script And Unity
+## Code Formatting And Style
-Before attempting to build Synthesis, ensure you have all dependencies installed.
+All code is under a configured formatting utility. See each component for more details.
-1. Open a command prompt.
-2. Change directories to a location where you'd like to clone the Synthesis repository.
-3. Clone the Synthesis repository using `git clone https://github.com/Autodesk/synthesis --recurse-submodules`.
-4. Change directories into the root of the Synthesis repository and run the `init` script for your operating system.
- - Windows: `init.bat`
- - MacOS & Linux: `init.sh`
-5. Open `synthesis/engine` in Unity.
-6. From there, you can run the simulation engine inside the Unity editor by opening `MainScene` from the `Assets/Scenes` directory or build it as a standalone application.
- - To build Synthesis as a standalone application, go to `File -> Build Settings` and select your target platform. Then, click `Build` and select a location to save the built application.
+## Other Components
-## Contributing
+### Mirabuf
-This project welcomes community suggestions and contributions. Synthesis is 100% open source and relies on the FIRST community to help make it better. The [Synthesis Contribution Guide](/CONTRIBUTING.md) suggests ways in which you can get involved through development and non-development avenues.
+Mirabuf is a file format we use to store physical data from Fusion to load into the Synthesis simulator (Fission). This is a separate project that is a submodule of Synthesis. [See Mirabuf](https://github.com/HiceS/mirabuf/)
-Before you contribute to this repository, please first discuss the change you wish to make via a GitHub issue, email us ([frc@autodesk.com](mailto:frc@autodesk.com)), or reach out through our [community discord](https://www.discord.gg/hHcF9AVgZA). This way we can ensure that there is no overlap between outside contributors and internal development work.
+### Tutorials
-When ready to contribute, just submit a pull request and be sure to fill out the template accordingly so that we can verify them and eventually merge. Feel free to check out our [contributing guidelines](/CONTRIBUTING.md) to learn more.
+Our source code for the tutorials featured on our [Tutorials Page](https://synthesis.autodesk.com/tutorials.html).
-## Code Formatting And Style
+### Protocols
-Synthesis uses [clang-format](https://clang.llvm.org/docs/ClangFormat.html) and [black](https://black.readthedocs.io/en/stable/) to format all of our `C++`, `C#` and `Python` code. Additionally we have GitHub workflows that verify these formatting standards for each and every pull request. For more information about how to run these formatters yourself, check out the [formatting tools](/scripts/format/) we use.
-
-## Components
-
-Here is a brief overview of each of the components found in this repository. For more information about each component, their dependencies and their individual build processes, check out their respective *READMEs*.
-
-- [Synthesis API](/api/)
- - Components used to extend Synthesis' functionality while remaining Unity agnostic.
-- [Code Emulation](/emulation/)
- - Synthesis tool designed to help users test their FRC robot code in a simulated environment.
- - Code emulation is an advanced feature that is still under development, functionality and support is limited.
-- [Core Engine](/engine/)
- - The core of Synthesis, the Unity project that contains the simulation engine.
-- [Fusion Exporter](/exporter/SynthesisFusionAddin/)
- - The Fusion 360 plugin that allows users to export their robots and fields into Synthesis.
-- [Installer](/installer/)
- - Tools used to build the Synthesis installer for Windows, MacOS and Linux featured on our [Download Page](https://synthesis.autodesk.com/download.html).
-- [Mirabuf](https://github.com/HiceS/mirabuf/)
- - A custom 3D file format developed by [@HiceS](https://github.com/HiceS) that our Fusion 360 exporter uses.
-- [Tutorials](/tutorials/)
- - Our source code for the tutorials featured on our [Tutorials Page](https://synthesis.autodesk.com/tutorials.html).
+Additional protobuf files that we use in addition to Mirabuf. [See Protocols](/protocols/README.md)
## Tutorials
diff --git a/VersionManager.json b/VersionManager.json
deleted file mode 100644
index 836ad8ee36..0000000000
--- a/VersionManager.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "Version": "6.1.0",
- "URL": "https://synthesis.autodesk.com/download.html"
-}
diff --git a/api/.gitignore b/api/.gitignore
deleted file mode 100644
index 9e90125662..0000000000
--- a/api/.gitignore
+++ /dev/null
@@ -1,7 +0,0 @@
-*/bin
-*/obj
-
-.vscode/
-api.sln.DotSettings.user
-
-Api/Proto
diff --git a/api/Aardvark/Aardvark.csproj b/api/Aardvark/Aardvark.csproj
deleted file mode 100644
index 2096e2aa94..0000000000
--- a/api/Aardvark/Aardvark.csproj
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
- netstandard2.0
-
-
-
-
-
-
-
diff --git a/api/Aardvark/IO/BXDA/BXDAMesh.cs b/api/Aardvark/IO/BXDA/BXDAMesh.cs
deleted file mode 100644
index d5831de6bb..0000000000
--- a/api/Aardvark/IO/BXDA/BXDAMesh.cs
+++ /dev/null
@@ -1,210 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-
-///
-/// Represents a 3D object composed of one or more and physical properties of the object.
-///
-public partial class BXDAMesh : BinaryRWObject
-{
- ///
- /// Represents the revision id/version of the BXDA format (increment this when a new revision is released).
- ///
- const uint BXDA_CURRENT_VERSION = 0;
-
- ///
- /// The GUID for identifying the BXDAMesh.
- ///
- public Guid GUID
- {
- get;
- private set;
- }
-
- ///
- /// The physical properties of this object.
- ///
- public PhysicalProperties physics
- {
- get;
- private set;
- }
-
- ///
- /// This object's sub meshes.
- ///
- public List meshes
- {
- get;
- private set;
- }
-
- ///
- /// This object's collision meshes.
- ///
- public List colliders
- {
- get;
- private set;
- }
-
- ///
- /// Creates an empty BXDA Mesh.
- ///
- public BXDAMesh()
- : this(Guid.NewGuid())
- {
- }
-
- ///
- /// Creates an empty BXDA Mesh.
- ///
- public BXDAMesh(Guid guid)
- {
- GUID = guid;
- physics = new PhysicalProperties();
- meshes = new List();
- colliders = new List();
- }
-
- ///
- /// Writes all mesh data with the given BinaryWriter.
- ///
- ///
- public void WriteBinaryData(BinaryWriter writer)
- {
- writer.Write(BXDA_CURRENT_VERSION);
-
- writer.Write(GUID.ToString());
-
- WriteMeshList(writer, meshes);
- WriteMeshList(writer, colliders);
- physics.WriteBinaryData(writer);
- }
-
- ///
- /// Reads with the given BinaryReader to generate mesh data.
- ///
- ///
- public void ReadBinaryData(BinaryReader reader)
- {
- // Gets the version to determine how to read the file.
- uint version = reader.ReadUInt32();
-
- switch (version)
- {
- case 0:
- ReadData_v0(reader);
- break;
- }
- }
-
- ///
- /// Writes all the sub meshes in the given list to the given stream.
- ///
- /// Output stream
- /// Mesh list
- private static void WriteMeshList(BinaryWriter writer, List meshes)
- {
- writer.Write(meshes.Count);
- foreach (BXDASubMesh mesh in meshes)
- {
- mesh.WriteData(writer);
- }
- }
-
- ///
- /// Represents an indexed triangle mesh with normals and optional colors and texture coordinates.
- ///
- public partial class BXDASubMesh
- {
- ///
- /// Vertex positions. Three values (X, Y, Z) per vertex.
- ///
- public double[] verts;
-
- ///
- /// Vertex normals. Three values (X, Y, Z) composing one unit vector per vertex.
- ///
- public double[] norms;
-
- ///
- /// A list of indexed surfaces that make up the mesh
- ///
- public List surfaces = new List();
-
- public void WriteData(BinaryWriter writer)
- {
- int vertCount = verts.Length / 3;
- byte meshFlags = (byte)((norms != null ? 1 : 0));
-
- writer.Write(meshFlags);
- writer.WriteArray(verts, 0, vertCount * 3);
- if (norms != null)
- {
- writer.WriteArray(norms, 0, vertCount * 3);
- }
-
- writer.Write(surfaces.Count);
- foreach (BXDASurface surface in surfaces)
- {
- surface.WriteData(writer);
- }
- }
-
- public void ReadData(BinaryReader reader)
- {
-
- }
- }
-
- ///
- /// Index data representing a face with color, transparency, translucency, and specular
- ///
- public partial class BXDASurface
- {
- public bool hasColor = false;
- ///
- /// The color of the material packed as an unsigned integer
- ///
- public uint color = 0xFFFFFFFF;
-
- ///
- /// The transparency of the material. [0-1]
- ///
- public float transparency;
-
- ///
- /// The translucency of the material. [0-1]
- ///
- public float translucency;
-
- ///
- /// The specular intensity of the material. [0-1]
- ///
- public float specular = 0;
-
- ///
- /// The zero based index buffer for this specific surface of the mesh.
- ///
- public int[] indicies;
-
- public void WriteData(BinaryWriter writer)
- {
- int facetCount = indicies.Length / 3;
-
- writer.Write(hasColor);
- if (hasColor)
- {
- writer.Write(color);
- }
- writer.Write(transparency);
- writer.Write(translucency);
- writer.Write(specular);
-
- writer.WriteArray(indicies, 0, facetCount * 3);
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/api/Aardvark/IO/BXDA/BXDAReader_v0.cs b/api/Aardvark/IO/BXDA/BXDAReader_v0.cs
deleted file mode 100644
index ebb43b3cde..0000000000
--- a/api/Aardvark/IO/BXDA/BXDAReader_v0.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-
-///
-/// Represents a 3D object composed of one or more and physical properties of the object.
-///
-public partial class BXDAMesh : BinaryRWObject
-{
- ///
- /// Reads with the given BinaryReader to generate mesh data of v0.
- ///
- ///
- private void ReadData_v0(BinaryReader reader)
- {
- // Re-reads version just in case.
- GUID = new Guid(reader.ReadString());
-
- meshes.Clear();
- colliders.Clear();
- ReadMeshList_v0(reader, meshes);
- ReadMeshList_v0(reader, colliders);
-
- physics.ReadBinaryData(reader);
- }
-
- ///
- /// Reads a list of meshes from the given stream, adding them to the list passed into this function.
- ///
- /// Input stream
- /// List to output to
- private static void ReadMeshList_v0(BinaryReader reader, List meshes)
- {
- int meshCount = reader.ReadInt32();
- for (int id = 0; id < meshCount; id++)
- {
- BXDASubMesh mesh = new BXDASubMesh();
- mesh.ReadData_v0(reader);
- meshes.Add(mesh);
- }
- }
-
- ///
- /// Represents an indexed triangle mesh with normals and optional colors and texture coordinates.
- ///
- public partial class BXDASubMesh
- {
- ///
- /// Reads BXDASubMesh data of v0.
- ///
- ///
- public void ReadData_v0(BinaryReader reader)
- {
- byte meshFlags = reader.ReadByte();
- norms = (meshFlags & 1) == 1 ? new double[1 * 3] : null;
- verts = reader.ReadArray();
- if (norms != null)
- {
- norms = reader.ReadArray();
- }
-
- int surfaceCount = reader.ReadInt32();
- for (int i = 0; i < surfaceCount; i++)
- {
- BXDASurface nextSurface = new BXDASurface();
- nextSurface.ReadData_v0(reader);
- surfaces.Add(nextSurface);
- }
- }
- }
-
- ///
- /// Index data representing a face with color, transparency, translucency, and specular
- ///
- public partial class BXDASurface
- {
- ///
- /// Reads BXDASurface data of v0.
- ///
- ///
- public void ReadData_v0(BinaryReader reader)
- {
- hasColor = reader.ReadBoolean();
-
- if (hasColor)
- {
- color = reader.ReadUInt32();
- }
- transparency = reader.ReadSingle();
- translucency = reader.ReadSingle();
- specular = reader.ReadSingle();
-
- indicies = reader.ReadArray();
- }
- }
-}
\ No newline at end of file
diff --git a/api/Aardvark/IO/BXDF/BXDFProperties.cs b/api/Aardvark/IO/BXDF/BXDFProperties.cs
deleted file mode 100644
index 0b0f8d1a3e..0000000000
--- a/api/Aardvark/IO/BXDF/BXDFProperties.cs
+++ /dev/null
@@ -1,267 +0,0 @@
-using System.Collections.Generic;
-using System.Xml;
-
-public partial class BXDFProperties
-{
- ///
- /// Represents the current version of the BXDF file.
- ///
- public const string BXDF_CURRENT_VERSION = "2.2.0";
-
- ///
- /// Represents the default name of any element.
- ///
- public const string BXDF_DEFAULT_NAME = "UNDEFINED";
-
- ///
- /// Reads the given BXDF file from the given path with the latest version possible.
- ///
- ///
- ///
- public static FieldDefinition ReadProperties(string path)
- {
- string result;
- return ReadProperties(path, out result);
- }
-
- ///
- /// Reads the given BXDF file from the given path with the latest version possible.
- ///
- ///
- ///
- public static FieldDefinition ReadProperties(string path, out string result)
- {
- XmlReader reader = XmlReader.Create(path);
-
- // Find the BXDF element.
- if (reader.ReadToFollowing("BXDF"))
- {
- string version = reader["Version"];
-
- // Determine the version of the file.
- switch (version.Substring(0, version.LastIndexOf('.')))
- {
- case "2.2":
- return ReadProperties_2_2(path, out result);
- default: // If version is unknown.
- // Attempt to read with the most recent version (but without validation).
- return ReadProperties_2_2(path, out result, false);
- }
- }
- else
- {
- // Could not find element, so return null.
- result = "Could not find BXDF element.";
- return null;
- }
- }
-
- ///
- /// Writes out the properties file in XML format for the node with the base provided to
- /// the path provided.
- ///
- ///
- ///
- public static void WriteProperties(string path, FieldDefinition fieldDefinition)
- {
- if (System.IO.File.Exists(path)) System.IO.File.Delete(path);
- XmlWriterSettings settings = new XmlWriterSettings();
- settings.Indent = true;
-
- XmlWriter writer = XmlWriter.Create(path, settings);
-
- // Begins the document.
- writer.WriteStartDocument();
-
- /// Writes the root element and its GUID.
- writer.WriteStartElement("BXDF");
- writer.WriteAttributeString("Version", BXDF_CURRENT_VERSION);
- writer.WriteAttributeString("GUID", fieldDefinition.GUID.ToString());
-
- Dictionary propertySets = fieldDefinition.GetPropertySets();
-
- // Writes the data for each PropertySet.
- foreach (PropertySet propertySet in propertySets.Values)
- {
- // Starts the element.
- writer.WriteStartElement("PropertySet");
-
- // Writes the ID attribute for the PropertySet.
- writer.WriteAttributeString("ID", propertySet.PropertySetID);
-
- // Writes the collider property for the PropertySet.
- WriteCollider(writer, propertySet.Collider);
-
- // Writes the friction property for the PropertySet.
- writer.WriteElementString("Friction", propertySet.Friction.ToString());
-
- // Writes the mass property for the PropertySet.
- writer.WriteElementString("Mass", propertySet.Mass.ToString("F4"));
-
- // Ends the element.
- writer.WriteEndElement();
- }
-
- // Writes the node group.
- WriteFieldNodeGroup(writer, fieldDefinition.NodeGroup);
-
- // Ends the document.
- writer.WriteEndDocument();
-
- // Close the writer.
- writer.Close();
- }
-
- ///
- /// Writes the BXDVector3 to an XML file with the given XmlWriter.
- ///
- ///
- ///
- private static void WriteBXDVector3(XmlWriter writer, BXDVector3 vec, string id)
- {
- writer.WriteStartElement("BXDVector3");
-
- writer.WriteAttributeString("ID", id);
-
- writer.WriteElementString("X", vec.x.ToString("F4"));
- writer.WriteElementString("Y", vec.y.ToString("F4"));
- writer.WriteElementString("Z", vec.z.ToString("F4"));
-
- writer.WriteEndElement();
- }
-
- ///
- /// Writes the BXDQuaternion to an XML file with the given XmlWriter.
- ///
- ///
- ///
- ///
- private static void WriteBXDQuaternion(XmlWriter writer, BXDQuaternion quat, string id)
- {
- writer.WriteStartElement("BXDQuaternion");
-
- writer.WriteAttributeString("ID", id);
-
- writer.WriteElementString("X", quat.X.ToString("F4"));
- writer.WriteElementString("Y", quat.Y.ToString("F4"));
- writer.WriteElementString("Z", quat.Z.ToString("F4"));
- writer.WriteElementString("W", quat.W.ToString("F4"));
-
- writer.WriteEndElement();
- }
-
- ///
- /// Write the BoxCollider to an XML file with the given XmlWriter.
- ///
- ///
- ///
- private static void WriteBoxCollider(XmlWriter writer, PropertySet.BoxCollider boxCollider)
- {
- writer.WriteStartElement("BoxCollider");
-
- WriteBXDVector3(writer, boxCollider.Scale, "Scale");
-
- writer.WriteEndElement();
- }
-
- ///
- /// Write the SphereCollider to an XML file with the given XmlWriter.
- ///
- ///
- ///
- private static void WriteSphereCollider(XmlWriter writer, PropertySet.SphereCollider sphereCollider)
- {
- writer.WriteStartElement("SphereCollider");
-
- writer.WriteElementString("Scale", sphereCollider.Scale.ToString("F4"));
-
- writer.WriteEndElement();
- }
-
- ///
- /// Write the MeshCollider to an XML file with the given XmlWriter.
- ///
- ///
- ///
- private static void WriteMeshCollider(XmlWriter writer, PropertySet.MeshCollider meshCollider)
- {
- writer.WriteStartElement("MeshCollider");
-
- writer.WriteElementString("Convex", meshCollider.Convex.ToString().ToLower());
-
- writer.WriteEndElement();
- }
-
- ///
- /// Writes the given PropertySet's collider to an XML file with the given XmlWriter.
- ///
- ///
- ///
- private static void WriteCollider(XmlWriter writer, PropertySet.PropertySetCollider propertySetCollider)
- {
- switch (propertySetCollider.CollisionType)
- {
- case PropertySet.PropertySetCollider.PropertySetCollisionType.BOX:
- WriteBoxCollider(writer, (PropertySet.BoxCollider)propertySetCollider);
- break;
- case PropertySet.PropertySetCollider.PropertySetCollisionType.SPHERE:
- WriteSphereCollider(writer, (PropertySet.SphereCollider)propertySetCollider);
- break;
- case PropertySet.PropertySetCollider.PropertySetCollisionType.MESH:
- WriteMeshCollider(writer, (PropertySet.MeshCollider)propertySetCollider);
- break;
- }
- }
-
- ///
- /// Writes all the data included in a FieldNodeGroup.
- ///
- ///
- ///
- private static void WriteFieldNodeGroup(XmlWriter writer, FieldNodeGroup fieldNodeGroup)
- {
- // Starts the assembly element.
- writer.WriteStartElement("NodeGroup");
-
- // Writes the NodeGroupID property.
- writer.WriteAttributeString("ID", fieldNodeGroup.NodeGroupID);
-
- foreach (FieldNode node in fieldNodeGroup.EnumerateFieldNodes())
- {
- // Starts the element.
- writer.WriteStartElement("Node");
-
- // Writes the NodeID attribute.
- writer.WriteAttributeString("ID", node.NodeID);
-
- // Writes the Position property as a BXDVector3.
- WriteBXDVector3(writer, node.Position, "Position");
-
- // Write the EulerRotation property as a BXDQuaternion.
- WriteBXDQuaternion(writer, node.Rotation, "Rotation");
-
- // Writes the MeshID element.
- writer.WriteElementString("SubMeshID", node.SubMeshID.ToString());
-
- // Writes the CollisionMeshID element if a collider has been assigned.
- if (node.CollisionMeshID != -1)
- writer.WriteElementString("CollisionMeshID", node.CollisionMeshID.ToString());
-
- // Writes the PropertySetID element if a PropertySet has been assigned.
- if (node.PropertySetID != BXDF_DEFAULT_NAME)
- writer.WriteElementString("PropertySetID", node.PropertySetID);
-
- // Ends the element.
- writer.WriteEndElement();
- }
-
- foreach (FieldNodeGroup nodeGroup in fieldNodeGroup.EnumerateFieldNodeGroups())
- {
- // Reiterates as the current FieldNodeGroup.
- WriteFieldNodeGroup(writer, nodeGroup);
- }
-
- // Ends the assembly element.
- writer.WriteEndElement();
- }
-}
diff --git a/api/Aardvark/IO/BXDF/BXDFReader_2_2.cs b/api/Aardvark/IO/BXDF/BXDFReader_2_2.cs
deleted file mode 100644
index f408782547..0000000000
--- a/api/Aardvark/IO/BXDF/BXDFReader_2_2.cs
+++ /dev/null
@@ -1,482 +0,0 @@
-using System;
-using System.IO;
-using System.Xml;
-using System.Xml.Schema;
-
-public partial class BXDFProperties
-{
- #region XSD Markup
-
- ///
- /// The XSD markup to ensure valid document reading.
- ///
- private const string BXDF_XSD_2_2 =
- @"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ";
-
- #endregion
-
- ///
- /// Reads the properties contained in the XML BXDF file specified and returns
- /// the corresponding FieldDefinition.
- ///
- ///
- ///
- ///
- private static FieldDefinition ReadProperties_2_2(string path, out string result, bool useValidation = true)
- {
- // The FieldDefinition to be returned.
- FieldDefinition fieldDefinition = null;
-
- XmlReaderSettings settings = new XmlReaderSettings();
-
- if (useValidation)
- {
- settings.Schemas.Add(XmlSchema.Read(new StringReader(BXDF_XSD_2_2), null));
- settings.ValidationType = ValidationType.Schema;
- }
- else
- {
- settings.ValidationType = ValidationType.None;
- }
-
- XmlReader reader = XmlReader.Create(path, settings);
-
- try
- {
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDF":
- // Assign a value to fieldDefinition with the given GUID attribute.
- fieldDefinition = FieldDefinition.Factory(new Guid(reader["GUID"]));
- break;
- case "PropertySet":
- // Reads the current element as a PropertySet.
- ReadPropertySet_2_2(reader.ReadSubtree(), fieldDefinition);
- break;
- case "NodeGroup":
- // Reads the root FieldNodeGroup.
- ReadFieldNodeGroup_2_2(reader.ReadSubtree(), fieldDefinition.NodeGroup);
- break;
- }
- }
-
- result = "Success.";
-
- return fieldDefinition;
- }
- catch (Exception e)// A variety of exceptions can take place if the file is invalid, but we will always want to return null.
- {
- result = e.Message;
-
- // If the file is invalid, return null.
- return null;
- }
- finally
- {
- // Closes the reader.
- reader.Close();
- }
- }
-
- ///
- /// Reads a BXDVector3 with the given XmlReader and returns the reading.
- ///
- ///
- ///
- private static BXDVector3 ReadBXDVector3_2_2(XmlReader reader)
- {
- BXDVector3 vec = new BXDVector3();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "X":
- // Assign the x value.
- vec.x = float.Parse(reader.ReadElementContentAsString());
- break;
- case "Y":
- // Assign the y value.
- vec.y = float.Parse(reader.ReadElementContentAsString());
- break;
- case "Z":
- // Assign the z value.
- vec.z = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return vec;
- }
-
- ///
- /// Reads a BXDQuaternion with the given XmlReader and returns the reading.
- ///
- ///
- ///
- private static BXDQuaternion ReadBXDQuaternion_2_2(XmlReader reader)
- {
- BXDQuaternion quat = new BXDQuaternion();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "X":
- // Assign the X value.
- quat.X = float.Parse(reader.ReadElementContentAsString());
- break;
- case "Y":
- // Assign the Y value.
- quat.Y = float.Parse(reader.ReadElementContentAsString());
- break;
- case "Z":
- // Assign the Z value.
- quat.Z = float.Parse(reader.ReadElementContentAsString());
- break;
- case "W":
- // Assign the W value.
- quat.W = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return quat;
- }
-
- ///
- /// Reads a BoxCollider with the given XmlReader.
- ///
- ///
- ///
- private static PropertySet.BoxCollider ReadBoxCollider_2_2(XmlReader reader)
- {
- // Create the BoxCollider.
- PropertySet.BoxCollider boxCollider = null;
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- // Reads the scale properties and initializes the BoxCollider.
- boxCollider = new PropertySet.BoxCollider(ReadBXDVector3_2_2(reader.ReadSubtree()));
- break;
- }
- }
-
- return boxCollider;
- }
-
- ///
- /// Reads a SphereCollider with the given XmlReader.
- ///
- ///
- ///
- private static PropertySet.SphereCollider ReadSphereCollider_2_2(XmlReader reader)
- {
- // Create the SphereCollider.
- PropertySet.SphereCollider sphereCollider = null;
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "Scale":
- // Reads the scale property and initializes the SphereCollider.
- sphereCollider = new PropertySet.SphereCollider(float.Parse(reader.ReadElementContentAsString()));
- break;
- }
- }
-
- return sphereCollider;
- }
-
- ///
- /// Reads a MeshCollider with the given XmlReader.
- ///
- ///
- ///
- private static PropertySet.MeshCollider ReadMeshCollider_2_2(XmlReader reader)
- {
- // Create the MeshCollider.
- PropertySet.MeshCollider meshCollider = null;
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "Convex":
- // Reads the convex property and initializes the MeshCollider.
- meshCollider = new PropertySet.MeshCollider(reader.ReadElementContentAsBoolean());
- break;
- }
- }
-
- return meshCollider;
- }
-
- ///
- /// Reads the subtree of a PropertySet element.
- ///
- ///
- ///
- private static void ReadPropertySet_2_2(XmlReader reader, FieldDefinition fieldDefinition)
- {
- // Creates a new PropertySet.
- PropertySet propertySet = new PropertySet();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "PropertySet":
- // Assigns the ID attribute value to the PropertySetID property.
- propertySet.PropertySetID = reader["ID"];
- break;
- case "BoxCollider":
- // Assigns the BoxCollider read by the XmlReader to the PropertySet's Collider property.
- propertySet.Collider = ReadBoxCollider_2_2(reader.ReadSubtree());
- break;
- case "SphereCollider":
- // Assigns the SphereCollider read by the XmlReader to the PropertySet's Collider property.
- propertySet.Collider = ReadSphereCollider_2_2(reader.ReadSubtree());
- break;
- case "MeshCollider":
- // Assigns the MeshCollider read by the XmlReader to the PropertySet's Collider property.
- propertySet.Collider = ReadMeshCollider_2_2(reader.ReadSubtree());
- break;
- case "Friction":
- // Assings the Friction attribute value to the Friction property.
- propertySet.Friction = reader.ReadElementContentAsInt();
- break;
- case "Mass":
- // Assings the Mass attribute value to the Mass property.
- propertySet.Mass = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- // Adds the PropertySet to the fieldDefinition.
- fieldDefinition.AddPropertySet(propertySet);
- }
-
- ///
- /// Reads the subtree of a FieldNode and returns the result.
- ///
- ///
- ///
- private static FieldNode ReadFieldNode_2_2(XmlReader reader)
- {
- FieldNode node = null;
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "Node":
- node = new FieldNode(reader["ID"]);
- break;
- case "BXDVector3":
- // Read the BXDVector3 as the node's position.
- node.Position = ReadBXDVector3_2_2(reader.ReadSubtree());
- break;
- case "BXDQuaternion":
- // Read the BXDVector3 as the node's rotation.
- node.Rotation = ReadBXDQuaternion_2_2(reader.ReadSubtree());
- break;
- case "SubMeshID":
- // Assign the MeshID attribute value to the SubMeshID property.
- node.SubMeshID = reader.ReadElementContentAsInt();
- break;
- case "CollisionMeshID":
- // Assign the CollisionMeshID attribute value to the CollisionMeshID property.
- node.CollisionMeshID = reader.ReadElementContentAsInt();
- break;
- case "PropertySetID":
- // Assign the PropertySetID attribute value to the PropertySetID property.
- node.PropertySetID = reader.ReadElementContentAsString();
- break;
- }
- }
-
- return node;
- }
-
- ///
- /// Iterates through each child FieldNodeGroup and adds all FieldNodes to the given FieldNodeGroup.
- ///
- ///
- ///
- private static void ReadFieldNodeGroup_2_2(XmlReader reader, FieldNodeGroup fieldNodeGroup)
- {
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "Node":
- // Add the FieldNode to fieldNodeGroup.
- fieldNodeGroup.AddNode(ReadFieldNode_2_2(reader.ReadSubtree()));
- break;
- case "NodeGroup":
- // If an ID has not been assigned to the current FieldNodeGroup.
- if (fieldNodeGroup.NodeGroupID.Equals(BXDFProperties.BXDF_DEFAULT_NAME))
- {
- // Assign the ID attribute value to the NodeGroupID property.
- fieldNodeGroup.NodeGroupID = reader["ID"];
- }
- else
- {
- // Creates a new FieldNodeGroup.
- FieldNodeGroup childNodeGroup = new FieldNodeGroup(BXDFProperties.BXDF_DEFAULT_NAME);
-
- // Re-iterate as the childNodeGroup.
- ReadFieldNodeGroup_2_2(reader.ReadSubtree(), childNodeGroup);
-
- // Add the processed FieldNodeGroup to fieldNodeGroup.
- fieldNodeGroup.AddNodeGroup(childNodeGroup);
- }
- break;
- }
- }
- }
-}
diff --git a/api/Aardvark/IO/BXDIO.cs b/api/Aardvark/IO/BXDIO.cs
deleted file mode 100644
index 928c8251ba..0000000000
--- a/api/Aardvark/IO/BXDIO.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-using System;
-
-///
-/// Utility functions for file I/O
-///
-public class BXDIO
-{
- public const byte MAJOR_VERSION = 0; // Bump on stable releases
- public const byte MINOR_VERSION = 3; // Bump on beta releases
- public const byte REVISION_VERSION = 3; // Bump on major IO changes.
- public const byte REVISION_PORTION = 1; // Bump on IO changes in a meta chunk.
-
- public const string ASSEMBLY_VERSION = "0.3.3.1"; // I'm so sorry that this isn't dynamic :'(
-
- public delegate void ProgressReporter(long progress, long total);
-
- ///
- /// The version of the file format this file can read and write.
- ///
- public const uint FORMAT_VERSION = (MAJOR_VERSION << 24) | (MINOR_VERSION << 16) | (REVISION_VERSION << 8) | REVISION_PORTION;
-
- ///
- /// Converts the given version ID number to decimal notation.
- ///
- /// Version ID
- /// Decimal notation of the version ID
- public static string VersionToString(uint version)
- {
- return ((version >> 24) & 0xFF) + "." + ((version >> 16) & 0xFF) + "." + ((version >> 8) & 0xFF) + "." + ((version >> 0) & 0xFF);
- }
-
- ///
- /// Talks about compatibility.
- ///
- /// The version to compare with
- public static void CheckReadVersion(uint version)
- {
- if ((version & 0xFF000000) == (FORMAT_VERSION & 0xFF000000))
- {
- if ((version & 0xFFFF0000) != (FORMAT_VERSION & 0xFFFF0000))
- {
- Console.Write("Trying to read version " + VersionToString(version) + " using API version " + VersionToString(FORMAT_VERSION) + ". Continue? (y/N) ");
- }
- return;
- }
- throw new FormatException("Trying to read version " + VersionToString(version) + " using API version " + VersionToString(FORMAT_VERSION));
- }
-
- // Prevents creation of an instance of this class
- private BXDIO()
- {
- }
-}
diff --git a/api/Aardvark/IO/BXDJ/BXDJReader_2_0.cs b/api/Aardvark/IO/BXDJ/BXDJReader_2_0.cs
deleted file mode 100644
index 7a6e7fb0f9..0000000000
--- a/api/Aardvark/IO/BXDJ/BXDJReader_2_0.cs
+++ /dev/null
@@ -1,908 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Xml;
-using System.Xml.Schema;
-
-///
-/// Utility functions for reading/writing BXDJ files
-///
-public partial class BXDJSkeleton
-{
- #region XSD Markup
-
- ///
- /// The XSD markup to ensure valid document reading.
- ///
- private const string BXDJ_XSD_2_0 =
- @"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ";
-
- #endregion
-
- ///
- /// Reads the skeleton contained in the XML BXDJ file specified and
- /// returns the corresponding RigidNode_Base.
- ///
- ///
- ///
- private static RigidNode_Base ReadSkeleton_2_0(string path, bool useValidation = true)
- {
- RigidNode_Base root = null;
- List nodes = new List();
-
- XmlReaderSettings settings = new XmlReaderSettings();
-
- if (useValidation)
- {
- settings.Schemas.Add(XmlSchema.Read(new StringReader(BXDJ_XSD_2_0), null));
- settings.ValidationType = ValidationType.Schema;
- }
- else
- {
- settings.ValidationType = ValidationType.None;
- }
-
- XmlReader reader = XmlReader.Create(path, settings);
-
- try
- {
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "Node":
- // Reads the current element as a node.
- ReadNode_2_0(reader.ReadSubtree(), nodes, ref root);
- break;
- }
- }
- }
- catch (Exception)// A variety of exceptions can take place if the file is invalid, but we will always want to return null.
- {
- // If the file is invalid, return null.
- return null;
- }
- finally
- {
- // Closes the reader.
- reader.Close();
- }
-
- return nodes[0];
- }
-
- ///
- /// Reads a RigidNode_Base with the given reader, list of nodes, and root node reference.
- ///
- ///
- ///
- ///
- private static void ReadNode_2_0(XmlReader reader, List nodes, ref RigidNode_Base root)
- {
- int parentID = -1;
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "Node":
- // Adds a new node to the list of RigidNode_Bases.
- nodes.Add(RigidNode_Base.NODE_FACTORY(new Guid(reader["GUID"])));
- break;
- case "ParentID":
- // Stores this ID for later use.
- parentID = reader.ReadElementContentAsInt();
-
- if (parentID == -1) // If this is the root...
- root = nodes[nodes.Count - 1];
- break;
- case "ModelFileName":
- // Assigns the ModelFileName property to the ModelFileName element value.
- nodes[nodes.Count - 1].ModelFileName = reader.ReadElementContentAsString();
- break;
- case "ModelID":
- // Assigns the ModelFullID property to the ModelID element value.
- nodes[nodes.Count - 1].ModelFullID = reader.ReadElementContentAsString();
- break;
- case "BallJoint":
- // Reads the current element as a BallJoint.
- nodes[parentID].AddChild(ReadBallJoint_2_0(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "CylindricalJoint":
- // Reads the current element as a CylindricalJoint.
- nodes[parentID].AddChild(ReadCylindricalJoint_2_0(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "LinearJoint":
- // Reads the current element as a LinearJoint.
- nodes[parentID].AddChild(ReadLinearJoint_2_0(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "PlanarJoint":
- // Reads the current element as a PlanarJoint.
- nodes[parentID].AddChild(ReadPlanarJoint_2_0(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "RotationalJoint":
- // Reads the current elemenet as a RotationalJoint.
- nodes[parentID].AddChild(ReadRotationalJoint_2_0(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "JointDriver":
- // Add a joint driver to the skeletal joint of the current node.
- nodes[nodes.Count - 1].GetSkeletalJoint().cDriver = ReadJointDriver_2_0(reader.ReadSubtree());
- break;
- case "RobotSensor":
- nodes[nodes.Count - 1].GetSkeletalJoint().attachedSensors.Add(ReadRobotSensor_2_0(reader.ReadSubtree()));
- break;
- }
- }
- }
-
- ///
- /// Reads a BallJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static BallJoint_Base ReadBallJoint_2_0(XmlReader reader)
- {
- // Create a new BallJoint_Base.
- BallJoint_Base ballJoint = (BallJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.BALL);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- // Read the BXDVector3 as the basePoint.
- ballJoint.basePoint = ReadBXDVector3_2_0(reader.ReadSubtree());
- break;
- }
- }
-
- return ballJoint;
- }
-
- ///
- /// Reads a CylindricalJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static CylindricalJoint_Base ReadCylindricalJoint_2_0(XmlReader reader)
- {
- // Create a new CylindricalJoint_Base.
- CylindricalJoint_Base cylindricalJoint = (CylindricalJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.CYLINDRICAL);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "BasePoint":
- // Assign the BXDVector3 to the basePoint.
- cylindricalJoint.basePoint = ReadBXDVector3_2_0(reader.ReadSubtree());
- break;
- case "Axis":
- // Assign the BXDVector3 to the axis.
- cylindricalJoint.axis = ReadBXDVector3_2_0(reader.ReadSubtree());
- break;
- }
- break;
- case "AngularLowLimit":
- // Assign a value to the angularLimitLow.
- cylindricalJoint.hasAngularLimit = true;
- cylindricalJoint.angularLimitLow = float.Parse(reader.ReadElementContentAsString());
- break;
- case "AngularHighLimit":
- // Assign a value to the angularLimitHigh.
- cylindricalJoint.angularLimitHigh = float.Parse(reader.ReadElementContentAsString());
- break;
- case "LinearStartLimit":
- // Assign a value to the linearLimitStart.
- cylindricalJoint.hasLinearStartLimit = true;
- cylindricalJoint.linearLimitStart = float.Parse(reader.ReadElementContentAsString());
- break;
- case "LinearEndLimit":
- // Assign a value to the linearLimitEnd.
- cylindricalJoint.hasLinearEndLimit = true;
- cylindricalJoint.linearLimitEnd = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentLinearPosition":
- // Assign a value to the currentLinearPosition.
- cylindricalJoint.currentLinearPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentAngularPosition":
- // Assign a value to the currentAngularPosition.
- cylindricalJoint.currentAngularPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return cylindricalJoint;
- }
-
- ///
- /// Reads a LinearJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static LinearJoint_Base ReadLinearJoint_2_0(XmlReader reader)
- {
- // Create a new LinearJoint_Base.
- LinearJoint_Base linearJoint = (LinearJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.LINEAR);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "BasePoint":
- // Assign the BXDVector3 to the basePoint.
- linearJoint.basePoint = ReadBXDVector3_2_0(reader.ReadSubtree());
- break;
- case "Axis":
- // Assign the BXDVector3 to the axis.
- linearJoint.axis = ReadBXDVector3_2_0(reader.ReadSubtree());
- break;
- }
- break;
- case "LinearLowLimit":
- // Assign a value to the linearLimitLow.
- linearJoint.hasLowerLimit = true;
- linearJoint.linearLimitLow = float.Parse(reader.ReadElementContentAsString());
- break;
- case "LinearUpperLimit":
- // Assign a value to the linearLimitHigh.
- linearJoint.hasUpperLimit = true;
- linearJoint.linearLimitHigh = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentLinearPosition":
- // Assign a value to the currentLinearPosition.
- linearJoint.currentLinearPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return linearJoint;
- }
-
- ///
- /// Reads a PlanarJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static PlanarJoint_Base ReadPlanarJoint_2_0(XmlReader reader)
- {
- // Create a new PlanarJoint_Base.
- PlanarJoint_Base planarJoint = (PlanarJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.PLANAR);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "Normal":
- // Assign the BXDVector3 to the normal.
- planarJoint.normal = ReadBXDVector3_2_0(reader.ReadSubtree());
- break;
- case "BasePoint":
- // Assign the BXDVector3 to the basePoint.s
- planarJoint.basePoint = ReadBXDVector3_2_0(reader.ReadSubtree());
- break;
- }
- break;
- }
- }
-
- return planarJoint;
- }
-
- ///
- /// Reads a RotationalJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static RotationalJoint_Base ReadRotationalJoint_2_0(XmlReader reader)
- {
- // Create a new RotationalJoint_Base.
- RotationalJoint_Base rotationalJoint = (RotationalJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.ROTATIONAL);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "BasePoint":
- // Read the BXDVector3 as the basePoint.
- rotationalJoint.basePoint = ReadBXDVector3_2_0(reader.ReadSubtree());
- break;
- case "Axis":
- // Read the BXDVector3 as the axis.
- rotationalJoint.axis = ReadBXDVector3_2_0(reader.ReadSubtree());
- break;
- }
- break;
- case "AngularLowLimit":
- // Assign the current element value to angularLimitLow.
- rotationalJoint.hasAngularLimit = true;
- rotationalJoint.angularLimitLow = float.Parse(reader.ReadElementContentAsString());
- break;
- case "AngularHighLimit":
- // Assign the current element value to angularLimitHigh.
- rotationalJoint.angularLimitHigh = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentAngularPosition":
- // Assign the current element value to currentAngularPosition.
- rotationalJoint.currentAngularPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return rotationalJoint;
- }
-
- ///
- /// Reads a BXDVector3 with the given XmlReader and returns the reading.
- ///
- ///
- ///
- private static BXDVector3 ReadBXDVector3_2_0(XmlReader reader)
- {
- BXDVector3 vec = new BXDVector3();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "X":
- // Assign the x value.
- vec.x = float.Parse(reader.ReadElementContentAsString());
- break;
- case "Y":
- // Assign the y value.
- vec.y = float.Parse(reader.ReadElementContentAsString());
- break;
- case "Z":
- // Assign the z value.
- vec.z = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return vec;
- }
-
- ///
- /// Reads a JointDriver from the given XmlReader.
- ///
- ///
- ///
- private static JointDriver ReadJointDriver_2_0(XmlReader reader)
- {
- JointDriver driver = null;
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "DriveType":
- // Initialize the driver.
- driver = new JointDriver((JointDriverType)Enum.Parse(typeof(JointDriverType), reader.ReadElementContentAsString()));
- break;
- case "PortA":// mismatched naming to maintain backwards compatibility
- // Assign a value to portA.
- driver.port1 = reader.ReadElementContentAsInt();
- break;
- case "PortB":
- // Assign a value to port2.
- driver.port2 = reader.ReadElementContentAsInt();
- break;
- case "LowerLimit":
- // Assign a value to the lowerLimit.
- driver.lowerLimit = float.Parse(reader.ReadElementContentAsString());
- break;
- case "UpperLimit":
- // Assign a value to the upperLimit.
- driver.upperLimit = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SignalType":
- // Assign a value to isCan.
- driver.isCan = reader.ReadElementContentAsString().Equals("CAN") ? true : false;
- break;
- case "ElevatorDriverMeta":
- // Add an ElevatorDriverMeta.
- driver.AddInfo(ReadElevatorDriverMeta_2_0(reader.ReadSubtree()));
- break;
- case "PneumaticDriverMeta":
- // Add a PneumaticsDriverMeta.
- driver.AddInfo(ReadPneumaticDriverMeta_2_0(reader.ReadSubtree()));
- break;
- case "WheelDriverMeta":
- // Add a WheelDriverMeta.
- driver.AddInfo(ReadWheelDriverMeta_2_0(reader.ReadSubtree()));
- break;
- }
- }
-
- return driver;
- }
-
- ///
- /// Reads an ElevatorDriverMeta from the given XmlReader.
- ///
- ///
- ///
- private static ElevatorDriverMeta ReadElevatorDriverMeta_2_0(XmlReader reader)
- {
- // Create a new ElevatorDriveMeta.
- ElevatorDriverMeta elevatorDriverMeta = new ElevatorDriverMeta();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "ElevatorType":
- // Assign the type to the current element value.
- elevatorDriverMeta.type = (ElevatorType)Enum.Parse(typeof(ElevatorType), reader.ReadElementContentAsString());
- break;
- }
- }
-
- return elevatorDriverMeta;
- }
-
- ///
- /// Reads a PneumaticDriverMeta from the given XmlReader.
- ///
- ///
- ///
- private static PneumaticDriverMeta ReadPneumaticDriverMeta_2_0(XmlReader reader)
- {
- // Create a new pneumaticDriverMeta.
- PneumaticDriverMeta pneumaticDriverMeta = new PneumaticDriverMeta();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "WidthMM":
- // Assign the current element value to widthMM.
- pneumaticDriverMeta.widthMM = reader.ReadElementContentAsInt();
- break;
- case "PressurePSI":
- // Assign the current element value to pressurePSI.
- pneumaticDriverMeta.pressurePSI = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return pneumaticDriverMeta;
- }
-
- ///
- /// Reads a WheelDriverMeta from the given XmlReader.
- ///
- ///
- ///
- private static WheelDriverMeta ReadWheelDriverMeta_2_0(XmlReader reader)
- {
- // Create new WheelDriveMeta.
- WheelDriverMeta wheelDriverMeta = new WheelDriverMeta();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "WheelType":
- // Assign a value to the type.
- wheelDriverMeta.type = (WheelType)Enum.Parse(typeof(WheelType), reader.ReadElementContentAsString());
- break;
- case "WheelRadius":
- // Assign a value to the radius.
- wheelDriverMeta.radius = float.Parse(reader.ReadElementContentAsString());
- break;
- case "WheelWidth":
- // Assign a value to the width.
- wheelDriverMeta.width = float.Parse(reader.ReadElementContentAsString());
- break;
- case "BXDVector3":
- // Assign a value to the center.
- wheelDriverMeta.center = ReadBXDVector3_2_0(reader.ReadSubtree());
- break;
- case "ForwardAsympSlip":
- // Assign a value to the forwardAsympSlip.
- wheelDriverMeta.forwardAsympSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "ForwardAsympValue":
- // Assign a value to the forwardAsympValue.
- wheelDriverMeta.forwardAsympValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "ForwardExtremeSlip":
- // Assign a value to the forwardExtremeSlip.
- wheelDriverMeta.forwardExtremeSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "ForwardExtremeValue":
- // Assign a value to the forwardExtremeValue.
- wheelDriverMeta.forwardExtremeValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideAsympSlip":
- // Assign a value to the sideAsympSlip.
- wheelDriverMeta.sideAsympSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideAsympValue":
- // Assign a value to the sideAsympValue.
- wheelDriverMeta.sideAsympValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideExtremeSlip":
- // Assign a value to the sideExtremeSlip.
- wheelDriverMeta.sideExtremeSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideExtremeValue":
- // Assign a value to the sideExtremeValue.
- wheelDriverMeta.sideExtremeValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "IsDriveWheel":
- // Assign a value to isDriveWheel.
- wheelDriverMeta.isDriveWheel = reader.ReadElementContentAsBoolean();
- break;
- }
- }
-
- return wheelDriverMeta;
- }
-
- ///
- /// Read a RobotSensor from the given XmlReader.
- ///
- ///
- ///
- private static RobotSensor ReadRobotSensor_2_0(XmlReader reader)
- {
- RobotSensor robotSensor = null;
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "SensorType":
- // Initialize the RobotSensor.
- robotSensor = new RobotSensor((RobotSensorType)Enum.Parse(typeof(RobotSensorType), reader.ReadElementContentAsString()));
- break;
- case "SensorModule":
- // Assign a value to the module.
- short m = (short)reader.ReadElementContentAsInt();
- break;
- case "SensorPort":
- // Assign a value to the port.
- short p = (short)reader.ReadElementContentAsInt();
- break;
- case "Polynomial":
- // Create a polynomial and assign it to the equation.
- Polynomial r = ReadPolynomial_2_0(reader.ReadSubtree());
- break;
- case "UseSecondarySource":
- // Assign a value to useSecondarySource.
- reader.ReadElementContentAsBoolean();
- break;
- }
- }
-
- return robotSensor;
- }
-
- ///
- /// Reads a Polynomial from the given XmlReader.
- ///
- ///
- ///
- private static Polynomial ReadPolynomial_2_0(XmlReader reader)
- {
- // Initialize a list of floats.
- List coeff = new List();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "Coefficient":
- // Add a new coefficient to the list of floats.
- coeff.Add(float.Parse(reader.ReadElementContentAsString()));
- break;
- }
- }
-
- // Convert the list of floats to a Polynomial.
- return new Polynomial(coeff.ToArray());
- }
-}
diff --git a/api/Aardvark/IO/BXDJ/BXDJReader_3_0.cs b/api/Aardvark/IO/BXDJ/BXDJReader_3_0.cs
deleted file mode 100644
index 8f3697343b..0000000000
--- a/api/Aardvark/IO/BXDJ/BXDJReader_3_0.cs
+++ /dev/null
@@ -1,900 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Xml;
-using System.Xml.Schema;
-
-///
-/// Utility functions for reading/writing BXDJ files
-///
-public partial class BXDJSkeleton
-{
- #region XSD Markup
-
- ///
- /// The XSD markup to ensure valid document reading.
- ///
- private const string BXDJ_XSD_3_0 =
- @"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ";
-
- #endregion
-
- ///
- /// Reads the skeleton contained in the XML BXDJ file specified and
- /// returns the corresponding RigidNode_Base.
- ///
- ///
- ///
- private static RigidNode_Base ReadSkeleton_3_0(string path, bool useValidation = true)
- {
- RigidNode_Base root = null;
- List nodes = new List();
-
- XmlReaderSettings settings = new XmlReaderSettings();
-
- if (useValidation)
- {
- settings.Schemas.Add(XmlSchema.Read(new StringReader(BXDJ_XSD_3_0), null));
- settings.ValidationType = ValidationType.Schema;
- }
- else
- {
- settings.ValidationType = ValidationType.None;
- }
-
- XmlReader reader = XmlReader.Create(path, settings);
-
- try
- {
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "Node":
- // Reads the current element as a node.
- ReadNode_3_0(reader.ReadSubtree(), nodes, ref root);
- break;
- }
- }
- }
- catch (Exception)// A variety of exceptions can take place if the file is invalid, but we will always want to return null.
- {
- // If the file is invalid, return null.
- return null;
- }
- finally
- {
- // Closes the reader.
- reader.Close();
- }
-
- return nodes[0];
- }
-
- ///
- /// Reads a RigidNode_Base with the given reader, list of nodes, and root node reference.
- ///
- ///
- ///
- ///
- private static void ReadNode_3_0(XmlReader reader, List nodes, ref RigidNode_Base root)
- {
- int parentID = -1;
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "Node":
- // Adds a new node to the list of RigidNode_Bases.
- nodes.Add(RigidNode_Base.NODE_FACTORY(new Guid(reader["GUID"])));
- break;
- case "ParentID":
- // Stores this ID for later use.
- parentID = reader.ReadElementContentAsInt();
-
- if (parentID == -1) // If this is the root...
- root = nodes[nodes.Count - 1];
- break;
- case "ModelFileName":
- // Assigns the ModelFileName property to the ModelFileName element value.
- nodes[nodes.Count - 1].ModelFileName = reader.ReadElementContentAsString();
- break;
- case "ModelID":
- // Assigns the ModelFullID property to the ModelID element value.
- nodes[nodes.Count - 1].ModelFullID = reader.ReadElementContentAsString();
- break;
- case "BallJoint":
- // Reads the current element as a BallJoint.
- nodes[parentID].AddChild(ReadBallJoint_3_0(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "CylindricalJoint":
- // Reads the current element as a CylindricalJoint.
- nodes[parentID].AddChild(ReadCylindricalJoint_3_0(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "LinearJoint":
- // Reads the current element as a LinearJoint.
- nodes[parentID].AddChild(ReadLinearJoint_3_0(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "PlanarJoint":
- // Reads the current element as a PlanarJoint.
- nodes[parentID].AddChild(ReadPlanarJoint_3_0(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "RotationalJoint":
- // Reads the current elemenet as a RotationalJoint.
- nodes[parentID].AddChild(ReadRotationalJoint_3_0(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "JointDriver":
- // Add a joint driver to the skeletal joint of the current node.
- nodes[nodes.Count - 1].GetSkeletalJoint().cDriver = ReadJointDriver_3_0(reader.ReadSubtree());
- break;
- case "RobotSensor":
- nodes[nodes.Count - 1].GetSkeletalJoint().attachedSensors.Add(ReadRobotSensor_3_0(reader.ReadSubtree()));
- break;
- }
- }
- }
-
- ///
- /// Reads a BallJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static BallJoint_Base ReadBallJoint_3_0(XmlReader reader)
- {
- // Create a new BallJoint_Base.
- BallJoint_Base ballJoint = (BallJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.BALL);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- // Read the BXDVector3 as the basePoint.
- ballJoint.basePoint = ReadBXDVector3_3_0(reader.ReadSubtree());
- break;
- }
- }
-
- return ballJoint;
- }
-
- ///
- /// Reads a CylindricalJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static CylindricalJoint_Base ReadCylindricalJoint_3_0(XmlReader reader)
- {
- // Create a new CylindricalJoint_Base.
- CylindricalJoint_Base cylindricalJoint = (CylindricalJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.CYLINDRICAL);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "BasePoint":
- // Assign the BXDVector3 to the basePoint.
- cylindricalJoint.basePoint = ReadBXDVector3_3_0(reader.ReadSubtree());
- break;
- case "Axis":
- // Assign the BXDVector3 to the axis.
- cylindricalJoint.axis = ReadBXDVector3_3_0(reader.ReadSubtree());
- break;
- }
- break;
- case "AngularLowLimit":
- // Assign a value to the angularLimitLow.
- cylindricalJoint.hasAngularLimit = true;
- cylindricalJoint.angularLimitLow = float.Parse(reader.ReadElementContentAsString());
- break;
- case "AngularHighLimit":
- // Assign a value to the angularLimitHigh.
- cylindricalJoint.angularLimitHigh = float.Parse(reader.ReadElementContentAsString());
- break;
- case "LinearStartLimit":
- // Assign a value to the linearLimitStart.
- cylindricalJoint.hasLinearStartLimit = true;
- cylindricalJoint.linearLimitStart = float.Parse(reader.ReadElementContentAsString());
- break;
- case "LinearEndLimit":
- // Assign a value to the linearLimitEnd.
- cylindricalJoint.hasLinearEndLimit = true;
- cylindricalJoint.linearLimitEnd = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentLinearPosition":
- // Assign a value to the currentLinearPosition.
- cylindricalJoint.currentLinearPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentAngularPosition":
- // Assign a value to the currentAngularPosition.
- cylindricalJoint.currentAngularPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return cylindricalJoint;
- }
-
- ///
- /// Reads a LinearJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static LinearJoint_Base ReadLinearJoint_3_0(XmlReader reader)
- {
- // Create a new LinearJoint_Base.
- LinearJoint_Base linearJoint = (LinearJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.LINEAR);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "BasePoint":
- // Assign the BXDVector3 to the basePoint.
- linearJoint.basePoint = ReadBXDVector3_3_0(reader.ReadSubtree());
- break;
- case "Axis":
- // Assign the BXDVector3 to the axis.
- linearJoint.axis = ReadBXDVector3_3_0(reader.ReadSubtree());
- break;
- }
- break;
- case "LinearLowLimit":
- // Assign a value to the linearLimitLow.
- linearJoint.hasLowerLimit = true;
- linearJoint.linearLimitLow = float.Parse(reader.ReadElementContentAsString());
- break;
- case "LinearUpperLimit":
- // Assign a value to the linearLimitHigh.
- linearJoint.hasUpperLimit = true;
- linearJoint.linearLimitHigh = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentLinearPosition":
- // Assign a value to the currentLinearPosition.
- linearJoint.currentLinearPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return linearJoint;
- }
-
- ///
- /// Reads a PlanarJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static PlanarJoint_Base ReadPlanarJoint_3_0(XmlReader reader)
- {
- // Create a new PlanarJoint_Base.
- PlanarJoint_Base planarJoint = (PlanarJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.PLANAR);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "Normal":
- // Assign the BXDVector3 to the normal.
- planarJoint.normal = ReadBXDVector3_3_0(reader.ReadSubtree());
- break;
- case "BasePoint":
- // Assign the BXDVector3 to the basePoint.s
- planarJoint.basePoint = ReadBXDVector3_3_0(reader.ReadSubtree());
- break;
- }
- break;
- }
- }
-
- return planarJoint;
- }
-
- ///
- /// Reads a RotationalJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static RotationalJoint_Base ReadRotationalJoint_3_0(XmlReader reader)
- {
- // Create a new RotationalJoint_Base.
- RotationalJoint_Base rotationalJoint = (RotationalJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.ROTATIONAL);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "BasePoint":
- // Read the BXDVector3 as the basePoint.
- rotationalJoint.basePoint = ReadBXDVector3_3_0(reader.ReadSubtree());
- break;
- case "Axis":
- // Read the BXDVector3 as the axis.
- rotationalJoint.axis = ReadBXDVector3_3_0(reader.ReadSubtree());
- break;
- }
- break;
- case "AngularLowLimit":
- // Assign the current element value to angularLimitLow.
- rotationalJoint.hasAngularLimit = true;
- rotationalJoint.angularLimitLow = float.Parse(reader.ReadElementContentAsString());
- break;
- case "AngularHighLimit":
- // Assign the current element value to angularLimitHigh.
- rotationalJoint.angularLimitHigh = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentAngularPosition":
- // Assign the current element value to currentAngularPosition.
- rotationalJoint.currentAngularPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return rotationalJoint;
- }
-
- ///
- /// Reads a BXDVector3 with the given XmlReader and returns the reading.
- ///
- ///
- ///
- private static BXDVector3 ReadBXDVector3_3_0(XmlReader reader)
- {
- BXDVector3 vec = new BXDVector3();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "X":
- // Assign the x value.
- vec.x = float.Parse(reader.ReadElementContentAsString());
- break;
- case "Y":
- // Assign the y value.
- vec.y = float.Parse(reader.ReadElementContentAsString());
- break;
- case "Z":
- // Assign the z value.
- vec.z = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return vec;
- }
-
- ///
- /// Reads a JointDriver from the given XmlReader.
- ///
- ///
- ///
- private static JointDriver ReadJointDriver_3_0(XmlReader reader)
- {
- JointDriver driver = null;
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "DriveType":
- // Initialize the driver.
- driver = new JointDriver((JointDriverType)Enum.Parse(typeof(JointDriverType), reader.ReadElementContentAsString()));
- break;
- case "PortA":// mismatched naming so we can keep backwards compatibility
- // Assign a value to portA.
- driver.port1 = reader.ReadElementContentAsInt();
- break;
- case "PortB":
- // Assign a value to port2.
- driver.port2 = reader.ReadElementContentAsInt();
- break;
-
- case "InputGear":
- // Assign a value to InputGear
- driver.InputGear = reader.ReadElementContentAsDouble();
- break;
-
- case "OutputGear":
- // Assign a value to OutputGear
- driver.OutputGear = reader.ReadElementContentAsDouble();
- break;
-
- case "LowerLimit":
- // Assign a value to the lowerLimit.
- driver.lowerLimit = float.Parse(reader.ReadElementContentAsString());
- break;
- case "UpperLimit":
- // Assign a value to the upperLimit.
- driver.upperLimit = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SignalType":
- // Assign a value to isCan.
- driver.isCan = reader.ReadElementContentAsString().Equals("CAN") ? true : false;
- break;
- case "ElevatorDriverMeta":
- // Add an ElevatorDriverMeta.
- driver.AddInfo(ReadElevatorDriverMeta_3_0(reader.ReadSubtree()));
- break;
- case "PneumaticDriverMeta":
- // Add a PneumaticsDriverMeta.
- driver.AddInfo(ReadPneumaticDriverMeta_3_0(reader.ReadSubtree()));
- break;
- case "WheelDriverMeta":
- // Add a WheelDriverMeta.
- driver.AddInfo(ReadWheelDriverMeta_3_0(reader.ReadSubtree()));
- break;
- }
- }
-
- return driver;
- }
-
- ///
- /// Reads an ElevatorDriverMeta from the given XmlReader.
- ///
- ///
- ///
- private static ElevatorDriverMeta ReadElevatorDriverMeta_3_0(XmlReader reader)
- {
- // Create a new ElevatorDriveMeta.
- ElevatorDriverMeta elevatorDriverMeta = new ElevatorDriverMeta();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "ElevatorType":
- // Assign the type to the current element value.
- elevatorDriverMeta.type = (ElevatorType)Enum.Parse(typeof(ElevatorType), reader.ReadElementContentAsString());
- break;
- }
- }
-
- return elevatorDriverMeta;
- }
-
- ///
- /// Reads a PneumaticDriverMeta from the given XmlReader.
- ///
- ///
- ///
- private static PneumaticDriverMeta ReadPneumaticDriverMeta_3_0(XmlReader reader)
- {
- // Create a new pneumaticDriverMeta.
- PneumaticDriverMeta pneumaticDriverMeta = new PneumaticDriverMeta();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "WidthMM":
- // Assign the current element value to widthMM.
- pneumaticDriverMeta.widthMM = reader.ReadElementContentAsInt();
- break;
- case "PressurePSI":
- // Assign the current element value to pressurePSI.
- pneumaticDriverMeta.pressurePSI = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return pneumaticDriverMeta;
- }
-
- ///
- /// Reads a WheelDriverMeta from the given XmlReader.
- ///
- ///
- ///
- private static WheelDriverMeta ReadWheelDriverMeta_3_0(XmlReader reader)
- {
- // Create new WheelDriveMeta.
- WheelDriverMeta wheelDriverMeta = new WheelDriverMeta();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "WheelType":
- // Assign a value to the type.
- wheelDriverMeta.type = (WheelType)Enum.Parse(typeof(WheelType), reader.ReadElementContentAsString());
- break;
- case "WheelRadius":
- // Assign a value to the radius.
- wheelDriverMeta.radius = float.Parse(reader.ReadElementContentAsString());
- break;
- case "WheelWidth":
- // Assign a value to the width.
- wheelDriverMeta.width = float.Parse(reader.ReadElementContentAsString());
- break;
- case "BXDVector3":
- // Assign a value to the center.
- wheelDriverMeta.center = ReadBXDVector3_3_0(reader.ReadSubtree());
- break;
- case "ForwardAsympSlip":
- // Assign a value to the forwardAsympSlip.
- wheelDriverMeta.forwardAsympSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "ForwardAsympValue":
- // Assign a value to the forwardAsympValue.
- wheelDriverMeta.forwardAsympValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "ForwardExtremeSlip":
- // Assign a value to the forwardExtremeSlip.
- wheelDriverMeta.forwardExtremeSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "ForwardExtremeValue":
- // Assign a value to the forwardExtremeValue.
- wheelDriverMeta.forwardExtremeValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideAsympSlip":
- // Assign a value to the sideAsympSlip.
- wheelDriverMeta.sideAsympSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideAsympValue":
- // Assign a value to the sideAsympValue.
- wheelDriverMeta.sideAsympValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideExtremeSlip":
- // Assign a value to the sideExtremeSlip.
- wheelDriverMeta.sideExtremeSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideExtremeValue":
- // Assign a value to the sideExtremeValue.
- wheelDriverMeta.sideExtremeValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "IsDriveWheel":
- // Assign a value to isDriveWheel.
- wheelDriverMeta.isDriveWheel = reader.ReadElementContentAsBoolean();
- break;
- }
- }
-
- return wheelDriverMeta;
- }
-
- ///
- /// Read a RobotSensor from the given XmlReader.
- ///
- ///
- ///
- private static RobotSensor ReadRobotSensor_3_0(XmlReader reader)
- {
- RobotSensor robotSensor = null;
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "SensorType":
- // Initialize the RobotSensor.
- robotSensor = new RobotSensor((RobotSensorType)Enum.Parse(typeof(RobotSensorType), reader.ReadElementContentAsString()));
- break;
- case "SensorModule":
- // Assign a value to the module.
- short m = (short)reader.ReadElementContentAsInt();
- break;
- case "SensorPort":
- // Assign a value to the port.
- short s = (short)reader.ReadElementContentAsInt();
- break;
- case "Polynomial":
- // Create a polynomial and assign it to the equation.
- Polynomial e = ReadPolynomial_3_0(reader.ReadSubtree());
- break;
- case "UseSecondarySource":
- // Assign a value to useSecondarySource.
- reader.ReadElementContentAsBoolean();
- break;
- }
- }
-
- return robotSensor;
- }
-
- ///
- /// Reads a Polynomial from the given XmlReader.
- ///
- ///
- ///
- private static Polynomial ReadPolynomial_3_0(XmlReader reader)
- {
- // Initialize a list of floats.
- List coeff = new List();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "Coefficient":
- // Add a new coefficient to the list of floats.
- coeff.Add(float.Parse(reader.ReadElementContentAsString()));
- break;
- }
- }
-
- // Convert the list of floats to a Polynomial.
- return new Polynomial(coeff.ToArray());
- }
-}
\ No newline at end of file
diff --git a/api/Aardvark/IO/BXDJ/BXDJReader_4_0.cs b/api/Aardvark/IO/BXDJ/BXDJReader_4_0.cs
deleted file mode 100644
index 6a9fd35cdc..0000000000
--- a/api/Aardvark/IO/BXDJ/BXDJReader_4_0.cs
+++ /dev/null
@@ -1,926 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Xml;
-using System.Xml.Schema;
-
-///
-/// Utility functions for reading/writing BXDJ files in the engine
-///
-public partial class BXDJSkeleton
-{
- #region BXDJ Schema
-
- ///
- /// The XSD markup to ensure valid document reading.
- /// This is the schema that the engine reads against when reading back the BXDJ
- ///
- private const string BXDJ_XSD_4_0 =
- @"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ";
-
- #endregion
-
- ///
- /// Reads the skeleton contained in the XML BXDJ file specified and
- /// returns the corresponding RigidNode_Base.
- ///
- ///
- ///
- private static RigidNode_Base ReadSkeleton_4_0(string path, bool useValidation = true)
- {
- RigidNode_Base root = null;
- List nodes = new List();
-
- XmlReaderSettings settings = new XmlReaderSettings();
-
- if (useValidation)// if the schema should be validated, then run the BXDJ against the schema to make sure all the value are there, oftentimes robot instace invalid issues are found here
- {
- settings.Schemas.Add(XmlSchema.Read(new StringReader(BXDJ_XSD_4_0), null));
- settings.ValidationType = ValidationType.Schema;
- }
- else
- {
- settings.ValidationType = ValidationType.None;
- }
-
- XmlReader reader = XmlReader.Create(path, settings);
-
- try
- {
- foreach (string name in IOUtilities.AllElements(reader))// iterates over all the top level data
- {
- switch (name)// handles reading the different XML tags
- {
- case "DriveTrainType":
- // Reads the current element as a drive train type.
- root.driveTrainType = (RigidNode_Base.DriveTrainType)Enum.Parse(typeof(RigidNode_Base.DriveTrainType), reader.ReadElementContentAsString());
- break;
- case "Node":
- // Reads the current element as a node.
- ReadNode_4_0(reader.ReadSubtree(), nodes, ref root);
- break;
- }
- }
- }
- catch (Exception)// A variety of exceptions can take place if the file is invalid, but we will always want to return null.
- {
- // If the file is invalid, return null.
- return null;
- }
- finally
- {
- // Closes the reader.
- reader.Close();
- }
-
- return nodes[0];// returns the base node of the skeleton
- }
-
- ///
- /// Reads a RigidNode_Base with the given reader, list of nodes, and root node reference.
- ///
- ///
- ///
- ///
- private static void ReadNode_4_0(XmlReader reader, List nodes, ref RigidNode_Base root)
- {
- int parentID = -1;
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "Node":
- // Adds a new node to the list of RigidNode_Bases.
- nodes.Add(RigidNode_Base.NODE_FACTORY(new Guid(reader["GUID"])));
- break;
- case "ParentID":
- // Stores this ID for later use.
- parentID = reader.ReadElementContentAsInt();
-
- if (parentID == -1) // If this is the root...
- root = nodes[nodes.Count - 1];
- break;
- case "ModelFileName":
- // Assigns the ModelFileName property to the ModelFileName element value.
- nodes[nodes.Count - 1].ModelFileName = reader.ReadElementContentAsString();
- break;
- case "ModelID":
- // Assigns the ModelFullID property to the ModelID element value.
- nodes[nodes.Count - 1].ModelFullID = reader.ReadElementContentAsString();
- break;
- case "BallJoint":
- // Reads the current element as a BallJoint.
- nodes[parentID].AddChild(ReadBallJoint_4_0(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "CylindricalJoint":
- // Reads the current element as a CylindricalJoint.
- nodes[parentID].AddChild(ReadCylindricalJoint_4_0(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "LinearJoint":
- // Reads the current element as a LinearJoint.
- nodes[parentID].AddChild(ReadLinearJoint_4_0(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "PlanarJoint":
- // Reads the current element as a PlanarJoint.
- nodes[parentID].AddChild(ReadPlanarJoint_4_0(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "RotationalJoint":
- // Reads the current elemenet as a RotationalJoint.
- nodes[parentID].AddChild(ReadRotationalJoint_4_0(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "JointDriver":
- // Add a joint driver to the skeletal joint of the current node.
- nodes[nodes.Count - 1].GetSkeletalJoint().cDriver = ReadJointDriver_4_0(reader.ReadSubtree());
- break;
- case "RobotSensor":
- // Add a sensor to the skeletal joint of the current node.
- nodes[nodes.Count - 1].GetSkeletalJoint().attachedSensors.Add(ReadRobotSensor_4_0(reader.ReadSubtree()));
- break;
- }
- }
- }
-
- ///
- /// Reads a BallJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static BallJoint_Base ReadBallJoint_4_0(XmlReader reader)
- {
- // Create a new BallJoint_Base.
- BallJoint_Base ballJoint = (BallJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.BALL);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- // Read the BXDVector3 as the basePoint.
- ballJoint.basePoint = ReadBXDVector4_0(reader.ReadSubtree());
- break;
- }
- }
-
- return ballJoint;
- }
-
- ///
- /// Reads a CylindricalJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static CylindricalJoint_Base ReadCylindricalJoint_4_0(XmlReader reader)
- {
- // Create a new CylindricalJoint_Base.
- CylindricalJoint_Base cylindricalJoint = (CylindricalJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.CYLINDRICAL);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "BasePoint":
- // Assign the BXDVector3 to the basePoint.
- cylindricalJoint.basePoint = ReadBXDVector4_0(reader.ReadSubtree());
- break;
- case "Axis":
- // Assign the BXDVector3 to the axis.
- cylindricalJoint.axis = ReadBXDVector4_0(reader.ReadSubtree());
- break;
- }
- break;
- case "AngularLowLimit":
- // Assign a value to the angularLimitLow.
- cylindricalJoint.hasAngularLimit = true;
- cylindricalJoint.angularLimitLow = float.Parse(reader.ReadElementContentAsString());
- break;
- case "AngularHighLimit":
- // Assign a value to the angularLimitHigh.
- cylindricalJoint.angularLimitHigh = float.Parse(reader.ReadElementContentAsString());
- break;
- case "LinearStartLimit":
- // Assign a value to the linearLimitStart.
- cylindricalJoint.hasLinearStartLimit = true;
- cylindricalJoint.linearLimitStart = float.Parse(reader.ReadElementContentAsString());
- break;
- case "LinearEndLimit":
- // Assign a value to the linearLimitEnd.
- cylindricalJoint.hasLinearEndLimit = true;
- cylindricalJoint.linearLimitEnd = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentLinearPosition":
- // Assign a value to the currentLinearPosition.
- cylindricalJoint.currentLinearPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentAngularPosition":
- // Assign a value to the currentAngularPosition.
- cylindricalJoint.currentAngularPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return cylindricalJoint;
- }
-
- ///
- /// Reads a LinearJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static LinearJoint_Base ReadLinearJoint_4_0(XmlReader reader)
- {
- // Create a new LinearJoint_Base.
- LinearJoint_Base linearJoint = (LinearJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.LINEAR);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "BasePoint":
- // Assign the BXDVector3 to the basePoint.
- linearJoint.basePoint = ReadBXDVector4_0(reader.ReadSubtree());
- break;
- case "Axis":
- // Assign the BXDVector3 to the axis.
- linearJoint.axis = ReadBXDVector4_0(reader.ReadSubtree());
- break;
- }
- break;
- case "LinearLowLimit":
- // Assign a value to the linearLimitLow.
- linearJoint.hasLowerLimit = true;
- linearJoint.linearLimitLow = float.Parse(reader.ReadElementContentAsString());
- break;
- case "LinearUpperLimit":
- // Assign a value to the linearLimitHigh.
- linearJoint.hasUpperLimit = true;
- linearJoint.linearLimitHigh = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentLinearPosition":
- // Assign a value to the currentLinearPosition.
- linearJoint.currentLinearPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return linearJoint;
- }
-
- ///
- /// Reads a PlanarJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static PlanarJoint_Base ReadPlanarJoint_4_0(XmlReader reader)
- {
- // Create a new PlanarJoint_Base.
- PlanarJoint_Base planarJoint = (PlanarJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.PLANAR);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "Normal":
- // Assign the BXDVector3 to the normal.
- planarJoint.normal = ReadBXDVector4_0(reader.ReadSubtree());
- break;
- case "BasePoint":
- // Assign the BXDVector3 to the basePoint.s
- planarJoint.basePoint = ReadBXDVector4_0(reader.ReadSubtree());
- break;
- }
- break;
- }
- }
-
- return planarJoint;
- }
-
- ///
- /// Reads a RotationalJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static RotationalJoint_Base ReadRotationalJoint_4_0(XmlReader reader)
- {
- // Create a new RotationalJoint_Base.
- RotationalJoint_Base rotationalJoint = (RotationalJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.ROTATIONAL);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "BasePoint":
- // Read the BXDVector3 as the basePoint.
- rotationalJoint.basePoint = ReadBXDVector4_0(reader.ReadSubtree());
- break;
- case "Axis":
- // Read the BXDVector3 as the axis.
- rotationalJoint.axis = ReadBXDVector4_0(reader.ReadSubtree());
- break;
- }
- break;
- case "AngularLowLimit":
- // Assign the current element value to angularLimitLow.
- rotationalJoint.hasAngularLimit = true;
- rotationalJoint.angularLimitLow = float.Parse(reader.ReadElementContentAsString());
- break;
- case "AngularHighLimit":
- // Assign the current element value to angularLimitHigh.
- rotationalJoint.angularLimitHigh = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentAngularPosition":
- // Assign the current element value to currentAngularPosition.
- rotationalJoint.currentAngularPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return rotationalJoint;
- }
-
- ///
- /// Reads a BXDVector3 with the given XmlReader and returns the reading.
- ///
- ///
- ///
- private static BXDVector3 ReadBXDVector4_0(XmlReader reader)
- {
- BXDVector3 vec = new BXDVector3();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "X":
- // Assign the x value.
- vec.x = float.Parse(reader.ReadElementContentAsString());
- break;
- case "Y":
- // Assign the y value.
- vec.y = float.Parse(reader.ReadElementContentAsString());
- break;
- case "Z":
- // Assign the z value.
- vec.z = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return vec;
- }
-
- ///
- /// Reads a JointDriver from the given XmlReader.
- ///
- ///
- ///
- private static JointDriver ReadJointDriver_4_0(XmlReader reader)
- {
- JointDriver driver = null;
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "DriveType":
- // Initialize the driver.
- driver = new JointDriver((JointDriverType)Enum.Parse(typeof(JointDriverType), reader.ReadElementContentAsString()));
- break;
- case "Port1":
- // Assign a value to port1.
- driver.port1 = reader.ReadElementContentAsInt();
- break;
- case "Port2":
- // Assign a value to port2.
- driver.port2 = reader.ReadElementContentAsInt();
- break;
-
- case "InputGear":
- // Assign a value to InputGear
- driver.InputGear = reader.ReadElementContentAsDouble();
- break;
-
- case "OutputGear":
- // Assign a value to OutputGear
- driver.OutputGear = reader.ReadElementContentAsDouble();
- break;
-
- case "LowerLimit":
- // Assign a value to the lowerLimit.
- driver.lowerLimit = float.Parse(reader.ReadElementContentAsString());
- break;
- case "UpperLimit":
- // Assign a value to the upperLimit.
- driver.upperLimit = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SignalType":
- // Assign a value to isCan.
- driver.isCan = reader.ReadElementContentAsString().Equals("CAN") ? true : false;
- break;
- case "ElevatorDriverMeta":
- // Add an ElevatorDriverMeta.
- driver.AddInfo(ReadElevatorDriverMeta_4_0(reader.ReadSubtree()));
- break;
- case "PneumaticDriverMeta":
- // Add a PneumaticsDriverMeta.
- driver.AddInfo(ReadPneumaticDriverMeta_4_0(reader.ReadSubtree()));
- break;
- case "WheelDriverMeta":
- // Add a WheelDriverMeta.
- driver.AddInfo(ReadWheelDriverMeta_4_0(reader.ReadSubtree()));
- break;
- }
- }
-
- return driver;
- }
-
- ///
- /// Reads an ElevatorDriverMeta from the given XmlReader.
- ///
- ///
- ///
- private static ElevatorDriverMeta ReadElevatorDriverMeta_4_0(XmlReader reader)
- {
- // Create a new ElevatorDriveMeta.
- ElevatorDriverMeta elevatorDriverMeta = new ElevatorDriverMeta();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "ElevatorType":
- // Assign the type to the current element value.
- elevatorDriverMeta.type = (ElevatorType)Enum.Parse(typeof(ElevatorType), reader.ReadElementContentAsString());
- break;
- }
- }
-
- return elevatorDriverMeta;
- }
-
- ///
- /// Reads a PneumaticDriverMeta from the given XmlReader.
- ///
- ///
- ///
- private static PneumaticDriverMeta ReadPneumaticDriverMeta_4_0(XmlReader reader)
- {
- // Create a new pneumaticDriverMeta.
- PneumaticDriverMeta pneumaticDriverMeta = new PneumaticDriverMeta();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "WidthMM":
- // Assign the current element value to widthMM.
- pneumaticDriverMeta.widthMM = reader.ReadElementContentAsInt();
- break;
- case "PressurePSI":
- // Assign the current element value to pressurePSI.
- pneumaticDriverMeta.pressurePSI = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return pneumaticDriverMeta;
- }
-
- ///
- /// Reads a WheelDriverMeta from the given XmlReader.
- ///
- ///
- ///
- private static WheelDriverMeta ReadWheelDriverMeta_4_0(XmlReader reader)
- {
- // Create new WheelDriveMeta.
- WheelDriverMeta wheelDriverMeta = new WheelDriverMeta();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "WheelType":
- // Assign a value to the type.
- wheelDriverMeta.type = (WheelType)Enum.Parse(typeof(WheelType), reader.ReadElementContentAsString());
- break;
- case "WheelRadius":
- // Assign a value to the radius.
- wheelDriverMeta.radius = float.Parse(reader.ReadElementContentAsString());
- break;
- case "WheelWidth":
- // Assign a value to the width.
- wheelDriverMeta.width = float.Parse(reader.ReadElementContentAsString());
- break;
- case "BXDVector3":
- // Assign a value to the center.
- wheelDriverMeta.center = ReadBXDVector4_0(reader.ReadSubtree());
- break;
- case "ForwardAsympSlip":
- // Assign a value to the forwardAsympSlip.
- wheelDriverMeta.forwardAsympSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "ForwardAsympValue":
- // Assign a value to the forwardAsympValue.
- wheelDriverMeta.forwardAsympValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "ForwardExtremeSlip":
- // Assign a value to the forwardExtremeSlip.
- wheelDriverMeta.forwardExtremeSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "ForwardExtremeValue":
- // Assign a value to the forwardExtremeValue.
- wheelDriverMeta.forwardExtremeValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideAsympSlip":
- // Assign a value to the sideAsympSlip.
- wheelDriverMeta.sideAsympSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideAsympValue":
- // Assign a value to the sideAsympValue.
- wheelDriverMeta.sideAsympValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideExtremeSlip":
- // Assign a value to the sideExtremeSlip.
- wheelDriverMeta.sideExtremeSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideExtremeValue":
- // Assign a value to the sideExtremeValue.
- wheelDriverMeta.sideExtremeValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "IsDriveWheel":
- // Assign a value to isDriveWheel.
- wheelDriverMeta.isDriveWheel = reader.ReadElementContentAsBoolean();
- break;
- }
- }
-
- return wheelDriverMeta;
- }
-
- ///
- /// Read a RobotSensor from the given XmlReader.
- ///
- ///
- ///
- private static RobotSensor ReadRobotSensor_4_0(XmlReader reader)
- {
- RobotSensor robotSensor = null;
- //throw (new Exception("Reading thing"));
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "SensorType":
- // Initialize the RobotSensor.
- robotSensor = new RobotSensor((RobotSensorType)Enum.Parse(typeof(RobotSensorType), reader.ReadElementContentAsString()));
- break;
- case "SensorPortNumberA":
- // Assign a value to the 1st port.
- robotSensor.portA = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SensorSignalTypeA":
- // Assign a value to the 2nd port.
- robotSensor.conTypePortA = (SensorConnectionType)Enum.Parse(typeof(SensorConnectionType), reader.ReadElementContentAsString());
- break;
- case "SensorPortNumberB":
- // Assign a port type to the 1st port
- robotSensor.portB = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SensorSignalTypeB":
- // Assign a port type to the 1st port
- robotSensor.conTypePortB = (SensorConnectionType)Enum.Parse(typeof(SensorConnectionType), reader.ReadElementContentAsString());
- break;
- case "SensorConversionFactor":
- // assings the generic conversion facter, this is a different type/ unit for every robot (CPR in encoders)
- robotSensor.conversionFactor = double.Parse(reader.ReadElementContentAsString());
- if(robotSensor.conversionFactor == 0)
- {
- robotSensor.conversionFactor = 1;
- }
- break;
- }
- }
-
- return robotSensor;
- }
-}
diff --git a/api/Aardvark/IO/BXDJ/BXDJReader_4_1.cs b/api/Aardvark/IO/BXDJ/BXDJReader_4_1.cs
deleted file mode 100644
index cf01a5e3cb..0000000000
--- a/api/Aardvark/IO/BXDJ/BXDJReader_4_1.cs
+++ /dev/null
@@ -1,932 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Xml;
-using System.Xml.Schema;
-
-///
-/// Utility functions for reading/writing BXDJ files in the engine
-///
-public partial class BXDJSkeleton
-{
- #region BXDJ Schema
-
- ///
- /// The XSD markup to ensure valid document reading.
- /// This is the schema that the engine reads against when reading back the BXDJ
- ///
- private const string BXDJ_XSD_4_1 =
- @"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ";
-
- #endregion
-
- ///
- /// Reads the skeleton contained in the XML BXDJ file specified and
- /// returns the corresponding RigidNode_Base.
- ///
- ///
- ///
- private static RigidNode_Base ReadSkeleton_4_1(string path, bool useValidation = true)
- {
- RigidNode_Base root = null;
- List nodes = new List();
-
- XmlReaderSettings settings = new XmlReaderSettings();
-
- if (useValidation)// if the schema should be validated, then run the BXDJ against the schema to make sure all the value are there, oftentimes robot instace invalid issues are found here
- {
- settings.Schemas.Add(XmlSchema.Read(new StringReader(BXDJ_XSD_4_1), null));
- settings.ValidationType = ValidationType.Schema;
- }
- else
- {
- settings.ValidationType = ValidationType.None;
- }
-
- XmlReader reader = XmlReader.Create(path, settings);
-
- try
- {
- foreach (string name in IOUtilities.AllElements(reader))// iterates over all the top level data
- {
- switch (name)// handles reading the different XML tags
- {
- case "DriveTrainType":
- // Reads the current element as a drive train type.
- root.driveTrainType = (RigidNode_Base.DriveTrainType)Enum.Parse(typeof(RigidNode_Base.DriveTrainType), reader.ReadElementContentAsString());
- break;
- case "Node":
- // Reads the current element as a node.
- ReadNode_4_1(reader.ReadSubtree(), nodes, ref root);
- break;
- }
- }
- }
- catch (Exception)// A variety of exceptions can take place if the file is invalid, but we will always want to return null.
- {
- // If the file is invalid, return null.
- return null;
- }
- finally
- {
- // Closes the reader.
- reader.Close();
- }
-
- return nodes[0];// returns the base node of the skeleton
- }
-
- ///
- /// Reads a RigidNode_Base with the given reader, list of nodes, and root node reference.
- ///
- ///
- ///
- ///
- private static void ReadNode_4_1(XmlReader reader, List nodes, ref RigidNode_Base root)
- {
- int parentID = -1;
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "Node":
- // Adds a new node to the list of RigidNode_Bases.
- nodes.Add(RigidNode_Base.NODE_FACTORY(new Guid(reader["GUID"])));
- break;
- case "ParentID":
- // Stores this ID for later use.
- parentID = reader.ReadElementContentAsInt();
-
- if (parentID == -1) // If this is the root...
- root = nodes[nodes.Count - 1];
- break;
- case "ModelFileName":
- // Assigns the ModelFileName property to the ModelFileName element value.
- nodes[nodes.Count - 1].ModelFileName = reader.ReadElementContentAsString();
- break;
- case "ModelID":
- // Assigns the ModelFullID property to the ModelID element value.
- nodes[nodes.Count - 1].ModelFullID = reader.ReadElementContentAsString();
- break;
- case "BallJoint":
- // Reads the current element as a BallJoint.
- nodes[parentID].AddChild(ReadBallJoint_4_1(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "CylindricalJoint":
- // Reads the current element as a CylindricalJoint.
- nodes[parentID].AddChild(ReadCylindricalJoint_4_1(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "LinearJoint":
- // Reads the current element as a LinearJoint.
- nodes[parentID].AddChild(ReadLinearJoint_4_1(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "PlanarJoint":
- // Reads the current element as a PlanarJoint.
- nodes[parentID].AddChild(ReadPlanarJoint_4_1(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "RotationalJoint":
- // Reads the current elemenet as a RotationalJoint.
- nodes[parentID].AddChild(ReadRotationalJoint_4_1(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "JointDriver":
- // Add a joint driver to the skeletal joint of the current node.
- nodes[nodes.Count - 1].GetSkeletalJoint().cDriver = ReadJointDriver_4_1(reader.ReadSubtree());
- break;
- case "RobotSensor":
- // Add a sensor to the skeletal joint of the current node.
- nodes[nodes.Count - 1].GetSkeletalJoint().attachedSensors.Add(ReadRobotSensor_4_1(reader.ReadSubtree()));
- break;
- }
- }
- }
-
- ///
- /// Reads a BallJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static BallJoint_Base ReadBallJoint_4_1(XmlReader reader)
- {
- // Create a new BallJoint_Base.
- BallJoint_Base ballJoint = (BallJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.BALL);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- // Read the BXDVector3 as the basePoint.
- ballJoint.basePoint = ReadBXDVector4_1(reader.ReadSubtree());
- break;
- }
- }
-
- return ballJoint;
- }
-
- ///
- /// Reads a CylindricalJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static CylindricalJoint_Base ReadCylindricalJoint_4_1(XmlReader reader)
- {
- // Create a new CylindricalJoint_Base.
- CylindricalJoint_Base cylindricalJoint = (CylindricalJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.CYLINDRICAL);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "BasePoint":
- // Assign the BXDVector3 to the basePoint.
- cylindricalJoint.basePoint = ReadBXDVector4_1(reader.ReadSubtree());
- break;
- case "Axis":
- // Assign the BXDVector3 to the axis.
- cylindricalJoint.axis = ReadBXDVector4_1(reader.ReadSubtree());
- break;
- }
- break;
- case "AngularLowLimit":
- // Assign a value to the angularLimitLow.
- cylindricalJoint.hasAngularLimit = true;
- cylindricalJoint.angularLimitLow = float.Parse(reader.ReadElementContentAsString());
- break;
- case "AngularHighLimit":
- // Assign a value to the angularLimitHigh.
- cylindricalJoint.angularLimitHigh = float.Parse(reader.ReadElementContentAsString());
- break;
- case "LinearStartLimit":
- // Assign a value to the linearLimitStart.
- cylindricalJoint.hasLinearStartLimit = true;
- cylindricalJoint.linearLimitStart = float.Parse(reader.ReadElementContentAsString());
- break;
- case "LinearEndLimit":
- // Assign a value to the linearLimitEnd.
- cylindricalJoint.hasLinearEndLimit = true;
- cylindricalJoint.linearLimitEnd = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentLinearPosition":
- // Assign a value to the currentLinearPosition.
- cylindricalJoint.currentLinearPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentAngularPosition":
- // Assign a value to the currentAngularPosition.
- cylindricalJoint.currentAngularPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return cylindricalJoint;
- }
-
- ///
- /// Reads a LinearJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static LinearJoint_Base ReadLinearJoint_4_1(XmlReader reader)
- {
- // Create a new LinearJoint_Base.
- LinearJoint_Base linearJoint = (LinearJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.LINEAR);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "BasePoint":
- // Assign the BXDVector3 to the basePoint.
- linearJoint.basePoint = ReadBXDVector4_1(reader.ReadSubtree());
- break;
- case "Axis":
- // Assign the BXDVector3 to the axis.
- linearJoint.axis = ReadBXDVector4_1(reader.ReadSubtree());
- break;
- }
- break;
- case "LinearLowLimit":
- // Assign a value to the linearLimitLow.
- linearJoint.hasLowerLimit = true;
- linearJoint.linearLimitLow = float.Parse(reader.ReadElementContentAsString());
- break;
- case "LinearUpperLimit":
- // Assign a value to the linearLimitHigh.
- linearJoint.hasUpperLimit = true;
- linearJoint.linearLimitHigh = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentLinearPosition":
- // Assign a value to the currentLinearPosition.
- linearJoint.currentLinearPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return linearJoint;
- }
-
- ///
- /// Reads a PlanarJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static PlanarJoint_Base ReadPlanarJoint_4_1(XmlReader reader)
- {
- // Create a new PlanarJoint_Base.
- PlanarJoint_Base planarJoint = (PlanarJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.PLANAR);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "Normal":
- // Assign the BXDVector3 to the normal.
- planarJoint.normal = ReadBXDVector4_1(reader.ReadSubtree());
- break;
- case "BasePoint":
- // Assign the BXDVector3 to the basePoint.s
- planarJoint.basePoint = ReadBXDVector4_1(reader.ReadSubtree());
- break;
- }
- break;
- }
- }
-
- return planarJoint;
- }
-
- ///
- /// Reads a RotationalJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static RotationalJoint_Base ReadRotationalJoint_4_1(XmlReader reader)
- {
- // Create a new RotationalJoint_Base.
- RotationalJoint_Base rotationalJoint = (RotationalJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.ROTATIONAL);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "BasePoint":
- // Read the BXDVector3 as the basePoint.
- rotationalJoint.basePoint = ReadBXDVector4_1(reader.ReadSubtree());
- break;
- case "Axis":
- // Read the BXDVector3 as the axis.
- rotationalJoint.axis = ReadBXDVector4_1(reader.ReadSubtree());
- break;
- }
- break;
- case "AngularLowLimit":
- // Assign the current element value to angularLimitLow.
- rotationalJoint.hasAngularLimit = true;
- rotationalJoint.angularLimitLow = float.Parse(reader.ReadElementContentAsString());
- break;
- case "AngularHighLimit":
- // Assign the current element value to angularLimitHigh.
- rotationalJoint.angularLimitHigh = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentAngularPosition":
- // Assign the current element value to currentAngularPosition.
- rotationalJoint.currentAngularPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return rotationalJoint;
- }
-
- ///
- /// Reads a BXDVector3 with the given XmlReader and returns the reading.
- ///
- ///
- ///
- private static BXDVector3 ReadBXDVector4_1(XmlReader reader)
- {
- BXDVector3 vec = new BXDVector3();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "X":
- // Assign the x value.
- vec.x = float.Parse(reader.ReadElementContentAsString());
- break;
- case "Y":
- // Assign the y value.
- vec.y = float.Parse(reader.ReadElementContentAsString());
- break;
- case "Z":
- // Assign the z value.
- vec.z = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return vec;
- }
-
- ///
- /// Reads a JointDriver from the given XmlReader.
- ///
- ///
- ///
- private static JointDriver ReadJointDriver_4_1(XmlReader reader)
- {
- JointDriver driver = null;
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "DriveType":
- // Initialize the driver.
- driver = new JointDriver((JointDriverType)Enum.Parse(typeof(JointDriverType), reader.ReadElementContentAsString()));
- break;
- case "Port1":
- // Assign a value to port1.
- driver.port1 = reader.ReadElementContentAsInt();
- break;
- case "Port2":
- // Assign a value to port2.
- driver.port2 = reader.ReadElementContentAsInt();
- break;
-
- case "InputGear":
- // Assign a value to InputGear
- driver.InputGear = reader.ReadElementContentAsDouble();
- break;
-
- case "OutputGear":
- // Assign a value to OutputGear
- driver.OutputGear = reader.ReadElementContentAsDouble();
- break;
-
- case "LowerLimit":
- // Assign a value to the lowerLimit.
- driver.lowerLimit = float.Parse(reader.ReadElementContentAsString());
- break;
- case "UpperLimit":
- // Assign a value to the upperLimit.
- driver.upperLimit = float.Parse(reader.ReadElementContentAsString());
- break;
- case "HasBrake":
- // Assign a value to the upperLimit.
- driver.hasBrake = reader.ReadElementContentAsBoolean();
- break;
- case "SignalType":
- // Assign a value to isCan.
- driver.isCan = reader.ReadElementContentAsString().Equals("CAN") ? true : false;
- break;
- case "ElevatorDriverMeta":
- // Add an ElevatorDriverMeta.
- driver.AddInfo(ReadElevatorDriverMeta_4_1(reader.ReadSubtree()));
- break;
- case "PneumaticDriverMeta":
- // Add a PneumaticsDriverMeta.
- driver.AddInfo(ReadPneumaticDriverMeta_4_1(reader.ReadSubtree()));
- break;
- case "WheelDriverMeta":
- // Add a WheelDriverMeta.
- driver.AddInfo(ReadWheelDriverMeta_4_1(reader.ReadSubtree()));
- break;
- }
- }
-
- return driver;
- }
-
- ///
- /// Reads an ElevatorDriverMeta from the given XmlReader.
- ///
- ///
- ///
- private static ElevatorDriverMeta ReadElevatorDriverMeta_4_1(XmlReader reader)
- {
- // Create a new ElevatorDriveMeta.
- ElevatorDriverMeta elevatorDriverMeta = new ElevatorDriverMeta();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "ElevatorType":
- // Assign the type to the current element value.
- elevatorDriverMeta.type = (ElevatorType)Enum.Parse(typeof(ElevatorType), reader.ReadElementContentAsString());
- break;
- }
- }
-
- return elevatorDriverMeta;
- }
-
- ///
- /// Reads a PneumaticDriverMeta from the given XmlReader.
- ///
- ///
- ///
- private static PneumaticDriverMeta ReadPneumaticDriverMeta_4_1(XmlReader reader)
- {
- // Create a new pneumaticDriverMeta.
- PneumaticDriverMeta pneumaticDriverMeta = new PneumaticDriverMeta();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "WidthMM":
- // Assign the current element value to widthMM.
- pneumaticDriverMeta.widthMM = reader.ReadElementContentAsInt();
- break;
- case "PressurePSI":
- // Assign the current element value to pressurePSI.
- pneumaticDriverMeta.pressurePSI = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return pneumaticDriverMeta;
- }
-
- ///
- /// Reads a WheelDriverMeta from the given XmlReader.
- ///
- ///
- ///
- private static WheelDriverMeta ReadWheelDriverMeta_4_1(XmlReader reader)
- {
- // Create new WheelDriveMeta.
- WheelDriverMeta wheelDriverMeta = new WheelDriverMeta();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "WheelType":
- // Assign a value to the type.
- wheelDriverMeta.type = (WheelType)Enum.Parse(typeof(WheelType), reader.ReadElementContentAsString());
- break;
- case "WheelRadius":
- // Assign a value to the radius.
- wheelDriverMeta.radius = float.Parse(reader.ReadElementContentAsString());
- break;
- case "WheelWidth":
- // Assign a value to the width.
- wheelDriverMeta.width = float.Parse(reader.ReadElementContentAsString());
- break;
- case "BXDVector3":
- // Assign a value to the center.
- wheelDriverMeta.center = ReadBXDVector4_1(reader.ReadSubtree());
- break;
- case "ForwardAsympSlip":
- // Assign a value to the forwardAsympSlip.
- wheelDriverMeta.forwardAsympSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "ForwardAsympValue":
- // Assign a value to the forwardAsympValue.
- wheelDriverMeta.forwardAsympValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "ForwardExtremeSlip":
- // Assign a value to the forwardExtremeSlip.
- wheelDriverMeta.forwardExtremeSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "ForwardExtremeValue":
- // Assign a value to the forwardExtremeValue.
- wheelDriverMeta.forwardExtremeValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideAsympSlip":
- // Assign a value to the sideAsympSlip.
- wheelDriverMeta.sideAsympSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideAsympValue":
- // Assign a value to the sideAsympValue.
- wheelDriverMeta.sideAsympValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideExtremeSlip":
- // Assign a value to the sideExtremeSlip.
- wheelDriverMeta.sideExtremeSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideExtremeValue":
- // Assign a value to the sideExtremeValue.
- wheelDriverMeta.sideExtremeValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "IsDriveWheel":
- // Assign a value to isDriveWheel.
- wheelDriverMeta.isDriveWheel = reader.ReadElementContentAsBoolean();
- break;
- }
- }
-
- return wheelDriverMeta;
- }
-
- ///
- /// Read a RobotSensor from the given XmlReader.
- ///
- ///
- ///
- private static RobotSensor ReadRobotSensor_4_1(XmlReader reader)
- {
- RobotSensor robotSensor = null;
- //throw (new Exception("Reading thing"));
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "SensorType":
- // Initialize the RobotSensor.
- robotSensor = new RobotSensor((RobotSensorType)Enum.Parse(typeof(RobotSensorType), reader.ReadElementContentAsString()));
- break;
- case "SensorPortNumberA":
- // Assign a value to the 1st port.
- robotSensor.portA = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SensorSignalTypeA":
- // Assign a value to the 2nd port.
- robotSensor.conTypePortA = (SensorConnectionType)Enum.Parse(typeof(SensorConnectionType), reader.ReadElementContentAsString());
- break;
- case "SensorPortNumberB":
- // Assign a port type to the 1st port
- robotSensor.portB = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SensorSignalTypeB":
- // Assign a port type to the 1st port
- robotSensor.conTypePortB = (SensorConnectionType)Enum.Parse(typeof(SensorConnectionType), reader.ReadElementContentAsString());
- break;
- case "SensorConversionFactor":
- // assings the generic conversion facter, this is a different type/ unit for every robot (CPR in encoders)
- robotSensor.conversionFactor = double.Parse(reader.ReadElementContentAsString());
- if(robotSensor.conversionFactor == 0)
- {
- robotSensor.conversionFactor = 1;
- }
- break;
- }
- }
-
- return robotSensor;
- }
-}
diff --git a/api/Aardvark/IO/BXDJ/BXDJReader_4_2.cs b/api/Aardvark/IO/BXDJ/BXDJReader_4_2.cs
deleted file mode 100644
index 3bb0b879b9..0000000000
--- a/api/Aardvark/IO/BXDJ/BXDJReader_4_2.cs
+++ /dev/null
@@ -1,982 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Xml;
-using System.Xml.Schema;
-
-///
-/// Utility functions for reading/writing BXDJ files in the engine
-///
-public partial class BXDJSkeleton
-{
- #region BXDJ Schema
-
- ///
- /// The XSD markup to ensure valid document reading.
- /// This is the schema that the engine reads against when reading back the BXDJ
- ///
- private const string BXDJ_XSD_4_2 =
- @"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ";
-
- #endregion
-
- ///
- /// Reads the skeleton contained in the XML BXDJ file specified and
- /// returns the corresponding RigidNode_Base.
- ///
- ///
- ///
- private static RigidNode_Base ReadSkeleton_4_2(string path, bool useValidation = true)
- {
- RigidNode_Base root = null;
- List nodes = new List();
-
- XmlReaderSettings settings = new XmlReaderSettings();
-
- if (useValidation)// if the schema should be validated, then run the BXDJ against the schema to make sure all the value are there, oftentimes robot instace invalid issues are found here
- {
- settings.Schemas.Add(XmlSchema.Read(new StringReader(BXDJ_XSD_4_2), null));
- settings.ValidationType = ValidationType.Schema;
- }
- else
- {
- settings.ValidationType = ValidationType.None;
- }
-
- XmlReader reader = XmlReader.Create(path, settings);
-
- try
- {
- foreach (string name in IOUtilities.AllElements(reader))// iterates over all the top level data
- {
- switch (name)// handles reading the different XML tags
- {
- case "DriveTrainType":
- // Reads the current element as a drive train type.
- root.driveTrainType = (RigidNode_Base.DriveTrainType)Enum.Parse(typeof(RigidNode_Base.DriveTrainType), reader.ReadElementContentAsString());
- break;
- case "SoftwareExportedWith":
- // Reads the current element as a drive train type.
- root.exportedWith = (RigidNode_Base.SoftwareExportedWith)Enum.Parse(typeof(RigidNode_Base.SoftwareExportedWith), reader.ReadElementContentAsString());
- break;
- case "Node":
- // Reads the current element as a node.
- ReadNode_4_2(reader.ReadSubtree(), nodes, ref root);
- break;
- }
- }
- }
- catch (Exception)// A variety of exceptions can take place if the file is invalid, but we will always want to return null.
- {
- // If the file is invalid, return null.
- return null;
- }
- finally
- {
- // Closes the reader.
- reader.Close();
- }
-
- return nodes[0];// returns the base node of the skeleton
- }
-
- ///
- /// Reads a RigidNode_Base with the given reader, list of nodes, and root node reference.
- ///
- ///
- ///
- ///
- private static void ReadNode_4_2(XmlReader reader, List nodes, ref RigidNode_Base root)
- {
- int parentID = -1;
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "Node":
- // Adds a new node to the list of RigidNode_Bases.
- nodes.Add(RigidNode_Base.NODE_FACTORY(new Guid(reader["GUID"])));
- break;
- case "ParentID":
- // Stores this ID for later use.
- parentID = reader.ReadElementContentAsInt();
-
- if (parentID == -1) // If this is the root...
- root = nodes[nodes.Count - 1];
- break;
- case "ModelFileName":
- // Assigns the ModelFileName property to the ModelFileName element value.
- nodes[nodes.Count - 1].ModelFileName = reader.ReadElementContentAsString();
- break;
- case "ModelID":
- // Assigns the ModelFullID property to the ModelID element value.
- nodes[nodes.Count - 1].ModelFullID = reader.ReadElementContentAsString();
- break;
- case "BallJoint":
- // Reads the current element as a BallJoint.
- nodes[parentID].AddChild(ReadBallJoint_4_2(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "CylindricalJoint":
- // Reads the current element as a CylindricalJoint.
- nodes[parentID].AddChild(ReadCylindricalJoint_4_2(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "LinearJoint":
- // Reads the current element as a LinearJoint.
- nodes[parentID].AddChild(ReadLinearJoint_4_2(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "PlanarJoint":
- // Reads the current element as a PlanarJoint.
- nodes[parentID].AddChild(ReadPlanarJoint_4_2(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "RotationalJoint":
- // Reads the current elemenet as a RotationalJoint.
- nodes[parentID].AddChild(ReadRotationalJoint_4_2(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "JointDriver":
- // Add a joint driver to the skeletal joint of the current node.
- nodes[nodes.Count - 1].GetSkeletalJoint().cDriver = ReadJointDriver_4_2(reader.ReadSubtree());
- break;
- case "RobotSensor":
- // Add a sensor to the skeletal joint of the current node.
- nodes[nodes.Count - 1].GetSkeletalJoint().attachedSensors.Add(ReadRobotSensor_4_2(reader.ReadSubtree()));
- break;
- }
- }
- }
-
- ///
- /// Reads a BallJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static BallJoint_Base ReadBallJoint_4_2(XmlReader reader)
- {
- // Create a new BallJoint_Base.
- BallJoint_Base ballJoint = (BallJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.BALL);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- // Read the BXDVector3 as the basePoint.
- ballJoint.basePoint = ReadBXDVector4_2(reader.ReadSubtree());
- break;
- }
- }
-
- return ballJoint;
- }
-
- ///
- /// Reads a CylindricalJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static CylindricalJoint_Base ReadCylindricalJoint_4_2(XmlReader reader)
- {
- // Create a new CylindricalJoint_Base.
- CylindricalJoint_Base cylindricalJoint = (CylindricalJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.CYLINDRICAL);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "BasePoint":
- // Assign the BXDVector3 to the basePoint.
- cylindricalJoint.basePoint = ReadBXDVector4_2(reader.ReadSubtree());
- break;
- case "Axis":
- // Assign the BXDVector3 to the axis.
- cylindricalJoint.axis = ReadBXDVector4_2(reader.ReadSubtree());
- break;
- }
- break;
- case "AngularLowLimit":
- // Assign a value to the angularLimitLow.
- cylindricalJoint.hasAngularLimit = true;
- cylindricalJoint.angularLimitLow = float.Parse(reader.ReadElementContentAsString());
- break;
- case "AngularHighLimit":
- // Assign a value to the angularLimitHigh.
- cylindricalJoint.angularLimitHigh = float.Parse(reader.ReadElementContentAsString());
- break;
- case "LinearStartLimit":
- // Assign a value to the linearLimitStart.
- cylindricalJoint.hasLinearStartLimit = true;
- cylindricalJoint.linearLimitStart = float.Parse(reader.ReadElementContentAsString());
- break;
- case "LinearEndLimit":
- // Assign a value to the linearLimitEnd.
- cylindricalJoint.hasLinearEndLimit = true;
- cylindricalJoint.linearLimitEnd = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentLinearPosition":
- // Assign a value to the currentLinearPosition.
- cylindricalJoint.currentLinearPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentAngularPosition":
- // Assign a value to the currentAngularPosition.
- cylindricalJoint.currentAngularPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return cylindricalJoint;
- }
-
- ///
- /// Reads a LinearJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static LinearJoint_Base ReadLinearJoint_4_2(XmlReader reader)
- {
- // Create a new LinearJoint_Base.
- LinearJoint_Base linearJoint = (LinearJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.LINEAR);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "BasePoint":
- // Assign the BXDVector3 to the basePoint.
- linearJoint.basePoint = ReadBXDVector4_2(reader.ReadSubtree());
- break;
- case "Axis":
- // Assign the BXDVector3 to the axis.
- linearJoint.axis = ReadBXDVector4_2(reader.ReadSubtree());
- break;
- }
- break;
- case "LinearLowLimit":
- // Assign a value to the linearLimitLow.
- linearJoint.hasLowerLimit = true;
- linearJoint.linearLimitLow = float.Parse(reader.ReadElementContentAsString());
- break;
- case "LinearUpperLimit":
- // Assign a value to the linearLimitHigh.
- linearJoint.hasUpperLimit = true;
- linearJoint.linearLimitHigh = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentLinearPosition":
- // Assign a value to the currentLinearPosition.
- linearJoint.currentLinearPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return linearJoint;
- }
-
- ///
- /// Reads a PlanarJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static PlanarJoint_Base ReadPlanarJoint_4_2(XmlReader reader)
- {
- // Create a new PlanarJoint_Base.
- PlanarJoint_Base planarJoint = (PlanarJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.PLANAR);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "Normal":
- // Assign the BXDVector3 to the normal.
- planarJoint.normal = ReadBXDVector4_2(reader.ReadSubtree());
- break;
- case "BasePoint":
- // Assign the BXDVector3 to the basePoint.s
- planarJoint.basePoint = ReadBXDVector4_2(reader.ReadSubtree());
- break;
- }
- break;
- }
- }
-
- return planarJoint;
- }
-
- ///
- /// Reads a RotationalJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static RotationalJoint_Base ReadRotationalJoint_4_2(XmlReader reader)
- {
- // Create a new RotationalJoint_Base.
- RotationalJoint_Base rotationalJoint = (RotationalJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.ROTATIONAL);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "BasePoint":
- // Read the BXDVector3 as the basePoint.
- rotationalJoint.basePoint = ReadBXDVector4_2(reader.ReadSubtree());
- break;
- case "Axis":
- // Read the BXDVector3 as the axis.
- rotationalJoint.axis = ReadBXDVector4_2(reader.ReadSubtree());
- break;
- }
- break;
- case "AngularLowLimit":
- // Assign the current element value to angularLimitLow.
- rotationalJoint.hasAngularLimit = true;
- rotationalJoint.angularLimitLow = float.Parse(reader.ReadElementContentAsString());
- break;
- case "AngularHighLimit":
- // Assign the current element value to angularLimitHigh.
- rotationalJoint.angularLimitHigh = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentAngularPosition":
- // Assign the current element value to currentAngularPosition.
- rotationalJoint.currentAngularPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return rotationalJoint;
- }
-
- ///
- /// Reads a BXDVector3 with the given XmlReader and returns the reading.
- ///
- ///
- ///
- private static BXDVector3 ReadBXDVector4_2(XmlReader reader)
- {
- BXDVector3 vec = new BXDVector3();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "X":
- // Assign the x value.
- vec.x = float.Parse(reader.ReadElementContentAsString());
- break;
- case "Y":
- // Assign the y value.
- vec.y = float.Parse(reader.ReadElementContentAsString());
- break;
- case "Z":
- // Assign the z value.
- vec.z = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return vec;
- }
-
- ///
- /// Reads a JointDriver from the given XmlReader.
- ///
- ///
- ///
- private static JointDriver ReadJointDriver_4_2(XmlReader reader)
- {
- JointDriver driver = null;
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "DriveType":
- // Initialize the driver.
- driver = new JointDriver((JointDriverType)Enum.Parse(typeof(JointDriverType), reader.ReadElementContentAsString()));
- break;
- case "MotorType":
- // Initialize the driver.
- driver.motor = (MotorType)Enum.Parse(typeof(MotorType), reader.ReadElementContentAsString());
- break;
- case "Port1":
- // Assign a value to port1.
- driver.port1 = reader.ReadElementContentAsInt();
- break;
- case "Port2":
- // Assign a value to port2.
- driver.port2 = reader.ReadElementContentAsInt();
- break;
-
- case "InputGear":
- // Assign a value to InputGear
- driver.InputGear = reader.ReadElementContentAsDouble();
- break;
-
- case "OutputGear":
- // Assign a value to OutputGear
- driver.OutputGear = reader.ReadElementContentAsDouble();
- break;
-
- case "LowerLimit":
- // Assign a value to the lowerLimit.
- driver.lowerLimit = float.Parse(reader.ReadElementContentAsString());
- break;
- case "UpperLimit":
- // Assign a value to the upperLimit.
- driver.upperLimit = float.Parse(reader.ReadElementContentAsString());
- break;
- case "HasBrake":
- // Assign a value to the upperLimit.
- driver.hasBrake = reader.ReadElementContentAsBoolean();
- break;
- case "SignalType":
- // Assign a value to isCan.
- driver.isCan = reader.ReadElementContentAsString().Equals("CAN") ? true : false;
- break;
- case "ElevatorDriverMeta":
- // Add an ElevatorDriverMeta.
- driver.AddInfo(ReadElevatorDriverMeta_4_2(reader.ReadSubtree()));
- break;
- case "PneumaticDriverMeta":
- // Add a PneumaticsDriverMeta.
- driver.AddInfo(ReadPneumaticDriverMeta_4_2(reader.ReadSubtree()));
- break;
- case "WheelDriverMeta":
- // Add a WheelDriverMeta.
- driver.AddInfo(ReadWheelDriverMeta_4_2(reader.ReadSubtree()));
- break;
- }
- }
-
- return driver;
- }
-
- ///
- /// Reads an ElevatorDriverMeta from the given XmlReader.
- ///
- ///
- ///
- private static ElevatorDriverMeta ReadElevatorDriverMeta_4_2(XmlReader reader)
- {
- // Create a new ElevatorDriveMeta.
- ElevatorDriverMeta elevatorDriverMeta = new ElevatorDriverMeta();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "ElevatorType":
- // Assign the type to the current element value.
- elevatorDriverMeta.type = (ElevatorType)Enum.Parse(typeof(ElevatorType), reader.ReadElementContentAsString());
- break;
- }
- }
-
- return elevatorDriverMeta;
- }
-
- ///
- /// Reads a PneumaticDriverMeta from the given XmlReader.
- ///
- ///
- ///
- private static PneumaticDriverMeta ReadPneumaticDriverMeta_4_2(XmlReader reader)
- {
- // Create a new pneumaticDriverMeta.
- PneumaticDriverMeta pneumaticDriverMeta = new PneumaticDriverMeta();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "WidthMM":
- // Assign the current element value to widthMM.
- pneumaticDriverMeta.widthMM = reader.ReadElementContentAsInt();
- break;
- case "PressurePSI":
- // Assign the current element value to pressurePSI.
- pneumaticDriverMeta.pressurePSI = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return pneumaticDriverMeta;
- }
-
- ///
- /// Reads a WheelDriverMeta from the given XmlReader.
- ///
- ///
- ///
- private static WheelDriverMeta ReadWheelDriverMeta_4_2(XmlReader reader)
- {
- // Create new WheelDriveMeta.
- WheelDriverMeta wheelDriverMeta = new WheelDriverMeta();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "WheelType":
- // Assign a value to the type.
- wheelDriverMeta.type = (WheelType)Enum.Parse(typeof(WheelType), reader.ReadElementContentAsString());
- break;
- case "WheelRadius":
- // Assign a value to the radius.
- wheelDriverMeta.radius = float.Parse(reader.ReadElementContentAsString());
- break;
- case "WheelWidth":
- // Assign a value to the width.
- wheelDriverMeta.width = float.Parse(reader.ReadElementContentAsString());
- break;
- case "BXDVector3":
- // Assign a value to the center.
- wheelDriverMeta.center = ReadBXDVector4_2(reader.ReadSubtree());
- break;
- case "ForwardAsympSlip":
- // Assign a value to the forwardAsympSlip.
- wheelDriverMeta.forwardAsympSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "ForwardAsympValue":
- // Assign a value to the forwardAsympValue.
- wheelDriverMeta.forwardAsympValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "ForwardExtremeSlip":
- // Assign a value to the forwardExtremeSlip.
- wheelDriverMeta.forwardExtremeSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "ForwardExtremeValue":
- // Assign a value to the forwardExtremeValue.
- wheelDriverMeta.forwardExtremeValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideAsympSlip":
- // Assign a value to the sideAsympSlip.
- wheelDriverMeta.sideAsympSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideAsympValue":
- // Assign a value to the sideAsympValue.
- wheelDriverMeta.sideAsympValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideExtremeSlip":
- // Assign a value to the sideExtremeSlip.
- wheelDriverMeta.sideExtremeSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideExtremeValue":
- // Assign a value to the sideExtremeValue.
- wheelDriverMeta.sideExtremeValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "IsDriveWheel":
- // Assign a value to isDriveWheel.
- wheelDriverMeta.isDriveWheel = reader.ReadElementContentAsBoolean();
- break;
- }
- }
-
- return wheelDriverMeta;
- }
-
- ///
- /// Read a RobotSensor from the given XmlReader.
- ///
- ///
- ///
- private static RobotSensor ReadRobotSensor_4_2(XmlReader reader)
- {
- RobotSensor robotSensor = null;
- //throw (new Exception("Reading thing"));
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "SensorType":
- // Initialize the RobotSensor.
- robotSensor = new RobotSensor((RobotSensorType)Enum.Parse(typeof(RobotSensorType), reader.ReadElementContentAsString()));
- break;
- case "SensorPortNumberA":
- // Assign a value to the 1st port.
- robotSensor.portA = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SensorSignalTypeA":
- // Assign a value to the 2nd port.
- robotSensor.conTypePortA = (SensorConnectionType)Enum.Parse(typeof(SensorConnectionType), reader.ReadElementContentAsString());
- break;
- case "SensorPortNumberB":
- // Assign a port type to the 1st port
- robotSensor.portB = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SensorSignalTypeB":
- // Assign a port type to the 1st port
- robotSensor.conTypePortB = (SensorConnectionType)Enum.Parse(typeof(SensorConnectionType), reader.ReadElementContentAsString());
- break;
- case "SensorConversionFactor":
- // assings the generic conversion facter, this is a different type/ unit for every robot (CPR in encoders)
- robotSensor.conversionFactor = double.Parse(reader.ReadElementContentAsString());
- if(robotSensor.conversionFactor == 0)
- {
- robotSensor.conversionFactor = 1;
- }
- break;
- }
- }
-
- return robotSensor;
- }
-}
diff --git a/api/Aardvark/IO/BXDJ/BXDJReader_5_0.cs b/api/Aardvark/IO/BXDJ/BXDJReader_5_0.cs
deleted file mode 100644
index 653b08f140..0000000000
--- a/api/Aardvark/IO/BXDJ/BXDJReader_5_0.cs
+++ /dev/null
@@ -1,923 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Xml;
-using System.Xml.Schema;
-
-///
-/// Utility functions for reading/writing BXDJ files
-///
-public partial class BXDJSkeleton
-{
- #region XSD Markup
-
- ///
- /// The XSD markup to ensure valid document reading.
- ///
- private const string BXDJ_XSD_5_0 =
- @"
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ";
-
- #endregion
-
- ///
- /// Reads the skeleton contained in the XML BXDJ file specified and
- /// returns the corresponding RigidNode_Base.
- ///
- ///
- ///
- private static RigidNode_Base ReadSkeleton_5_0(string path, bool useValidation = true)
- {
- RigidNode_Base root = null;
- List nodes = new List();
-
- XmlReaderSettings settings = new XmlReaderSettings();
-
- if (useValidation)
- {
- settings.Schemas.Add(XmlSchema.Read(new StringReader(BXDJ_XSD_5_0), null));
- settings.ValidationType = ValidationType.Schema;
- }
- else
- {
- settings.ValidationType = ValidationType.None;
- }
-
- XmlReader reader = XmlReader.Create(path, settings);
-
- try
- {
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "DriveTrainType":
- ReadNode_5_0(reader.ReadSubtree(), nodes, ref root);
- break;
- case "Node":
- // Reads the current element as a node.
- ReadNode_5_0(reader.ReadSubtree(), nodes, ref root);
- break;
- }
- }
- }
- catch (Exception)// A variety of exceptions can take place if the file is invalid, but we will always want to return null.
- {
- // If the file is invalid, return null.
- return null;
- }
- finally
- {
- // Closes the reader.
- reader.Close();
- }
-
- return nodes[0];
- }
-
- ///
- /// Reads a RigidNode_Base with the given reader, list of nodes, and root node reference.
- ///
- ///
- ///
- ///
- private static void ReadNode_5_0(XmlReader reader, List nodes, ref RigidNode_Base root)
- {
- int parentID = -1;
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "Node":
- // Adds a new node to the list of RigidNode_Bases.
- nodes.Add(RigidNode_Base.NODE_FACTORY(new Guid(reader["GUID"])));
- break;
- case "ParentID":
- // Stores this ID for later use.
- parentID = reader.ReadElementContentAsInt();
-
- if (parentID == -1) // If this is the root...
- root = nodes[nodes.Count - 1];
- break;
- case "DriveTrainTypeNumber":
- root.driveTrainType = (RigidNode_Base.DriveTrainType) reader.ReadElementContentAsInt();
- break;
- case "ModelFileName":
- // Assigns the ModelFileName property to the ModelFileName element value.
- nodes[nodes.Count - 1].ModelFileName = reader.ReadElementContentAsString();
- break;
- case "ModelID":
- // Assigns the ModelFullID property to the ModelID element value.
- nodes[nodes.Count - 1].ModelFullID = reader.ReadElementContentAsString();
- break;
- case "BallJoint":
- // Reads the current element as a BallJoint.
- nodes[parentID].AddChild(ReadBallJoint_5_0(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "CylindricalJoint":
- // Reads the current element as a CylindricalJoint.
- nodes[parentID].AddChild(ReadCylindricalJoint_5_0(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "LinearJoint":
- // Reads the current element as a LinearJoint.
- nodes[parentID].AddChild(ReadLinearJoint_5_0(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "PlanarJoint":
- // Reads the current element as a PlanarJoint.
- nodes[parentID].AddChild(ReadPlanarJoint_5_0(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "RotationalJoint":
- // Reads the current elemenet as a RotationalJoint.
- nodes[parentID].AddChild(ReadRotationalJoint_5_0(reader.ReadSubtree()), nodes[nodes.Count - 1]);
- break;
- case "JointDriver":
- // Add a joint driver to the skeletal joint of the current node.
- nodes[nodes.Count - 1].GetSkeletalJoint().cDriver = ReadJointDriver_5_0(reader.ReadSubtree());
- break;
- case "RobotSensor":
- nodes[nodes.Count - 1].GetSkeletalJoint().attachedSensors.Add(ReadRobotSensor_5_0(reader.ReadSubtree()));
- break;
- }
- }
- }
-
- ///
- /// Reads a BallJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static BallJoint_Base ReadBallJoint_5_0(XmlReader reader)
- {
- // Create a new BallJoint_Base.
- BallJoint_Base ballJoint = (BallJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.BALL);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- // Read the BXDVector3 as the basePoint.
- ballJoint.basePoint = ReadBXDVector5_0(reader.ReadSubtree());
- break;
- }
- }
-
- return ballJoint;
- }
-
- ///
- /// Reads a CylindricalJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static CylindricalJoint_Base ReadCylindricalJoint_5_0(XmlReader reader)
- {
- // Create a new CylindricalJoint_Base.
- CylindricalJoint_Base cylindricalJoint = (CylindricalJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.CYLINDRICAL);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "BasePoint":
- // Assign the BXDVector3 to the basePoint.
- cylindricalJoint.basePoint = ReadBXDVector5_0(reader.ReadSubtree());
- break;
- case "Axis":
- // Assign the BXDVector3 to the axis.
- cylindricalJoint.axis = ReadBXDVector5_0(reader.ReadSubtree());
- break;
- }
- break;
- case "AngularLowLimit":
- // Assign a value to the angularLimitLow.
- cylindricalJoint.hasAngularLimit = true;
- cylindricalJoint.angularLimitLow = float.Parse(reader.ReadElementContentAsString());
- break;
- case "AngularHighLimit":
- // Assign a value to the angularLimitHigh.
- cylindricalJoint.angularLimitHigh = float.Parse(reader.ReadElementContentAsString());
- break;
- case "LinearStartLimit":
- // Assign a value to the linearLimitStart.
- cylindricalJoint.hasLinearStartLimit = true;
- cylindricalJoint.linearLimitStart = float.Parse(reader.ReadElementContentAsString());
- break;
- case "LinearEndLimit":
- // Assign a value to the linearLimitEnd.
- cylindricalJoint.hasLinearEndLimit = true;
- cylindricalJoint.linearLimitEnd = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentLinearPosition":
- // Assign a value to the currentLinearPosition.
- cylindricalJoint.currentLinearPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentAngularPosition":
- // Assign a value to the currentAngularPosition.
- cylindricalJoint.currentAngularPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return cylindricalJoint;
- }
-
- ///
- /// Reads a LinearJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static LinearJoint_Base ReadLinearJoint_5_0(XmlReader reader)
- {
- // Create a new LinearJoint_Base.
- LinearJoint_Base linearJoint = (LinearJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.LINEAR);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "BasePoint":
- // Assign the BXDVector3 to the basePoint.
- linearJoint.basePoint = ReadBXDVector5_0(reader.ReadSubtree());
- break;
- case "Axis":
- // Assign the BXDVector3 to the axis.
- linearJoint.axis = ReadBXDVector5_0(reader.ReadSubtree());
- break;
- }
- break;
- case "LinearLowLimit":
- // Assign a value to the linearLimitLow.
- linearJoint.hasLowerLimit = true;
- linearJoint.linearLimitLow = float.Parse(reader.ReadElementContentAsString());
- break;
- case "LinearUpperLimit":
- // Assign a value to the linearLimitHigh.
- linearJoint.hasUpperLimit = true;
- linearJoint.linearLimitHigh = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentLinearPosition":
- // Assign a value to the currentLinearPosition.
- linearJoint.currentLinearPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return linearJoint;
- }
-
- ///
- /// Reads a PlanarJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static PlanarJoint_Base ReadPlanarJoint_5_0(XmlReader reader)
- {
- // Create a new PlanarJoint_Base.
- PlanarJoint_Base planarJoint = (PlanarJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.PLANAR);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "Normal":
- // Assign the BXDVector3 to the normal.
- planarJoint.normal = ReadBXDVector5_0(reader.ReadSubtree());
- break;
- case "BasePoint":
- // Assign the BXDVector3 to the basePoint.s
- planarJoint.basePoint = ReadBXDVector5_0(reader.ReadSubtree());
- break;
- }
- break;
- }
- }
-
- return planarJoint;
- }
-
- ///
- /// Reads a RotationalJoint_Base from the given XmlReader.
- ///
- ///
- ///
- private static RotationalJoint_Base ReadRotationalJoint_5_0(XmlReader reader)
- {
- // Create a new RotationalJoint_Base.
- RotationalJoint_Base rotationalJoint = (RotationalJoint_Base)SkeletalJoint_Base.JOINT_FACTORY(SkeletalJointType.ROTATIONAL);
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "BXDVector3":
- switch (reader["VectorID"])
- {
- case "BasePoint":
- // Read the BXDVector3 as the basePoint.
- rotationalJoint.basePoint = ReadBXDVector5_0(reader.ReadSubtree());
- break;
- case "Axis":
- // Read the BXDVector3 as the axis.
- rotationalJoint.axis = ReadBXDVector5_0(reader.ReadSubtree());
- break;
- }
- break;
- case "AngularLowLimit":
- // Assign the current element value to angularLimitLow.
- rotationalJoint.hasAngularLimit = true;
- rotationalJoint.angularLimitLow = float.Parse(reader.ReadElementContentAsString());
- break;
- case "AngularHighLimit":
- // Assign the current element value to angularLimitHigh.
- rotationalJoint.angularLimitHigh = float.Parse(reader.ReadElementContentAsString());
- break;
- case "CurrentAngularPosition":
- // Assign the current element value to currentAngularPosition.
- rotationalJoint.currentAngularPosition = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return rotationalJoint;
- }
-
- ///
- /// Reads a BXDVector3 with the given XmlReader and returns the reading.
- ///
- ///
- ///
- private static BXDVector3 ReadBXDVector5_0(XmlReader reader)
- {
- BXDVector3 vec = new BXDVector3();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "X":
- // Assign the x value.
- vec.x = float.Parse(reader.ReadElementContentAsString());
- break;
- case "Y":
- // Assign the y value.
- vec.y = float.Parse(reader.ReadElementContentAsString());
- break;
- case "Z":
- // Assign the z value.
- vec.z = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return vec;
- }
-
- ///
- /// Reads a JointDriver from the given XmlReader.
- ///
- ///
- ///
- private static JointDriver ReadJointDriver_5_0(XmlReader reader)
- {
- JointDriver driver = null;
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "DriveType":
- // Initialize the driver.
- driver = new JointDriver((JointDriverType)Enum.Parse(typeof(JointDriverType), reader.ReadElementContentAsString()));
- break;
- case "port1":
- // Assign a value to port1.
- driver.port1 = reader.ReadElementContentAsInt();
- break;
- case "port2":
- // Assign a value to port2.
- driver.port2 = reader.ReadElementContentAsInt();
- break;
-
- case "InputGear":
- // Assign a value to InputGear
- driver.InputGear = reader.ReadElementContentAsDouble();
- break;
-
- case "OutputGear":
- // Assign a value to OutputGear
- driver.OutputGear = reader.ReadElementContentAsDouble();
- break;
-
- case "LowerLimit":
- // Assign a value to the lowerLimit.
- driver.lowerLimit = float.Parse(reader.ReadElementContentAsString());
- break;
- case "UpperLimit":
- // Assign a value to the upperLimit.
- driver.upperLimit = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SignalType":
- // Assign a value to isCan.
- driver.isCan = reader.ReadElementContentAsString().Equals("CAN") ? true : false;
- break;
- case "ElevatorDriverMeta":
- // Add an ElevatorDriverMeta.
- driver.AddInfo(ReadElevatorDriverMeta_5_0(reader.ReadSubtree()));
- break;
- case "PneumaticDriverMeta":
- // Add a PneumaticsDriverMeta.
- driver.AddInfo(ReadPneumaticDriverMeta_5_0(reader.ReadSubtree()));
- break;
- case "WheelDriverMeta":
- // Add a WheelDriverMeta.
- driver.AddInfo(ReadWheelDriverMeta_5_0(reader.ReadSubtree()));
- break;
- }
- }
-
- return driver;
- }
-
- ///
- /// Reads an ElevatorDriverMeta from the given XmlReader.
- ///
- ///
- ///
- private static ElevatorDriverMeta ReadElevatorDriverMeta_5_0(XmlReader reader)
- {
- // Create a new ElevatorDriveMeta.
- ElevatorDriverMeta elevatorDriverMeta = new ElevatorDriverMeta();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "ElevatorType":
- // Assign the type to the current element value.
- elevatorDriverMeta.type = (ElevatorType)Enum.Parse(typeof(ElevatorType), reader.ReadElementContentAsString());
- break;
- }
- }
-
- return elevatorDriverMeta;
- }
-
- ///
- /// Reads a PneumaticDriverMeta from the given XmlReader.
- ///
- ///
- ///
- private static PneumaticDriverMeta ReadPneumaticDriverMeta_5_0(XmlReader reader)
- {
- // Create a new pneumaticDriverMeta.
- PneumaticDriverMeta pneumaticDriverMeta = new PneumaticDriverMeta();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "WidthMM":
- // Assign the current element value to widthMM.
- pneumaticDriverMeta.widthMM = reader.ReadElementContentAsInt();
- break;
- case "PressurePSI":
- // Assign the current element value to pressurePSI.
- pneumaticDriverMeta.pressurePSI = float.Parse(reader.ReadElementContentAsString());
- break;
- }
- }
-
- return pneumaticDriverMeta;
- }
-
- ///
- /// Reads a WheelDriverMeta from the given XmlReader.
- ///
- ///
- ///
- private static WheelDriverMeta ReadWheelDriverMeta_5_0(XmlReader reader)
- {
- // Create new WheelDriveMeta.
- WheelDriverMeta wheelDriverMeta = new WheelDriverMeta();
-
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "WheelType":
- // Assign a value to the type.
- wheelDriverMeta.type = (WheelType)Enum.Parse(typeof(WheelType), reader.ReadElementContentAsString());
- break;
- case "WheelRadius":
- // Assign a value to the radius.
- wheelDriverMeta.radius = float.Parse(reader.ReadElementContentAsString());
- break;
- case "WheelWidth":
- // Assign a value to the width.
- wheelDriverMeta.width = float.Parse(reader.ReadElementContentAsString());
- break;
- case "BXDVector3":
- // Assign a value to the center.
- wheelDriverMeta.center = ReadBXDVector5_0(reader.ReadSubtree());
- break;
- case "ForwardAsympSlip":
- // Assign a value to the forwardAsympSlip.
- wheelDriverMeta.forwardAsympSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "ForwardAsympValue":
- // Assign a value to the forwardAsympValue.
- wheelDriverMeta.forwardAsympValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "ForwardExtremeSlip":
- // Assign a value to the forwardExtremeSlip.
- wheelDriverMeta.forwardExtremeSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "ForwardExtremeValue":
- // Assign a value to the forwardExtremeValue.
- wheelDriverMeta.forwardExtremeValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideAsympSlip":
- // Assign a value to the sideAsympSlip.
- wheelDriverMeta.sideAsympSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideAsympValue":
- // Assign a value to the sideAsympValue.
- wheelDriverMeta.sideAsympValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideExtremeSlip":
- // Assign a value to the sideExtremeSlip.
- wheelDriverMeta.sideExtremeSlip = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SideExtremeValue":
- // Assign a value to the sideExtremeValue.
- wheelDriverMeta.sideExtremeValue = float.Parse(reader.ReadElementContentAsString());
- break;
- case "IsDriveWheel":
- // Assign a value to isDriveWheel.
- wheelDriverMeta.isDriveWheel = reader.ReadElementContentAsBoolean();
- break;
- }
- }
-
- return wheelDriverMeta;
- }
-
- ///
- /// Read a RobotSensor from the given XmlReader.
- ///
- ///
- ///
- private static RobotSensor ReadRobotSensor_5_0(XmlReader reader)
- {
- RobotSensor robotSensor = null;
- //throw (new Exception("Reading thing"));
- foreach (string name in IOUtilities.AllElements(reader))
- {
- switch (name)
- {
- case "SensorType":
- // Initialize the RobotSensor.
- robotSensor = new RobotSensor((RobotSensorType)Enum.Parse(typeof(RobotSensorType), reader.ReadElementContentAsString()));
- break;
- case "SensorPortNumberA":
- // Assign a value to the port.
- robotSensor.portA = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SensorSignalTypeA":
- // Assign a value to the port.
- robotSensor.conTypePortA = (SensorConnectionType)Enum.Parse(typeof(SensorConnectionType), reader.ReadElementContentAsString());
- break;
- case "SensorPortNumberB":
- // Assign a value to the port.
- robotSensor.portB = float.Parse(reader.ReadElementContentAsString());
- break;
- case "SensorSignalTypeB":
- // Assign a value to the port.
- robotSensor.conTypePortB = (SensorConnectionType)Enum.Parse(typeof(SensorConnectionType), reader.ReadElementContentAsString());
- break;
- case "SensorConversionFactor":
- // Assign a value to useSecondarySource.
- robotSensor.conversionFactor = double.Parse(reader.ReadElementContentAsString());
- if(robotSensor.conversionFactor == 0)
- {
- robotSensor.conversionFactor = 1;
- }
- break;
- }
- }
-
- return robotSensor;
- }
-}
\ No newline at end of file
diff --git a/api/Aardvark/IO/BXDJ/BXDJSkeleton.cs b/api/Aardvark/IO/BXDJ/BXDJSkeleton.cs
deleted file mode 100644
index a8dfa036d3..0000000000
--- a/api/Aardvark/IO/BXDJ/BXDJSkeleton.cs
+++ /dev/null
@@ -1,562 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Xml;
-///
-/// Utility functions for reading/writing BXDJ files
-///
-
-public static partial class BXDJSkeleton
-{
- ///
- /// Represents the current version of the BXDA file.
- ///
- public const string BXDJ_CURRENT_VERSION = "4.2.0";
-
- ///
- /// Ensures that every node is assigned a model file name by assigning all nodes without a file name a generated name.
- ///
- /// The base node of the skeleton
- /// Overwrite existing
- public static void SetupFileNames(RigidNode_Base baseNode)
- {
- List nodes = new List();
- baseNode.ListAllNodes(nodes);
-
- for (int i = 0; i < nodes.Count; i++)
- {
- if (nodes[i].ModelFileName == null)
- nodes[i].ModelFileName = ("node_" + i + ".bxda");
- }
- }
-
- ///
- /// Writes out the skeleton file for the skeleton with the base provided to the path provided.
- ///
- ///
- ///
- public static void WriteSkeleton(string path, RigidNode_Base baseNode)
- {
-
- //EXPERIMENT
-
- // JSONExport(path, baseNode);
- List nodes = new List();
- baseNode.ListAllNodes(nodes);
-
- // Determine the parent ID for each node in the list.
- int[] parentID = new int[nodes.Count];
-
- for (int i = 0; i < nodes.Count; i++)
- {
- if (nodes[i].GetParent() != null)
- {
- parentID[i] = nodes.IndexOf(nodes[i].GetParent());
-
- if (parentID[i] < 0) throw new Exception("Can't resolve parent ID for " + nodes[i].ToString());
- }
- else
- {
- parentID[i] = -1;
- }
- }
-
- XmlWriterSettings settings = new XmlWriterSettings();
- settings.Indent = true;
-
- XmlWriter writer = XmlWriter.Create(path, settings);
-
- writer.WriteStartDocument();
-
- writer.WriteStartElement("BXDJ");
- writer.WriteAttributeString("Version", BXDJ_CURRENT_VERSION);
-
- for (int i = 0; i < nodes.Count; i++)
- {
- writer.WriteStartElement("Node");
-
- writer.WriteAttributeString("GUID", nodes[i].GUID.ToString());
-
- writer.WriteElementString("ParentID", parentID[i].ToString());
-
- writer.WriteElementString("ModelFileName", FileUtilities.SanatizeFileName("node_" + i + ".bxda"));
-
- writer.WriteElementString("ModelID", nodes[i].GetModelID());
-
- if (parentID[i] >= 0)
- WriteJoint(nodes[i].GetSkeletalJoint(), writer);
-
- writer.WriteEndElement();
- }
-
- writer.WriteElementString("DriveTrainType", (baseNode.driveTrainType).ToString());
-
- writer.WriteElementString("SoftwareExportedWith", "INVENTOR");
-
- writer.Close();
- }
-
- ///
- /// Writes the backing information and ID for this joint with the given XmlWriter.
- ///
- ///
- ///
- private static void WriteJoint(SkeletalJoint_Base joint, XmlWriter writer)
- {
- switch (joint.GetJointType())
- {
- case SkeletalJointType.BALL:
- WriteBallJoint((BallJoint_Base)joint, writer);
- break;
- case SkeletalJointType.CYLINDRICAL:
- WriteCylindricalJoint((CylindricalJoint_Base)joint, writer);
- break;
- case SkeletalJointType.LINEAR:
- WriteLinearJoint((LinearJoint_Base)joint, writer);
- break;
- case SkeletalJointType.PLANAR:
- WritePlanarJoint((PlanarJoint_Base)joint, writer);
- break;
- case SkeletalJointType.ROTATIONAL:
- WriteRotationalJoint((RotationalJoint_Base)joint, writer);
- break;
- default:
- throw new Exception("Could not determine type of joint");
- }
-
- if (joint.cDriver != null)
- WriteJointDriver(joint.cDriver, writer);
-
- for (int i = 0; i < joint.attachedSensors.Count; i++)
- {
- WriteRobotSensor(joint.attachedSensors[i], writer);
- }
- }
-
- ///
- /// Used for writing the data of a BallJoint_Base.
- ///
- ///
- ///
- private static void WriteBallJoint(BallJoint_Base joint, XmlWriter writer)
- {
- writer.WriteStartElement("BallJoint");
-
- WriteBXDVector3(joint.basePoint, writer, "BasePoint");
-
- writer.WriteEndElement();
- }
-
- ///
- /// Used for writing the data of a CylindricalJoint_Base.
- ///
- ///
- ///
- private static void WriteCylindricalJoint(CylindricalJoint_Base joint, XmlWriter writer)
- {
- writer.WriteStartElement("CylindricalJoint");
-
- joint.EnforceOrder();
-
- WriteBXDVector3(joint.basePoint, writer, "BasePoint");
- WriteBXDVector3(joint.axis, writer, "Axis");
-
- if (joint.hasAngularLimit)
- {
- writer.WriteElementString("AngularLowLimit", joint.angularLimitLow.ToString("F4"));
- writer.WriteElementString("AngularHighLimit", joint.angularLimitHigh.ToString("F4"));
- }
-
- if (joint.hasLinearStartLimit)
- writer.WriteElementString("LinearStartLimit", joint.linearLimitStart.ToString("F4"));
-
- if (joint.hasLinearEndLimit)
- writer.WriteElementString("LinearEndLimit", joint.linearLimitEnd.ToString("F4"));
- //writer.WriteElementString("CurrentLinearPosition", joint.currentLinearPosition.ToString("F4"));
- //writer.WriteElementString("CurrentAngularPosition", joint.currentAngularPosition.ToString("F4"));
-
- writer.WriteElementString("CurrentLinearPosition", joint.currentLinearPosition.ToString("F4"));// writes the lowest point of the joint to the file as the positon so the joint starts at the bottom, hopefully prevents any weird issues with the joint limits being messed up do to being relative to the start of the joint
-
- writer.WriteElementString("CurrentAngularPosition", joint.currentAngularPosition.ToString("F4"));// writes the lowest point of the joint to the file as the positon so the joint starts at the bottom, hopefully prevents any weird issues with the joint limits being messed up do to being relative to the start of the joint
-
-
- writer.WriteEndElement();
- }
-
- ///
- /// Used for writing the data of a LinearJoint_Base.
- ///
- ///
- ///
- private static void WriteLinearJoint(LinearJoint_Base joint, XmlWriter writer)
- {
- writer.WriteStartElement("LinearJoint");
-
- joint.EnforceOrder();
-
- WriteBXDVector3(joint.basePoint, writer, "BasePoint");
- WriteBXDVector3(joint.axis, writer, "Axis");
-
- if (joint.hasLowerLimit)
- writer.WriteElementString("LinearLowLimit", joint.linearLimitLow.ToString("F4"));
-
- if (joint.hasUpperLimit)
- writer.WriteElementString("LinearUpperLimit", joint.linearLimitHigh.ToString("F4"));
-
- // writer.WriteElementString("CurrentLinearPosition", joint.currentLinearPosition.ToString("F4"));
- writer.WriteElementString("CurrentLinearPosition", joint.currentLinearPosition.ToString("F4"));// writes the lowest point of the joint to the file as the positon so the joint starts at the bottom, hopefully prevents any weird issues with the joint limits being messed up do to being relative to the start of the joint
-
- writer.WriteEndElement();
- }
-
- ///
- /// Used for writing the data of a PlanarJoint_Base.
- ///
- ///
- ///
- private static void WritePlanarJoint(PlanarJoint_Base joint, XmlWriter writer)
- {
- writer.WriteStartElement("PlanarJoint");
-
- WriteBXDVector3(joint.normal, writer, "Normal");
- WriteBXDVector3(joint.basePoint, writer, "BasePoint");
-
- writer.WriteEndElement();
- }
-
- ///
- /// Used for writing the data of a RotationalJoint_Base.
- ///
- ///
- ///
- private static void WriteRotationalJoint(RotationalJoint_Base joint, XmlWriter writer)
- {
- writer.WriteStartElement("RotationalJoint");
-
- joint.EnforceOrder();
-
- WriteBXDVector3(joint.basePoint, writer, "BasePoint");
- WriteBXDVector3(joint.axis, writer, "Axis");
-
- if (joint.hasAngularLimit)
- {
- writer.WriteElementString("AngularLowLimit", joint.angularLimitLow.ToString("F4"));
- writer.WriteElementString("AngularHighLimit", joint.angularLimitHigh.ToString("F4"));
- }
-
- // writer.WriteElementString("CurrentAngularPosition", joint.currentAngularPosition.ToString("F4"));
- writer.WriteElementString("CurrentAngularPosition", joint.currentAngularPosition.ToString("F4"));// writes the lowest point of the joint to the file as the positon so the joint starts at the bottom, hopefully prevents any weird issues with the joint limits being messed up do to being relative to the start of the joint
-
-
- writer.WriteEndElement();
- }
-
- ///
- /// Writes the BXDVector3 to an XML file with the given XmlWriter.
- ///
- ///
- ///
- private static void WriteBXDVector3(BXDVector3 vec, XmlWriter writer, string id)
- {
- writer.WriteStartElement("BXDVector3");
-
- writer.WriteAttributeString("VectorID", id);
-
- writer.WriteElementString("X", vec.x.ToString("F4"));
- writer.WriteElementString("Y", vec.y.ToString("F4"));
- writer.WriteElementString("Z", vec.z.ToString("F4"));
-
- writer.WriteEndElement();
- }
-
- ///
- /// Used for writing joint driver data.
- ///
- ///
- ///
- private static void WriteJointDriver(JointDriver driver, XmlWriter writer)
- {
- writer.WriteStartElement("JointDriver");
-
- writer.WriteElementString("DriveType", driver.GetDriveType().ToString());
- writer.WriteElementString("MotorType", driver.GetMotorType().ToString());
-
- writer.WriteElementString("Port1", (driver.port1 + 1).ToString()); // Synthesis engine downshifts port numbers due to old code using 1 and 2 for drive.
- writer.WriteElementString("Port2", (driver.port2 + 1).ToString()); // For backwards compatibility, ports will be stored one larger than their actual value.
- if (driver.InputGear == 0)// prevents a gearing of 0 from being written to the bxdj
- {
- driver.InputGear = 1;
- }
- if (driver.OutputGear == 0)// prevents a gearing of 0 from being written to the bxdj
- {
- driver.OutputGear = 1;
- }
- writer.WriteElementString("InputGear", driver.InputGear.ToString());// writes the input gear's string to the XMLWriter
- writer.WriteElementString("OutputGear", driver.OutputGear.ToString());// writes the output gear's string to the XMLWriter
- writer.WriteElementString("LowerLimit", driver.lowerLimit.ToString("F4"));
- writer.WriteElementString("UpperLimit", driver.upperLimit.ToString("F4"));
- writer.WriteElementString("SignalType", driver.isCan ? "CAN" : "PWM");
- writer.WriteElementString("HasBrake", driver.hasBrake.ToString().ToLower());
-
- foreach (JointDriverMeta meta in driver.MetaInfo.Values)
- {
- WriteJointDriverMeta(meta, writer);
- }
-
- writer.WriteEndElement();
- }
-
- ///
- /// Used for writing joint driver meta data.
- ///
- ///
- ///
- private static void WriteJointDriverMeta(JointDriverMeta meta, XmlWriter writer)
- {
- switch (meta.GetType().ToString())
- {
- case "ElevatorDriverMeta":
- WriteElevatorDriverMeta((ElevatorDriverMeta)meta, writer);
- break;
- case "PneumaticDriverMeta":
- WritePneumaticDriverMeta((PneumaticDriverMeta)meta, writer);
- break;
- case "WheelDriverMeta":
- WriteWheelDriverMeta((WheelDriverMeta)meta, writer);
- break;
- }
- }
-
- ///
- /// Used for writing elevator driver meta data.
- ///
- ///
- ///
- private static void WriteElevatorDriverMeta(ElevatorDriverMeta meta, XmlWriter writer)
- {
- writer.WriteStartElement("ElevatorDriverMeta");
-
- writer.WriteAttributeString("DriverMetaID", meta.GetID().ToString());
-
- writer.WriteElementString("ElevatorType", meta.type.ToString());
-
- writer.WriteEndElement();
- }
-
- ///
- /// Used for writing pneumatic driver meta data.
- ///
- ///
- ///
- private static void WritePneumaticDriverMeta(PneumaticDriverMeta meta, XmlWriter writer)
- {
- writer.WriteStartElement("PneumaticDriverMeta");
-
- writer.WriteAttributeString("DriverMetaID", meta.GetID().ToString());
-
- writer.WriteElementString("WidthMM", (meta.width * 25.4).ToString("F4"));
- writer.WriteElementString("PressurePSI", meta.pressurePSI.ToString("F4"));
-
- writer.WriteEndElement();
- }
-
- ///
- /// Used for writing wheel driver meta data.
- ///
- ///
- ///
- private static void WriteWheelDriverMeta(WheelDriverMeta meta, XmlWriter writer)
- {
- writer.WriteStartElement("WheelDriverMeta");
-
- writer.WriteAttributeString("DriverMetaID", meta.GetID().ToString());
-
- writer.WriteElementString("WheelType", meta.type.ToString());
- writer.WriteElementString("WheelRadius", meta.radius.ToString("F4"));
- writer.WriteElementString("WheelWidth", meta.width.ToString("F4"));
-
- WriteBXDVector3(meta.center, writer, "WheelCenter");
-
- writer.WriteElementString("ForwardAsympSlip", meta.forwardAsympSlip.ToString("F4"));
- writer.WriteElementString("ForwardAsympValue", meta.forwardAsympValue.ToString("F4"));
- writer.WriteElementString("ForwardExtremeSlip", meta.forwardExtremeSlip.ToString("F4"));
- writer.WriteElementString("ForwardExtremeValue", meta.forwardExtremeValue.ToString("F4"));
- writer.WriteElementString("SideAsympSlip", meta.sideAsympSlip.ToString("F4"));
- writer.WriteElementString("SideAsympValue", meta.sideAsympValue.ToString("F4"));
- writer.WriteElementString("SideExtremeSlip", meta.sideExtremeSlip.ToString("F4"));
- writer.WriteElementString("SideExtremeValue", meta.sideExtremeValue.ToString("F4"));
- writer.WriteElementString("IsDriveWheel", meta.isDriveWheel.ToString().ToLower());
-
- writer.WriteEndElement();
- }
-
- ///
- /// Used for writing the data from a RobotSensor.
- ///
- ///
- ///
- private static void WriteRobotSensor(RobotSensor sensor, XmlWriter writer)
- {
- writer.WriteStartElement("RobotSensor");
-
- writer.WriteElementString("SensorType", sensor.type.ToString());
- writer.WriteElementString("SensorPortNumberA", sensor.portA.ToString());
- writer.WriteElementString("SensorSignalTypeA", sensor.conTypePortA.ToString());
- writer.WriteElementString("SensorPortNumberB", sensor.portB.ToString());
- writer.WriteElementString("SensorSignalTypeB", sensor.conTypePortB.ToString());
- writer.WriteElementString("SensorConversionFactor", sensor.conversionFactor.ToString());
-
- writer.WriteEndElement();
- }
-
- ///
- /// Reads the skeleton contained in the BXDJ XML file specified and returns the root node for that skeleton.
- ///
- ///
- ///
- public static RigidNode_Base ReadSkeleton(string path)
- {
- XmlReader reader = XmlReader.Create(path);
-
- if (reader.ReadToFollowing("BXDJ"))
- {
- string version = reader["Version"];
-
- switch (version.Substring(0, version.LastIndexOf('.')))// sends each version of the BXDJ to the appropriate reader
- {
- case "4.2":
- return ReadSkeleton_4_2(path);
- case "4.1":
- return ReadSkeleton_4_1(path);
- case "4.0":
- return ReadSkeleton_4_0(path);
- case "3.0":
- return ReadSkeleton_3_0(path);
- case "2.0":
- return ReadSkeleton_2_0(path);
- default: // If version is unknown.
- // Attempt to read with the most recent version (but without validation).
- // helps a little with forward compatibility
- return ReadSkeleton_4_2(path, false);
- }
- }
- else
- {
- // Could not find element, so return null.
- return null;
- }
- }
-
- ///
- /// Reads the skeleton contained in the BXDJ file specified and returns the root node for that skeleton.
- ///
- /// The input BXDJ file
- /// The root node of the skeleton
- public static RigidNode_Base ReadBinarySkeleton(string path)
- {
- BinaryReader reader = null;
- try
- {
- reader = new BinaryReader(new FileStream(path, FileMode.Open)); //Throws IOException
- // Sanity check
- uint version = reader.ReadUInt32();
- BXDIO.CheckReadVersion(version); //Throws FormatException
-
- int nodeCount = reader.ReadInt32();
- if (nodeCount <= 0) throw new Exception("This appears to be an empty skeleton");
-
- RigidNode_Base root = null;
- RigidNode_Base[] nodes = new RigidNode_Base[nodeCount];
-
- for (int i = 0; i < nodeCount; i++)
- {
- //nodes[i] = RigidNode_Base.NODE_FACTORY();
-
- int parent = reader.ReadInt32();
- nodes[i].ModelFileName = (reader.ReadString());
- nodes[i].ModelFullID = (reader.ReadString());
-
- if (parent != -1)
- {
- SkeletalJoint_Base joint = SkeletalJoint_Base.ReadJointFully(reader);
- nodes[parent].AddChild(joint, nodes[i]);
-
- }
- else
- {
- root = nodes[i];
- }
- }
-
- if (root == null)
- {
- throw new Exception("This skeleton has no known base. \"" + path + "\" is probably corrupted.");
- }
-
- return root;
- }
- catch (FormatException fe)
- {
- Console.WriteLine("File version mismatch");
- Console.WriteLine(fe);
- return null;
- }
- catch (IOException ie)
- {
- Console.WriteLine("Could not open skeleton file");
- Console.WriteLine(ie);
- return null;
- }
- catch (Exception e)
- {
- Console.WriteLine(e);
- return null;
- }
- finally
- {
- if (reader != null) reader.Close();
- }
- }
-
- ///
- /// Clones joint settings for matching skeletal joints from one skeleton to the other. This does not overwrite existing joint drivers.
- ///
- /// Source skeleton
- /// Destination skeleton
- public static void CloneDriversFromTo(RigidNode_Base from, RigidNode_Base to, bool overwrite = false)
- {
- List tempNodes = new List();
- from.ListAllNodes(tempNodes);
-
- Dictionary fromNodes = new Dictionary();
- foreach (RigidNode_Base cpy in tempNodes)
- {
- fromNodes[cpy.GetModelID()] = cpy;
- }
-
- tempNodes.Clear();
- to.ListAllNodes(tempNodes);
- foreach (RigidNode_Base copyTo in tempNodes)
- {
- RigidNode_Base fromNode;
- if (fromNodes.TryGetValue(copyTo.GetModelID(), out fromNode))
- {
- if (copyTo.GetSkeletalJoint() != null && fromNode.GetSkeletalJoint() != null && copyTo.GetSkeletalJoint().GetJointType() == fromNode.GetSkeletalJoint().GetJointType())
- {
- if(copyTo.GetSkeletalJoint().cDriver == null || overwrite)
- {
- // Swap driver.
- copyTo.GetSkeletalJoint().cDriver = fromNode.GetSkeletalJoint().cDriver;
- }
-
- if (copyTo.GetSkeletalJoint().attachedSensors.Count == 0 || overwrite)
- {
- // Swap sensors.
- copyTo.GetSkeletalJoint().attachedSensors = fromNode.GetSkeletalJoint().attachedSensors;
- }
- }
- }
- }
- }
-
-}
diff --git a/api/Aardvark/IO/BXDJ/BXDJSkeletonJson.cs b/api/Aardvark/IO/BXDJ/BXDJSkeletonJson.cs
deleted file mode 100644
index 0f1ad2d344..0000000000
--- a/api/Aardvark/IO/BXDJ/BXDJSkeletonJson.cs
+++ /dev/null
@@ -1,386 +0,0 @@
-using System;
-
-using System.Collections.Generic;
-using System.IO;
-using System.Xml;
-using Newtonsoft.Json;
-using BXDSim.IO.BXDJ;
-using Newtonsoft.Json.Linq;
-///
-/// Utility functions for reading/writing BXDJ files
-///
-
-
-
-public static partial class BXDJSkeletonJson
-{
- ///
- /// Represents the current version of the BXDA file.
- ///
- public const string BXDJ_CURRENT_VERSION = "4.3.0";
-
- ///
- /// Ensures that every node is assigned a model file name by assigning all nodes without a file name a generated name.
- ///
- /// The base node of the skeleton
- /// Overwrite existing
- ///
-
-
-
- public static void SetupFileNames(RigidNode_Base baseNode)
- {
- List nodes = new List();
- baseNode.ListAllNodes(nodes);
-
- for (int i = 0; i < nodes.Count; i++)
- {
- if (nodes[i].ModelFileName == null)
- nodes[i].ModelFileName = ("node_" + i + ".bxda");
- }
- }
-
- ///
- /// Writes out the skeleton file for the skeleton with the base provided to the path provided.
- ///
- ///
- ///
- public static void WriteSkeleton(string path, RigidNode_Base baseNode)
- {
-
- //EXPERIMENT
-
- // JSONExport(path, baseNode);
- List nodes = new List();
- baseNode.ListAllNodes(nodes);
-
- // Determine the parent ID for each node in the list.
- int[] parentID = new int[nodes.Count];
-
- for (int i = 0; i < nodes.Count; i++)
- {
- if (nodes[i].GetParent() != null)
- {
- parentID[i] = nodes.IndexOf(nodes[i].GetParent());
-
- if (parentID[i] < 0) throw new Exception("Can't resolve parent ID for " + nodes[i].ToString());
- }
- else
- {
- parentID[i] = -1;
- }
- }
-
-
- JsonSkeleton jsonSkeleton = new JsonSkeleton();
- jsonSkeleton.Version = BXDJ_CURRENT_VERSION;
-
- for (int i = 0; i < nodes.Count; i++)
- {
- JsonSkeletonNode node = new JsonSkeletonNode();
-
- node.GUID = nodes[i].GUID.ToString();
- node.ParentID = parentID[i].ToString();
- node.ModelFileName = FileUtilities.SanatizeFileName("node_" + i + ".bxda");
- node.ModelID = nodes[i].GetModelID();
-
-
-
- if (parentID[i] >= 0)
- {
- node.joint = nodes[i].GetSkeletalJoint();
-
- node.joint.typeSave = node.joint.GetJointType();
-
- if (node.joint.cDriver != null)
- {
- node.joint.cDriver.port1 += 1;
- node.joint.cDriver.port2 += 1;
- }
-
-
- }
-
-
-
- //WriteJoint(nodes[i].GetSkeletalJoint(), node);
-
- jsonSkeleton.Nodes.Add(node);
- }
- jsonSkeleton.DriveTrainType = baseNode.driveTrainType;
- jsonSkeleton.SoftwareExportedWith = "INVENTOR";
- var settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Auto };
- string toWrite = JsonConvert.SerializeObject(jsonSkeleton, settings);
- File.WriteAllText(path, toWrite);
- }
-
- public static RigidNode_Base ReadSkeleton(string path)
- {
- string jsonData = File.ReadAllText(path);
- RigidNode_Base root = null;
- JsonConverter[] converters = { new JointConverter(), new DriverMetaConverter() };
- JsonSkeleton skeleton = JsonConvert.DeserializeObject(jsonData, new JsonSerializerSettings() { Converters = converters });
- List nodes = skeleton.Nodes;
-
- if(nodes.Count < 1)
- {
- Console.Error.WriteLine("0 Nodes Loaded! Failed import");
-
- return null;
- }
-
- foreach(JsonSkeletonNode node in nodes)
- {
- RigidNode_Base newNode = RigidNode_Base.NODE_FACTORY(new Guid(node.GUID));
- newNode.ModelFileName = node.ModelFileName;
- newNode.ModelFullID = node.ModelID;
-
-
- if (node.ParentID == "-1")
- {
- root = newNode;
- root.driveTrainType = skeleton.DriveTrainType;
-
- }
- else
- {
-
- root.AddChild(node.joint, newNode);
- }
-
-
- }
-
-
-
- return root;
- }
- public class JointConverter : JsonConverter
- {
- public override bool CanConvert(Type objectType)
- {
- return (objectType == typeof(SkeletalJoint_Base));
- }
-
- public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
- {
- if (reader.TokenType == JsonToken.Null)
- return null;
-
- JObject jo = JObject.Load(reader);
-
- switch (jo["typeSave"].Value())
- {
- case "BALL":
-
- return jo.ToObject (serializer);
-
- break;
-
- case "CYLINDRICAL":
- return jo.ToObject (serializer);
-
- break;
-
- case "LINEAR":
- return jo.ToObject (serializer);
-
- break;
-
- case "PLANAR":
- return jo.ToObject < PlanarJoint_Base > (serializer);
-
- break;
-
- case "ROTATIONAL":
- return jo.ToObject < RotationalJoint_Base > (serializer);
-
- break;
-
- default:
- return null;
-
- }
-
-
- }
-
- public override bool CanWrite
- {
- get { return false; }
- }
-
- public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
- {
- throw new NotImplementedException();
- }
- }
-
- public class DriverMetaConverter : JsonConverter
- {
- public override bool CanConvert(Type objectType)
- {
- return (objectType == typeof(JointDriverMeta));
- }
-
- public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
- {
- if (reader.TokenType == JsonToken.Null)
- return null;
-
- JObject jo = JObject.Load(reader);
-
- switch (jo["$type"].Value())
- {
- case "WheelDriverMeta, SimulatorAPI":
-
- return jo.ToObject(serializer);
-
- break;
-
- case "ElevatorDriverMeta, SimulatorAPI":
- return jo.ToObject(serializer);
-
- break;
-
- case "PneumaticDriverMeta, SimulatorAPI":
- return jo.ToObject(serializer);
-
- break;
-
-
-
- default:
- return null;
-
- }
-
- }
-
- public override bool CanWrite
- {
- get { return false; }
- }
-
- public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
- {
- throw new NotImplementedException();
- }
- }
-
-
-
-
-
- ///
- /// Reads the skeleton contained in the BXDJ file specified and returns the root node for that skeleton.
- ///
- /// The input BXDJ file
- /// The root node of the skeleton
- public static RigidNode_Base ReadBinarySkeleton(string path)
- {
- BinaryReader reader = null;
- try
- {
- reader = new BinaryReader(new FileStream(path, FileMode.Open)); //Throws IOException
- // Sanity check
- uint version = reader.ReadUInt32();
- BXDIO.CheckReadVersion(version); //Throws FormatException
-
- int nodeCount = reader.ReadInt32();
- if (nodeCount <= 0) throw new Exception("This appears to be an empty skeleton");
-
- RigidNode_Base root = null;
- RigidNode_Base[] nodes = new RigidNode_Base[nodeCount];
-
- for (int i = 0; i < nodeCount; i++)
- {
- //nodes[i] = RigidNode_Base.NODE_FACTORY();
-
- int parent = reader.ReadInt32();
- nodes[i].ModelFileName = (reader.ReadString());
- nodes[i].ModelFullID = (reader.ReadString());
-
- if (parent != -1)
- {
- SkeletalJoint_Base joint = SkeletalJoint_Base.ReadJointFully(reader);
- nodes[parent].AddChild(joint, nodes[i]);
- }
- else
- {
- root = nodes[i];
- }
- }
-
- if (root == null)
- {
- throw new Exception("This skeleton has no known base. \"" + path + "\" is probably corrupted.");
- }
-
- return root;
- }
- catch (FormatException fe)
- {
- Console.WriteLine("File version mismatch");
- Console.WriteLine(fe);
- return null;
- }
- catch (IOException ie)
- {
- Console.WriteLine("Could not open skeleton file");
- Console.WriteLine(ie);
- return null;
- }
- catch (Exception e)
- {
- Console.WriteLine(e);
- return null;
- }
- finally
- {
- if (reader != null) reader.Close();
- }
- }
-
- ///
- /// Clones joint settings for matching skeletal joints from one skeleton to the other. This does not overwrite existing joint drivers.
- ///
- /// Source skeleton
- /// Destination skeleton
- public static void CloneDriversFromTo(RigidNode_Base from, RigidNode_Base to, bool overwrite = false)
- {
- List tempNodes = new List();
- from.ListAllNodes(tempNodes);
-
- Dictionary fromNodes = new Dictionary();
- foreach (RigidNode_Base cpy in tempNodes)
- {
- fromNodes[cpy.GetModelID()] = cpy;
- }
-
- tempNodes.Clear();
- to.ListAllNodes(tempNodes);
- foreach (RigidNode_Base copyTo in tempNodes)
- {
- RigidNode_Base fromNode;
- if (fromNodes.TryGetValue(copyTo.GetModelID(), out fromNode))
- {
- if (copyTo.GetSkeletalJoint() != null && fromNode.GetSkeletalJoint() != null && copyTo.GetSkeletalJoint().GetJointType() == fromNode.GetSkeletalJoint().GetJointType())
- {
- if(copyTo.GetSkeletalJoint().cDriver == null || overwrite)
- {
- // Swap driver.
- copyTo.GetSkeletalJoint().cDriver = fromNode.GetSkeletalJoint().cDriver;
- }
-
- if (copyTo.GetSkeletalJoint().attachedSensors.Count == 0 || overwrite)
- {
- // Swap sensors.
- copyTo.GetSkeletalJoint().attachedSensors = fromNode.GetSkeletalJoint().attachedSensors;
- }
- }
- }
- }
- }
-
-}
diff --git a/api/Aardvark/IO/BXDJ/BXDJSkeletonJsonDefinitions.cs b/api/Aardvark/IO/BXDJ/BXDJSkeletonJsonDefinitions.cs
deleted file mode 100644
index 5f961e5d93..0000000000
--- a/api/Aardvark/IO/BXDJ/BXDJSkeletonJsonDefinitions.cs
+++ /dev/null
@@ -1,126 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace BXDSim.IO.BXDJ
-{
- public class JsonSkeleton
- {
- public string Version;
- public RigidNode_Base.DriveTrainType DriveTrainType;
- public string SoftwareExportedWith;
- public List Nodes = new List();
- }
-
-
- public class JsonSkeletonNode
- {
- public string GUID;
- public string ParentID;
- public string ModelFileName;
- public string ModelID;
-
- public SkeletalJoint_Base joint;
-
- }
-
-
- // JSON Redefintions (Not Nessary as most internal classes are "json-friendly")
-
- /*
- public class JsonSkeletonJoint_Base
- {
- public string type = "BaseJoint";
- public BXDVector3 basePoint;
- }
- public class JsonSkeletonJoint_Ball : JsonSkeletonJoint_Base
- {
- // Same as parent
- }
-
- public class JsonSkeletonJoint_Cylindrical : JsonSkeletonJoint_Base
- {
- public BXDVector3 Axis;
- public string AngularLowLimit, AngularHighLimit;
- public string LinearStartLimit;
- public string LinearEndLimit;
- public string CurrentLinearPosition;
- public string CurrentAngularPosition;
-
- }
-
- public class JsonSkeletonJoint_Linear : JsonSkeletonJoint_Base
- {
- public BXDVector3 Axis;
- public string LinearLowLimit;
- public string LinearUpperLimit;
- public string CurrentLinearPosition;
- }
-
- public class JsonSkeletonJoint_Planar : JsonSkeletonJoint_Base
- {
- public BXDVector3 normal;
- }
- public class JsonSkeletonJoint_Rotational : JsonSkeletonJoint_Base
- {
- public BXDVector3 Axis;
- public string AngularLowLimit, AngularHighLimit;
- public string CurrentAngularPosition;
- }
-
- public class JsonSkeletonJointDriver
- {
- public string DriverType;
- public string MotorType;
- public string Port1;
- public string Port2;
- public string InputGear;
- public string OutputGear;
- public string LowerLimit;
- public string UpperLimit;
- public string SignalType;
- public string HasBreak;
- public List Meta = new List();
- }
-
- public class JsonSkeletonDriverMeta_Base
- {
- public string DriverMetaID;
- }
-
- public class JsonSkeletonDriverMeta_Elevator : JsonSkeletonDriverMeta_Base
- {
- public string ElevatorType;
- }
- public class JsonSkeletonDriverMeta_Pnuematic : JsonSkeletonDriverMeta_Base
- {
- public double WidthMM;
- public double PressurePSI;
-
- }
- public class JsonSkeletonDriverMeta_Wheel : JsonSkeletonDriverMeta_Base
- {
- public string WheelType;
- public string WheelRadius;
- public BXDVector3 WheelCenter;
- public string ForwardAsympSlip;
- public string ForwardAsympValue;
- public string ForwardExtremeSlip;
- public string ForwardExtremeValue;
- public string SideAsympSlip;
- public string SideAsympValue;
- public bool IsDriveWheel;
- }
-
- public class JsonSkeletonSensor
- {
- public string SensorType;
- public int SensorPortNumberA;
- public string SignalTypeA;
- public int SensorPortNumberB;
- public string SignalTypeB;
- public double SensorConversionFactor;
- }
- */
-}
diff --git a/api/Aardvark/IO/BinaryArrayIO.cs b/api/Aardvark/IO/BinaryArrayIO.cs
deleted file mode 100644
index 0eb43be449..0000000000
--- a/api/Aardvark/IO/BinaryArrayIO.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-using System;
-using System.IO;
-using System.Reflection;
-
-public static class BinaryArrayIO
-{
-
- public static void WriteArray(this BinaryWriter writer, T[] arr, int off = 0, int len = -1)
- {
- if (len == -1) len = arr.Length - off;
-
- if (typeof(BinaryRWObject).IsAssignableFrom(typeof(T)))
- {
- writer.Write(len);
- for (int i = off; i < off + len; i++)
- {
- writer.Write((BinaryRWObject) arr[i]);
- }
-
- return;
- }
- else if (typeof(T).IsPrimitive)
- {
- int size = Buffer.ByteLength(new T[1]);
- byte[] res = new byte[len * size];
- Buffer.BlockCopy(arr, off * size, res, 0, res.Length);
-
- writer.Write(len);
- writer.Write(res);
- }
- else
- {
- MethodInfo tMeth = typeof(BinaryWriter).GetMethod("Write", new Type[] { typeof(T) });
- if (tMeth == null) throw new IOException("Unsupported write object.");
-
- writer.Write(len);
- for (int i = off; i < off + len; i++)
- {
- tMeth.Invoke(writer, new object[] { arr[i] });
- }
- }
- }
-
- public static T[] ReadArray(this BinaryReader reader, BinaryRWObjectExtensions.ReadObjectFully readInternal = null)
- {
- if (typeof(BinaryRWObject).IsAssignableFrom(typeof(T)))
- {
- if (readInternal == null)
- {
- // Try to find a constructor...
- ConstructorInfo ctr = typeof(T).GetConstructor(new Type[0]);
- if (ctr == null) throw new IOException("Can't read array of RWObjects directly!\n");
-
- readInternal = (BinaryReader rdr) =>
- {
- BinaryRWObject ro = (BinaryRWObject) ctr.Invoke(new object[0]);
- ro.ReadBinaryData(rdr);
- return ro;
- };
- }
-
- T[] arr = new T[reader.ReadInt32()];
- for (int i = 0; i < arr.Length; i++)
- {
- arr[i] = (T) readInternal(reader);
- }
-
- return arr;
- }
- else if (typeof(T).IsPrimitive)
- {
- int len = reader.ReadInt32();
- int size = Buffer.ByteLength(new T[1]);
- byte[] res = new byte[len * size];
-
- int count = reader.Read(res, 0, res.Length);
- while (count != res.Length)
- {
- int read = reader.Read(res, count, res.Length - count);
- count += read;
- if (read < 0) throw new IOException("Failed to read enough bytes to fill array!\n");
- }
-
- T[] dest = new T[len];
- Buffer.BlockCopy(res, 0, dest, 0, res.Length);
- return dest;
- }
- else
- {
- MethodInfo tMeth = typeof(BinaryReader).GetMethod("Read" + typeof(T).Name);
- if (tMeth == null) throw new IOException("Unsupported read object.");
-
- T[] arr = new T[reader.ReadInt32()];
- for (int i = 0; i < arr.Length; i++)
- {
- arr[i] = (T) tMeth.Invoke(reader, new object[0]);
- }
-
- return arr;
- }
- }
-
-}
diff --git a/api/Aardvark/IO/BinaryRWObject.cs b/api/Aardvark/IO/BinaryRWObject.cs
deleted file mode 100644
index be72344a01..0000000000
--- a/api/Aardvark/IO/BinaryRWObject.cs
+++ /dev/null
@@ -1,125 +0,0 @@
-using System;
-using System.IO;
-
-///
-/// Interface for objects that can read/write binary data to files
-///
-public interface BinaryRWObject
-{
- ///
- /// Serializes this object to the given stream
- ///
- /// Output stream
- void WriteBinaryData(BinaryWriter writer);
-
- ///
- /// Deserializes this object from the given stream.
- ///
- /// Input stream
- void ReadBinaryData(BinaryReader reader);
-}
-
-///
-/// Extension functions for objects implementing the BinaryRWObject interface
-///
-public static class BinaryRWObjectExtensions
-{
-
- ///
- /// Delegate function to read a RWObject from a binary stream
- ///
- /// Binary stream to read object from
- /// The created object
- public delegate BinaryRWObject ReadObjectFully(BinaryReader reader);
-
- ///
- /// Writes this object to the given output path.
- ///
- /// Output path
- public static void WriteToFile(this BinaryRWObject obj, String path)
- {
- if (File.Exists(path)) File.Delete(path);
- using(BinaryWriter writer = new BinaryWriter(new FileStream(path, FileMode.OpenOrCreate)))
- {
- writer.Write(obj);
- }
- }
-
- ///
- /// Reads this object from the given input path.
- ///
- /// Input path
- public static void ReadFromFile(this BinaryRWObject obj, String path, BXDIO.ProgressReporter progress = null)
- {
- using (BinaryReader reader = new BinaryReader(new FileStream(path, FileMode.Open)))
- {
- System.Threading.Thread progressThread = null;
- if (progress != null)
- {
- // Not the most informative, but it is something.
- progressThread = new System.Threading.Thread(() =>
- {
- while (true)
- {
- progress(reader.BaseStream.Position, reader.BaseStream.Length);
- System.Threading.Thread.Sleep(10);
- }
- });
- progressThread.Start();
- }
- obj.ReadBinaryData(reader);
- if (progressThread != null)
- {
- progressThread.Abort();
- }
- }
- }
-
- ///
- /// Serializes the object into this stream
- ///
- /// Output stream
- public static void Write(this BinaryWriter writer, BinaryRWObject obj)
- {
- obj.WriteBinaryData(writer);
- }
-
- ///
- /// Deserializes the object from this stream
- ///
- /// Input stream
- /// Optional delegate to create the object
- public static T ReadRWObject(this BinaryReader reader, BinaryRWObjectExtensions.ReadObjectFully readInternal = null)
- {
- if (readInternal == null)
- {
- // Try to find a constructor...
- System.Reflection.ConstructorInfo ctr = typeof(T).GetConstructor(new Type[0]);
- if (ctr == null)
- {
- throw new IOException("Can't read " + typeof(T).Name + " directly!\n");
- }
- else
- {
- readInternal = (BinaryReader rdr) =>
- {
- BinaryRWObject ro = (BinaryRWObject) ctr.Invoke(new object[0]);
- ro.ReadBinaryData(rdr);
- return ro;
- };
- }
- }
- return (T) readInternal(reader);
- }
-
- ///
- /// Deserializes the object from this stream
- ///
- /// Input stream
- /// Read into
- public static T ReadRWInto(this BinaryReader reader, T t) where T : BinaryRWObject
- {
- t.ReadBinaryData(reader);
- return t;
- }
-}
\ No newline at end of file
diff --git a/api/Aardvark/IO/IOUtilities.cs b/api/Aardvark/IO/IOUtilities.cs
deleted file mode 100644
index 6f0865cb43..0000000000
--- a/api/Aardvark/IO/IOUtilities.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System.Collections.Generic;
-using System.Xml;
-
-///
-/// Used for simplifying reading and writing operations.
-///
-public static class IOUtilities
-{
- ///
- /// Used for easy access of all elements read by an XmlReader.
- ///
- ///
- ///
- public static IEnumerable AllElements(XmlReader reader)
- {
- while (reader.Read())
- {
- if (reader.IsStartElement())
- yield return reader.Name;
- }
- }
-}
diff --git a/api/Aardvark/IO/JsonExportGood.txt b/api/Aardvark/IO/JsonExportGood.txt
deleted file mode 100644
index cea81d753a..0000000000
--- a/api/Aardvark/IO/JsonExportGood.txt
+++ /dev/null
@@ -1 +0,0 @@
-{"Version":"4.3.0","DriveTrainType":"NONE","SoftwareExportedWith":"INVENTOR","Nodes":[{"GUID":"00000000-0000-0000-0000-000000000000","ParentID":"-1","ModelFileName":"node_0.bxda","ModelID":null,"joint":null},{"GUID":"00000000-0000-0000-0000-000000000000","ParentID":"0","ModelFileName":"node_1.bxda","ModelID":null,"joint":{"axis":null,"basePoint":null,"currentAngularPosition":0.0,"hasAngularLimit":false,"angularLimitLow":0.0,"angularLimitHigh":0.0,"cDriver":null,"attachedSensors":[]}}]}
\ No newline at end of file
diff --git a/api/Aardvark/IO/README.md b/api/Aardvark/IO/README.md
deleted file mode 100644
index 75e3593609..0000000000
--- a/api/Aardvark/IO/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# SimulatorFileIO/IO
-## This contains all the xml/ binary readers and writers and schemas for BXDJs, BXDAs, and BXDFs.
-
diff --git a/api/Aardvark/Joints/AngularDOF.cs b/api/Aardvark/Joints/AngularDOF.cs
deleted file mode 100644
index fd99db46c2..0000000000
--- a/api/Aardvark/Joints/AngularDOF.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-///
-/// Contains information about a rotational degree of freedom.
-///
-public interface AngularDOF
-{
- float currentPosition
- {
- get;
- }
- float upperLimit
- {
- get;
- set;
- }
- float lowerLimit
- {
- get;
- set;
- }
-
- BXDVector3 rotationAxis
- {
- get;
- set;
- }
- BXDVector3 basePoint
- {
- get;
- set;
- }
-}
-
-public static class AngularDOFExtensions
-{
- public static bool hasAngularLimits(this AngularDOF dof)
- {
- return !float.IsPositiveInfinity(dof.upperLimit) || !float.IsNegativeInfinity(dof.lowerLimit);
- }
-}
\ No newline at end of file
diff --git a/api/Aardvark/Joints/BallJoint_Base.cs b/api/Aardvark/Joints/BallJoint_Base.cs
deleted file mode 100644
index 9af835f568..0000000000
--- a/api/Aardvark/Joints/BallJoint_Base.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-public class BallJoint_Base : SkeletalJoint_Base
-{
- #region AngularDOF_Impl
- private class AngularDOF_Impl : AngularDOF
- {
- private readonly BallJoint_Base bjb;
- private readonly int axis;
- public AngularDOF_Impl(BallJoint_Base bjb, int axis)
- {
- this.bjb = bjb;
- this.axis = axis;
- }
-
- public float currentPosition
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public float upperLimit
- {
- get
- {
- return float.PositiveInfinity;
- }
- set
- {
- throw new NotImplementedException();
- }
- }
-
- public float lowerLimit
- {
- get
- {
- return float.NegativeInfinity;
- }
- set
- {
- throw new NotImplementedException();
- }
- }
-
- public BXDVector3 rotationAxis
- {
- get
- {
- throw new NotImplementedException();
- }
- set
- {
- throw new NotImplementedException();
- }
- }
-
- public BXDVector3 basePoint
- {
- get
- {
- return bjb.basePoint;
- }
- set
- {
- bjb.basePoint = value;
- }
- }
- }
- #endregion
-
- public BXDVector3 basePoint;
-
- private readonly AngularDOF[] angularDOF;
-
- public BallJoint_Base()
- {
- angularDOF = new AngularDOF[] { new AngularDOF_Impl(this, 0), new AngularDOF_Impl(this, 1), new AngularDOF_Impl(this, 2) };
- }
-
- public override SkeletalJointType GetJointType()
- {
- return SkeletalJointType.BALL;
- }
-
- protected override void WriteBinaryJointInternal(System.IO.BinaryWriter writer)
- {
- writer.Write(basePoint);
- }
-
- protected override void ReadBinaryJointInternal(System.IO.BinaryReader reader)
- {
- basePoint = reader.ReadRWObject();
- }
-
- public override IEnumerable GetAngularDOF()
- {
- return angularDOF;
- }
-
- public override IEnumerable GetLinearDOF()
- {
- return new LinearDOF[0];
- }
-}
\ No newline at end of file
diff --git a/api/Aardvark/Joints/CylindricalJoint_Base.cs b/api/Aardvark/Joints/CylindricalJoint_Base.cs
deleted file mode 100644
index 61d1ccca0e..0000000000
--- a/api/Aardvark/Joints/CylindricalJoint_Base.cs
+++ /dev/null
@@ -1,259 +0,0 @@
-using System.Collections.Generic;
-
-///
-/// Contains DOF information for a cylindrical joint. (1 angular and 1 linear)
-///
-public class CylindricalJoint_Base : SkeletalJoint_Base
-{
- #region LinearDOF_Impl
- private class LinearDOF_Impl : LinearDOF
- {
- private readonly CylindricalJoint_Base cjb;
- public LinearDOF_Impl(CylindricalJoint_Base cjb)
- {
- this.cjb = cjb;
- }
-
- public float currentPosition
- {
- get
- {
- return cjb.currentLinearPosition;
- }
- }
-
- public float upperLimit
- {
- get
- {
- cjb.EnforceOrder();
- return cjb.hasLinearEndLimit ? cjb.linearLimitEnd : float.PositiveInfinity;
- }
- set
- {
- cjb.linearLimitEnd = value;
- cjb.hasLinearEndLimit = !float.IsInfinity(cjb.linearLimitEnd);
- }
- }
-
- public float lowerLimit
- {
- get
- {
- cjb.EnforceOrder();
- return cjb.hasLinearStartLimit ? cjb.linearLimitStart : float.NegativeInfinity;
- }
- set
- {
- cjb.linearLimitStart = value;
- cjb.hasLinearStartLimit = !float.IsInfinity(cjb.linearLimitStart);
- }
- }
-
- public BXDVector3 translationalAxis
- {
- get
- {
- return cjb.axis;
- }
- set
- {
- cjb.axis = value;
- }
- }
-
- public BXDVector3 basePoint
- {
- get
- {
- return cjb.basePoint;
- }
- set
- {
- cjb.basePoint = value;
- }
- }
- }
- #endregion
- #region AngularDOF_Impl
- private class AngularDOF_Impl : AngularDOF
- {
- private readonly CylindricalJoint_Base cjb;
- public AngularDOF_Impl(CylindricalJoint_Base cjb)
- {
- this.cjb = cjb;
- }
- public float currentPosition
- {
- get
- {
- return cjb.currentAngularPosition;
- }
- }
-
- public float upperLimit
- {
- get
- {
- cjb.EnforceOrder();
- return cjb.hasAngularLimit ? cjb.angularLimitHigh : float.PositiveInfinity;
- }
- set
- {
- cjb.angularLimitHigh = value;
- cjb.hasAngularLimit = !float.IsInfinity(cjb.angularLimitHigh) && !float.IsInfinity(cjb.angularLimitLow);
- }
- }
-
- public float lowerLimit
- {
- get
- {
- cjb.EnforceOrder();
- return cjb.hasAngularLimit ? cjb.angularLimitLow : float.NegativeInfinity;
- }
- set
- {
- cjb.angularLimitLow = value;
- cjb.hasAngularLimit = !float.IsInfinity(cjb.angularLimitHigh) && !float.IsInfinity(cjb.angularLimitLow);
- }
- }
-
- public BXDVector3 rotationAxis
- {
- get
- {
- return cjb.axis;
- }
- set
- {
- cjb.axis = value;
- }
- }
-
- public BXDVector3 basePoint
- {
- get
- {
- return cjb.basePoint;
- }
- set
- {
- cjb.basePoint = value;
- }
- }
- }
- #endregion
-
- public BXDVector3 axis; //The axis of both rotation and movement;
- public BXDVector3 basePoint;
-
- public float currentLinearPosition, currentAngularPosition;
-
- public bool hasAngularLimit;
- public float angularLimitLow;
- public float angularLimitHigh;
- public bool hasLinearStartLimit;
- public bool hasLinearEndLimit;
- public float linearLimitStart;
- public float linearLimitEnd;
-
- private readonly LinearDOF[] linearDOF;
- private readonly AngularDOF[] angularDOF;
-
- public CylindricalJoint_Base()
- {
- linearDOF = new LinearDOF[] { new LinearDOF_Impl(this) };
- angularDOF = new AngularDOF[] { new AngularDOF_Impl(this) };
- }
-
- public override SkeletalJointType GetJointType()
- {
- return SkeletalJointType.CYLINDRICAL;
- }
-
- protected override void WriteBinaryJointInternal(System.IO.BinaryWriter writer)
- {
- EnforceOrder();
-
- writer.Write(basePoint);
- writer.Write(axis);
-
- //1 indicates a linear limit.
- writer.Write((byte) ((hasAngularLimit ? 1 : 0) | (hasLinearStartLimit ? 2 : 0) | (hasLinearEndLimit ? 4 : 0)));
- if (hasAngularLimit)
- {
- writer.Write(angularLimitLow);
- writer.Write(angularLimitHigh);
- }
-
- if (hasLinearStartLimit)
- {
- writer.Write(linearLimitStart);
- }
- if (hasLinearEndLimit)
- {
- writer.Write(linearLimitEnd);
- }
-
- writer.Write(currentLinearPosition);
- writer.Write(currentAngularPosition);
- }
-
- protected override void ReadBinaryJointInternal(System.IO.BinaryReader reader)
- {
- basePoint = reader.ReadRWObject();
- axis = reader.ReadRWObject();
-
- byte limits = reader.ReadByte();
- hasAngularLimit = (limits & 1) == 1;
- hasLinearStartLimit = (limits & 2) == 2;
- hasLinearEndLimit = (limits & 4) == 4;
-
- if (hasAngularLimit)
- {
- angularLimitLow = reader.ReadSingle();
- angularLimitHigh = reader.ReadSingle();
- }
-
- if (hasLinearStartLimit)
- {
- linearLimitStart = reader.ReadSingle();
- }
- if (hasLinearEndLimit)
- {
- linearLimitEnd = reader.ReadSingle();
- }
-
- currentLinearPosition = reader.ReadSingle();
- currentAngularPosition = reader.ReadSingle();
-
- EnforceOrder();
- }
-
- public void EnforceOrder()
- {
- if (hasAngularLimit && angularLimitLow > angularLimitHigh)
- {
- float temp = angularLimitHigh;
- angularLimitHigh = angularLimitLow;
- angularLimitLow = temp;
- }
- if (hasLinearStartLimit && hasLinearEndLimit && linearLimitStart > linearLimitEnd)
- {
- float temp = linearLimitEnd;
- linearLimitEnd = linearLimitStart;
- linearLimitStart = temp;
- }
- }
-
- public override IEnumerable GetAngularDOF()
- {
- return angularDOF;
- }
-
- public override IEnumerable GetLinearDOF()
- {
- return linearDOF;
- }
-}
diff --git a/api/Aardvark/Joints/Driver/ElevatorDriverMeta.cs b/api/Aardvark/Joints/Driver/ElevatorDriverMeta.cs
deleted file mode 100644
index a7a041697d..0000000000
--- a/api/Aardvark/Joints/Driver/ElevatorDriverMeta.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-public enum ElevatorType : byte
-{
- NOT_MULTI = 0, //Single stage elevator, constitutes most frc elevator
- CASCADING_STAGE_1 = 1,
- CASCADING_STAGE_2 = 2,
- CONTINUOUS_STAGE_1 = 3,
- CONTINUOUS_STAGE_2 = 4
-}
-public class ElevatorDriverMeta : JointDriverMeta
-{
- public ElevatorType type;
-
- public ElevatorDriverMeta()
- {
- }
-
- protected override void WriteDataInternal(System.IO.BinaryWriter writer)
- {
- writer.Write((byte)((int)type));
- }
-
- protected override void ReadDataInternal(System.IO.BinaryReader reader)
- {
- type = (ElevatorType)reader.ReadByte();
- }
-
-}
\ No newline at end of file
diff --git a/api/Aardvark/Joints/Driver/JointDriver.cs b/api/Aardvark/Joints/Driver/JointDriver.cs
deleted file mode 100644
index 6e30ebb39b..0000000000
--- a/api/Aardvark/Joints/Driver/JointDriver.cs
+++ /dev/null
@@ -1,308 +0,0 @@
-using System;
-using System.Collections.Generic;
-///
-/// Generic class able to represent all types of joint drivers.
-///
-public class JointDriver : BinaryRWObject, IComparable
-{
- ///
- /// The type of this joint driver.
- ///
- private JointDriverType type;
-
- ///
- /// The motor type of this joint driver.
- ///
- public MotorType motor { get; set; }
-
- ///
- /// The port(s) that this joint driver uses.
- ///
- public int port1, port2;
- ///
- /// The gear ratio that the input gear uses
- ///
- /// Input gear ratio
- public double InputGear { get; set; }// getter/setter for the input gear internal data structure
-
- ///
- /// The gear ratio that the output gear uses
- ///
- /// Output gear ratio
- public double OutputGear { get; set; }// getter/setter for the output gear internal data structure
-
- ///
- /// Whether or not the driver has an attached brake
- ///
- /// Determines whether or not the joint has a brake
- public bool hasBrake { get; set; }// getter/setter for the output gear internal data structure
-
- //wat
- public bool isCan = false;
-
- ///
- /// The motion limits for this driver. For continuous rotation this is likely a force or velocity.
- /// For linear or limited movement it is motion limits.
- ///
- public float lowerLimit, upperLimit;
-
- ///
- /// Metadata information for this joint driver.
- ///
- public Dictionary MetaInfo
- {
- get;
- private set;
- }
-
- ///
- /// Creates as joint driver with no type. This is mainly for IO
- ///
- public JointDriver()
- {
- MetaInfo = new Dictionary();
- }
-
- ///
- /// Creates a joint driver with the given type.
- ///
- /// Driver type
- public JointDriver(JointDriverType type)
- : this()
- {
- this.type = type;
- }
-
- ///
- /// Adds the given joint driver metadata object to this driver, or replaces the existing metadata of the same type.
- ///
- /// The metadata
- public void AddInfo(JointDriverMeta metaDriver)
- {
- try
- {
- MetaInfo.Add(metaDriver.GetType(), metaDriver);
- // metaDriver.LoadJSONType();
- }
- catch
- {
- //Always throws SystemNullReferenceException here when you are exporting pneumatic
- //Go to JointDrivderMeta.cs Line 15 to patch
- MetaInfo[metaDriver.GetType()] = metaDriver;
- }
- }
-
-
- ///
- /// Removes the metadata of the given type stored in this joint driver and returns it, or null if no such metadata exists.
- ///
- /// The type of the metadata
- /// Metadata, or null
- public T RemoveInfo() where T : JointDriverMeta
- {
- JointDriverMeta val;
- System.Type type = typeof(T);
- if (MetaInfo.TryGetValue(type, out val))
- {
- MetaInfo.Remove(type);
- return (T) val;
- }
- return null;
- }
-
- ///
- /// Gets the metadata of the given type stored in this joint driver, or null if no such metadata exists.
- ///
- /// The type of the metadata
- /// Metadata, or null
- public T GetInfo() where T : JointDriverMeta
- {
- JointDriverMeta val;
- System.Type type = typeof(T);
- if (MetaInfo.TryGetValue(type, out val))
- {
- return (T) val;
- }
- return null;
- }
-
- ///
- /// Gets the metadata of the given type stored in this joint driver, or null if no such metadata exists.
- ///
- /// The type to get info for
- /// Metadata, or null
- public JointDriverMeta GetInfo(System.Type type)
- {
- JointDriverMeta val;
- if (MetaInfo.TryGetValue(type, out val))
- {
- return val;
- }
- return null;
- }
-
- public void CopyMetaInfo(JointDriver toCopy)
- {
- foreach (KeyValuePair pair in MetaInfo)
- {
- toCopy.MetaInfo.Add(pair.Key, pair.Value);
- }
- }
-
- ///
- /// Gets the possible types of joint drivers for the given skeletal joint.
- ///
- /// Skeletal joint to get allowed types for
- /// Joint driver options
- public static JointDriverType[] GetAllowedDrivers(SkeletalJoint_Base joint)
- {
- switch (joint.GetJointType())
- {
- case SkeletalJointType.ROTATIONAL:
- // Pneumatic and Worm Screw map to angles
- return new JointDriverType[] { // These other options work, but aren't yet supported by the engine
- JointDriverType.MOTOR,
-// JointDriverType.SERVO,
-// JointDriverType.BUMPER_PNEUMATIC,
-// JointDriverType.RELAY_PNEUMATIC,
-// JointDriverType.WORM_SCREW,
-// JointDriverType.DUAL_MOTOR
- };
- case SkeletalJointType.LINEAR:
- return new JointDriverType[]
- {
- JointDriverType.ELEVATOR,
-// JointDriverType.BUMPER_PNEUMATIC,
-// JointDriverType.RELAY_PNEUMATIC,
-// JointDriverType.WORM_SCREW
- };
- case SkeletalJointType.CYLINDRICAL:
- return new JointDriverType[] {
-// JointDriverType.BUMPER_PNEUMATIC,
-// JointDriverType.RELAY_PNEUMATIC,
-// JointDriverType.WORM_SCREW,
- JointDriverType.MOTOR,
-// JointDriverType.SERVO,
-// JointDriverType.DUAL_MOTOR
-
- };
- case SkeletalJointType.PLANAR:
- //Not sure of an FRC part with planar motion. Will add later if needed.
- return new JointDriverType[] { };
- case SkeletalJointType.BALL:
- return new JointDriverType[] { };
- default:
- return new JointDriverType[0];// Not implemented
- }
- }
-
- ///
- /// Sets the port(s) for this driver.
- ///
- /// First port
- /// Option second port
- public void SetPort(int port1, int port2 = -1)
- {
- this.port1 = port1;
- this.port2 = port2;
- }
-
- ///
- /// Sets the limits for this driver.
- ///
- ///
- /// For all linear motion these represent the linear limits on that motion.
- /// For all limited angular motion these represent the angular limits on that motion.
- /// For all continuous angular motion these represent the force limits on that motion.
- ///
- /// Lower limit
- /// Upper limit
- public void SetLimits(float lower, float upper)
- {
- lowerLimit = lower;
- upperLimit = upper;
- }
-
- public override string ToString()
- {
- string info = "";
-
- // Joint type
- string jointType = System.Enum.GetName(typeof(JointDriverType), GetDriveType()).Replace('_', ' ').ToLowerInvariant();
- info += jointType.Substring(0, 1).ToUpper() + jointType.Substring(1); // Capitalize first letter
-
- // Port information
- info += ", Ports: " + type.GetPortType(isCan) + " " + port1 + (type.HasTwoPorts() ? " and " + port2 : "");
-
- return info;
- }
-
- ///
- /// Gets the type of this joint driver.
- ///
- /// Driver type
- public JointDriverType GetDriveType()
- {
- return type;
- }
-
- ///
- /// Gets the motor of this joint driver.
- ///
- /// Motor type
- public MotorType GetMotorType()
- {
- return motor;
- }
-
- ///
- /// Writes the binary representation of this driver to the stream.
- ///
- /// Output stream
- public void WriteBinaryData(System.IO.BinaryWriter writer)
- {//these need to stay in the correct order to read the data properly, and need to stay with the same data type so the byte order stays correct
- writer.Write((byte) ((int) GetDriveType()));
- writer.Write((short)port1);
- writer.Write((short)port2);
- writer.Write((double)InputGear);// write the input gear to the Binary writer
- writer.Write((double)OutputGear);// write the output gear to the Binary writer
- writer.Write(lowerLimit);
- writer.Write(upperLimit);
- writer.Write(isCan);
- writer.Write(MetaInfo.Count); // Extension count
- foreach (JointDriverMeta meta in MetaInfo.Values)
- {
- meta.WriteData(writer);
- }
- }
-
- ///
- /// Reads the binary representation of this driver from the stream.
- ///
- /// Input stream
- public void ReadBinaryData(System.IO.BinaryReader reader)
- {
- type = (JointDriverType) ((int) reader.ReadByte());
- port1 = reader.ReadInt16();
- port2 = reader.ReadInt16();
- lowerLimit = reader.ReadSingle();
- upperLimit = reader.ReadSingle();
- isCan = reader.ReadBoolean();
- int extensions = reader.ReadInt32();
- MetaInfo.Clear();
- for (int i = 0; i < extensions; i++)
- {
- JointDriverMeta meta = JointDriverMeta.ReadDriverMeta(reader);
- AddInfo(meta);
- }
- }
-
- public int CompareTo(JointDriver driver)
- {
- if (driver == null) return 1;
-
- if (ToString() == driver.ToString()) return 0;
- else return 1;
- }
-
-}
\ No newline at end of file
diff --git a/api/Aardvark/Joints/Driver/JointDriverMeta.cs b/api/Aardvark/Joints/Driver/JointDriverMeta.cs
deleted file mode 100644
index 8d9b249542..0000000000
--- a/api/Aardvark/Joints/Driver/JointDriverMeta.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System;
-using System.IO;
-
-///
-/// Base class all joint metadata should inherit from.
-///
-///
-/// If you inherit make sure to add your type to ,
-/// and make sure you have a public constructor that takes no arguments.
-///
-public abstract class JointDriverMeta
-{
- // Constant, but can't be declared so.
- public readonly static Type[] JOINT_DRIVER_META_TYPES = new Type[] { typeof(WheelDriverMeta), typeof(PneumaticDriverMeta), typeof(ElevatorDriverMeta) };
-
- protected abstract void WriteDataInternal(BinaryWriter writer);
- protected abstract void ReadDataInternal(BinaryReader reader);
-
- public int GetID()
- {
- // Find my ID
- int myID = -1;
- for (int i = 0; i < JOINT_DRIVER_META_TYPES.Length; i++)
- {
- if (JOINT_DRIVER_META_TYPES[i].Equals(GetType()))
- {
- myID = i;
- break;
- }
- }
- System.Diagnostics.Debug.Assert(myID >= 0, "Unknown Driver Meta. Did you register your type?");
- return myID;
- }
-
- public void WriteData(BinaryWriter writer)
- {
- writer.Write((byte) GetID());
- WriteDataInternal(writer);
- }
-
- public static JointDriverMeta ReadDriverMeta(BinaryReader reader)
- {
- int type = reader.ReadByte();
- JointDriverMeta meta = (JointDriverMeta) JOINT_DRIVER_META_TYPES[type].GetConstructor(new Type[0]).Invoke(new Object[0]);
- meta.ReadDataInternal(reader);
- return meta;
- }
-}
diff --git a/api/Aardvark/Joints/Driver/JointDriverType.cs b/api/Aardvark/Joints/Driver/JointDriverType.cs
deleted file mode 100644
index 8a12c124d6..0000000000
--- a/api/Aardvark/Joints/Driver/JointDriverType.cs
+++ /dev/null
@@ -1,188 +0,0 @@
-///
-/// Types of joint drivers.
-///
-public enum JointDriverType : byte
-{
- MOTOR = 1,
- SERVO = 2,
- WORM_SCREW = 3,
- BUMPER_PNEUMATIC = 4,
- RELAY_PNEUMATIC = 5,
- DUAL_MOTOR = 6,
- ELEVATOR = 7
-}
-
-///
-/// Types of joint motors
-///
-public enum MotorType : byte
-{
- GENERIC = 0,
- CIM = 1,
- MINI_CIM = 2,
- BAG_MOTOR = 3,
- REDLINE_775_PRO = 4,
- ANDYMARK_9015 = 5,
- BANEBOTS_775_18v = 6,
- BANEBOTS_775_12v = 7,
- BANEBOTS_550_12v = 8,
- ANDYMARK_775_125 = 9,
- SNOW_BLOWER = 10,
- NIDEC_BLDC = 11,
- THROTTLE_MOTOR = 12,
- WINDOW_MOTOR = 13,
- NEVEREST = 14,
- TETRIX_MOTOR = 15,
- MODERN_ROBOTICS_MATRIX = 16,
- REV_ROBOTICS_HD_HEX_20_TO_1 = 17,
- REV_ROBOTICS_HD_HEX_40_TO_1 = 18,
- REV_ROBOTICS_CORE_HEX = 19,
- VEX_V5_Smart_Motor_600_RPM = 20,
- VEX_V5_Smart_Motor_200_RPM = 21,
- VEX_V5_Smart_Motor_100_RPM = 22,
- VEX_393_NORMAL_SPEED = 23,
- VEX_393_HIGH_SPEED = 24,
- VEX_393_TURBO_GEAR_SET = 25
-}
-
-public static class JointDriverTypeExtensions
-{
- ///
- /// Checks if the given driver type requires two ports.
- ///
- /// Driver type
- /// True is the given type requires two ports
- public static bool HasTwoPorts(this JointDriverType type)
- {
- return type == JointDriverType.BUMPER_PNEUMATIC || type == JointDriverType.DUAL_MOTOR;
- }
-
- ///
- /// Gets the string representation of the port for the given driver type.
- ///
- /// Driver type
- /// Name of port type
- public static string GetPortType(this JointDriverType type)
- {
- switch (type)
- {
- case JointDriverType.MOTOR:
- case JointDriverType.SERVO:
- case JointDriverType.DUAL_MOTOR:
- case JointDriverType.WORM_SCREW:
- case JointDriverType.ELEVATOR:
- return "PWM";
- case JointDriverType.BUMPER_PNEUMATIC:
- return "Solenoid";
- case JointDriverType.RELAY_PNEUMATIC:
- return "Relay";
- default:
- return "Unknown";
- }
- }
-
- ///
- /// Gets the string representation of the port for the given driver type.
- ///
- /// Driver type
- /// Name of port type
- public static string GetPortType(this JointDriverType type, bool isCan)
- {
- switch (type)
- {
- case JointDriverType.MOTOR:
- case JointDriverType.SERVO:
- case JointDriverType.DUAL_MOTOR:
- case JointDriverType.WORM_SCREW:
- case JointDriverType.ELEVATOR:
- return isCan ? "CAN" : "PWM";
- case JointDriverType.BUMPER_PNEUMATIC:
- return "Solenoid";
- case JointDriverType.RELAY_PNEUMATIC:
- return "Relay";
- default:
- return "Unknown";
- }
- }
-
- ///
- /// Checks if the given driver type is a motor.
- ///
- /// Driver type
- /// Boolean
- public static bool IsMotor(this JointDriverType type)
- {
- switch (type)
- {
- case JointDriverType.MOTOR:
- case JointDriverType.DUAL_MOTOR:
- return true;
- default:
- return false;
- }
- }
-
- public static bool IsElevator(this JointDriverType type)
- {
- return type == JointDriverType.ELEVATOR;
- }
- ///
- /// Checks if the given driver type is pneumatic.
- ///
- /// Driver type
- /// Boolean
- public static bool IsPneumatic(this JointDriverType type)
- {
- switch (type)
- {
- case JointDriverType.BUMPER_PNEUMATIC:
- case JointDriverType.RELAY_PNEUMATIC:
- return true;
- default:
- return false;
- }
- }
- ///
- /// Checks if the given driver type is a worm screw.
- ///
- /// Driver type
- /// Boolean
- public static bool IsWormScrew(this JointDriverType type)
- {
- switch (type)
- {
- case JointDriverType.WORM_SCREW:
- return true;
- default:
- return false;
- }
- }
-
- ///
- /// Gets the maximum port number for the given driver type.
- ///
- /// Driver type
- /// Max port number
- public static int GetPortMax(this JointDriverType type, bool isCan)
- {
-
- switch (type)
- {
- case JointDriverType.MOTOR:
-
- case JointDriverType.DUAL_MOTOR:
- case JointDriverType.SERVO:
- case JointDriverType.WORM_SCREW:
- case JointDriverType.ELEVATOR:
- return isCan ? 63 : 19;
- case JointDriverType.BUMPER_PNEUMATIC:
- return 8; // Bumper
- case JointDriverType.RELAY_PNEUMATIC:
- return 8; // Relay
- default:
- return -1;
- }
- }
-
-
-}
\ No newline at end of file
diff --git a/api/Aardvark/Joints/Driver/PneumaticDriverMeta.cs b/api/Aardvark/Joints/Driver/PneumaticDriverMeta.cs
deleted file mode 100644
index 6fb2f4cf46..0000000000
--- a/api/Aardvark/Joints/Driver/PneumaticDriverMeta.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using System.IO;
-
-public enum PneumaticPressure : byte
-{
- HIGH = 0,
- MEDIUM = 1,
- LOW = 2
-}
-
-
-///
-/// Stores the variables concerning a pneumatic cylinder.
-///
-public class PneumaticDriverMeta : JointDriverMeta
-{
- public float widthMM;
- public float pressurePSI;
-
- #region WHERE IS YOUR _TODD_ NOW
- public double width;
-
-
- public PneumaticPressure pressureEnum
- {
- get
- {
- if (pressurePSI == 20)
- return PneumaticPressure.LOW;
- if (pressurePSI == 40)
- return PneumaticPressure.MEDIUM;
- return PneumaticPressure.HIGH;
- }
- set
- {
- switch (value)
- {
- case PneumaticPressure.MEDIUM:
- pressurePSI = 40;
- break;
- case PneumaticPressure.LOW:
- pressurePSI = 20;
- break;
- default:
- case PneumaticPressure.HIGH:
- pressurePSI = 60;
- break;
- }
- }
- }
- #endregion
-
-
- protected override void WriteDataInternal(BinaryWriter writer)
- {
- writer.Write(widthMM);
- writer.Write(pressurePSI);
- }
- protected override void ReadDataInternal(BinaryReader reader)
- {
- widthMM = reader.ReadSingle();
- pressurePSI = reader.ReadSingle();
- }
-}
\ No newline at end of file
diff --git a/api/Aardvark/Joints/Driver/WheelDriverMeta.cs b/api/Aardvark/Joints/Driver/WheelDriverMeta.cs
deleted file mode 100644
index cbab6754b0..0000000000
--- a/api/Aardvark/Joints/Driver/WheelDriverMeta.cs
+++ /dev/null
@@ -1,181 +0,0 @@
-using System.IO;
-
-public enum WheelType : byte
-{
- NOT_A_WHEEL = 0,
- NORMAL = 1, //As in, not omni or mecanum.
- OMNI = 2,
- MECANUM = 3
-}
-
-public enum FrictionLevel : byte
-{
- HIGH = 0,
- MEDIUM = 1,
- LOW = 2
-}
-
-///
-/// Stores the variables concerning a wheel, such as its position (which may be removed later) and radius.
-///
-public class WheelDriverMeta : JointDriverMeta
-{
- public float radius;
- public WheelType type;
- public float width;
- public BXDVector3 center;
-
- public float forwardExtremeSlip;
- public float forwardExtremeValue;
- public float forwardAsympSlip;
- public float forwardAsympValue;
- public float sideExtremeSlip;
- public float sideExtremeValue;
- public float sideAsympSlip;
- public float sideAsympValue;
- public bool isDriveWheel;
- public WheelDriverMeta()
- {
- center = new BXDVector3();
-
- }
-
- //Writes the position of the wheel to the file.
- protected override void WriteDataInternal(BinaryWriter writer)
- {
- writer.Write((byte) ((int) type));
- writer.Write(radius);
- writer.Write(width);
-
- writer.Write(center);
-
- writer.Write(forwardAsympSlip);
- writer.Write(forwardAsympValue);
- writer.Write(forwardExtremeSlip);
- writer.Write(forwardExtremeValue);
- writer.Write(sideAsympSlip);
- writer.Write(sideAsympValue);
- writer.Write(sideExtremeSlip);
- writer.Write(sideExtremeValue);
- writer.Write(isDriveWheel);
- }
-
- //Reads the position of the wheel from the file.
- protected override void ReadDataInternal(BinaryReader reader)
- {
- type = (WheelType) reader.ReadByte();
- radius = reader.ReadSingle();
- width = reader.ReadSingle();
-
- center = reader.ReadRWObject();
-
- forwardAsympSlip = reader.ReadSingle();
- forwardAsympValue = reader.ReadSingle();
- forwardExtremeSlip = reader.ReadSingle();
- forwardExtremeValue = reader.ReadSingle();
- sideAsympSlip = reader.ReadSingle();
- sideAsympValue = reader.ReadSingle();
- sideExtremeSlip = reader.ReadSingle();
- sideExtremeValue = reader.ReadSingle();
- isDriveWheel = reader.ReadBoolean();
- }
-
- public void SetFrictionLevel(FrictionLevel level)
- {
- switch (level)
- {
- case FrictionLevel.HIGH:
- forwardExtremeSlip = 1; //Speed of max static friction force.
- forwardExtremeValue = 10; //Force of max static friction force.
- forwardAsympSlip = 1.5f; //Speed of leveled off kinetic friction force.
- forwardAsympValue = 8; //Force of leveld off kinetic friction force.
-
- if (type == WheelType.OMNI) //Set to relatively low friction, as omni wheels can move sidways.
- {
- sideExtremeSlip = 1; //Same as above, but orthogonal to the movement of the wheel.
- sideExtremeValue = .01f;
- sideAsympSlip = 1.5f;
- sideAsympValue = .005f;
- }
- else
- {
- sideExtremeSlip = 1;
- sideExtremeValue = 10;
- sideAsympSlip = 1.5f;
- sideAsympValue = 8;
- }
- break;
- case FrictionLevel.MEDIUM:
- forwardExtremeSlip = 1f;
- forwardExtremeValue = 7;
- forwardAsympSlip = 1.5f;
- forwardAsympValue = 5;
-
- if (type == WheelType.OMNI)
- {
- sideExtremeSlip = 1;
- sideExtremeValue = .01f;
- sideAsympSlip = 1.5f;
- sideAsympValue = .005f;
- }
- else
- {
- sideExtremeSlip = 1;
- sideExtremeValue = 7;
- sideAsympSlip = 1.5f;
- sideAsympValue = 5;
- }
- break;
- case FrictionLevel.LOW:
- forwardExtremeSlip = 1;
- forwardExtremeValue = 5;
- forwardAsympSlip = 1.5f;
- forwardAsympValue = 3;
-
- if (type == WheelType.OMNI)
- {
- sideExtremeSlip = 1;
- sideExtremeValue = .01f;
- sideAsympSlip = 1.5f;
- sideAsympValue = .005f;
- }
- else
- {
- sideExtremeSlip = 1;
- sideExtremeValue = 5;
- sideAsympSlip = 1.5f;
- sideAsympValue = 3;
- }
- break;
- }
- }
-
- public FrictionLevel GetFrictionLevel()
- {
- if (forwardExtremeValue >= 10)
- return FrictionLevel.HIGH;
- else if (forwardExtremeValue >= 7)
- return FrictionLevel.MEDIUM;
- else
- return FrictionLevel.LOW;
- }
-
- public string GetTypeString()
- {
- switch (type)
- {
- case WheelType.OMNI:
- return "Omni Wheel";
- case WheelType.MECANUM:
- return "Mecanum";
- default:
- return "Normal";
- }
- }
-
- public override string ToString()
- {
- return "WheelMeta[rad=" + radius + "]";
- }
-
-}
\ No newline at end of file
diff --git a/api/Aardvark/Joints/LinearDOF.cs b/api/Aardvark/Joints/LinearDOF.cs
deleted file mode 100644
index d0e1caf8f8..0000000000
--- a/api/Aardvark/Joints/LinearDOF.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-///
-/// Contains information about a linear degree of freedom.
-///
-public interface LinearDOF
-{
- float currentPosition
- {
- get;
- }
- float upperLimit
- {
- get;
- set;
- }
- float lowerLimit
- {
- get;
- set;
- }
-
- BXDVector3 translationalAxis
- {
- get;
- set;
- }
- BXDVector3 basePoint
- {
- get;
- set;
- }
-}
-
-public static class LinearDOFExtensions
-{
- public static bool hasUpperLinearLimit(this LinearDOF dof)
- {
- return !float.IsPositiveInfinity(dof.upperLimit);
- }
-
- public static bool hasLowerLinearLimit(this LinearDOF dof)
- {
- return !float.IsNegativeInfinity(dof.lowerLimit);
- }
-}
\ No newline at end of file
diff --git a/api/Aardvark/Joints/LinearJoint_Base.cs b/api/Aardvark/Joints/LinearJoint_Base.cs
deleted file mode 100644
index a82374998e..0000000000
--- a/api/Aardvark/Joints/LinearJoint_Base.cs
+++ /dev/null
@@ -1,154 +0,0 @@
-
-using System.Collections.Generic;
-public class LinearJoint_Base : SkeletalJoint_Base
-{
- #region LinearDOF_Impl
- private class LinearDOF_Impl : LinearDOF
- {
- private readonly LinearJoint_Base ljb;
- public LinearDOF_Impl(LinearJoint_Base ljb)
- {
- this.ljb = ljb;
- }
-
- public float currentPosition
- {
- get
- {
- return ljb.currentLinearPosition;
- }
- }
-
- public float upperLimit
- {
- get
- {
- ljb.EnforceOrder();
- return ljb.hasUpperLimit ? ljb.linearLimitHigh : float.PositiveInfinity;
- }
- set
- {
- ljb.linearLimitHigh = value;
- ljb.hasUpperLimit = !float.IsInfinity(ljb.linearLimitHigh);
- }
- }
-
- public float lowerLimit
- {
- get
- {
- ljb.EnforceOrder();
- return ljb.hasLowerLimit ? ljb.linearLimitLow : float.NegativeInfinity;
- }
- set
- {
- ljb.linearLimitLow = value;
- ljb.hasLowerLimit = !float.IsInfinity(ljb.linearLimitLow);
- }
- }
-
- public BXDVector3 translationalAxis
- {
- get
- {
- return ljb.axis;
- }
- set
- {
- ljb.axis = value;
- }
- }
-
- public BXDVector3 basePoint
- {
- get
- {
- return ljb.basePoint;
- }
- set
- {
- ljb.basePoint = value;
- }
- }
- }
- #endregion
-
- public BXDVector3 axis;
- public BXDVector3 basePoint;
-
- public float currentLinearPosition;
- public bool hasUpperLimit, hasLowerLimit;
- public float linearLimitLow, linearLimitHigh;
-
- private readonly LinearDOF[] linearDOF;
-
- public LinearJoint_Base() {
- linearDOF = new LinearDOF[]{ new LinearDOF_Impl(this) };
- }
-
- public override SkeletalJointType GetJointType()
- {
- return SkeletalJointType.LINEAR;
- }
-
- protected override void WriteBinaryJointInternal(System.IO.BinaryWriter writer)
- {
- EnforceOrder();
-
- writer.Write(basePoint);
- writer.Write(axis);
-
- writer.Write((byte) ((hasLowerLimit ? 1 : 0) | (hasUpperLimit ? 2 : 0)));
- if (hasLowerLimit)
- {
- writer.Write(linearLimitLow);
- }
- if (hasUpperLimit)
- {
- writer.Write(linearLimitHigh);
- }
-
- writer.Write(currentLinearPosition);
- }
-
- protected override void ReadBinaryJointInternal(System.IO.BinaryReader reader)
- {
- basePoint = reader.ReadRWObject();
- axis = reader.ReadRWObject();
-
- byte limitFlags = reader.ReadByte();
- hasLowerLimit = (limitFlags & 1) == 1;
- hasUpperLimit = (limitFlags & 2) == 2;
- if (hasLowerLimit)
- {
- linearLimitLow = reader.ReadSingle();
- }
- if (hasUpperLimit)
- {
- linearLimitHigh = reader.ReadSingle();
- }
- currentLinearPosition = reader.ReadSingle();
-
- EnforceOrder();
- }
-
- public void EnforceOrder()
- {
- if (hasLowerLimit && hasUpperLimit && linearLimitLow > linearLimitHigh)
- {
- float temp = linearLimitHigh;
- linearLimitHigh = linearLimitLow;
- linearLimitLow = temp;
- }
- }
-
- public override IEnumerable GetAngularDOF()
- {
- return new AngularDOF[0];
- }
-
- public override IEnumerable GetLinearDOF()
- {
- return linearDOF;
- }
-}
\ No newline at end of file
diff --git a/api/Aardvark/Joints/PlanarJoint_Base.cs b/api/Aardvark/Joints/PlanarJoint_Base.cs
deleted file mode 100644
index 895c45e75c..0000000000
--- a/api/Aardvark/Joints/PlanarJoint_Base.cs
+++ /dev/null
@@ -1,189 +0,0 @@
-using System.Collections.Generic;
-using System;
-
-///
-/// Contains a joint with two degrees of linear freedom and one degree of rotational freedom.
-///
-public class PlanarJoint_Base : SkeletalJoint_Base
-{
- private static readonly BXDVector3 PLANAR_JOINT_BASIS = new BXDVector3(1.12824E-7, 0.418275, 0.90832);
-
- #region AngularDOF_Impl
- private class AngularDOF_Impl : AngularDOF
- {
- private readonly PlanarJoint_Base pjb;
- public AngularDOF_Impl(PlanarJoint_Base pjb)
- {
- this.pjb = pjb;
- }
-
- public float currentPosition
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public float upperLimit
- {
- get
- {
- return float.PositiveInfinity;
- }
- set
- {
- throw new NotImplementedException();
- }
- }
-
- public float lowerLimit
- {
- get
- {
- return float.NegativeInfinity;
- }
- set
- {
- throw new NotImplementedException();
- }
- }
-
- public BXDVector3 rotationAxis
- {
- get
- {
- return pjb.normal;
- }
- set
- {
- pjb.normal = value;
- }
- }
-
- public BXDVector3 basePoint
- {
- get
- {
- return pjb.basePoint;
- }
- set
- {
- pjb.basePoint = value;
- }
- }
- }
- #endregion
- #region LinearDOF_Impl
- private class LinearDOF_Impl : LinearDOF
- {
- private readonly PlanarJoint_Base pjb;
- private readonly int axis;
- public LinearDOF_Impl(PlanarJoint_Base pjb, int axis)
- {
- this.pjb = pjb;
- this.axis = axis;
- }
-
- public float currentPosition
- {
- get
- {
- throw new NotImplementedException();
- }
- }
-
- public float upperLimit
- {
- get
- {
- throw new NotImplementedException();
- }
- set
- {
- throw new NotImplementedException();
- }
- }
-
- public float lowerLimit
- {
- get
- {
- throw new NotImplementedException();
- }
- set
- {
- throw new NotImplementedException();
- }
- }
-
- public BXDVector3 translationalAxis
- {
- get
- {
- BXDVector3 rot = BXDVector3.CrossProduct(PlanarJoint_Base.PLANAR_JOINT_BASIS, pjb.normal);
- if (axis == 1)
- {
- rot = BXDVector3.CrossProduct(rot, pjb.normal);
- }
- return rot;
- }
- set
- {
- throw new NotImplementedException();
- }
- }
-
- public BXDVector3 basePoint
- {
- get
- {
- return pjb.basePoint;
- }
- set
- {
- pjb.basePoint = value;
- }
- }
- }
- #endregion
-
- public BXDVector3 normal;
- public BXDVector3 basePoint;
-
- private readonly AngularDOF[] angularDOF;
- private readonly LinearDOF[] linearDOF;
-
- public PlanarJoint_Base()
- {
- angularDOF = new AngularDOF[] { new AngularDOF_Impl(this) };
- linearDOF = new LinearDOF[] { new LinearDOF_Impl(this, 0), new LinearDOF_Impl(this, 1) };
- }
-
- public override SkeletalJointType GetJointType()
- {
- return SkeletalJointType.PLANAR;
- }
-
- protected override void WriteBinaryJointInternal(System.IO.BinaryWriter writer)
- {
- writer.Write(normal);
- writer.Write(basePoint);
- }
-
- protected override void ReadBinaryJointInternal(System.IO.BinaryReader reader)
- {
- normal = reader.ReadRWObject();
- basePoint = reader.ReadRWObject();
- }
-
- public override IEnumerable GetAngularDOF()
- {
- return angularDOF;
- }
-
- public override IEnumerable GetLinearDOF()
- {
- return linearDOF;
- }
-}
diff --git a/api/Aardvark/Joints/RotationalJoint_Base.cs b/api/Aardvark/Joints/RotationalJoint_Base.cs
deleted file mode 100644
index 7750b1f144..0000000000
--- a/api/Aardvark/Joints/RotationalJoint_Base.cs
+++ /dev/null
@@ -1,149 +0,0 @@
-
-using System.Collections.Generic;
-using Newtonsoft.Json;
-
-
-public class RotationalJoint_Base : SkeletalJoint_Base
-{
- #region AngularDOF_Impl
- private class AngularDOF_Impl : AngularDOF
- {
- private readonly RotationalJoint_Base rjb;
- public AngularDOF_Impl(RotationalJoint_Base rjb)
- {
- this.rjb = rjb;
- }
- public float currentPosition
- {
- get
- {
- return rjb.currentAngularPosition;
- }
- }
-
- public float upperLimit
- {
- get
- {
- rjb.EnforceOrder();
- return rjb.hasAngularLimit ? rjb.angularLimitHigh : float.PositiveInfinity;
- }
- set
- {
- rjb.angularLimitHigh = value;
- rjb.hasAngularLimit = !float.IsInfinity(rjb.angularLimitLow) && !float.IsInfinity(rjb.angularLimitHigh);
- }
- }
-
- public float lowerLimit
- {
- get
- {
- rjb.EnforceOrder();
- return rjb.hasAngularLimit ? rjb.angularLimitLow : float.NegativeInfinity;
- }
- set
- {
- rjb.angularLimitLow = value;
- rjb.hasAngularLimit = !float.IsInfinity(rjb.angularLimitLow) && !float.IsInfinity(rjb.angularLimitHigh);
- }
- }
-
- public BXDVector3 rotationAxis
- {
- get
- {
- return rjb.axis;
- }
- set
- {
- rjb.axis = value;
- }
- }
-
- public BXDVector3 basePoint
- {
- get
- {
- return rjb.basePoint;
- }
- set
- {
- rjb.basePoint = value;
- }
- }
- }
- #endregion
-
- public BXDVector3 axis;
- public BXDVector3 basePoint;
-
- public float currentAngularPosition;
- public bool hasAngularLimit;
- public float angularLimitLow;
- public float angularLimitHigh;
-
- private readonly AngularDOF[] angularDOF;
-
- public RotationalJoint_Base()
- {
- angularDOF = new AngularDOF[] { new AngularDOF_Impl(this) };
- }
-
- public override SkeletalJointType GetJointType()
- {
- return SkeletalJointType.ROTATIONAL;
- }
-
- protected override void WriteBinaryJointInternal(System.IO.BinaryWriter writer)
- {
- EnforceOrder();
- writer.Write(basePoint);
- writer.Write(axis);
-
- writer.Write((byte)((hasAngularLimit ? 1 : 0)));
- if (hasAngularLimit)
- {
- writer.Write(angularLimitLow);
- writer.Write(angularLimitHigh);
- }
-
- writer.Write(currentAngularPosition);
- }
-
- protected override void ReadBinaryJointInternal(System.IO.BinaryReader reader)
- {
- basePoint = reader.ReadRWObject();
- axis = reader.ReadRWObject();
-
- hasAngularLimit = (reader.ReadByte() & 1) == 1;
- if (hasAngularLimit)
- {
- angularLimitLow = reader.ReadSingle();
- angularLimitHigh = reader.ReadSingle();
- }
-
- currentAngularPosition = reader.ReadSingle();
- EnforceOrder();
- }
-
- public void EnforceOrder()
- {
- if (hasAngularLimit && angularLimitLow > angularLimitHigh)
- {
- float temp = angularLimitHigh;
- angularLimitHigh = angularLimitLow;
- angularLimitLow = temp;
- }
- }
-
- public override IEnumerable GetAngularDOF()
- {
- return angularDOF;
- }
-
- public override IEnumerable GetLinearDOF()
- {
- return new LinearDOF[0];
- }
-}
\ No newline at end of file
diff --git a/api/Aardvark/Joints/Sensors/RobotSensor.cs b/api/Aardvark/Joints/Sensors/RobotSensor.cs
deleted file mode 100644
index 54b8e8ada1..0000000000
--- a/api/Aardvark/Joints/Sensors/RobotSensor.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-using System.IO;
-
-public enum RobotSensorType : byte
-{
- ENCODER = 0,
- LIMIT = 1,
- POTENTIOMETER = 2,
- LIMIT_HALL = 3,
- ACCELEROMETER = 4,
- MAGNETOMETER = 5,
- GYRO = 6
-}
-public enum SensorConnectionType : byte
-{
- DIO = 0,
- ANALOG = 1,
- SPI = 2,
- I2C = 3,
-}
-
-public class RobotSensor : BinaryRWObject
-{
- public float portA;
- public float portB;
- public RobotSensorType type;
- public SensorConnectionType conTypePortA;
- public SensorConnectionType conTypePortB;
- public double conversionFactor;
- public RobotSensor()
- {
- }
-
- public RobotSensor(RobotSensorType type)
- {
- this.type = type;
-
- switch (type)
- {
- case RobotSensorType.ENCODER:
- conTypePortA = SensorConnectionType.DIO;
- conTypePortB = SensorConnectionType.DIO;
- break;
- case RobotSensorType.LIMIT:
- conTypePortA = SensorConnectionType.DIO;
- conTypePortB = SensorConnectionType.DIO;
- break;
- case RobotSensorType.POTENTIOMETER:
- conTypePortA = SensorConnectionType.ANALOG;
- conTypePortB = SensorConnectionType.ANALOG;
- break;
- }
- }
-
- public static RobotSensorType[] GetAllowedSensors(SkeletalJoint_Base joint)
- {
- switch (joint.GetJointType())
- {
- case SkeletalJointType.ROTATIONAL:
- return new RobotSensorType[] {RobotSensorType.ENCODER/*, RobotSensorType.POTENTIOMETER, RobotSensorType.LIMIT*/};
- case SkeletalJointType.LINEAR:
- return new RobotSensorType[] {RobotSensorType.ENCODER };
- case SkeletalJointType.CYLINDRICAL:
- return new RobotSensorType[] {RobotSensorType.ENCODER/*, RobotSensorType.POTENTIOMETER, RobotSensorType.LIMIT*/};
- case SkeletalJointType.PLANAR:
- return new RobotSensorType[] { };
- case SkeletalJointType.BALL:
- return new RobotSensorType[] { };
- default:
- return new RobotSensorType[0];// Not implemented
- }
- }
-
- public void WriteBinaryData(BinaryWriter writer)
- {
- writer.Write((byte) type);
- writer.Write(portA);
- writer.Write((byte)conTypePortA);
- writer.Write(portB);
- writer.Write((byte)conTypePortB);
- writer.Write(conversionFactor);
- }
-
- public void ReadBinaryData(BinaryReader reader)
- {
- type = (RobotSensorType) reader.ReadByte();
- portA = reader.ReadInt16();
- portB = reader.ReadInt16();
- conversionFactor = reader.ReadDouble();
- }
-
- public static RobotSensor ReadSensorFully(BinaryReader reader)
- {
- RobotSensor sensor = new RobotSensor(RobotSensorType.LIMIT);
- sensor.ReadBinaryData(reader);
- return sensor;
- }
-
- ///
- /// Compares two sensors, returns true if all fields are identical.
- ///
- ///
- public bool Equals(RobotSensor otherSensor)
- {
- return portA == otherSensor.portA && portB == otherSensor.portB && conversionFactor == otherSensor.conversionFactor; // Other fields are not important for equivalancy
- }
-}
diff --git a/api/Aardvark/Joints/SkeletalJoint_Base.cs b/api/Aardvark/Joints/SkeletalJoint_Base.cs
deleted file mode 100644
index 00c146d791..0000000000
--- a/api/Aardvark/Joints/SkeletalJoint_Base.cs
+++ /dev/null
@@ -1,177 +0,0 @@
-using System;
-using System.Collections.Generic;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Converters;
-///
-/// Possible types of skeletal joints.
-///
-///
-[JsonConverter(typeof(StringEnumConverter))]
-public enum SkeletalJointType : byte
-{
- DEFAULT = 0,
- ROTATIONAL = 1,
- LINEAR = 2,
- PLANAR = 3,
- CYLINDRICAL = 4,
- BALL = 5
-}
-
-///
-/// Represents a moving joint between two nodes.
-///
-///
-
-public abstract class SkeletalJoint_Base
-{
- public SkeletalJointType typeSave;
- ///
- /// Generic delegate for creating skeletal joints from a joint type.
- ///
- public delegate SkeletalJoint_Base SkeletalJointFactory(SkeletalJointType type);
-
- ///
- /// Factory object used to create skeletal joint objects when reading skeletons from a file.
- ///
- public static SkeletalJointFactory JOINT_FACTORY = delegate(SkeletalJointType type)
- {
- switch (type)
- {
- case SkeletalJointType.ROTATIONAL:
- return new RotationalJoint_Base();
- case SkeletalJointType.LINEAR:
- return new LinearJoint_Base();
- case SkeletalJointType.CYLINDRICAL:
- return new CylindricalJoint_Base();
- case SkeletalJointType.PLANAR:
- return new PlanarJoint_Base();
- case SkeletalJointType.BALL:
- return new BallJoint_Base();
- default:
- return null;
- }
- };
-
- ///
- /// The joint driver for this joint. This can be null.
- ///
- public JointDriver cDriver;
-
- public double weight = 10;
-
- ///
- /// The sensors that read information from this joint.
- ///
- public List attachedSensors = new List();
-
- ///
- /// The type of this joint.
- ///
- /// The joint type
- public abstract SkeletalJointType GetJointType();
-
- ///
- /// Gets all the angular degrees of freedom for this joint.
- ///
- /// The angular degrees of freedom
- public abstract IEnumerable GetAngularDOF();
- ///
- /// Gets all the linear degrees of freedom for this joint.
- ///
- /// The linear degrees of freedom
- public abstract IEnumerable GetLinearDOF();
-
- ///
- /// Writes the backing information and ID for this joint to the output stream.
- ///
- /// Output stream
- public void WriteBinaryJoint(System.IO.BinaryWriter writer)
- {
- writer.Write((byte) ((int) GetJointType()));
- writer.Write((double)((double)weight));
- WriteBinaryJointInternal(writer);
-
- writer.Write(cDriver != null);
- if (cDriver!=null){
- cDriver.WriteBinaryData(writer);
- }
- writer.Write(attachedSensors.Count);
- for (int i = 0; i < attachedSensors.Count; i++)
- {
- attachedSensors[i].WriteBinaryData(writer);
- }
- }
- protected abstract void WriteBinaryJointInternal(System.IO.BinaryWriter writer);
-
- ///
- /// Reads the backing information for this joint from the input stream.
- ///
- /// Input stream
- public void ReadBinaryJoint(System.IO.BinaryReader reader)
- {
- weight = reader.ReadDouble();
- // ID is already read
- ReadBinaryJointInternal(reader);
-
- if (reader.ReadBoolean())
- {
- cDriver = new JointDriver(JointDriverType.MOTOR);
- cDriver.ReadBinaryData(reader);
- }
- else
- {
- cDriver = null;
- }
- int sensorCount = reader.ReadInt32();
- attachedSensors = new List(sensorCount);
- for (int i = 0; i < sensorCount; i++)
- {
- attachedSensors.Add(RobotSensor.ReadSensorFully(reader));
- }
- }
- protected abstract void ReadBinaryJointInternal(System.IO.BinaryReader reader);
-
- ///
- /// Identifies the type of a joint, creates an instance, and reads that joint from the given input stream.
- ///
- /// Input stream
- /// The created joint
- public static SkeletalJoint_Base ReadJointFully(System.IO.BinaryReader reader)
- {
- SkeletalJointType type = (SkeletalJointType)((int)reader.ReadByte());
- SkeletalJoint_Base joint = JOINT_FACTORY(type);
- joint.ReadBinaryJoint(reader);
- return joint;
- }
-
- protected virtual string ToString_Internal()
- {
- return Enum.GetName(typeof(SkeletalJointType), GetJointType());
- }
-
- public override string ToString()
- {
- string info = ToString_Internal();
- if (cDriver != null)
- {
- info += "\n Driver: " + cDriver.ToString().Replace("\n", "\n ");
- }
- return info;
- }
-
- public void WriteBinaryData(System.IO.BinaryWriter writer)
- {
- WriteBinaryJoint(writer);
- }
-
- public void ReadBinaryData(System.IO.BinaryReader reader)
- {
- throw new NotImplementedException("Don't read a joint directly!");
- }
-
- public void ClearConfiguration()
- {
- cDriver = null;
- attachedSensors = new List();
- }
-}
diff --git a/api/Aardvark/Math/BXDBox.cs b/api/Aardvark/Math/BXDBox.cs
deleted file mode 100644
index edd99ab6db..0000000000
--- a/api/Aardvark/Math/BXDBox.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-public class BXDBox : System.IComparable
-{
- BXDVector3 minPoint;
- BXDVector3 maxPoint;
-
- public BXDBox(double passMinX, double passMinY, double passMinZ,
- double passMaxX, double passMaxY, double passMaxZ)
- {
- minPoint = new BXDVector3(passMinX, passMinY, passMinZ);
- maxPoint = new BXDVector3(passMaxX, passMaxY, passMaxZ);
- }
-
- public BXDBox(BXDVector3 passMinPoint, BXDVector3 passMaxPoint)
- {
- minPoint = passMinPoint;
- maxPoint = passMaxPoint;
- }
-
- public float GetPossibleRadius()
- {
- return minPoint.Copy().Subtract(maxPoint).Magnitude();
- }
-
- public int CompareTo(BXDBox other)
- {
- float thisRadius = GetPossibleRadius();
- float otherRadius = other.GetPossibleRadius();
-
- if (thisRadius > otherRadius)
- {
- return 1;
- }
- else if (thisRadius < otherRadius)
- {
- return -1;
- }
- else
- {
- return 0;
- }
- }
-}
-
diff --git a/api/Aardvark/Math/BXDQuaternion.cs b/api/Aardvark/Math/BXDQuaternion.cs
deleted file mode 100644
index 500659a0ec..0000000000
--- a/api/Aardvark/Math/BXDQuaternion.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-public class BXDQuaternion
-{
- ///
- /// The X value of the BXDQuaternion.
- ///
- public float X;
-
- ///
- /// The Y value of the BXDQuaternion.
- ///
- public float Y;
-
- ///
- /// The Z value of the BXDQuaternion.
- ///
- public float Z;
-
- ///
- /// The W value of the BXDQuaternion.
- ///
- public float W;
-
- ///
- /// Initializes a new instance of the BXDQuaternion class with an identity value.
- ///
- public BXDQuaternion()
- : this(0f, 0f, 0f, 0f)
- {
- }
-
- ///
- /// Initializes a new instance of the BXDQuaternion class with the values given.
- ///
- ///
- ///
- ///
- ///
- public BXDQuaternion(float x, float y, float z, float w)
- {
- X = x;
- Y = y;
- Z = z;
- W = w;
- }
-
- ///
- /// Returns a string containing labeled x, y, z, and w values.
- ///
- ///
- public override string ToString()
- {
- return "(X: " + X + ", Y: " + Y + ", Z: " + Z + ", W: " + W + ")";
- }
-}
\ No newline at end of file
diff --git a/api/Aardvark/Math/BXDVector3.cs b/api/Aardvark/Math/BXDVector3.cs
deleted file mode 100644
index 95ca7b68c4..0000000000
--- a/api/Aardvark/Math/BXDVector3.cs
+++ /dev/null
@@ -1,170 +0,0 @@
-using System;
-
-public class BXDVector3 : BinaryRWObject
-{
- ///
- /// If two floating point values have an absolute difference less than this they are considered the same.
- ///
- private const float EPSILON = 1.0E-6F;
-
- ///
- /// The x, y, and z values for the BXDVector3.
- ///
- public float x, y, z;
-
- ///
- /// Initializes a new instance of the BXDVector3 class.
- ///
- public BXDVector3()
- {
- }
-
- ///
- /// Initializes a new instance of the BXDVector3 class from the given x, y, and z values.
- ///
- ///
- ///
- ///
- public BXDVector3(double x, double y, double z)
- {
- this.x = (float) x;
- this.y = (float) y;
- this.z = (float) z;
- }
-
- ///
- /// Initializes a new instance of the BXDVector3 class from the given x, y, and z values.
- ///
- ///
- ///
- ///
- public BXDVector3(float x, float y, float z)
- {
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- ///
- /// Converts the x, y, and z values to a string.
- ///
- ///
- public override String ToString()
- {
- return "[" + x + "," + y + "," + z + "]";
- }
-
- ///
- /// Multiplies this vector by the given scalar and returns this object (for method chaining)
- ///
- /// The scalar to multiply by
- /// This vector.
- public BXDVector3 Multiply(float f)
- {
- x *= f;
- y *= f;
- z *= f;
- return this;
- }
-
- ///
- /// Adds the given vector to this vector and returns this object. (For method chaining)
- ///
- /// The vector to add
- /// This vector.
- public BXDVector3 Add(BXDVector3 f)
- {
- x += f.x;
- y += f.y;
- z += f.z;
- return this;
- }
-
- ///
- /// Subtracts the given vector from this vector and returns this object. (For method chaining)
- ///
- /// The vector to subtract
- /// This vector.
- public BXDVector3 Subtract(BXDVector3 f)
- {
- x -= f.x;
- y -= f.y;
- z -= f.z;
- return this;
- }
-
- ///
- /// Gets the magnitude of this vector.
- ///
- /// The magnitude of this vector
- public float Magnitude()
- {
- return (float) Math.Sqrt(x * x + y * y + z * z);
- }
-
- ///
- /// Computes the cross product of two vectors. (lhs x rhs)
- ///
- /// The left hand element
- /// The right hand element
- /// (lhs x rhs)
- public static BXDVector3 CrossProduct(BXDVector3 lhs, BXDVector3 rhs)
- {
- return new BXDVector3(lhs.y * rhs.z - lhs.z * rhs.y, lhs.z * rhs.x - lhs.x * rhs.z, lhs.x * rhs.y - lhs.y * rhs.x);
- }
-
- ///
- /// Computes the dot product of two vectors.
- ///
- /// One vector
- /// Another vector
- /// (a · b)
- public static float DotProduct(BXDVector3 a, BXDVector3 b)
- {
- return a.x * b.x + a.y * b.y + a.z * b.z;
- }
-
- public void WriteBinaryData(System.IO.BinaryWriter w)
- {
- w.Write(x);
- w.Write(y);
- w.Write(z);
- }
-
- public void ReadBinaryData(System.IO.BinaryReader r)
- {
- x = r.ReadSingle();
- y = r.ReadSingle();
- z = r.ReadSingle();
- }
-
- ///
- /// Creates an identical copy of this vector.
- ///
- /// The copy
- public BXDVector3 Copy()
- {
- return new BXDVector3(x, y, z);
- }
-
- public override bool Equals(object obj)
- {
- if (obj is BXDVector3)
- {
- BXDVector3 v = (BXDVector3) obj;
- return Math.Abs(v.x - x) < EPSILON && Math.Abs(v.y - y) < EPSILON && Math.Abs(v.z - z) < EPSILON;
- }
- return false;
- }
-
- public override int GetHashCode()
- {
- int x = (int) (100 * this.x);
- int y = (int) (100 * this.y);
- int z = (int) (100 * this.z);
- const int p1 = 73856093;
- const int p2 = 19349663;
- const int p3 = 83492791;
- return (x * p1) ^ (y * p2) ^ (z * p3);
- }
-}
diff --git a/api/Aardvark/Math/PhysicalProperties.cs b/api/Aardvark/Math/PhysicalProperties.cs
deleted file mode 100644
index b88851344b..0000000000
--- a/api/Aardvark/Math/PhysicalProperties.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System.IO;
-
-public class PhysicalProperties : BinaryRWObject
-{
- public BXDVector3 centerOfMass = new BXDVector3();
- public float mass;
-
- public void Add(float addMass, BXDVector3 addCOM)
- {
- centerOfMass.Multiply(mass);
- centerOfMass.Add(addCOM.Copy().Multiply(addMass));
- mass += addMass;
- centerOfMass.Multiply(1.0f / mass);
- }
-
- public void WriteBinaryData(BinaryWriter writer)
- {
- writer.Write(centerOfMass);
- writer.Write(mass);
- }
-
- public void ReadBinaryData(BinaryReader reader)
- {
- centerOfMass = reader.ReadRWObject();
- mass = reader.ReadSingle();
- }
-}
diff --git a/api/Aardvark/Math/Polynomial.cs b/api/Aardvark/Math/Polynomial.cs
deleted file mode 100644
index 3d56290e35..0000000000
--- a/api/Aardvark/Math/Polynomial.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-using System.Text;
-
-public class Polynomial : BinaryRWObject
-{
- public float[] coeff;
-
- public Polynomial()
- {
- coeff = new float[0];
- }
-
- ///
- /// Coefficients are based on array indicies, so the first one is multiplied by 1, the second by x, the third by x^2...
- ///
- /// Coeffecients for the polynomial
- public Polynomial(params float[] coeff)
- {
- this.coeff = coeff;
- }
-
- public float Evaluate(float x)
- {
- float result = 0;
- float pow = 1;
- for (int i = 0; i < coeff.Length; i++)
- {
- result += coeff[i] * pow;
- pow *= x;
- }
- return result;
- }
-
- public void WriteBinaryData(System.IO.BinaryWriter writer)
- {
- writer.WriteArray(coeff);
- }
-
- public void ReadBinaryData(System.IO.BinaryReader reader)
- {
- coeff = reader.ReadArray();
- }
-
- public override string ToString()
- {
- StringBuilder result = new StringBuilder();
- for (int i = coeff.Length - 1; i >= 0; i--)
- {
- if (coeff[i] != 0)
- {
- if (result.Length > 0)
- {
- result.Append(" + ");
- }
- result.Append(coeff[i]);
- if (i > 0)
- {
- result.Append('x');
- if (i > 1)
- {
- result.Append('^').Append(i);
- }
- }
- }
- }
- return result.ToString();
- }
-}
diff --git a/api/Aardvark/ModelTree/FieldDefinition.cs b/api/Aardvark/ModelTree/FieldDefinition.cs
deleted file mode 100644
index 1e78bd7faf..0000000000
--- a/api/Aardvark/ModelTree/FieldDefinition.cs
+++ /dev/null
@@ -1,129 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-public class FieldDefinition
-{
- ///
- /// Used for creating new instances of a FieldDefinition.
- ///
- ///
- ///
- ///
- public delegate FieldDefinition FieldDefinitionFactory(Guid guid, string name = BXDFProperties.BXDF_DEFAULT_NAME);
-
- ///
- /// The default delegate for creating new FieldDefinition instances.
- ///
- public static FieldDefinitionFactory Factory = delegate(Guid guid, string name)
- {
- return new FieldDefinition(guid, name);
- };
-
- ///
- /// The globally unique identifier.
- ///
- public Guid GUID
- {
- get;
- private set;
- }
-
- ///
- /// The group containing each child node.
- ///
- public FieldNodeGroup NodeGroup
- {
- get;
- private set;
- }
-
- ///
- /// A dictionary containing each PropertySet and a string identifier.
- ///
- private Dictionary propertySets;
-
- ///
- /// The mesh to be exported.
- ///
- private BXDAMesh mesh;
-
- ///
- /// Initailizes a new instance of the FieldDefinition class.
- ///
- ///
- protected FieldDefinition(Guid guid, string name)
- {
- GUID = guid;
- NodeGroup = new FieldNodeGroup(name);
- propertySets = new Dictionary();
- mesh = new BXDAMesh(GUID);
- }
-
- ///
- /// Adds a child PhysicsGroup to physicsGroups.
- ///
- ///
- ///
- public void AddPropertySet(PropertySet group)
- {
- propertySets.Add(group.PropertySetID, group);
- }
-
- ///
- /// Returns a Dictionary containing each PhysicsGroup.
- ///
- ///
- public Dictionary GetPropertySets()
- {
- return propertySets;
- }
-
- ///
- /// Used for adding a submesh and creating a sub mesh ID for the given node.
- ///
- ///
- ///
- public void AddSubMesh(BXDAMesh.BXDASubMesh subMesh)
- {
- mesh.meshes.Add(subMesh);
- }
-
- ///
- /// Used for adding a collision mesh and creating a collision mesh ID for the given node.
- ///
- ///
- ///
- public void AddCollisionMesh(BXDAMesh.BXDASubMesh collisionMesh)
- {
- mesh.colliders.Add(collisionMesh);
- }
-
- ///
- /// Used for getting a submesh from the given ID.
- ///
- ///
- ///
- public BXDAMesh.BXDASubMesh GetSubMesh(int id)
- {
- return mesh.meshes[id];
- }
-
- ///
- /// Used for getting a collision mesh from the given ID.
- ///
- ///
- ///
- public BXDAMesh.BXDASubMesh GetCollisionMesh(int id)
- {
- return mesh.colliders[id];
- }
-
- ///
- /// Returns the mesh to be exported.
- ///
- ///
- public BXDAMesh GetMeshOutput()
- {
- return mesh;
- }
-}
\ No newline at end of file
diff --git a/api/Aardvark/ModelTree/FieldNode.cs b/api/Aardvark/ModelTree/FieldNode.cs
deleted file mode 100644
index 360e599147..0000000000
--- a/api/Aardvark/ModelTree/FieldNode.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-public class FieldNode
-{
- ///
- /// The string ID for the node.
- ///
- public string NodeID;
-
- ///
- /// The initial position for the FieldNode.
- ///
- public BXDVector3 Position;
-
- ///
- /// The initial rotation for the FieldNode.
- ///
- public BXDQuaternion Rotation;
-
- ///
- /// The sub mesh ID for the FieldNode.
- ///
- public int SubMeshID;
-
- ///
- /// The collision mesh ID for the FieldNode.
- ///
- public int CollisionMeshID;
-
- ///
- /// The string ID for the parent PropertySet.
- ///
- public string PropertySetID;
-
- ///
- /// Constructs a new instance of the FieldNode class.
- ///
- ///
- ///
- public FieldNode(string nodeID, string physicsGroupID = BXDFProperties.BXDF_DEFAULT_NAME)
- {
- NodeID = nodeID;
- Position = new BXDVector3();
- Rotation = new BXDQuaternion();
- SubMeshID = -1;
- CollisionMeshID = -1;
- PropertySetID = physicsGroupID;
- }
-}
diff --git a/api/Aardvark/ModelTree/FieldNodeGroup.cs b/api/Aardvark/ModelTree/FieldNodeGroup.cs
deleted file mode 100644
index aa60cbea70..0000000000
--- a/api/Aardvark/ModelTree/FieldNodeGroup.cs
+++ /dev/null
@@ -1,235 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-
-public class FieldNodeGroup
-{
- ///
- /// The string ID for the FieldNodeGroup.
- ///
- public string NodeGroupID;
-
- ///
- /// A list containing each child FieldNode.
- ///
- private Dictionary childNodes;
-
- ///
- /// A list containing each child FieldNodeGroup.
- ///
- private Dictionary childNodeGroups;
-
- ///
- /// Used for defining how a child will be processed while iterating through a node path.
- ///
- ///
- ///
- ///
- ///
- private delegate FieldNode HandleChildInfo(string childName, string childPath, bool lastChild);
-
- ///
- /// Used for setting or getting a FieldNode from the path supplied.
- ///
- ///
- ///
- public FieldNode this[string path]
- {
- set
- {
- ProcessNextChild(path,
- new HandleChildInfo((string childName, string childPath, bool lastChild) =>
- {
- if (lastChild)
- {
- FieldNode node = GetNode(childName);
-
- if (node == null)
- AddNode(value);
- else
- node = value;
- }
- else
- {
- FieldNodeGroup nodeGroup = GetNodeGroup(childName);
-
- if (nodeGroup == null)
- nodeGroup = AddNodeGroup(childName);
-
- nodeGroup[childPath] = value;
- }
-
- return null;
- }));
- }
-
- get
- {
- return ProcessNextChild(path,
- new HandleChildInfo((string childName, string childPath, bool lastChild) =>
- {
- if (lastChild)
- {
- return GetNode(childName);
- }
- else
- {
- FieldNodeGroup nodeGroup = GetNodeGroup(childName);
-
- if (nodeGroup == null)
- return null;
-
- return nodeGroup[childPath];
- }
- }));
- }
- }
-
- ///
- /// Constructs a new instance of the FieldNodeGroup class.
- ///
- ///
- public FieldNodeGroup(string nodeGroupID)
- {
- NodeGroupID = nodeGroupID;
- childNodes = new Dictionary();
- childNodeGroups = new Dictionary();
- }
-
- ///
- /// Adds a new node with the given ID and physicsGroupID to the childNodes Dictionary.
- ///
- ///
- public FieldNode AddNode(string nodeID, string physicsGroupID = BXDFProperties.BXDF_DEFAULT_NAME)
- {
- if (!childNodes.ContainsKey(nodeID))
- {
- FieldNode node = new FieldNode(nodeID, physicsGroupID);
- childNodes.Add(nodeID, node);
-
- return node;
- }
-
- return null;
- }
-
- ///
- /// Adds the given FieldNode to the ChildNodes Dictionary.
- ///
- ///
- public void AddNode(FieldNode node)
- {
- if (!childNodes.ContainsKey(node.NodeID))
- childNodes.Add(node.NodeID, node);
- }
-
- ///
- /// Returns the child FieldNode with the given nodeID.
- ///
- ///
- /// The FieldNode.
- public FieldNode GetNode(string nodeID)
- {
- if (childNodes.ContainsKey(nodeID))
- return childNodes[nodeID];
-
- return null;
- }
-
- ///
- /// Adds a new FieldNodeGroup with the given ID.
- ///
- ///
- public FieldNodeGroup AddNodeGroup(string nodeGroupID)
- {
- if (!childNodeGroups.ContainsKey(nodeGroupID))
- {
- FieldNodeGroup nodeGroup = new FieldNodeGroup(nodeGroupID);
- childNodeGroups.Add(nodeGroupID, nodeGroup);
-
- return nodeGroup;
- }
-
- return null;
- }
-
- ///
- /// Adds the given FieldNodeGroup to the childNodeGroups Dictionary.
- ///
- ///
- public void AddNodeGroup(FieldNodeGroup nodeGroup)
- {
- if (!childNodeGroups.ContainsKey(nodeGroup.NodeGroupID))
- childNodeGroups.Add(nodeGroup.NodeGroupID, nodeGroup);
- }
-
- ///
- /// Returns the FieldNodeGroup with the given nodeGroupID.
- ///
- ///
- /// The FieldNodeGroup.
- public FieldNodeGroup GetNodeGroup(string nodeGroupID)
- {
- if (childNodeGroups.ContainsKey(nodeGroupID))
- return childNodeGroups[nodeGroupID];
-
- return null;
- }
-
- ///
- /// Enumerates through all direct child FieldNodes.
- ///
- ///
- public IEnumerable EnumerateFieldNodes()
- {
- foreach (KeyValuePair node in childNodes)
- {
- yield return node.Value;
- }
- }
-
- ///
- /// Enumerates through all direct child FieldNodeGroups.
- ///
- ///
- public IEnumerable EnumerateFieldNodeGroups()
- {
- foreach (KeyValuePair nodeGroup in childNodeGroups)
- {
- yield return nodeGroup.Value;
- }
- }
-
- ///
- /// Enumerates through each child FieldNode in all child FieldNodeGroups.
- ///
- ///
- public IEnumerable EnumerateAllLeafFieldNodes()
- {
- foreach (FieldNode node in EnumerateFieldNodes())
- {
- yield return node;
- }
-
- foreach (FieldNodeGroup nodeGroup in EnumerateFieldNodeGroups())
- {
- foreach (FieldNode node in nodeGroup.EnumerateAllLeafFieldNodes())
- {
- yield return node;
- }
- }
- }
-
- ///
- /// Used for processing the next child in a path string.
- ///
- ///
- ///
- ///
- private FieldNode ProcessNextChild(string path, HandleChildInfo Handle)
- {
- if (path.Contains('/'))
- return Handle(path.Substring(0, path.IndexOf('/')), path.Substring(path.IndexOf('/') + 1), false);
- else
- return Handle(path, path, true);
- }
-}
\ No newline at end of file
diff --git a/api/Aardvark/ModelTree/PropertySet.cs b/api/Aardvark/ModelTree/PropertySet.cs
deleted file mode 100644
index 64dfb40593..0000000000
--- a/api/Aardvark/ModelTree/PropertySet.cs
+++ /dev/null
@@ -1,147 +0,0 @@
-///
-/// Stores physical properties for a node or group of nodes.
-///
-public struct PropertySet
-{
- ///
- /// Stores collider information for a PropertySet.
- ///
- public abstract class PropertySetCollider
- {
- ///
- /// Used for defining the type of collision for the PropertySetCollider.
- ///
- public enum PropertySetCollisionType : int
- {
- ///
- /// Used for approximating collision boundaries with a box.
- ///
- BOX = 0,
-
- ///
- /// Used for approximating collision boundaries with a sphere.
- ///
- SPHERE = 1,
-
- ///
- /// Used for taking the object's visible mesh and simplifying it for collision.
- ///
- MESH = 2
- }
-
- ///
- /// Stores the type of collision for the PropertySetCollider
- ///
- public PropertySetCollisionType CollisionType
- {
- get;
- private set;
- }
-
- ///
- /// Initializes a new instance of the PropertySetCollider class.
- ///
- ///
- public PropertySetCollider(PropertySetCollisionType collisionType)
- {
- CollisionType = collisionType;
- }
- }
-
- public class BoxCollider : PropertySetCollider
- {
- ///
- /// The scale of the BoxCollider.
- ///
- public BXDVector3 Scale
- {
- get;
- private set;
- }
-
- ///
- /// Initializes a new instance of the BoxCollider class.
- ///
- public BoxCollider(BXDVector3 scale)
- : base(PropertySetCollider.PropertySetCollisionType.BOX)
- {
- Scale = scale;
- }
- }
-
- public class SphereCollider : PropertySetCollider
- {
- ///
- /// The scale of the SphereCollider.
- ///
- public float Scale
- {
- get;
- private set;
- }
-
- ///
- /// Initializes a new instance of the SphereCollider class.
- ///
- public SphereCollider(float scale)
- : base(PropertySetCollisionType.SPHERE)
- {
- Scale = scale;
- }
- }
-
- public class MeshCollider : PropertySetCollider
- {
- ///
- /// Determines whether or not the MeshCollider is convex.
- ///
- public bool Convex
- {
- get;
- private set;
- }
-
- ///
- /// Initializes a new instance of the MeshCollider class.
- ///
- public MeshCollider(bool convex)
- : base(PropertySetCollisionType.MESH)
- {
- Convex = convex;
- }
- }
-
- ///
- /// ID of the PropertySet.
- ///
- public string PropertySetID;
-
- ///
- /// Collider of the PhysicsGroup.
- ///
- public PropertySetCollider Collider;
-
- ///
- /// Friction value of the PhysicsGroup.
- ///
- public int Friction;
-
- ///
- /// Stores the mass of the object.
- ///
- public float Mass;
-
- ///
- /// Constructs a new PhysicsGroup with the specified values.
- ///
- ///
- ///
- ///
- public PropertySet(string physicsGroupID, PropertySetCollider collider, int friction, float mass = 0.0f)
- {
- PropertySetID = physicsGroupID;
- Collider = collider;
- Friction = friction;
- Mass = mass;
- }
-}
\ No newline at end of file
diff --git a/api/Aardvark/ModelTree/RigidNode_Base.cs b/api/Aardvark/ModelTree/RigidNode_Base.cs
deleted file mode 100644
index 0058f89cfb..0000000000
--- a/api/Aardvark/ModelTree/RigidNode_Base.cs
+++ /dev/null
@@ -1,194 +0,0 @@
-using System;
-using System.Collections.Generic;
-
-
-///
-/// Represents a node inside the hierarchy representing how a robot moves.
-///
-public class RigidNode_Base
-{
- ///
- /// Types of joint drivers.
- ///
- public enum SoftwareExportedWith : byte
- {
- INVENTOR = 0,
- FUSION_360 = 1
- }
- ///
- /// The software this model was orginally exported with
- ///
- public SoftwareExportedWith exportedWith;
- ///
- /// Generic delegate for creating rigid node instances
- ///
- public delegate RigidNode_Base RigidNodeFactory(Guid guid);
-
- ///
- /// By setting this to a custom value skeletons that are read using can
- /// be composed of a custom rigid node type.
- ///
- public static RigidNodeFactory NODE_FACTORY = delegate(Guid guid)
- {
- return new RigidNode_Base(guid);
- };
-
- ///
- /// How far down in the hierarchy this element is. The higher it is the farther from the root node.
- ///
- protected int level;
-
- ///
- /// The node that represents the parent of this node. If this is null then this is a root node.
- ///
- private RigidNode_Base parent;
-
- ///
- /// The joint that connects this node to its parent.
- ///
- private SkeletalJoint_Base parentConnection;
-
- ///
- /// The name of the file holding this node's model.
- ///
- public string ModelFileName;
-
-
- ///
- /// The globally unique identifier.
- ///
- public Guid GUID
- {
- get;
- private set;
- }
-
- ///
- /// Contains the drivetrain type for the model, only implemented at the top node
- ///
- public enum DriveTrainType
- {
- NONE = 0,
- TANK = 1,
- H_DRIVE = 2,
- CUSTOM = 3
- }
-
- public DriveTrainType driveTrainType;
-
- ///
- /// A very verbose identifier that represents the element this node is in the overall structure.
- ///
- public string ModelFullID;
-
- ///
- /// A mapping between each child node of this node and the joint connection between the two.
- ///
- public Dictionary Children = new Dictionary();
-
- ///
- /// Initializes a new instance of the RigidNode_Base class.
- ///
- ///
- public RigidNode_Base(Guid guid)
- {
- GUID = guid;
- }
-
- ///
- /// Adds the given node as a child of this node.
- ///
- /// The joint connecting this node to the child
- /// The child node
- public void AddChild(SkeletalJoint_Base joint, RigidNode_Base child)
- {
- Children.Add(joint, child);
- child.parentConnection = joint;
- child.parent = this;
- child.level = level + 1;
- }
-
- ///
- /// Gets the parent node for this node.
- ///
- /// The parent node, or null if this node is a root node
- public RigidNode_Base GetParent()
- {
- return parent;
- }
-
- ///
- /// Gets the skeletal joint connecting this node to its parent.
- ///
- ///
- /// This should always be non-null when the current node isn't a root node.
- ///
- /// The joint connection, or null if no connection exists.
- public SkeletalJoint_Base GetSkeletalJoint()
- {
- return parentConnection;
- }
-
- ///
- /// Gets the actual object visually representing this rigid node if such an item exists.
- ///
- /// The representation, or null
- public virtual object GetModel()
- {
- return null;
- }
-
- ///
- /// Gets a very verbose identifier that represents the element this node is in the overall structure.
- ///
- /// The model identifier
- public virtual string GetModelID()
- {
- return ModelFullID;
- }
-
- public override string ToString()
- {
- string result = new string('\t', level) + "Rigid Node" + System.Environment.NewLine;
- result += new string('\t', level) + "ID: " + ModelFullID + System.Environment.NewLine;
- if (parentConnection != null && parentConnection.cDriver != null)
- {
- result += new string('\t', level) + "Driver: " + ("\n" + parentConnection.cDriver.ToString()).Replace("\n", "\n" + new string('\t', level + 1));
- }
- if (Children.Count > 0)
- {
- result += new string('\t', level) + "Children: ";
- foreach (KeyValuePair pair in Children)
- {
- result += System.Environment.NewLine + new string('\t', level) + " - " + pair.Key.ToString();
- result += System.Environment.NewLine + pair.Value.ToString();
- result += "\n";
- }
- }
- return result;
- }
-
- ///
- /// Gets a list of all the rigid nodes at or below this item in the tree.
- ///
- /// The list of nodes
- public List ListAllNodes()
- {
- List list = new List();
- ListAllNodes(list);
- return list;
- }
-
- ///
- /// Gets a list of all the rigid nodes at or below this item in the tree.
- ///
- /// The list to write the nodes to
- public void ListAllNodes(List list)
- {
- list.Add(this);
- foreach (KeyValuePair pair in Children)
- {
- pair.Value.ListAllNodes(list);
- }
- }
-}
\ No newline at end of file
diff --git a/api/Aardvark/README.md b/api/Aardvark/README.md
deleted file mode 100644
index e1329c7a77..0000000000
--- a/api/Aardvark/README.md
+++ /dev/null
@@ -1 +0,0 @@
-For BXDJ information look here: https://github.com/Autodesk/synthesis/wiki/XML-Based-BXDJ-File-Format
diff --git a/api/Aardvark/SimulatorFileIO/obj/SimulatorAPI.csproj.nuget.dgspec.json b/api/Aardvark/SimulatorFileIO/obj/SimulatorAPI.csproj.nuget.dgspec.json
deleted file mode 100644
index 38cf22222b..0000000000
--- a/api/Aardvark/SimulatorFileIO/obj/SimulatorAPI.csproj.nuget.dgspec.json
+++ /dev/null
@@ -1,61 +0,0 @@
-{
- "format": 1,
- "restore": {
- "C:\\Users\\hunte\\git\\synthesis\\api\\aardvark\\SimulatorFileIO\\SimulatorAPI.csproj": {}
- },
- "projects": {
- "C:\\Users\\hunte\\git\\synthesis\\api\\aardvark\\SimulatorFileIO\\SimulatorAPI.csproj": {
- "version": "1.0.0",
- "restore": {
- "projectUniqueName": "C:\\Users\\hunte\\git\\synthesis\\api\\aardvark\\SimulatorFileIO\\SimulatorAPI.csproj",
- "projectName": "SimulatorAPI",
- "projectPath": "C:\\Users\\hunte\\git\\synthesis\\api\\aardvark\\SimulatorFileIO\\SimulatorAPI.csproj",
- "packagesPath": "C:\\Users\\hunte\\.nuget\\packages\\",
- "outputPath": "C:\\Users\\hunte\\git\\synthesis\\api\\aardvark\\SimulatorFileIO\\obj\\",
- "projectStyle": "PackageReference",
- "skipContentFileWrite": true,
- "fallbackFolders": [
- "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
- ],
- "configFilePaths": [
- "C:\\Users\\hunte\\AppData\\Roaming\\NuGet\\NuGet.Config",
- "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
- "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
- ],
- "originalTargetFrameworks": [
- "net45"
- ],
- "sources": {
- "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
- "https://api.nuget.org/v3/index.json": {}
- },
- "frameworks": {
- "net45": {
- "projectReferences": {}
- }
- }
- },
- "frameworks": {
- "net45": {
- "dependencies": {
- "Newtonsoft.Json": {
- "target": "Package",
- "version": "[12.0.2, )"
- }
- }
- }
- },
- "runtimes": {
- "win": {
- "#import": []
- },
- "win-x64": {
- "#import": []
- },
- "win-x86": {
- "#import": []
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/api/Aardvark/SimulatorFileIO/obj/SimulatorAPI.csproj.nuget.g.props b/api/Aardvark/SimulatorFileIO/obj/SimulatorAPI.csproj.nuget.g.props
deleted file mode 100644
index 17a75d7382..0000000000
--- a/api/Aardvark/SimulatorFileIO/obj/SimulatorAPI.csproj.nuget.g.props
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
- True
- NuGet
- $(MSBuildThisFileDirectory)project.assets.json
- $(UserProfile)\.nuget\packages\
- C:\Users\hunte\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages
- PackageReference
- 5.8.0
-
-
-
-
-
- $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
-
-
\ No newline at end of file
diff --git a/api/Aardvark/SimulatorFileIO/obj/SimulatorAPI.csproj.nuget.g.targets b/api/Aardvark/SimulatorFileIO/obj/SimulatorAPI.csproj.nuget.g.targets
deleted file mode 100644
index 53cfaa19b1..0000000000
--- a/api/Aardvark/SimulatorFileIO/obj/SimulatorAPI.csproj.nuget.g.targets
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
- $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
-
-
\ No newline at end of file
diff --git a/api/Aardvark/SimulatorFileIO/obj/project.assets.json b/api/Aardvark/SimulatorFileIO/obj/project.assets.json
deleted file mode 100644
index c76211b0d5..0000000000
--- a/api/Aardvark/SimulatorFileIO/obj/project.assets.json
+++ /dev/null
@@ -1,143 +0,0 @@
-{
- "version": 3,
- "targets": {
- ".NETFramework,Version=v4.5": {
- "Newtonsoft.Json/12.0.2": {
- "type": "package",
- "compile": {
- "lib/net45/Newtonsoft.Json.dll": {}
- },
- "runtime": {
- "lib/net45/Newtonsoft.Json.dll": {}
- }
- }
- },
- ".NETFramework,Version=v4.5/win": {
- "Newtonsoft.Json/12.0.2": {
- "type": "package",
- "compile": {
- "lib/net45/Newtonsoft.Json.dll": {}
- },
- "runtime": {
- "lib/net45/Newtonsoft.Json.dll": {}
- }
- }
- },
- ".NETFramework,Version=v4.5/win-x64": {
- "Newtonsoft.Json/12.0.2": {
- "type": "package",
- "compile": {
- "lib/net45/Newtonsoft.Json.dll": {}
- },
- "runtime": {
- "lib/net45/Newtonsoft.Json.dll": {}
- }
- }
- },
- ".NETFramework,Version=v4.5/win-x86": {
- "Newtonsoft.Json/12.0.2": {
- "type": "package",
- "compile": {
- "lib/net45/Newtonsoft.Json.dll": {}
- },
- "runtime": {
- "lib/net45/Newtonsoft.Json.dll": {}
- }
- }
- }
- },
- "libraries": {
- "Newtonsoft.Json/12.0.2": {
- "sha512": "rTK0s2EKlfHsQsH6Yx2smvcTCeyoDNgCW7FEYyV01drPlh2T243PR2DiDXqtC5N4GDm4Ma/lkxfW5a/4793vbA==",
- "type": "package",
- "path": "newtonsoft.json/12.0.2",
- "files": [
- ".nupkg.metadata",
- ".signature.p7s",
- "LICENSE.md",
- "lib/net20/Newtonsoft.Json.dll",
- "lib/net20/Newtonsoft.Json.xml",
- "lib/net35/Newtonsoft.Json.dll",
- "lib/net35/Newtonsoft.Json.xml",
- "lib/net40/Newtonsoft.Json.dll",
- "lib/net40/Newtonsoft.Json.xml",
- "lib/net45/Newtonsoft.Json.dll",
- "lib/net45/Newtonsoft.Json.xml",
- "lib/netstandard1.0/Newtonsoft.Json.dll",
- "lib/netstandard1.0/Newtonsoft.Json.xml",
- "lib/netstandard1.3/Newtonsoft.Json.dll",
- "lib/netstandard1.3/Newtonsoft.Json.xml",
- "lib/netstandard2.0/Newtonsoft.Json.dll",
- "lib/netstandard2.0/Newtonsoft.Json.xml",
- "lib/portable-net40+sl5+win8+wp8+wpa81/Newtonsoft.Json.dll",
- "lib/portable-net40+sl5+win8+wp8+wpa81/Newtonsoft.Json.xml",
- "lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.dll",
- "lib/portable-net45+win8+wp8+wpa81/Newtonsoft.Json.xml",
- "newtonsoft.json.12.0.2.nupkg.sha512",
- "newtonsoft.json.nuspec"
- ]
- }
- },
- "projectFileDependencyGroups": {
- ".NETFramework,Version=v4.5": [
- "Newtonsoft.Json >= 12.0.2"
- ]
- },
- "packageFolders": {
- "C:\\Users\\hunte\\.nuget\\packages\\": {},
- "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {}
- },
- "project": {
- "version": "1.0.0",
- "restore": {
- "projectUniqueName": "C:\\Users\\hunte\\git\\synthesis\\api\\aardvark\\SimulatorFileIO\\SimulatorAPI.csproj",
- "projectName": "SimulatorAPI",
- "projectPath": "C:\\Users\\hunte\\git\\synthesis\\api\\aardvark\\SimulatorFileIO\\SimulatorAPI.csproj",
- "packagesPath": "C:\\Users\\hunte\\.nuget\\packages\\",
- "outputPath": "C:\\Users\\hunte\\git\\synthesis\\api\\aardvark\\SimulatorFileIO\\obj\\",
- "projectStyle": "PackageReference",
- "skipContentFileWrite": true,
- "fallbackFolders": [
- "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
- ],
- "configFilePaths": [
- "C:\\Users\\hunte\\AppData\\Roaming\\NuGet\\NuGet.Config",
- "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
- "C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
- ],
- "originalTargetFrameworks": [
- "net45"
- ],
- "sources": {
- "C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
- "https://api.nuget.org/v3/index.json": {}
- },
- "frameworks": {
- "net45": {
- "projectReferences": {}
- }
- }
- },
- "frameworks": {
- "net45": {
- "dependencies": {
- "Newtonsoft.Json": {
- "target": "Package",
- "version": "[12.0.2, )"
- }
- }
- }
- },
- "runtimes": {
- "win": {
- "#import": []
- },
- "win-x64": {
- "#import": []
- },
- "win-x86": {
- "#import": []
- }
- }
- }
-}
\ No newline at end of file
diff --git a/api/Aardvark/SimulatorFileIO/obj/project.nuget.cache b/api/Aardvark/SimulatorFileIO/obj/project.nuget.cache
deleted file mode 100644
index 1f5613401c..0000000000
--- a/api/Aardvark/SimulatorFileIO/obj/project.nuget.cache
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "version": 2,
- "dgSpecHash": "8pD7Bb3/xSdFCAlN1y6LICoZcW4bjFP2YEP6kKg+uDWdj5crXFThFeneqk8O5XzxA44chxHJlYlq1KPcTfvYRw==",
- "success": true,
- "projectFilePath": "C:\\Users\\hunte\\git\\synthesis\\api\\aardvark\\SimulatorFileIO\\SimulatorAPI.csproj",
- "expectedPackageFiles": [
- "C:\\Users\\hunte\\.nuget\\packages\\newtonsoft.json\\12.0.2\\newtonsoft.json.12.0.2.nupkg.sha512"
- ],
- "logs": []
-}
\ No newline at end of file
diff --git a/api/Aardvark/Utilities/ArrayUtilities.cs b/api/Aardvark/Utilities/ArrayUtilities.cs
deleted file mode 100644
index f751ed59b6..0000000000
--- a/api/Aardvark/Utilities/ArrayUtilities.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-public class ArrayUtilities
-{
- public delegate T MakeVector2(double x, double y);
- public delegate T MakeVector3(double x, double y, double z);
- public delegate T MakeColor(byte r, byte g, byte b, byte a);
-
- ///
- /// Wraps the given array of 2D vector elements into an array of 2D vectors
- ///
- /// The type to create
- /// The delegate to create an instance
- /// The vector element array
- /// The wrapped array
- public static T[] WrapArray(MakeVector2 maker, double[] array)
- {
- T[] results = new T[array.Length / 2];
- for (int i = 0, j = 0; i < results.Length; i++, j += 2)
- {
- results[i] = maker(array[j], array[j + 1]);
- }
- return results;
- }
-
- ///
- /// Wraps the given array of 3D vector elements into an array of 3D vectors
- ///
- /// The type to create
- /// The delegate to create an instance
- /// The vector element array
- /// The wrapped array
- public static T[] WrapArray(MakeVector3 maker, double[] array)
- {
- T[] results = new T[array.Length / 3];
- for (int i = 0, j = 0; i < results.Length; i++, j += 3)
- {
- results[i] = maker(array[j], array[j + 1], array[j + 2]);
- }
- return results;
- }
-
- ///
- /// Wraps the given array of 4D color elements into an array of colors
- ///
- /// The type to create
- /// The delegate to create an instance
- /// The vector element array
- /// The wrapped array
- public static T[] WrapArray(MakeColor maker, uint[] array)
- {
- T[] results = new T[array.Length];
- for (int i = 0; i < results.Length; i++)
- {
- uint val = array[i];
- results[i] = maker((byte) (val & 0xFF), (byte) ((val >> 8) & 0xFF), (byte) ((val >> 16) & 0xFF), (byte) ((val >> 24) & 0xFF));
- }
- return results;
- }
-}
\ No newline at end of file
diff --git a/api/Aardvark/Utilities/FileUtilities.cs b/api/Aardvark/Utilities/FileUtilities.cs
deleted file mode 100644
index 13e1bb1c06..0000000000
--- a/api/Aardvark/Utilities/FileUtilities.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-
-class FileUtilities
-{
- ///
- /// Removes unsanitary characters from a file name and replaces them with sane ones.
- ///
- /// The filename
- /// The optional character to replace with
- /// The sane filename
- public static string SanatizeFileName(string fileName, char sanity = '_')
- {
- foreach (char c in System.IO.Path.GetInvalidFileNameChars())
- {
- fileName = fileName.Replace(c, sanity);
- }
- return fileName;
- }
-}
diff --git a/api/Api/Aether/Lobby/LobbyClient.cs b/api/Api/Aether/Lobby/LobbyClient.cs
deleted file mode 100644
index effb1eae1e..0000000000
--- a/api/Api/Aether/Lobby/LobbyClient.cs
+++ /dev/null
@@ -1,506 +0,0 @@
-using Google.Protobuf;
-using SynthesisAPI.Controller;
-using SynthesisAPI.Utilities;
-using System;
-using System.Collections.Concurrent;
-using System.IO;
-using System.Text;
-using System.Collections.Generic;
-using System.Net.Sockets;
-using System.Threading;
-using System.Threading.Tasks;
-
-#nullable enable
-
-namespace SynthesisAPI.Aether.Lobby {
- public class LobbyClient : IDisposable {
-
- private const long HEARTBEAT_FREQUENCY = 1000;
-
- public string IP => _instance == null ? string.Empty : _instance.IP;
- private Inner? _instance;
-
- public ulong? Guid => _instance?.Handler.Guid;
- public string Name => _instance?.Handler.Name ?? "--unknown--";
- public bool IsAlive => _instance != null;
-
- public List RobotsFromServer => _instance?.RobotsFromServer ?? new List();
-
- public LobbyClient(string ip, string name) {
- _instance = new Inner(ip, name);
- }
-
- public Task? GetLobbyInformation() {
- return _instance?.GetLobbyInformation();
- }
-
- public Task> UploadRobotData(DataRobot robot)
- => _instance?.UploadRobotData(robot) ?? Task.FromResult(new Result(new Exception("No instance")));
-
- public Task> RequestServerRobotData()
- => _instance?.RequestServerRobotData() ?? Task.FromResult(new Result(new Exception("No instance")));
-
- public Task> UpdateControllableState(List updates)
- => _instance?.UpdateControllableState(updates) ?? Task.FromResult(new Result(new Exception("No instance")));
-
- public Task> UpdateTransforms(List transforms)
- => _instance?.UpdateTransforms(transforms) ?? Task.FromResult(new Result(new Exception("No instance")));
-
- private class Inner : IDisposable {
-
- private Atomic _isAlive = new Atomic(true);
-
- public readonly string IP;
- private readonly LobbyClientHandler _handler;
- public LobbyClientHandler Handler => _handler;
-
- public ReaderWriterLockSlim TransformDataLock;
- public Dictionary TransformData;
-
- private ConcurrentQueue>> _requestQueue;
-
- private readonly Thread _heartbeatThread;
- private readonly Thread _requestSenderThread;
-
- public List RobotsFromServer { get; private set; }
-
- public Inner(string ip, string name) {
- IP = ip;
-
- TransformData = new Dictionary();
- TransformDataLock = new ReaderWriterLockSlim();
-
- _requestQueue = new ConcurrentQueue>>();
-
- var tcp = new TcpClient();
- tcp.Connect(ip, LobbyServer.TCP_PORT);
-
- var handlerRes = LobbyClientHandler.InitClientSide(tcp, name);
- if (handlerRes.isError)
- throw handlerRes.GetError();
- _handler = handlerRes.GetResult();
-
- // TODO: Add lifetime stuff
- _heartbeatThread = new Thread(ClientHeartbeat);
- _heartbeatThread.Start();
-
- _requestSenderThread = new Thread(RequestQueueProcessor);
- _requestSenderThread.Start();
-
- RobotsFromServer = new List();
- }
-
- ~Inner() {
- if (_isAlive)
- Dispose();
- }
-
- public Task? GetLobbyInformation() {
- var msg = new LobbyMessage{
- ToGetLobbyInformation = new LobbyMessage.Types.ToGetLobbyInformation{
- SenderGuid = _handler.Guid
- }
- };
-
- if (_handler.WriteMessage(msg).isError) {
- return null;
- }
-
- return Task.Factory.StartNew(() => {
- var msgTask = _handler.ReadMessage();
- msgTask.Wait();
- var msgRes = msgTask.Result;
-
- if (msgRes.isError) {
- Logger.Log($"Failed to Read: [{msgRes.GetError().GetType().Name}] {msgRes.GetError().Message}\n\n{msgRes.GetError().StackTrace}");
- }
-
- var msg = msgRes.GetResult();
-
- if (msg.MessageTypeCase != LobbyMessage.MessageTypeOneofCase.FromGetLobbyInformation) {
- return null;
- }
-
- return msg.FromGetLobbyInformation;
- });
- }
-
- private void RequestQueueProcessor() {
- while (_isAlive) {
- var success = _requestQueue.TryDequeue(out var task);
- if (!success)
- continue;
-
- task.Start();
- task.Wait();
- }
- }
-
- private void ClientHeartbeat() {
- long lastUpdate = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
- while (_isAlive) {
- long currentTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
- if (currentTime - lastUpdate > HEARTBEAT_FREQUENCY) {
- var task = new Task>(() => {
- var res = _handler.WriteMessage(new LobbyMessage { ToClientHeartbeat = new LobbyMessage.Types.ToClientHeartbeat() });
- if (res.isError)
- return new Result(res.GetError());
- return new Result(val: null);
- });
- _requestQueue.Enqueue(task);
-
- lastUpdate = currentTime;
- } else {
- Thread.Sleep(100);
- }
- }
- }
-
- public Task> UploadRobotData(DataRobot robot) {
- if (!_isAlive.Value)
- return Task.FromResult(new Result(new Exception("Client no longer alive")));
-
- var request = new LobbyMessage.Types.ToDataRobot {
- Guid = _handler.Guid,
- DataRobot = robot
- };
-
- var task = new Task>(() => {
- var response = HandleResponseBoilerplate(new LobbyMessage { ToDataRobot = request });
- if (response.isError) {
- return response;
- }
-
- var msg = response.GetResult()!;
- if (msg.MessageTypeCase != LobbyMessage.MessageTypeOneofCase.FromDataRobot) {
- return new Result(new Exception("Invalid message"));
- }
-
- return new Result(msg);
- });
-
- _requestQueue.Enqueue(task);
- return task;
- }
-
- public Task> RequestServerRobotData() {
- if (!_isAlive.Value)
- return Task.FromResult(new Result(new Exception("Client no longer alive")));
-
- var request = new LobbyMessage.Types.ToRequestDataRobots {
- Guid = _handler.Guid
- };
-
- var task = new Task>(() => {
- var response = HandleResponseBoilerplate(new LobbyMessage { ToRequestDataRobots = request });
- if (response.isError) {
- return response;
- }
-
- var msg = response.GetResult()!;
- if (msg.MessageTypeCase != LobbyMessage.MessageTypeOneofCase.FromRequestDataRobots) {
- return new Result(new Exception("Invalid message"));
- }
-
- RobotsFromServer = new List(msg.FromRequestDataRobots.AllAvailableRobots);
- return new Result(msg);
- });
-
- _requestQueue.Enqueue(task);
- return task;
- }
-
- public Task> UpdateControllableState(List updates) {
- if (!_isAlive.Value)
- return Task.FromResult(new Result(new Exception("Client no longer alive")));
-
- var request = new LobbyMessage.Types.ToUpdateControllableState {
- Guid = _handler.Guid
- };
- request.Data.Add(updates);
-
- var task = new Task>(() => {
- var response = HandleResponseBoilerplate(new LobbyMessage { ToUpdateControllableState = request });
- if (response.isError) {
- return response;
- }
-
- var msg = response.GetResult()!;
- switch (msg.MessageTypeCase) {
- case LobbyMessage.MessageTypeOneofCase.FromSimulationTransformData:
- // Logger.Log("Received transform response");
- break;
- default:
- return new Result(new Exception("Invalid message"));
- }
-
- return new Result(msg);
-
- });
- _requestQueue.Enqueue(task);
- return task;
- }
-
- public Task> UpdateTransforms(List transforms) {
- if (!_isAlive.Value)
- return Task.FromResult(new Result(new Exception("Client no longer alive")));
-
- var request = new LobbyMessage.Types.ToUpdateTransformData();
- request.TransformData.AddRange(transforms);
-
- var task = new Task>(() => {
- var response = HandleResponseBoilerplate(new LobbyMessage { ToUpdateTransformData = request });
- if (response.isError) {
- return response;
- }
-
- var msg = response.GetResult()!;
- switch (msg.MessageTypeCase) {
- case LobbyMessage.MessageTypeOneofCase.FromControllableStates:
- // TODO: Update signal data
- // Logger.Log("Received controllable state response");
- break;
- default:
- return new Result(new Exception("Invalid message"));
- }
-
- return new Result(msg);
-
- });
- _requestQueue.Enqueue(task);
- return task;
- }
-
- ///
- /// TODO: Rename
- ///
- private Result HandleResponseBoilerplate(LobbyMessage request) {
- var writeResult = _handler.WriteMessage(request);
- if (writeResult.isError)
- return new Result(writeResult.GetError());
-
- var readResult = _handler.ReadMessage();
- var completedBeforeTimeout = readResult.Wait(1000);
- if (!completedBeforeTimeout)
- return new Result(new Exception("Task Timeout"));
- else if (readResult.Result.isError)
- return new Result(readResult.Result.GetError());
-
- return new Result(readResult.Result.GetResult());
- }
-
- public void Dispose() {
- _isAlive.Value = false;
- _heartbeatThread.Join();
- _requestSenderThread.Join();
- _handler.Dispose();
- }
-
- }
-
- public void Dispose() {
- _instance?.Dispose();
- _instance = null;
- }
-
- }
-
- internal class LobbyClientHandler : IDisposable {
-
- private const int READ_TIMEOUT_MS = 10000;
- private const int READ_BUFFER_SIZE = 2048;
-
- private readonly LobbyClientInformation _clientInformation;
- public LobbyClientInformation ClientInformation => _clientInformation.Clone();
-
- public DateTime? LastHeartbeat { get; private set; } // Milliseconds
-
- public ulong Guid => _clientInformation.Guid;
- public string Name => _clientInformation.Name;
-
- private readonly TcpClient _tcp;
- private NetworkStream _stream => _tcp.GetStream(); // Concurrency issues?
- private readonly Mutex _streamLock;
-
- private LobbyClientHandler(TcpClient tcp, string name, ulong guid) {
- _tcp = tcp;
- _clientInformation = new LobbyClientInformation { Name = name, Guid = guid };
- _streamLock = new Mutex();
- }
-
- public void UpdateHeartbeat() {
- LastHeartbeat = DateTime.UtcNow;
- }
-
- public Task> ReadMessage()
- => ReadMessage(_stream, _streamLock);
-
- public Result WriteMessage(LobbyMessage message)
- => WriteMessage(message, _stream, _streamLock);
-
- private static Task> ReadMessage(NetworkStream stream, Mutex? mutex = null) {
- return Task>.Factory.StartNew(() => {
- Result? result = null;
- bool isLocked = false;
- try {
-
- // DateTime startedRead = DateTime.UtcNow;
- // while (!stream.DataAvailable && (DateTime.UtcNow - startedRead).TotalMilliseconds < READ_TIMEOUT_MS) {
- // Thread.Sleep(50);
- // }
-
- // if (!stream.DataAvailable) {
- // result = new Result(new NoDataException());
- // throw result.GetError();
- // }
-
- mutex?.WaitOne();
- isLocked = true;
-
- var intBuf = new byte[4];
- stream.Read(intBuf, 0, 4);
- int msgSize = BitConverter.ToInt32(intBuf, 0);
-
- var msgBuf = new byte[msgSize];
- int bytesRead = 0;
- while (bytesRead < msgSize) {
- bytesRead += stream.Read(msgBuf, bytesRead, msgSize - bytesRead);
- }
-
- if (bytesRead != msgSize) {
- Logger.Log($"Mismatch of read bytes. Expected '{msgSize}', read '{bytesRead}'");
- }
- LobbyMessage msg = LobbyMessage.Parser.ParseFrom(msgBuf);
-
- result = new Result(msg);
-
- } catch (IOException) {
- throw new NoDataException();
- } catch (Exception e) {
- if (result == null) {
- result = new Result(
- new ServerReadException($"Read failure:\n{e.Message}\n{e.StackTrace}")
- );
- }
- } finally {
- if (isLocked) {
- mutex?.ReleaseMutex();
- }
- }
-
- return result;
- });
- }
-
- private const bool TRUE = true;
-
- private static Result WriteMessage(LobbyMessage message, NetworkStream stream, Mutex? mutex = null) {
- try {
- int size = message.CalculateSize();
- mutex?.WaitOne();
- stream.Write(BitConverter.GetBytes(size), 0, 4);
- message.WriteTo(stream);
- stream.Flush();
-
- return new Result(TRUE);
- } catch (Exception e) {
- return new Result(e);
- } finally {
- mutex?.ReleaseMutex();
- }
- }
-
- public static Result InitServerSide(TcpClient tcp, ulong guid) {
-
- tcp.GetStream().ReadTimeout = READ_TIMEOUT_MS;
-
- var msgTask = ReadMessage(tcp.GetStream());
- msgTask.Wait();
- var msgRes = msgTask.Result;
- if (msgRes.isError) {
- Logger.Log($"Failed to Read: [{msgRes.GetError().GetType().Name}] {msgRes.GetError().Message}\n\n{msgRes.GetError().StackTrace}");
- return new Result(new Exception("Failed to read request"));
- }
-
- var msg = msgRes.GetResult();
-
- LobbyClientHandler? handler = null;
-
- switch (msg.MessageTypeCase) {
- case LobbyMessage.MessageTypeOneofCase.ToRegisterClient:
- var info = msg.ToRegisterClient.ClientInfo;
- if (info == null)
- break;
-
- info.Guid = guid;
- var response = new LobbyMessage.Types.FromRegisterClient { UpdatedClientInfo = info };
- if (WriteMessage(new LobbyMessage { FromRegisterClient = response }, tcp.GetStream()).isError)
- break;
-
- handler = new LobbyClientHandler(tcp, info.Name, info.Guid);
-
- break;
- }
-
- return handler == null ?
- new Result(new Exception("Failed to create ClientHandler")) :
- new Result(handler);
- }
-
- public static Result InitClientSide(TcpClient tcp, string name) {
-
- tcp.GetStream().ReadTimeout = READ_TIMEOUT_MS;
-
- var request = new LobbyMessage.Types.ToRegisterClient { ClientInfo = new LobbyClientInformation { Name = name } };
- if (WriteMessage(new LobbyMessage { ToRegisterClient = request }, tcp.GetStream()).isError)
- return new Result(new Exception("Failed to send Register request"));
-
- var msgTask = ReadMessage(tcp.GetStream());
- msgTask.Wait();
- var msgRes = msgTask.Result;
- if (msgRes.isError) {
- Logger.Log($"Failed to Read: [{msgRes.GetError().GetType().Name}] {msgRes.GetError().Message}\n\n{msgRes.GetError().StackTrace}");
- return new Result(new Exception("Failed to read response"));
- }
-
- var msg = msgRes.GetResult();
-
- LobbyClientHandler? handler = null;
-
- switch (msg.MessageTypeCase) {
- case LobbyMessage.MessageTypeOneofCase.FromRegisterClient:
- var info = msg.FromRegisterClient.UpdatedClientInfo;
- if (info == null)
- break;
-
- handler = new LobbyClientHandler(tcp, info.Name, info.Guid);
-
- break;
- }
-
- return handler == null ?
- new Result(new Exception("Failed to create ClientHandler")) :
- new Result(handler);
- }
-
- public override string ToString() {
- int time = LastHeartbeat.HasValue ? (int)System.Math.Round((DateTime.UtcNow - LastHeartbeat.Value).TotalMilliseconds) : -1;
- return $"[{ClientInformation.Guid}] {ClientInformation.Name} <- {time}ms";
- }
-
- public void Dispose() {
- _tcp.Dispose();
- }
-
- public class ServerReadException : Exception {
- public ServerReadException() { }
- public ServerReadException(string msg) : base(msg) { }
- }
- public class ReadTimeoutException : ServerReadException {
- public ReadTimeoutException() : base("Timeout") { }
- }
- public class NoDataException : ServerReadException {
- public NoDataException() : base("No Data") { }
- }
- }
-}
diff --git a/api/Api/Aether/Lobby/LobbyServer.cs b/api/Api/Aether/Lobby/LobbyServer.cs
deleted file mode 100644
index 6d0187a830..0000000000
--- a/api/Api/Aether/Lobby/LobbyServer.cs
+++ /dev/null
@@ -1,346 +0,0 @@
-using SynthesisAPI.Controller;
-using SynthesisAPI.Utilities;
-using System;
-using System.Collections.Generic;
-using System.Net;
-using System.Net.Sockets;
-using System.Security.Cryptography;
-using System.Threading;
-
-#nullable enable
-
-namespace SynthesisAPI.Aether.Lobby {
- public class LobbyServer : IDisposable {
-
- public const int TCP_PORT = 23456;
- public const int CLIENT_LISTEN_TIMEOUT_MS = 3000;
-
- private Inner? _instance;
-
- public IReadOnlyCollection Clients => _instance?.Clients ?? new List(1).AsReadOnly();
- public IReadOnlyCollection AvailableRobots => _instance?.AvailableRobots ?? new List(1).AsReadOnly();
-
- public LobbyServer() {
- _instance = new Inner();
- }
-
- public ControllableState? GetControllableState(ulong guid)
- => _instance?.GetControllableState(guid);
-
- private class Inner : IDisposable {
-
- private ulong _nextGuid = 1;
- private readonly Atomic _isAlive = new Atomic(true);
-
- private readonly ReaderWriterLockSlim _clientsLock;
- private readonly ReaderWriterLockSlim _remoteDataLock;
-
- private readonly TcpListener _listener;
- private readonly Dictionary _clients;
- private readonly LinkedList _clientThreads;
-
- private readonly Dictionary _remoteData;
-
- public IReadOnlyCollection Clients {
- get {
- List clientsInfo;
- _clientsLock.EnterReadLock();
- try {
- clientsInfo = new List(_clients.Count);
- _clients.Values.ForEach(x => clientsInfo.Add(x.ToString()));
- } finally {
- _clientsLock.ExitReadLock();
- }
-
- return clientsInfo.AsReadOnly();
- }
- }
-
- private readonly ReaderWriterLockSlim _robotDataLock;
- private List _availableRobots;
- public IReadOnlyCollection AvailableRobots {
- get {
- List robots;
- _robotDataLock.EnterReadLock();
- try {
- robots = new List(_availableRobots);
- } finally {
- _robotDataLock.ExitReadLock();
- }
-
- return robots.AsReadOnly();
- }
- }
-
- public Inner() {
- _clientsLock = new ReaderWriterLockSlim();
- _remoteDataLock = new ReaderWriterLockSlim();
- _robotDataLock = new ReaderWriterLockSlim();
-
- _clients = new Dictionary();
- _clientThreads = new LinkedList();
- _availableRobots = new List();
-
- _remoteData = new Dictionary();
-
- _listener = new TcpListener(IPAddress.Any, TCP_PORT);
- _listener.Start();
- _listener.BeginAcceptTcpClient(AcceptTcpClient, null);
- }
-
- ~Inner() {
- if (_isAlive)
- Dispose();
- }
-
- private void AcceptTcpClient(IAsyncResult result) {
- try {
- var clientTcp = _listener.EndAcceptTcpClient(result);
-
- if (clientTcp != null) {
- var client = LobbyClientHandler.InitServerSide(clientTcp, _nextGuid++);
- if (!client.isError) {
- _clientsLock.EnterWriteLock();
- var clientResult = client.GetResult();
- _clients.Add(clientResult.Guid, clientResult);
-
- _remoteDataLock.EnterWriteLock();
- _remoteData.Add(clientResult.Guid, new RemoteData(clientResult.Guid));
- _remoteDataLock.ExitWriteLock();
-
- var clientThread = new Thread(() => ClientListener(client));
- clientThread.Start();
- _clientThreads.AddLast(clientThread);
- }
-
- }
- } catch (ObjectDisposedException) {
- } catch (Exception e) {
- Logger.Log($"Failed to accept new client: {e.Message}");
- } finally {
- _clientsLock.ExitWriteLock();
- }
-
- if (_isAlive)
- _listener.BeginAcceptTcpClient(AcceptTcpClient, null);
- }
-
- private void ClientListener(LobbyClientHandler handler) {
- while (_isAlive) {
- var msgTask = handler.ReadMessage();
- var finishedBeforeTimeout = msgTask.Wait(CLIENT_LISTEN_TIMEOUT_MS);
- if (!finishedBeforeTimeout || msgTask.Result == null) {
- Logger.Log("Read Time Out");
- continue;
- }
-
- var msgRes = msgTask.Result;
- if (msgRes.isError) {
- if (!(msgRes.GetError() is LobbyClientHandler.ReadTimeoutException) && !(msgRes.GetError() is LobbyClientHandler.NoDataException)) {
- Logger.Log($"Failed to Read: [{msgRes.GetError().GetType().Name}] {msgRes.GetError().Message}\n\n{msgRes.GetError().StackTrace}");
- }
- continue;
- }
-
- var msg = msgRes.GetResult();
- switch (msg.MessageTypeCase) {
- case LobbyMessage.MessageTypeOneofCase.ToGetLobbyInformation:
- OnGetLobbyInformation(msg.ToGetLobbyInformation, handler);
- break;
- case LobbyMessage.MessageTypeOneofCase.ToDataRobot:
- AcceptRobotData(msg.ToDataRobot, handler);
- break;
- case LobbyMessage.MessageTypeOneofCase.ToRequestDataRobots:
- OnRequestDataRobots(msg.ToRequestDataRobots, handler);
- break;
- case LobbyMessage.MessageTypeOneofCase.ToUpdateControllableState:
- OnControllableStateUpdate(msg.ToUpdateControllableState, handler);
- break;
- case LobbyMessage.MessageTypeOneofCase.ToUpdateTransformData:
- OnTransformDataUpdate(msg.ToUpdateTransformData, handler);
- break;
- case LobbyMessage.MessageTypeOneofCase.ToDataDump:
- case LobbyMessage.MessageTypeOneofCase.ToClientHeartbeat:
- handler.UpdateHeartbeat();
- break;
- default:
- Logger.Log($"Received unknown message type: {msg.MessageTypeCase}");
- break;
- }
- }
- }
-
- private void OnGetLobbyInformation(LobbyMessage.Types.ToGetLobbyInformation _, LobbyClientHandler handler) {
- LobbyMessage.Types.FromGetLobbyInformation response;
- _clientsLock.EnterReadLock();
-
- try {
- response = new LobbyMessage.Types.FromGetLobbyInformation {
- LobbyInformation = new LobbyInformation()
- };
- _clients.Values.ForEach(x => response.LobbyInformation.Clients.Add(x.ClientInformation));
- } finally {
- _clientsLock.ExitReadLock();
- }
-
- handler.WriteMessage(new LobbyMessage { FromGetLobbyInformation = response });
- }
-
- private void AcceptRobotData(LobbyMessage.Types.ToDataRobot robot, LobbyClientHandler handler) {
- _robotDataLock.EnterWriteLock();
- try {
- SHA256 sha = SHA256.Create();
- var checksum = Convert.ToBase64String(sha.ComputeHash(robot.DataRobot.Data.ToByteArray()));
- _availableRobots.Add(new DataRobot(robot.DataRobot));
- } finally {
- _robotDataLock.ExitWriteLock();
- }
-
- var response = new LobbyMessage.Types.FromDataRobot {
- Guid = handler.Guid
- };
-
- handler.WriteMessage(new LobbyMessage { FromDataRobot = response });
- }
-
- private void OnRequestDataRobots(LobbyMessage.Types.ToRequestDataRobots request, LobbyClientHandler handler) {
- var response = new LobbyMessage.Types.FromRequestDataRobots();
- _robotDataLock.EnterReadLock();
- try {
- response.AllAvailableRobots.AddRange(_availableRobots);
- } finally {
- _robotDataLock.ExitReadLock();
- }
-
- handler.WriteMessage(new LobbyMessage { FromRequestDataRobots = response });
- }
-
- private void OnControllableStateUpdate(LobbyMessage.Types.ToUpdateControllableState updateRequest, LobbyClientHandler handler) {
- RemoteData data;
-
- _remoteDataLock.EnterReadLock();
- try {
- data = _remoteData[updateRequest.Guid];
- } finally {
- _remoteDataLock.ExitReadLock();
- }
-
- data.EnterWriteLock();
- try {
- updateRequest.Data.ForEach(x => {
- data.State.SetValue(x.SignalGuid, x.Value);
- data.State.SignalMap[x.SignalGuid].Name = x.Name;
- });
- } finally {
- data.ExitWriteLock();
- }
-
- var response = new LobbyMessage.Types.FromSimulationTransformData();
-
- _remoteDataLock.EnterReadLock();
- try {
- _remoteData.ForEach(kvp => {
- kvp.Value.EnterReadLock();
- response.TransformData.Add(kvp.Value.Transforms);
- kvp.Value.ExitReadLock();
- });
- } finally {
- _remoteDataLock.ExitReadLock();
- }
-
- handler.WriteMessage(new LobbyMessage { FromSimulationTransformData = response });
- }
-
- private void OnTransformDataUpdate(LobbyMessage.Types.ToUpdateTransformData updateRequest, LobbyClientHandler handler) {
- var response = new LobbyMessage.Types.FromControllableStates();
- _remoteDataLock.EnterReadLock();
- try {
- updateRequest.TransformData.ForEach(x => {
- var data = _remoteData[x.Guid];
- data.EnterWriteLock();
-
- x.Transforms.ForEach(kvp => {
- data.Transforms.Transforms[kvp.Key] = kvp.Value;
- });
-
- data.ExitWriteLock();
- });
-
-
- _remoteData.ForEach(kvp => {
- kvp.Value.EnterWriteLock();
- if (kvp.Value.State.HasUpdates) {
- SignalUpdates updates = new SignalUpdates {
- Guid = kvp.Key
- };
- updates.UpdatedSignals.AddRange(kvp.Value.State.CompileChanges());
- response.AllUpdates.Add(updates);
- }
- kvp.Value.ExitWriteLock();
- });
- } finally {
- _remoteDataLock.ExitReadLock();
- }
-
- handler.WriteMessage(new LobbyMessage { FromControllableStates = response });
- }
-
- public ControllableState? GetControllableState(ulong guid) {
- if (!_remoteData.ContainsKey(guid))
- return null;
-
- var data = _remoteData[guid];
- ControllableState state;
- data.EnterReadLock();
- try {
- state = new ControllableState(data.State);
- } finally {
- data.ExitReadLock();
- }
-
- return state;
- }
-
- public void Dispose() {
-
- Logger.Log("Disposing Server");
-
- _isAlive.Value = false;
- _listener.Stop();
- _clientThreads.ForEach(x => x.Join());
- _clients.ForEach(x => x.Value.Dispose());
-
- Logger.Log("Server Disposed");
- }
- }
-
- public void Dispose() {
- _instance?.Dispose();
- _instance = null;
- }
- }
-
- public class RemoteData {
- private readonly ulong _owningClient;
- public ulong OwningClient { get => _owningClient; }
-
- private readonly ReaderWriterLockSlim _lock;
-
- public ControllableState State;
- public ServerTransforms Transforms;
-
- public RemoteData(ulong owningClient) {
- _owningClient = owningClient;
- _lock = new ReaderWriterLockSlim();
-
- State = new ControllableState();
- Transforms = new ServerTransforms();
- Transforms.Guid = owningClient;
- }
-
- public void EnterReadLock() => _lock.EnterReadLock();
- public void EnterWriteLock() => _lock.EnterWriteLock();
- public void ExitReadLock() => _lock.ExitReadLock();
- public void ExitWriteLock() => _lock.ExitWriteLock();
- }
-}
diff --git a/api/Api/Aether/Proto/ServerTransformData.cs b/api/Api/Aether/Proto/ServerTransformData.cs
deleted file mode 100644
index ea1c64709b..0000000000
--- a/api/Api/Aether/Proto/ServerTransformData.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using UnityEngine;
-
-public partial class ServerTransformData {
- public static explicit operator ServerTransformData(Matrix4x4 m)
- => new ServerTransformData() {
- MatrixData = {
- m[0, 0], m[0, 1], m[0, 2], m[0, 3],
- m[1, 0], m[1, 1], m[1, 2], m[1, 3],
- m[2, 0], m[2, 1], m[2, 2], m[2, 3],
- m[3, 0], m[3, 1], m[3, 2], m[3, 3]
- }
- };
-
- public static explicit operator Matrix4x4(ServerTransformData transform)
- => new Matrix4x4(
- new Vector4(transform.MatrixData[0], transform.MatrixData[4], transform.MatrixData[8], transform.MatrixData[12]),
- new Vector4(transform.MatrixData[1], transform.MatrixData[5], transform.MatrixData[9], transform.MatrixData[13]),
- new Vector4(transform.MatrixData[2], transform.MatrixData[6], transform.MatrixData[10], transform.MatrixData[14]),
- new Vector4(transform.MatrixData[3], transform.MatrixData[7], transform.MatrixData[11], transform.MatrixData[15])
- );
-}
diff --git a/api/Api/Aether/Utilities/IO.cs b/api/Api/Aether/Utilities/IO.cs
deleted file mode 100644
index ea529bb8c8..0000000000
--- a/api/Api/Aether/Utilities/IO.cs
+++ /dev/null
@@ -1,127 +0,0 @@
-using Google.Protobuf;
-using Google.Protobuf.WellKnownTypes;
-using SynthesisServer.Proto;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net;
-using System.Net.Sockets;
-using System.Text;
-
-namespace SynthesisAPI.Aether
-{
- public static class IO
- {
- public static byte[] GetNextMessage(ref byte[] buffer)
- {
- byte[] msgLength = new byte[sizeof(int)];
- Array.Copy(buffer, 0, msgLength, 0, msgLength.Length);
-
- byte[] msg = new byte[BitConverter.ToInt32(msgLength, 0)];
- Array.Copy(buffer, sizeof(int), msg, 0, msg.Length);
-
- buffer = buffer.Skip(msgLength.Length + msg.Length).ToArray();
- return msg;
- }
- public static void SendMessage(IMessage msg, string clientID, Socket socket, AsyncCallback sendCallback)
- {
- Any packedMsg = Any.Pack(msg);
- byte[] msgBytes = new byte[packedMsg.CalculateSize()];
- packedMsg.WriteTo(msgBytes);
-
- MessageHeader header = new MessageHeader() { IsEncrypted = false, ClientId = clientID };
- byte[] headerBytes = new byte[header.CalculateSize()];
- header.WriteTo(headerBytes);
-
- byte[] data = new byte[sizeof(int) + headerBytes.Length + sizeof(int) + msgBytes.Length];
-
- BitConverter.GetBytes(headerBytes.Length).CopyTo(data, 0);
- headerBytes.CopyTo(data, sizeof(int));
-
- BitConverter.GetBytes(msgBytes.Length).CopyTo(data, sizeof(int) + headerBytes.Length);
- msgBytes.CopyTo(data, sizeof(int) + headerBytes.Length + sizeof(int));
-
- if (BitConverter.IsLittleEndian) { Array.Reverse(data); }
- socket.BeginSend(data, 0, data.Length, SocketFlags.None, sendCallback, null);
- }
- public static void SendEncryptedMessage(IMessage msg, string clientID, byte[] symmetricKey, Socket socket, SymmetricEncryptor encryptor, AsyncCallback sendCallback)
- {
- Any packedMsg = Any.Pack(msg);
- byte[] msgBytes = new byte[packedMsg.CalculateSize()];
- packedMsg.WriteTo(msgBytes);
-
- byte[] delimitedMessage = new byte[sizeof(int) + msgBytes.Length];
- BitConverter.GetBytes(msgBytes.Length).CopyTo(delimitedMessage, 0);
- msgBytes.CopyTo(delimitedMessage, sizeof(int));
-
- byte[] encryptedMessage = encryptor.Encrypt(delimitedMessage, symmetricKey);
-
- MessageHeader header = new MessageHeader() { IsEncrypted = true, ClientId = clientID };
- byte[] headerBytes = new byte[header.CalculateSize()];
- header.WriteTo(headerBytes);
-
- byte[] data = new byte[sizeof(int) + headerBytes.Length + encryptedMessage.Length];
-
- BitConverter.GetBytes(headerBytes.Length).CopyTo(data, 0);
- headerBytes.CopyTo(data, sizeof(int));
-
- encryptedMessage.CopyTo(data, sizeof(int) + headerBytes.Length);
-
- if (BitConverter.IsLittleEndian) { Array.Reverse(data); }
- socket.BeginSend(data, 0, data.Length, SocketFlags.None, sendCallback, null);
- }
- public static void SendMessageTo(IMessage msg, string clientID, Socket socket, EndPoint remoteEP, AsyncCallback sendCallback)
- {
- Any packedMsg = Any.Pack(msg);
- byte[] msgBytes = new byte[packedMsg.CalculateSize()];
- packedMsg.WriteTo(msgBytes);
-
- MessageHeader header = new MessageHeader() { IsEncrypted = false, ClientId = clientID };
- byte[] headerBytes = new byte[header.CalculateSize()];
- header.WriteTo(headerBytes);
-
- byte[] data = new byte[sizeof(int) + headerBytes.Length + sizeof(int) + msgBytes.Length];
-
- BitConverter.GetBytes(headerBytes.Length).CopyTo(data, 0);
- headerBytes.CopyTo(data, sizeof(int));
-
- BitConverter.GetBytes(msgBytes.Length).CopyTo(data, sizeof(int) + headerBytes.Length);
- msgBytes.CopyTo(data, sizeof(int) + headerBytes.Length + sizeof(int));
-
- if (BitConverter.IsLittleEndian) { Array.Reverse(data); }
- socket.BeginSendTo(data, 0, data.Length, SocketFlags.None, remoteEP, sendCallback, null);
- }
- public static void SendEncryptedMessageTo(IMessage msg, string clientID, byte[] symmetricKey, Socket socket, EndPoint remoteEP, SymmetricEncryptor encryptor, AsyncCallback sendCallback)
- {
- Any packedMsg = Any.Pack(msg);
- byte[] msgBytes = new byte[packedMsg.CalculateSize()];
- packedMsg.WriteTo(msgBytes);
-
- byte[] delimitedMessage = new byte[sizeof(int) + msgBytes.Length];
- BitConverter.GetBytes(msgBytes.Length).CopyTo(delimitedMessage, 0);
- msgBytes.CopyTo(delimitedMessage, sizeof(int));
-
- byte[] encryptedMessage = encryptor.Encrypt(delimitedMessage, symmetricKey);
-
- MessageHeader header = new MessageHeader() { IsEncrypted = true, ClientId = clientID };
- byte[] headerBytes = new byte[header.CalculateSize()];
- header.WriteTo(headerBytes);
-
- byte[] data = new byte[sizeof(int) + headerBytes.Length + encryptedMessage.Length];
-
- BitConverter.GetBytes(headerBytes.Length).CopyTo(data, 0);
- headerBytes.CopyTo(data, sizeof(int));
-
- encryptedMessage.CopyTo(data, sizeof(int) + headerBytes.Length);
-
- if (BitConverter.IsLittleEndian) { Array.Reverse(data); }
- socket.BeginSendTo(data, 0, data.Length, SocketFlags.None, remoteEP, sendCallback, null);
- }
-
- public static byte[] GetBuffer(this IMessage msg) {
- byte[] buf = new byte[msg.CalculateSize()];
- msg.WriteTo(buf);
- return buf;
- }
- }
-}
diff --git a/api/Api/Aether/Utilities/SymmetricEncryptor.cs b/api/Api/Aether/Utilities/SymmetricEncryptor.cs
deleted file mode 100644
index ed936bc72d..0000000000
--- a/api/Api/Aether/Utilities/SymmetricEncryptor.cs
+++ /dev/null
@@ -1,100 +0,0 @@
-using Org.BouncyCastle.Crypto;
-using Org.BouncyCastle.Crypto.Digests;
-using Org.BouncyCastle.Crypto.Generators;
-using Org.BouncyCastle.Crypto.Parameters;
-using Org.BouncyCastle.Math;
-using Org.BouncyCastle.Security;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Security.Cryptography;
-using System.Text;
-
-namespace SynthesisAPI.Aether
-{
- public class SymmetricEncryptor
- {
- private readonly RandomNumberGenerator _random;
- private const int _AES_BLOCK_BYTE_SIZE = 128 / 8;
-
- public SymmetricEncryptor()
- {
- _random = RandomNumberGenerator.Create();
- }
-
- private byte[] GenerateRandomBytes(int numberOfBytes)
- {
- var randomBytes = new byte[numberOfBytes];
- _random.GetBytes(randomBytes);
- return randomBytes;
- }
-
-
- public byte[] GenerateSharedSecret(string importedPublicKey, DHParameters parameters, AsymmetricCipherKeyPair keyPair)
- {
- DHPublicKeyParameters importedPublicKeyParameters = new DHPublicKeyParameters(new BigInteger(importedPublicKey), parameters);
- IBasicAgreement internalKeyAgreement = AgreementUtilities.GetBasicAgreement("DH");
- internalKeyAgreement.Init(keyPair.Private);
- BigInteger sharedKey = internalKeyAgreement.CalculateAgreement(importedPublicKeyParameters);
- byte[] sharedKeyBytes = sharedKey.ToByteArray();
-
- IDigest digest = new Sha256Digest();
- byte[] SymmetricKey = new byte[digest.GetDigestSize()];
- digest.BlockUpdate(sharedKeyBytes, 0, sharedKeyBytes.Length);
- digest.DoFinal(SymmetricKey, 0);
- return SymmetricKey;
- }
-
- public AsymmetricCipherKeyPair GenerateKeys(DHParameters parameters)
- {
- var keyGen = GeneratorUtilities.GetKeyPairGenerator("DH");
- var kgp = new DHKeyGenerationParameters(new SecureRandom(), parameters);
- keyGen.Init(kgp);
- return keyGen.GenerateKeyPair();
- }
-
- public DHParameters GenerateParameters()
- {
- DHParametersGenerator generator = new DHParametersGenerator();
- generator.Init(512, 80, new SecureRandom()); // not too sure about these numbers
- return generator.GenerateParameters();
- }
-
- public byte[] Encrypt(byte[] data, byte[] symmetricKey)
- {
- using (Aes aes = Aes.Create())
- {
- aes.Key = symmetricKey;
- aes.IV = GenerateRandomBytes(_AES_BLOCK_BYTE_SIZE);
-
- using (ICryptoTransform encryptor = aes.CreateEncryptor())
- {
-
- byte[] encryptedData = encryptor.TransformFinalBlock(data, 0, data.Length);
- byte[] result = new byte[aes.IV.Length + encryptedData.Length];
-
- aes.IV.CopyTo(result, 0);
- encryptedData.CopyTo(result, aes.IV.Length);
-
- return result;
- }
- }
- }
-
- public byte[] Decrypt(byte[] encryptedData, byte[] symmetricKey)
- {
- using (Aes aes = Aes.Create())
- {
- aes.Key = symmetricKey;
- aes.IV = encryptedData.Take(_AES_BLOCK_BYTE_SIZE).ToArray();
-
- byte[] data = encryptedData.Skip(_AES_BLOCK_BYTE_SIZE).ToArray();
-
- using (ICryptoTransform decryptor = aes.CreateDecryptor())
- {
- return decryptor.TransformFinalBlock(data, 0, data.Length);
- }
- }
- }
- }
-}
diff --git a/api/Api/Api.csproj b/api/Api/Api.csproj
deleted file mode 100644
index 0ef1db61ba..0000000000
--- a/api/Api/Api.csproj
+++ /dev/null
@@ -1,79 +0,0 @@
-
-
-
- netstandard2.0
- 8
- Autodesk.Synthesis.Module.API
- 0.1.0
- Autodesk Inc
- Autodesk
- Synthesis
- An API for developing modules for the Synthesis™ platform
- © 2020 Autodesk Inc.
- https://synthesis.autodesk.com/
- synthesis.png
- https://github.com/Autodesk/synthesis/tree/master/api
- git
- Autodesk, Synthesis, FRC, Robotics, Simulator
- An experimental release of the Synthesis Module API.
-
-This release is for those looking to kickstart their module development for the Synthesis platform early before the release of version 5.1.0.
-To get started with this API, you'll need to acquire a development build of Synthesis from either one of the following outlets:
-- Clone from Git into your local Unity environment: https://github.com/Autodesk/synthesis.git
-- Download an Engine build from our CI build artifacts: https://github.com/Autodesk/synthesis/actions
-
-Please note that this release is EXPERIMENTAL and still in development. More documentation will be available soon.
-
-For support contact frc@autodesk.com
- en-US
- Apache-2.0
- true
- disable
- false
-
-
-
-
-
-
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
- ..\libs\UnityEngine.dll
-
-
-
-
-
-
-
-
-
-
-
-
- True
-
-
-
-
-
-
- ..\libs\UnityEngine.dll
-
-
-
-
-
-
-
-
diff --git a/api/Api/AssetManager/Asset.cs b/api/Api/AssetManager/Asset.cs
deleted file mode 100644
index c7532fd07e..0000000000
--- a/api/Api/AssetManager/Asset.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-using SynthesisAPI.Utilities;
-using SynthesisAPI.VirtualFileSystem;
-using Directory = SynthesisAPI.VirtualFileSystem.Directory;
-
-#nullable enable
-
-namespace SynthesisAPI.AssetManager
-{
- ///
- /// Base class for any read-only data class in the vitual file system
- ///
- public abstract class Asset : IEntry
- {
- ///
- /// Initialize Asset data
- ///
- ///
- ///
- ///
- internal void Init(string name, Permissions perm, string sourcePath)
- {
- _name = name;
- _permissions = perm;
- _parent = null!;
- SourcePath = sourcePath;
- }
-
- public string Name => ((IEntry)this).Name;
- public Permissions Permissions => ((IEntry)this).Permissions;
- public Directory? Parent => ((IEntry)this).Parent;
-
- public string SourcePath { get; private set; } = "";
-
- private string _name { get; set; } = "";
- private Permissions _permissions { get; set; }
- private Directory? _parent { get; set; }
-
- string IEntry.Name { get => _name; set => _name = value; }
- Permissions IEntry.Permissions { get => _permissions; set => _permissions = value; }
- Directory? IEntry.Parent { get => _parent; set => _parent = value; }
-
- [ExposedApi]
- public virtual void Delete()
- {
- using var _ = ApiCallSource.StartExternalCall();
- DeleteInner();
- }
-
- [ExposedApi]
- void IEntry.Delete() {
- using var _ = ApiCallSource.StartExternalCall();
- DeleteInner();
- }
-
- internal virtual void DeleteInner()
- {
- ApiCallSource.AssertAccess(Permissions, Access.Write);
- if (Parent != null)
- {
- Parent.RemoveEntryInner(Name);
- }
- }
-
- void IEntry.DeleteInner()
- {
- ApiCallSource.AssertAccess(Permissions, Access.Write);
- DeleteInner();
- }
-
- ///
- /// This function should not be called manually. It is called automatically during the asset important process.
- ///
- ///
- /// This loaded asset
- public abstract IEntry Load(byte[] data);
- }
-}
diff --git a/api/Api/AssetManager/AssetImportEvent.cs b/api/Api/AssetManager/AssetImportEvent.cs
deleted file mode 100644
index 96a2ab4b63..0000000000
--- a/api/Api/AssetManager/AssetImportEvent.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace SynthesisAPI.AssetManager
-{
- public class AssetImportEvent : EventBus.IEvent
- {
- public const string Tag = "AssetImport";
-
- public string AssetName { get; }
- public string AssetLocation { get; }
- public string AssetType { get; }
-
- public AssetImportEvent(string assetName, string assetLocation, string assetType)
- {
- AssetName = assetName;
- AssetLocation = assetLocation;
- AssetType = assetType;
- }
-
- public object[] GetArguments() => new[] { AssetName, AssetLocation, AssetType };
- }
-}
diff --git a/api/Api/AssetManager/AssetManager.cs b/api/Api/AssetManager/AssetManager.cs
deleted file mode 100644
index a78931d7fd..0000000000
--- a/api/Api/AssetManager/AssetManager.cs
+++ /dev/null
@@ -1,522 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using SynthesisAPI.Utilities;
-using SynthesisAPI.VirtualFileSystem;
-
-#nullable enable
-
-namespace SynthesisAPI.AssetManager
-{
- ///
- /// API for managing asset types and importing and fetching loaded assets
- ///
- public static class AssetManager
- {
- ///
- /// Asset-type-specific function delegate used to process asset data on import
- ///
- ///
- ///
- ///
- ///
- ///
- public delegate Asset? HandlerFunc(string name, Permissions perm,
- string sourcePath, params object[] args);
-
- ///
- /// Register a handler for importing a new type of asset
- ///
- ///
- ///
- ///
- [ExposedApi]
- public static void RegisterAssetType(string assetType, string[] fileExtensions, HandlerFunc handler)
- {
- using var _ = ApiCallSource.StartExternalCall();
- RegisterAssetTypeInner(assetType, fileExtensions, handler);
- }
-
- internal static void RegisterAssetTypeInner(string assetType, string[] fileExtensions, HandlerFunc handler)
- {
- InnerInstance.RegisterAssetType(assetType, fileExtensions, handler);
- }
-
- ///
- /// Register a handler for importing a new type of asset
- ///
- ///
- ///
- ///
- ///
- [ExposedApi]
- public static void RegisterAssetType(string type, string subtype, string[] fileExtensions, HandlerFunc handler)
- {
- using var _ = ApiCallSource.StartExternalCall();
- RegisterAssetTypeInner(type, subtype, fileExtensions, handler);
- }
-
- internal static void RegisterAssetTypeInner(string type, string subtype, string[] fileExtensions, HandlerFunc handler)
- {
- InnerInstance.RegisterAsset(type, subtype, fileExtensions, handler);
- }
-
- ///
- /// Fetch an Asset from the virtual file system
- ///
- ///
- ///
- [ExposedApi]
- public static Asset? GetAsset(string targetPath)
- {
- using var _ = ApiCallSource.StartExternalCall();
- return GetAssetInner(targetPath);
- }
-
- internal static Asset? GetAssetInner(string targetPath)
- {
- return InnerInstance.GetAsset(targetPath);
- }
-
- ///
- /// Fetch an Asset from the virtual file system
- ///
- ///
- ///
- ///
- [ExposedApi]
- public static TAsset? GetAsset(string targetPath) where TAsset : Asset
- {
- using var _ = ApiCallSource.StartExternalCall();
- return GetAssetInner(targetPath);
- }
-
- internal static TAsset? GetAssetInner(string targetPath) where TAsset : Asset
- {
- return (TAsset?)InnerInstance.GetAsset(targetPath);
- }
-
- #region Search
-
- ///
- /// Recursively search the virtual file system for an asset with a given name
- ///
- ///
- ///
- ///
- [ExposedApi]
- public static TAsset? Search(string name) where TAsset : Asset
- {
- using var _ = ApiCallSource.StartExternalCall();
- return SearchInner(name);
- }
-
- internal static TAsset? SearchInner(string name) where TAsset : Asset
- {
- return FileSystem.SearchInner(name);
- }
-
- ///
- /// Recursively search a directory for an asset with a given name
- ///
- ///
- ///
- ///
- ///
- [ExposedApi]
- public static TAsset? Search(VirtualFileSystem.Directory parent, string name) where TAsset : Asset
- {
- using var _ = ApiCallSource.StartExternalCall();
- return SearchInner(parent, name);
- }
-
- internal static TAsset? SearchInner(VirtualFileSystem.Directory parent, string name) where TAsset : Asset
- {
- return FileSystem.SearchInner(parent, name);
- }
-
- ///
- /// Recursively search the virtual file system for an asset with a given name
- ///
- ///
- ///
- [ExposedApi]
- public static Asset? Search(string name)
- {
- using var _ = ApiCallSource.StartExternalCall();
- return SearchInner(name);
- }
-
- internal static Asset? SearchInner(string name)
- {
- return (Asset?)FileSystem.SearchInner(name);
- }
-
- ///
- /// Recursively search a directory for an asset with a given name
- ///
- ///
- ///
- ///
- [ExposedApi]
- public static Asset? Search(VirtualFileSystem.Directory parent, string name)
- {
- using var _ = ApiCallSource.StartExternalCall();
- return SearchInner(parent, name);
- }
-
- internal static Asset? SearchInner(VirtualFileSystem.Directory parent, string name)
- {
- return (Asset?)FileSystem.SearchInner(parent, name);
- }
-
- #endregion
-
- #region Import from File
-
- ///
- /// Import a new asset into the virtual file system and create it if import fails
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- [ExposedApi]
- public static Asset? Import(string assetType, bool createOnFail, string targetPath, string name, Permissions perm, string sourcePath, params object[] args)
- {
- using var _ = ApiCallSource.StartExternalCall();
- return ImportInner(assetType, createOnFail, targetPath, name, perm, sourcePath, args);
- }
-
- internal static Asset? ImportInner(string assetType, bool createOnFail, string targetPath, string name, Permissions perm, string sourcePath, params object[] args)
- {
- return InnerInstance.Import(assetType, createOnFail, false, null, targetPath, name, perm, sourcePath, args);
- }
-
- ///
- /// Import a new asset into the virtual file system and create it if import fails
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- [ExposedApi]
- public static TAsset? Import(string assetType, bool createOnFail, string targetPath, string name, Permissions perm, string sourcePath, params object[] args) where TAsset : Asset
- {
- using var _ = ApiCallSource.StartExternalCall();
- return ImportInner(assetType, createOnFail, targetPath, name, perm, sourcePath, args);
- }
-
- internal static TAsset? ImportInner(string assetType, bool createOnFail, string targetPath, string name, Permissions perm, string sourcePath, params object[] args) where TAsset : Asset
- {
- return (TAsset?)ImportInner(assetType, createOnFail, targetPath, name, perm, sourcePath, args);
- }
-
- #endregion
-
- #region Import from Stream
-
- ///
- /// Import a new asset into the virtual file system
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- [ExposedApi]
- public static Asset? Import(string assetType, Stream stream, string targetPath, string name,
- Permissions perm, string sourcePath, params object[] args)
- {
- using var _ = ApiCallSource.StartExternalCall();
- return ImportInner(assetType, stream, targetPath, name, perm, sourcePath, args);
- }
-
- internal static Asset? ImportInner(string assetType, Stream stream, string targetPath, string name,
- Permissions perm, string sourcePath, params object[] args)
- {
- return InnerInstance.Import(assetType, false, false, stream, targetPath, name, perm, sourcePath, args);
- }
-
- ///
- /// Import a new asset into the virtual file system
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- [ExposedApi]
- public static TAsset? Import(string assetType, Stream stream, string targetPath, string name,
- Permissions perm, string sourcePath, params object[] args) where TAsset : Asset
- {
- using var _ = ApiCallSource.StartExternalCall();
- return ImportInner(assetType, stream, targetPath, name, perm, sourcePath, args);
- }
-
- internal static TAsset? ImportInner(string assetType, Stream stream, string targetPath, string name,
- Permissions perm, string sourcePath, params object[] args) where TAsset : Asset
- {
- return (TAsset?)ImportInner(assetType, stream, targetPath, name, perm, sourcePath, args);
- }
-
- #region Lazy Imports
-
- [ExposedApi]
- public static LazyAsset? ImportLazy(string assetType, bool createOnFail, string targetPath, string name, Permissions perm, string sourcePath, params object[] args)
- {
- using var _ = ApiCallSource.StartExternalCall();
- return ImportLazyInner(assetType, createOnFail, targetPath, name, perm, sourcePath, args);
- }
-
- internal static LazyAsset? ImportLazyInner(string assetType, bool createOnFail, string targetPath, string name, Permissions perm, string sourcePath, params object[] args)
- {
- return (LazyAsset?)InnerInstance.Import(assetType, createOnFail, true, null, targetPath, name, perm, sourcePath, args);
- }
-
- [ExposedApi]
- public static LazyAsset? ImportLazy(string assetType, Stream stream, string targetPath, string name,
- Permissions perm, string sourcePath, params object[] args)
- {
- using var _ = ApiCallSource.StartExternalCall();
- return ImportLazyInner(assetType, stream, targetPath, name, perm, sourcePath, args);
- }
-
- internal static LazyAsset? ImportLazyInner(string assetType, Stream stream, string targetPath, string name,
- Permissions perm, string sourcePath, params object[] args)
- {
- return (LazyAsset?)InnerInstance.Import(assetType, false, true, stream, targetPath, name, perm, sourcePath, args);
- }
-
- #endregion
-
- #endregion
-
- public static string? GetTypeFromFileExtension(string fileName)
- {
- return InnerInstance.GetTypeFromFileExtension(fileName);
- }
-
- ///
- /// Implementation of the public API of the AssetManager
- ///
- private class Inner
- {
- private Inner()
- {
- AssetHandlers = new Dictionary>();
- FileExtensionAssetTypes = new Dictionary();
-
- RegisterAssetType("text/plain", new[]{".txt"},
- (name, perms, sourcePath, args) =>
- {
- if (args.Length != 0)
- throw new Exception("Import of text/plain asset: wrong number of arguments");
- return new TextAsset(name, perms, sourcePath);
- });
-
- RegisterAssetType("text/xml", new[] { ".xml" },
- (name, perm, sourcePath, args) =>
- {
- if (args.Length != 0)
- throw new Exception("Import of text/xml asset: wrong number of arguments");
- return new XmlAsset(name, perm, sourcePath);
- });
-
- RegisterAssetType("text/json", new[] { ".json" },
- (name, perm, sourcePath, args) =>
- {
- if (args.Length != 0)
- throw new Exception("Import of text/json asset: wrong number of arguments");
- return new JsonAsset(name, perm, sourcePath);
- });
-
- RegisterAssetType("text/uss", new[] { ".uss" },
- (name, perm, sourcePath, args) =>
- {
- if (args.Length != 0)
- throw new Exception("Import of text/uss asset: wrong number of arguments");
- return new UssAsset(name, perm, sourcePath);
- });
-
- RegisterAssetType("image/sprite", new[] { ".png", ".jpeg" },
- (name, perm, sourcePath, args) =>
- {
- if (args.Length != 0)
- throw new Exception("Import of image/sprite asset: wrong number of arguments");
- return new SpriteAsset(name, perm, sourcePath);
- });
-
- RegisterAssetType("text/uxml", new[] { ".uxml" },
- (name, perm, sourcePath, args) =>
- {
- if (args.Length != 0)
- throw new Exception("Import of text/uxml asset: wrong number of arguments");
- return new VisualElementAsset(name, perm, sourcePath);
- });
-
- // RegisterAssetType("text/gltf", new[] { ".gltf", ".glb" },
- // (name, perm, sourcePath, args) =>
- // {
- // if (args.Length != 0)
- // throw new Exception("Import of text/gltf asset: wrong number of arguments");
- // return new GltfAsset(name, perm, sourcePath);
- // });
- RegisterAssetType("audio/wav", new[] { ".wav" },
- (name, perm, sourcePath, args) =>
- {
- if (args.Length != 0)
- throw new Exception("Import of audio/wav asset: wrong number of arguments");
- return new AudioClipAsset(name, perm, sourcePath);
- });
- }
-
- private Dictionary> AssetHandlers { get; }
- private Dictionary FileExtensionAssetTypes { get; }
-
- ///
- /// Split a media type into type and subtype
- ///
- /// Example: "text/plain" => "test" "plain"
- ///
- ///
- ///
- private string[] SplitAssetType(string assetType)
- {
- var types = assetType.Split('/');
- if (types.Length != 2)
- {
- throw new Exception("Splitting asset type: wrong type format");
- }
- return types;
- }
-
- public void RegisterAssetType(string assetType, string[] fileExtensions, HandlerFunc handler)
- {
- string[] types = SplitAssetType(assetType);
- RegisterAsset(types[0], types[1], fileExtensions, handler);
- }
-
- public void RegisterAsset(string type, string subtype, string[] fileExtensions, HandlerFunc handler)
- {
- if(AssetHandlers.ContainsKey(type) && AssetHandlers[type].ContainsKey(subtype))
- {
- throw new Exception($"Registering duplicate handler for {type}/{subtype}");
- }
-
- if (!AssetHandlers.ContainsKey(type))
- {
- AssetHandlers[type] = new Dictionary();
- }
-
- foreach (var fileExtension in fileExtensions)
- {
- if (FileExtensionAssetTypes.ContainsKey(fileExtension))
- {
- throw new Exception($"Registering duplicate handler for asset type with file extension {fileExtension}");
- }
- FileExtensionAssetTypes[fileExtension] = type + "/" + subtype;
- }
-
- AssetHandlers[type][subtype] = handler;
- }
-
- public Asset? GetAsset(string targetPath) => (Asset?)FileSystem.TraverseInner(targetPath);
-
- public string? GetTypeFromFileExtension(string fileName)
- {
- return FileExtensionAssetTypes.TryGetValue(Path.GetExtension(fileName), out string type) ? type : null;
- }
-
- public Asset? Import(string assetType, bool createOnFail, bool lazyImport, Stream? sourceStream, string targetPath, string name,
- Permissions perm, string sourcePath, params object[] args)
- {
- var types = SplitAssetType(assetType);
- return Import(types[0], types[1], createOnFail, lazyImport, sourceStream, targetPath, name, perm, sourcePath, args);
- }
-
- public Asset? Import(string type, string subtype, bool createOnFail, bool lazyImport, Stream? sourceStream, string targetPath,
- string name, Permissions perm, string sourcePath, params object[] args)
- {
- if (!AssetHandlers.ContainsKey(type) || !AssetHandlers[type].ContainsKey(subtype))
- {
- throw new Exception($"Importing asset with unregistered type {type}/{subtype}");
- }
-
- string path = FileSystem.BasePath + sourcePath;
-
- if (sourceStream == null && sourcePath != "") // We need to read it
- {
- if (!File.Exists(path))
- {
- if (createOnFail)
- {
- System.IO.Directory.CreateDirectory(Path.GetDirectoryName(path));
- sourceStream = File.Create(path);
- }
- }
- else
- {
- sourceStream = File.Open(path, FileMode.Open, FileAccess.ReadWrite);
- }
-
- if (sourceStream == null)
- {
- throw new SynthesisException("Source stream for import is empty");
- }
- }
-
- Asset? newAsset = AssetHandlers[type][subtype](name, perm, path, args);
-
- if (newAsset == null)
- {
- return null;
- }
-
- EventBus.EventBus.Push(AssetImportEvent.Tag, new AssetImportEvent(name, targetPath, type + "/" + subtype));
-
- if (lazyImport)
- {
- if (sourceStream == null) {
- // I have no clue if this is true but apparently so.
- throw new Exception("Cannot load a lazy asset without a source stream.");
- }
- LazyAsset lazyAsset = new LazyAsset(newAsset, sourceStream, targetPath);
- return (Asset?)FileSystem.AddEntry(targetPath, lazyAsset.Load(new byte[0]));
- }
-
- byte[] data = new byte[0];
- if (sourceStream != null)
- {
- int streamLength = (int)sourceStream.Length;
-
- data = new byte[streamLength];
- sourceStream.Read(data, 0, streamLength);
-
- sourceStream.Close();
- }
-
- // TODO make it so we don't have to allocate twice the size of the asset every
- // time we import it (i.e. a 500 KB asset will result in 1000 KB of allocation)
- return (Asset?)FileSystem.AddEntry(targetPath, newAsset.Load(data));
- }
-
- public static readonly Inner InnerInstance = new Inner();
- }
- private static Inner InnerInstance => Inner.InnerInstance;
- }
-}
\ No newline at end of file
diff --git a/api/Api/AssetManager/AudioClipAsset.cs b/api/Api/AssetManager/AudioClipAsset.cs
deleted file mode 100644
index d34e3b17db..0000000000
--- a/api/Api/AssetManager/AudioClipAsset.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using SynthesisAPI.VirtualFileSystem;
-using System.IO;
-using UnityEngine;
-using UnityEngine.Networking;
-
-#nullable enable
-
-namespace SynthesisAPI.AssetManager
-{
- public class AudioClipAsset : Asset
- {
- private AudioClip _clip;
-
- // this should always return a clip but it's up to the user to decide if it's valid
- internal AudioClip GetClip() => _clip;
-
- public AudioClipAsset(string name, Permissions perm, string sourcePath)
- {
- Init(name, perm, sourcePath);
-
- // create empty clip
- _clip = AudioClip.Create("EmptyClip", 44100, 1, 44100, false);
- float[] data = new float[44100];
- _clip.SetData(data, 0);
- }
-
- public override IEntry Load(byte[] data)
- {
- string tempFile = Path.GetTempPath() + "\\synthesis_temp.wav";
- File.WriteAllBytes(tempFile, data);
- var request = UnityWebRequestMultimedia.GetAudioClip(tempFile, AudioType.WAV);
- var handle = request.SendWebRequest();
- while (!handle.isDone)
- _ = 0; //
- _clip = DownloadHandlerAudioClip.GetContent(request);
- return this;
- }
- }
-}
diff --git a/api/Api/AssetManager/BinaryAsset.cs b/api/Api/AssetManager/BinaryAsset.cs
deleted file mode 100644
index 43fdadc0db..0000000000
--- a/api/Api/AssetManager/BinaryAsset.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using SynthesisAPI.Utilities;
-using SynthesisAPI.VirtualFileSystem;
-using System;
-using System.IO;
-using System.Threading;
-
-#nullable enable
-
-namespace SynthesisAPI.AssetManager
-{
- ///
- /// Representation of a binary asset
- ///
- public class BinaryAsset : Asset
- {
- private readonly Stream _stream;
- private SharedBinaryStream SharedStream { get; set; } = null!;
- private readonly ReaderWriterLockSlim _rwLock;
-
- public BinaryAsset(string name, Permissions perm, string sourcePath)
- {
- Init(name, perm, sourcePath);
- _rwLock = new ReaderWriterLockSlim();
- _stream = new MemoryStream();
- }
-
- [ExposedApi]
- public void SaveToFile()
- {
- using var _ = ApiCallSource.StartExternalCall();
- SaveToFileInner();
- }
-
- private void SaveToFileInner()
- {
- ApiCallSource.AssertAccess(Permissions, Access.Write);
-
- long pos = SharedStream.Stream.Position;
- SharedStream.Seek(0);
- File.WriteAllBytes(SourcePath, SharedStream.ReadToEnd());
- SharedStream.Seek(pos);
- }
-
- public override IEntry Load(byte[] data)
- {
- _stream.Write(data, 0, data.Length);
- _stream.Position = 0;
- SharedStream = new SharedBinaryStream(_stream, _rwLock);
-
- return this;
- }
-
- [ExposedApi]
- public byte[]? ReadToEnd()
- {
- using var _ = ApiCallSource.StartExternalCall();
- return ReadToEndInner();
- }
-
- internal byte[]? ReadToEndInner()
- {
- ApiCallSource.AssertAccess(Permissions, Access.Read);
- return SharedStream?.ReadToEnd();
- }
-
- internal override void DeleteInner()
- {
- base.DeleteInner();
- _stream.Close();
- }
- }
-}
diff --git a/api/Api/AssetManager/GltfAsset.cs b/api/Api/AssetManager/GltfAsset.cs
deleted file mode 100644
index 4769ba2d6d..0000000000
--- a/api/Api/AssetManager/GltfAsset.cs
+++ /dev/null
@@ -1,329 +0,0 @@
-using System.Collections.Generic;
-using System;
-using System.IO;
-using SynthesisAPI.VirtualFileSystem;
-// using SharpGLTF.Schema2;
-using SynthesisAPI.Utilities;
-using SynthesisAPI.EnvironmentManager;
-using System.Linq;
-using MathNet.Spatial.Euclidean;
-// using SharpGLTF.IO;
-using SynthesisAPI.EventBus;
-using SynthesisAPI.EnvironmentManager.Components;
-// using Mesh = SharpGLTF.Schema2.Mesh;
-
-namespace SynthesisAPI.AssetManager
-{
- // public class GltfAsset : Asset
- // {
- // private string OFFICIAL_TRACKING_CODE = "228533714";
- //
- // private ModelRoot model = null;
- // private static int modelCounter = 0;
- // private static long triangleCount = 0;
- //
- // public GltfAsset(string name, Permissions perm, string sourcePath)
- // {
- // Init(name, perm, sourcePath);
- // }
- //
- // public override IEntry Load(byte[] data)
- // {
- // var stream = new MemoryStream();
- // stream.Write(data, 0, data.Length);
- // stream.Position = 0;
- //
- // GetModelInfo(stream, true);
- //
- // return this;
- // }
- //
- // private void GetModelInfo(MemoryStream stream, bool tryFix = false)
- // {
- // try
- // {
- // var settings = tryFix ? SharpGLTF.Validation.ValidationMode.TryFix : SharpGLTF.Validation.ValidationMode.Strict;
- //
- // model = ModelRoot.ReadGLB(stream, settings);
- // }
- // catch (Exception)
- // {
- // Logger.Log($"GLTF asset \"{Name}\" either could not be read or could not be interpretted", LogLevel.Error);
- // }
- // }
- //
- // #region Object Bundle
- //
- // public static implicit operator Bundle(GltfAsset gltfAsset) => gltfAsset.Parse();
- //
- // private Dictionary> preprocessedJoints;
- // private Dictionary rigidbodies;
- // private List<(EnvironmentManager.Components.Rigidbody, EnvironmentManager.Components.Rigidbody)> defaultRigidjoints;
- // private List exporterType;
- // private bool rigidbodyPresent;
- // public Bundle Parse()
- // {
- // if (model == null) return null;
- //
- // triangleCount = 0;
- //
- // preprocessedJoints = new Dictionary>();
- // rigidbodies = new Dictionary();
- // defaultRigidjoints = new List<(EnvironmentManager.Components.Rigidbody, EnvironmentManager.Components.Rigidbody)>();
- // exporterType = new List