Code Monkey home page Code Monkey logo

simunex's Introduction

Unity version Repo size GitHub issues GitHub last development commit


A modular high-fidelity dynamic simulation framework that runs on top of Unity.


SimuNEX

SimuNEX is a high-fidelity dynamic simulation framework designed as a modular platform to simulate dynamic systems across various domains. It serves as a powerful tool for researchers, engineering students, and members of the Intelligent Systems Lab, offering a versatile environment for simulating complex systems and phenomena.

Getting Started

  1. Install Unity: The project is currently developed in Unity 2022.3.10f1 but it may be compatible with other versions.
  2. Clone Repository: Use your preferred Git client to clone the repository from its GitHub page.
  3. Open in Unity Editor: This is done by adding the \UnityProject folder in the Unity Editor. You're now all set to start building and simulating dynamic systems!

For any additional details, configurations, or advanced setups, refer to the documentation.

Features

SimuNEX is in its early stages of development and is only usable through the Unity Editor, offering interfaces for building dynamic systems similar to an API. Currently, the following features are available:

  • Simulation of single rigid body systems including quadcopters and AUVs (autonomous underwater vehicles).
  • Reactive and event-driven simulation - constructed objects can have their properties modified and the changes occur immediately during simulation.
  • Environment-based force system where forces are automatically applied to systems within a boundary and removed when exiting the boundary.
  • A generic interface that can be used to incorporate different actuators, sensors, loads, and communication components into the system.
  • Functional interfaces have been established for actuators such as motors and loads like propellers.
  • Automated detection of actuators and sensors with supervisory systems.
  • Fault injection for actuators and sensors, including a user-friendly menus for adding and removing faults.
  • Support for ROS 2 integration ensures compatibility with current robotics systems.
  • Interfaces have also been created for modeling state-space systems, which are widely employed in control theory.
  • Various integrating techniques including Euler, Heun, and RK4 steppers are implemented for accurate simulation of dynamical systems.
  • A high performance matrix library built on top of eigen3 is incorporated to handle different state-spaces and functionals within the system efficiently.

For upcoming plans and features, please check out the ongoing projects.

Model Examples


Quadcopter


AUV


Mars Rover
3D Model by NASA.

Quadruped Robot



Multi-stage Rocket
3D Model by Stanley Creative.

Documentation

Our project documentation is hosted on Render and is structured as follows:

  • User Documentation: Accessible from the root URL https://simunex-web.onrender.com. This section contains guides, tutorials, and general information about the project.
  • Developer Documentation: Accessible at https://simunex-web.onrender.com/dev/. This section, generated by Doxygen, includes detailed API documentation and is intended for developers working with or contributing to the project.

Hosting Documentation Locally

To host the documentation locally, you'll need Docker installed on your system as it provides an isolated environment with all necessary dependencies. The documentation can be hosted using helper scripts included in the repository. Here's how to do it:

  1. Install Docker: Ensure Docker is installed on your system. Visit the Docker Installation Guide for instructions.

  2. Clone the Repository: If you haven't already, clone the repository to your local machine:

    git clone https://github.com/intelligent-systems-lab-org/SimuNEX.git
    cd SimuNEX
  3. Run the Build Script: Use the build_docs.sh script (or build_docs.bat on Windows) to build the Docker image and optionally run the container. This script updates the documentation version using the version specified in package.json, builds the Docker image that contains Sphinx and Doxygen documentation, and optionally runs the container locally. To build the Docker image and run the container (making the documentation available on localhost):

./build_docs.sh --host
  1. Accessing Documentation Locally: Once the container is running, you can access the user documentation at http://localhost and the developer documentation at http://localhost/dev/.

Notes

  • The build_docs.sh script automates the process of setting up and serving the documentation locally. It requires Docker to be installed because it builds the documentation inside Docker containers to ensure a consistent environment.
  • Running the script with the --host flag will start the Docker containers and serve the documentation on your local machine. Without the flag, it will only update the versions in the Doxyfile and sphinx's conf.py specified from the package.json file.

Plugins

Name Version Supported OS Purpose URL
ROS2ForUnity 1.1.0 Windows, Linux Communication using ROS 21 link
Eigen 3.4.0 Windows2 For matrix operations link
ErrorProne.NET.CoreAnalyzers 0.1.2 Windows For code analysis and Roslyn support3 link
NSubstitute (experimental) 5.1.0 Windows, Linux For mock testing link

ROS on Windows

