Giter VIP home page Giter VIP logo

crane3dplugin's Introduction

3D Crane physics model plugin for Unreal Engine 4

This repository contains a portable C++17 library for simulation INTECO 3DCrane and necessary Unreal Engine 4 bindings for visualization. For detailed description of this library, you can read the Diploma Thesis in Estonian Jorma_Rebane_Diplomitoo.pdf

You should also take a look at a simple project which uses this plugin: CraneVR

Image of 3DCrane

Setting up a basic build environment

The original version is built and tested with Visual Studio 2017, using C++17. For testing the plugin in a standalone console application, you can open Tests/Crane3dPluginTests.sln

How to add this to my project?

Simply add this plugin into YourProject/Plugins/Crane3dPlugin and compile your UE4 C++ project. The plugin and all its components are then accessible in the UE4 Editor after relaunching.

Alternatively after adding the plugin you can right click on YourProject.uproject and select "Generate Visual Studio project files" and then build everything through YourProject.sln.

How does this plugin work?

The simplistic overview of this simulation model is displayed in the following image. USimulationComponent sends appropriate inputs from UE4 and configures any parameters during runtime. During TickComponent, we call Model::UpdateFixed which will advance the simulation and returns the new observable state of the crane.

Arhitecture

How do I add new simulation implementations?

First you need to create a new class and inherit from crane3d::IModelImplementation. And of course implement the behaviour of Update and GetState(). You can see existing implementations in ModelImplementation.cpp

    class MyCustomLinearModel : public crane3d::IModelImplementation
    {
    public:
        using IModelImplementation::IModelImplementation;
        string Name() const override { return "MyLinearModel"; }
        void Update(double dt, Force Frail, Force Fcart, Force Fwind) override;
        CraneState GetState() const override;
    };

Then you can add your implementation to the crane model:

crane3d::Model model;
model.AddModel(std::make_shared<MyCustomLinearModel>(model));

In order to understand the existing physics components Rail(X), Cart(Y), Line(R), Alfa, Beta, then more in-depth analysis of the 3DCrane mathematical model is required. The following illustration from the diploma thesis describes the relations between the components. It must be mentioned that Alfa is part of the spherical coordinate system, so the angle is between Y axis and the cable itself.

3DCrane

How do I control the crane so it will follow a pattern?

For this purpose, you must include CraneController.h and use it to drive the simulation:

    crane3d::CraneController controller {&model};
    controller.SetDrivingForces(34_N, 30_N, 34_N);
    controller.SetWayPoints({
        {-0.3,  0.0,  0.5, 0, 1},
        {+0.3,  0.0,  0.5, 0, 1},
        { 0.0,  0.0,  0.5, 0, 1},

        { 0.0, -0.35, 0.5, 0, 1},
        { 0.0, +0.35, 0.5, 0, 1},
        { 0.0,  0.0,  0.5, 0, 1},
    });
    controller.Run(0.001, 12.0); // run for 12 seconds with a 0.001 timestep

This is a very basic waypoint-following controller that could need a lot of improvement.

How do I test without Unreal Engine 4?

The testing console application is created to allow quick iteration and debugging. The next step after debugging is recording your simulation to a CSV file, so you can generate a nice graph in Excel. Unfortunately there are no unit tests for this project.

    crane3d::Model model { "NonLinearComplete" };
    model.SetOutputCsv("NonLinear_Cross_12s_34N.csv");
    
    using namespace crane3d::literals;
    model.UpdateFixed(0.001, 3.0, 34_N, 0_N, 0_N);

Is this everything that is needed?

Not quite. This is a minimal implementation with many useful utilities, but there are many things that can be improved upon:

  • Keeping state inside the models to allow different physics component systems
  • Resetting each model separately to their default configuration and initializing them on the fly
  • Implementing a 3D vector based model
  • Expanding the CraneController to make stabilizing control algorithm development convenient

All in all there is a lot to improve!

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.