ROS 2 was tested on Windows, the ROSOnWindows binary was installed, which can be found here. This binary is provided by Microsoft's IoT team and is designed to simplify the installation process for ROS 2 on Windows. Credit should be given to the ms-iot team for their work on the binary, and their repository can be found here.

License

SimuNEX© 2022-2023 by Lee Bissessar, Intelligent Systems Lab (ISL) is licensed under the SimuNEX License.

Under this license, users may utilize the software for personal or educational purposes and are granted permission to modify and redistribute the software freely, subject to certain conditions outlined in the full license. These conditions include restrictions against commercial and military use, requirements for attribution, and guidelines for redistribution of altered versions.

Please note that the SimuNEX License supersedes the previous CC-BY-NC-SA-4 International License. For a detailed overview of the terms and conditions, please refer to the LICENSE file.

Footnotes

  1. Currently on Foxy installations only.

  2. Custom C# bindings that only currently support Windows. Separately maintained in another repository. See here.

  3. Functions with Visual Studio 2022.

simunex's People

Contributors

leebissessar5 avatar

Stargazers

 avatar

Watchers

 avatar

simunex's Issues

ROS 2 Communication does not work on Build

There is an ongoing issue with the build system, which is crucial for creating SimuNEX executables.

This issue relates only to ROS 2 since it is currently the only communication "protocol" (ROS 2 is actually a middleware, not really a protocol).

Upon building the demos, it seems that the topics created by the COMSystem with the ROS 2 Connector do not initialize at runtime.

This issue should be fixed ASAP.

Implement Validation Tests for Integrators

We have successfully encapsulated the Euler, Heun, and RK4 methods within our Integrator class. The unit testing framework we've constructed provides a robust preliminary examination of these methods across a set of three ODEs, benchmarking them against known solutions. However, this current setup predominantly confirms the capability of these solvers in handling ODEs, but it falls short of affirming the correct implementation of each individual integrator method.

To guarantee the correct implementation of our integrators, we need to add validation tests specific to each method. Here are some suggestions:

  1. Analytical Comparisons:

    • For simple ODEs with known analytical solutions, compare the numerical results from every integrator with their exact solutions.
    • Calculate and document errors such as absolute or relative error for various step sizes.
  2. Method-Specific Properties:

    • Confirm Euler's first-order accuracy, Heun's second-order accuracy, and RK4's fourth-order accuracy.
    • Also, test stability properties under different conditions.
  3. Comparisons with Established Libraries:

    • Contrast the solutions derived from our integrators with those obtained from well-regarded numerical libraries.
    • Document any discrepancies and address significant deviations that arise.

This initiative aims to provide a more meticulous validation of our integrators, ensuring that each method is accurately implemented and performs reliably under a broad spectrum of conditions. Your insights and contributions towards this goal are highly valued.

Looking forward to your constructive feedback and collaboration on this endeavor.

Simulate a AUV in SimuNEX

An AUV (Autonomous Underwater Vehicle) is a class of UUVs (Unmanned Underwater Vehicles) that can be considered an underwater counterpart of an UAV (Unmanned Aerial Vehicle). As they operate underwater, they experience a multitude of environmental forces such as drag, lift, buoyancy, and added mass.

Added mass is a unique force that acts on the acceleration of the moving body. Since the magnitude can vary across DOF, the simplest way to implement an acceleration-based force is by using a mass matrix $M$ and operating the physics engine in acceleration force mode by using the formula: $a = M^{-1} \times F$, where $F$ is the 6DOF applied force and $a$ is the 6DOF acceleration.

New to SimuNEX is the implementation of control surfaces such as fins which allow for movement underwater along with propulsion. Just like the PropellerFunction, an equivalent FinFunction would be implemented for fin dynamics as a MotorLoad object.

TODO

  • Implement drag forces (linear, quadratic, cross-drag etc) (see 5028e87)
  • Implement buoyancy (see 222f3c5)
  • Implement fin forces (see 576f66c)
  • Implement added mass forces (see 3f073b9)

Implement Actuator and Sensor Faults

Actuators and sensors play crucial roles in SimuNEX. By adding faults to both systems, it enhances the realism and variability of simulation scenarios and thus the fidelity of the simulator.

TODO:

  • Implement a system that "marks" and captures specific variables in an Actuator and Sensor as Faultable.
  • Implement FaultSystem* interface - this is for storing faults for each variable.
  • Implement the editing of faults in the Unity Editor.
  • Implement various types of faults including bias, scale, gaussian, dead zone, etc.

Implement Communication Interface

Implement communication mechanisms with external entities. Only ROS 2 would be sufficient to complete the task. No need for packet loss functionality yet.

TODO:

  • COMSystem and COMProtocol classes (implemented and test on bd69ad0)

Include Eigen C++ Library for Matrix Operations in Unity

Objective:
To integrate the Eigen C++ Library into the Unity framework for efficient matrix operations and advanced mathematical functionalities.

Background:
Unity lacks an efficient and transparent mechanism for intricate matrix operations. The Eigen C++ Library is widely used in high-performance applications, including TensorFlow and DART Physics. The inclusion of Eigen will bring transparency and reliability, which are vital for precision and repeatability in simulations, a shortfall observed in libraries like MathNet (which has been tried previously but was unsuccessful due to NuGet inconsistencies with Unity).

TODOS: (Do not tick unless there is an associated passing unit test)

  • Implement base constructor for a 1D array with column and row-major options (see 3a8687e)
  • Implement constructor for a 2D array (see 23d607c).
  • Implement function that formats a matrix to string
  • Implement matrix multiplication
  • Implement transpose (in place and copy) (see 0561b15)
  • Implement matrix addition and subtraction (see ae8b3fe)
  • Implement equality operators (see 0c28743)
  • Implement ordinary inverse (see d62cc11)
  • Implement identity (see 388b5cf)
  • Implement scalar multiplication (see a1c55c6)
  • Implement conversions to 1D and 2D arrays (see 78438d2 for 1D, 16b8821 for 2D)
  • Implement copy constructor (see 23b2516)

Exceptions
Exception handling is not needed at this stage in the interest of deadlines. However, at a later point in time, it will be mandatory to implement.

Deliverables:
A robust integration of the Eigen C++ Library into Unity, enabling high-performance matrix operations, enhancing algorithm efficiency, and paving the way for advanced mathematical and physics-based simulations in the Unity environment.

Difficulties with `checkout` Action: Lack of Clarity on Failures

In our CI/CD pipeline, the checkout GH action is a crucial for fetching the repository content into the runner environment. However, we've encountered situations where the action fails or behaves unexpectedly, and the logs do not provide sufficient detail to understand the root cause.

The checkout action was tested with v2-v4, all of which result in the same error: (Error: fatal: could not read Username for 'https://github.com': terminal prompts disabled), with various solutions tried but all of failed to work.

We are looking into an alternative workflow (e.g., CircleCI) and any contributions would be appreciated.

Implement Motor Functionality

Implement an interface and also models for simulating motors.

TODO

  • Motor interface
  • Identity, DC, PMSM motor models (complete as of 73cac1b)
  • StateSpace and Integrator interfaces (see bc49551)

Rework CoordinateFrame System

See 395919d.

A major change to the way forces is applied is necessary because of this issue.

One way I'm thinking of is have a Vector6DOF store a CoordinateFrame object which indicates its frame of reference. Then provide two methods to convert between frames and given a Vector6DOF is already in a specific CoordinateFrame, then do not apply.

Implement Environmental Fields

Description:

To implement a system of environment fields and forces to simulate various physical phenomena in SimuNEX.

A proof of concept is where an environment is defined as a specific space where these forces are applicable. Outside of the field, the forces are absent. Examples include gravitational fields and buoyancy when submerged in a fluid.

TODO:

  • RigidBodyF

    • A specialized class derived from RigidBody that contains relevant fluid properties such as volume, etc.
  • Environment Class:

    • This class should handle the registration and deregistration of objects within a defined boundary or area.
    • It should provide methods or mechanisms to apply forces or effects to objects within its boundaries.
  • ForceField Class:

    • This should be an abstract base class that provides a template for specific force fields.
    • It should define the core functionalities like applying and removing forces on objects.
  • SimpleGravity:

    • Implement a class that simulates the gravitational force.
    • This force should be constant and act in a specified direction.
  • SimpleBuoyancy:

    • Implement a class that simulates the buoyant force, which is felt by objects submerged in a fluid.
    • Should account for factors like the density of the fluid, the volume of the object submerged, etc.
  • SimpleGravityField:

    • Implement a force field that applies the simple gravity force to objects within its boundaries.
  • SimpleBuoyancyField:

    • Implement a force field that applies the buoyant force to objects submerged in a fluid within its boundaries.

Exception Handling for Eigen3

When implementing interoperability with eigen3 in C#, unit tests were conducted without considering exceptions in interest of time. For example, adding matrices of unequal size, multiplying matrices with incompatible sizes, inverse on a non-square matrix, etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.