Announcement

Collapse
No announcement yet.

[OPEN-SOURCE] Machinery Modelling Toolkit

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Hi there,
    I'm trying to move my tank-sim project from Unity to Unreal, and I'm using ModularDriveTrainV2 as a base. Track behaviour and physics looks great, but I would like to use my own input and engine model. So as an output I have engine torque and clutch and brake value for both tracks, and now I'm having hard time looking where to input them into your blueprints. I'm pretty new to Unreal and blueprint scripting so I could use a hint!
    Thanks in advance .

    Comment


      Originally posted by NiqonNO View Post
      Hi there,
      I'm trying to move my tank-sim project from Unity to Unreal, and I'm using ModularDriveTrainV2 as a base. Track behaviour and physics looks great, but I would like to use my own input and engine model. So as an output I have engine torque and clutch and brake value for both tracks, and now I'm having hard time looking where to input them into your blueprints. I'm pretty new to Unreal and blueprint scripting so I could use a hint!
      Thanks in advance .
      TrackTransmissionModuleR/L are the components that you need to provide input to. They have their own brakes and they integrate angular velocity of the sprocket. Their base class is TrackTransmissionProcessorModular and it implements interface that allows it to receive Torque/MomentOfInertia/AngularVelocity from other parts of drive train and send the same data back when requested.
      There was a bit of discussion about this starting from previous page of this thread.
      Youtube Channel

      Comment


        Originally posted by OldRaven View Post
        I always make everything myself.
        Just the current low res version, like your own examples.
        In this case I don't see any issues with adding Tiger into MMT - I hope it will be easier to keep it up-to-date this way.

        4.16 transition is not going smooth - can't open any other map besides MainMenu or LandVehicles in packaged project.
        Code:
        [2017.06.10-16.59.50:094][306]LogPackageName: SearchForPackageOnDisk took   0.028s, but failed to resolve Airplanes.umap.
        [2017.06.10-16.59.50:094][306]LogGameMode:Display: Match State Changed from InProgress to LeavingMap
        [2017.06.10-16.59.50:094][306]LogGameState: Match State Changed from InProgress to LeavingMap
        [2017.06.10-16.59.50:123][306]LogPackageName: SearchForPackageOnDisk took   0.028s, but failed to resolve Airplanes.umap.
        [2017.06.10-16.59.50:123][306]LogNet: Browse: /Game/Maps/MainMenu
        [2017.06.10-16.59.50:123][306]LogNet:Warning: Travel Failure: [InvalidURL]: Invalid URL: /Game/Maps/MainMenu
        [2017.06.10-16.59.50:123][306]LogNet: TravelFailure: InvalidURL, Reason for Failure: 'Invalid URL: /Game/Maps/MainMenu'
        [2017.06.10-16.59.50:123][306]LogGameMode:Display: Match State Changed from LeavingMap to Aborted
        [2017.06.10-16.59.50:123][306]LogGameState: Match State Changed from LeavingMap to Aborted
        Youtube Channel

        Comment


          Found what the issue was - there is new tab in Project Settings - Asset Manager. After adding maps, that should be packaged, manually in Asset Manager, they where finally cooked and now everything works.
          There are still warnings about some missing variables, divisions by zero and constraint components - I'll fix them later but right now uploading 4.16 version to github.
          Youtube Channel

          Comment


            Fixed Fokker D1 - apparently pitching moment calculation and application was all wrong, fixed it and re-balanced wings a bit. Now it flies much better.
            Youtube Channel

            Comment


              Hi BoredEngineer, I've been playing around with your plugin for a few weeks and I have to say it's awesome! I followed Raven's guide to get my first tank up and running using the M113 model. I used your movement, tracks and suspension and inherited all that behavior from MMPawn into my own tank base class that contained some basic AI & Turret/Barrel movement etc. This worked really well, my classes were able to run on top of your MMPawn class without any issues besides a few variable renaming.

              I am now trying to make an Abrams tank but use the T26 base instead of the M113. I think I'm really close to having it hooked (I think) but there's no guide so I've been trying and failing until something works. There's some weird behavior that I am not sure what it could be. I am going to outline my process I used so far first and then present the weird behavior. It's likely something super simple, but I've been looking and I can't seem to see it.

              So I chose to use the ModularDriveTrainV2 to base the Abrams tank off of. Reason for this was because the suspension implemented in the example was "somewhat" close to what I would need (it didn't have the little suspension pieces that the T26 normally does at the bottom) and I thought that removing the modular drive and replacing it with the arcade movement would be easier than the other way around if I had chosen to base it off LightTankPureBP. I'm not sure if this was the right call.

              Click image for larger version

Name:	tank1.JPG
Views:	1
Size:	58.9 KB
ID:	1129746

              This is what I ended up with after removing the modular drive, adding wheels ( to make them fit I just scaled the entire wheel hierarchy to 2.1/2.1/2.1, not sure if this is wrong vs using the linear limit or something (linear limit is set to 15 right now)) and adding all the necessary array elements to update TrackAnimationDriveR / TrackAnimationDriveL.

              Front view after adding the physics wheels and updating splines:
              Click image for larger version

Name:	tank5.JPG
Views:	1
Size:	56.2 KB
ID:	1129750

              TrackAnimationDriveR/L:
              Click image for larger version

Name:	tank2.JPG
Views:	1
Size:	92.6 KB
ID:	1129747Click image for larger version

Name:	tank3.JPG
Views:	1
Size:	86.9 KB
ID:	1129748

              RoadWheelPhys01R (Static Mesh Component):
              Click image for larger version

Name:	tank4.JPG
Views:	1
Size:	84.2 KB
ID:	1129749

              RoadWheelTAF01R ( Track Anisotropic Friction):
              Click image for larger version

Name:	tank6.JPG
Views:	1
Size:	56.8 KB
ID:	1129751

              RoadWheelPhys01PCR ( Physics Constraint Component):
              Click image for larger version

Name:	tank7.JPG
Views:	1
Size:	66.9 KB
ID:	1129752

              UpdateFriction / ResetFriction functions updated:
              Click image for larger version

Name:	tank9.JPG
Views:	1
Size:	201.3 KB
ID:	1129753
              Click image for larger version

Name:	tank13.JPG
Views:	1
Size:	298.0 KB
ID:	1129757


              To update the functions above and the Event Graph below I copied the way LightTankPureBP was implemented.

              Event Graph:

              The movement/input portion of the top of the event graph looks just like LightTankPureBP, I did not want to add 4 more pictures just to cover this as it's identical.

              I also added six (one for each new wheel ) of the OnComponentHit nodes:
              Click image for larger version

Name:	tank10.JPG
Views:	1
Size:	231.0 KB
ID:	1129754

              I think those are all the adjustments I made so far (I think, it's hard to remember back to all the minor changes I made along the way but those should be the main ones) and in view port this is what the tracks look like:

              Click image for larger version

Name:	tank11.JPG
Views:	1
Size:	137.6 KB
ID:	1129755


              PROBLEM:

              However, when I press play and possess the vehicle the wheels and track act really strange and I'm having a difficult time figuring out where I screwed up. Basically, the wheels are jittery, they do not line up correctly and the track goes all crazy. The tank moves ever so slightly if I hold down the throttle but for the most part the wheels just spin and the tank stays in place. I feel like there's a fundamental lack of understanding of the principles behind the physics involved here that I'm not getting so I am not able to configure it right. This is what it looks like, the spockets and wheels spin, the track moves as well but as you can see not exactly correctly:

              Click image for larger version

Name:	tank12.JPG
Views:	1
Size:	36.2 KB
ID:	1129756

              Any help is appreciated! It would be nice it this could turn this into a short "how to guide" to better understand how to utilize your new implementations with various different chassis types and wheel configurations. Again, this is an amazing plugin and I just want to thank you again for your contribution, cheers.
              Last edited by kensai01; 06-15-2017, 05:57 PM.

              Comment


                [MENTION=116099]kensai01[/MENTION]
                There are two principally different ways how suspension of the tank can be setup in MMT - rigid body physics wheels with constraints or "traces" suspension. As far as I see, you are using rigid body wheels. This was old approach I've experimented with and later switched to traced suspension. The main reason is because I couldn't avoid small jittering of the wheels even when everything is setup correctly. Another issue is performance impact - constraints and rigid bodies are quite expensive compared to raytraces or sweeps.

                Anyway, as you have it setup already, it makes sense to try this approach.
                It looks lovely is you are using old friction components and this has to be changed. But first, disable friction calculations and check if suspension works correctly - maybe wheels collide with each other or constraint force is too weak/strong.
                Youtube Channel

                Comment


                  To disable collision between wheels, select all physics wheels with cntrl (blue wireframe meshes), open Collision Preset in Collision tab and set their Object Type to wheels, make sure that in the list of collision channels Wheels and Chassis are set to Ignore. This way physics wheels should just clip through each other and chassis without collision.
                  Youtube Channel

                  Comment


                    So I will do this one step at a time to see any changes each step makes. I removed the collision from the wheels and it seems to have fixed the jitteryness / misalignment of the wheels. The track is still screwed up. Here's what it looks like now after just changing the collision tab of the physics wheels:

                    Click image for larger version

Name:	tank14.JPG
Views:	1
Size:	64.2 KB
ID:	1129837

                    I'm now going to start working on replacing the old friction components, can you elaborate a bit more on that? I saw a few pages back a post on how to set up Anisotropic Traction, is that what you are referring to - if so, would following those posts be what I would need to do? I will try that & play with it myself and report back.

                    Side note, when I press the forward button, all the wheels turn but some are turning clockwise and others counter clockwise, I don't see any particular pattern. I assume I just need to orient them correctly on their axis so they all face the right way. I'm going to look into this as well now.

                    Comment


                      Originally posted by kensai01 View Post
                      So I will do this one step at a time to see any changes each step makes. I removed the collision from the wheels and it seems to have fixed the jitteryness / misalignment of the wheels. The track is still screwed up. Here's what it looks like now after just changing the collision tab of the physics wheels:

                      [ATTACH=CONFIG]145305[/ATTACH]

                      I'm now going to start working on replacing the old friction components, can you elaborate a bit more on that? I saw a few pages back a post on how to set up Anisotropic Traction, is that what you are referring to - if so, would following those posts be what I would need to do? I will try that & play with it myself and report back.

                      Side note, when I press the forward button, all the wheels turn but some are turning clockwise and others counter clockwise, I don't see any particular pattern. I assume I just need to orient them correctly on their axis so they all face the right way. I'm going to look into this as well now.
                      Tracks
                      The issue with track is in which spline points of the track are binding to which wheels. If you are using TrackAnimationDrive component then settings look like this:
                      Click image for larger version

Name:	TrackAnimationDrive - spline points.JPG
Views:	1
Size:	49.8 KB
ID:	1129859

                      If you are using new component - MMT Track Animation Component then settings are these:
                      Click image for larger version

Name:	TrackAnimationComponent- Spline points.JPG
Views:	1
Size:	59.1 KB
ID:	1129860

                      So what you need to do is set proper spline point index and name of the physical wheel it should be using. If you look at how splines are made on example vehicles, you'll see that control points of the splines are aligned with wheels. So if your 5-th control point is under the first wheel, then you will have something like
                      Point Index: 4 (count starts from 0)
                      Mesh Name: PhysicsWheelLeft01
                      Socket Name: MyTreadSocket

                      Socket is placed on the wheel mesh itself and its offset to a position where track should pass. In case of existing meshes that you use, socket is inside of the mesh as physics mesh is thick enough to cover both roadwheel and track.

                      Check LightTankTraceWheelsWithAnimBPPrototype in the Land Vehicles level, as example of how to use new track animation component (MMT Track Animation Component), which is improved and ported to c++ version of previous component.

                      Friction
                      What you need is MMTFrictionComponent - it's a an optimized c++ implementation of the old BP code with plenty of fixes and issues solved. The usage is very similar to old component but as example you can use LightTankTraceWheelsWithAnimBPPrototype. It uses raytraces for roadwheels but Sprocket and Idler are using rigid bodies, just as in your setup. So you will use OnComponentHit events to pass contact information to friction component.

                      Roadwheels rotation
                      Most likely some of the wheels are rotated 180 degrees or "Flip Rotation" is set to true (or should be set to true) in TrackAnimationDrive component. You can see that option on the screenshots above.
                      Last edited by BoredEngineer; 06-18-2017, 07:11 AM.
                      Youtube Channel

                      Comment


                        Update

                        Added Anti-roll bar support for Suspension Stack component.
                        Anti-roll force is not calculated inside of the component but in BP that communicates between suspension stacks on the same axis:
                        Click image for larger version

Name:	AntiRollBar_1_Setup.JPG
Views:	1
Size:	109.4 KB
ID:	1129861

                        AntiRollRatio is clamped to 0..1 range, where at 0 no Anti-Roll force will be applied and at 1 there will be virtually no body rocking as full anti-roll force will be applied. Keep it lower than 1 if you want a bit more dynamic driving experience (vehicle tilting in turns) or set it to 1 if you need a perfectly balanced suspension.

                        The function itself uses suspension forces of each individual stack and Anti-Roll ratio to calculate appropriate anti-roll force:
                        Click image for larger version

Name:	AntiRollBar_2_Function.JPG
Views:	1
Size:	133.9 KB
ID:	1129862

                        Anti-roll force is applied separately from suspension force. For this to work, new function in suspension component had to be made - ApplyAntiRollForce() , so you have to use latest version of the Plugin or Content to be able to call this new function.

                        To see example of how it's used check 4WheeledVehicle in LandVehicles map.
                        Last edited by BoredEngineer; 06-18-2017, 10:41 AM.
                        Youtube Channel

                        Comment


                          Thanks for the detailed reply BoredEngineer. I am going to look into this now and report back. I have the spline points fixed now, it looks good so I will work on porting over the new c++ friction and animation components.

                          For the old ATrackedVehicle based system I have been playing with the suspension parameters and I was able to configure it in a fashion for the Abrams chassis at a weight of 60k that work really well to get over obstacles that fit under the chassis clearance but have a vertical slope such as a step. It took some playing around with the chassis collision box size and position as well as parameters. Basically, originally the tank kept getting stuck on various things in the environment and completely flip or just instantly stop and I wanted to adjust that so it could go over things that are rectangular easily.

                          Click image for larger version

Name:	tank15.JPG
Views:	1
Size:	70.8 KB
ID:	1129869
                          Notice that the first and last wheel on each side have a larger collision radius than the inner wheels. ie. 1st & 7th wheel have a collision radius of 47 and the rest have a collision radius of 43. This helped with going over rectangular bumps.

                          Click image for larger version

Name:	tank16.JPG
Views:	1
Size:	28.9 KB
ID:	1129870 Notice the tank weight of 60k, fairly accurate for the Abrams I think.


                          Click image for larger version

Name:	tank17.JPG
Views:	1
Size:	78.1 KB
ID:	1129871 I trimmed the collision box (green line) so that the front didn't collide before the wheels, this seemed to have a big effect. (In reality, I am not sure if the blue imported collision box is being used too so I don't know if I even need the green collision box but that's besides the point)

                          Here's how it drives now over some rectangular objects:
                          https://youtu.be/x5Pue4R3meo


                          I'm really happy with the way it looks now, some more tweaking needed but generally it performs great!
                          Last edited by kensai01; 06-18-2017, 02:06 PM.

                          Comment


                            I made some progress but I'm a bit stuck again. I updated the spline points so the track draws correctly now.

                            I then swapped out all the wheels with the same implementation that was used for the Idler/Sprocket of the LightTankTraceWheelsWithAnimBPPrototype. I also ported all the functions into blueprint from the LightTankTraceWheelsWithAnimBPPrototype that were related but not the ones that set up the suspension system as I was not using it. The track correctly spins but the wheels do not move, tank does not move either.

                            TrackAnimationDriver (new MMTTrack Animation Comp.) parameters, the animated spline points and track spline points have all been updated:
                            Click image for larger version

Name:	tank18.JPG
Views:	1
Size:	32.5 KB
ID:	1129879

                            RoadWheels Friction component added to all wheels ( new MMTFriction Comp.):
                            Click image for larger version

Name:	tank19.JPG
Views:	1
Size:	32.5 KB
ID:	1129880

                            I made a quick video showing my steps, all the various components parameters and blueprints I updated rather than post a bunch of screen captures. Let me know if that works well for you, I feel bad asking a bunch of questions.

                            Video of the conversion process:
                            https://youtu.be/-sqS7gkXeBE

                            Forgot to show in video, Updated OnHitComponents:
                            Click image for larger version

Name:	tank20.JPG
Views:	1
Size:	126.9 KB
ID:	1129881Click image for larger version

Name:	tank21.JPG
Views:	1
Size:	126.4 KB
ID:	1129882

                            Video of track spinning & wheels not spinning: https://youtu.be/fbN_MKH4zx0


                            I feel like I'm relatively close to getting it working, my instinct tells me that maybe I should be using the new suspension stack but it seems it needs a skeletal animation. Anyhow, I'll continue working on this over the next few days but I have to stop for now so I wanted to show where I'm at.

                            Comment


                              [MENTION=116099]kensai01[/MENTION] Don't worry, you can ask as many question as you want and I'll do my best to answer them. This system is work in progress and I know that it's not obvious how it can be used and which parts are responsible for what. Questions are like feedback - they help me to understand how people interact with the system and it provides insight on what should be changed and improved.

                              Just to clarify, suspension components don't require skeletal meshes or static meshes. Each suspension component calculates position of the center of the wheel and then this information can be retrieved and used with static/skeletal meshes, but it doesn't have too. T-26 (Light Tank) uses skeletal mesh to animate movement of bogies, animation is driven by positions of roadwheels and their position is calculated by suspension component. As another example, look at 4WheeledVehicle example, it uses the same suspension components as Light Tank but has just a single wheel with collision (used for shape sweeps). Visual wheels are just set into position calculated in suspension component.

                              I see couple of issues in your screenshots/video:
                              1) Register Friction Point - this function notifies friction component that there is some contact point with ground or another object and this contact need to be processed. There are two cases when this function is used: on collision events and with suspension components. In your case, as rigid bodies with physics constraints are used, only on collision events case is relevant. Then it's important to have "Treat as Impulse" flag of RegisterFrictionPoint as TRUE because collision force is reported as impulse (Normal Impulse). This flag is set to false when suspension component is used as suspension force is reported as force, not as impulse.

                              2) To get wheels/sprocker/idler rotating you have 2 options:
                              a) if your wheels and sprocket are static meshes (not part of the skeletal mesh) you can add them into array of first parameter in TrackAnimationDriver, called "Sprockets Idlers Roadwheels", you can see it in your screenshots. Then TrackAnimationDrive component should animate them automatically when it updates animation of the track
                              b) in case if you use skeletal mesh (wheels/sprocket/idler are parts of the skeletal mesh), then rotation information have to be manually passed into Animation Blueprint. For this, you can retrieve current angle of rotation of the sprocket from TrackAnimationDrive. This is what T-26 (Light Tank) is using to animate it's wheels/sprocket/idler

                              3) I suspect that you have collision problems because of how springs/drives of physics constraints are working. I see in the video that tank has a very high clearance, compared to what it has in real life. I had the same problem with old version of T-26 that was build using constraints.
                              What is happening is following. You have some limits of how far constraint body is allowed to travel along one of the axis, in relation to some starting point. When body is not moving anywhere and sits next to starting point, spring force is 0. When body is getting closer to the limit of allowed movement, spring force raises linearly until it reaches "Linear Drive Force" that you set as parameter of physics constraint. The problem with this setup is that you need to have some amount of suspension force to hold tank above the ground but it's not clear when you get this force. In theory, if you set "Linear Drive Force" twice of what is needed to hold the tank, then you should get desired amount of force at 50% compression of the suspension. Which means that your suspension travel distance have to be larger than it is on the real tank. In case of double suspension force it needs to be twice the size.
                              So what if we set "Linear Drive Force" three or four times higher than what we need to hold tank? We can do that and we will get require amount of force at 1/3rd or 1/4th of suspension compression, which means we can have a shorter suspension travel (closer to reality). Unfortunately this will have a downside - what if suspension compresses to 90% because tank is going over an obstacle? You will get too much suspension force. If you suspension even more stiff, like 10x required minimal force, it can send tank flying into the air.
                              The solution to this I've implemented in Suspension Stack component. Where spring compression is non-linear and you get required force just after 1cm of compression. After initial compression, force goes up to a user defined value (2-3x higher than required force). This allows to have a precise amount of clearance and stiffness of the suspension. Unfortunately, Suspension Stack currently doesn't work with rigid bodies but I'm planning to add this ability in feature.

                              4) Track Spline Point Locations and Track Spline Point Tangents are optional in new TrackAnimationDrive component. You can edit your spline directly in BP and component will use it as a template for animation. This was not possible in past and this is why those arrays are still there.


                              My conclusion is that "Treat as Impulse" flag of RegisterFrictionPoint is the issue here which prevents tank from driving forward.
                              Youtube Channel

                              Comment


                                Thanks for the detailed reply, it was very informative. Based on your paragraph about suspension systems working multiple ways and after reviewing the 4WheeledVehicle blueprint I decided to scrap my current progress and restart by duplicating the LightTank and reworking it's suspension to match the Abrams. This worked really well. Here's the process if anyone else is interested:

                                I started with LightTankTraceWheelsWithAnimBP, first I immediately removed the skeletal suspension and disconnected the corresponding blueprint links then retested - it still drove. Next I removed the sway links and the corresponding blueprint links, tank still drove.

                                Then I began setting up the tank:
                                Overview:
                                Click image for larger version

Name:	tank22.JPG
Views:	1
Size:	269.1 KB
ID:	1129969
                                Idler, Sprocket setup:
                                In order, Idler Physics Static Mesh, Idler Physics Constraint, MMFriction Component, Static Mesh for the visual of the wheel.
                                Click image for larger version

Name:	Tank23.JPG
Views:	1
Size:	58.6 KB
ID:	1129970Click image for larger version

Name:	Tank24.JPG
Views:	1
Size:	66.2 KB
ID:	1129971Click image for larger version

Name:	Tank25.JPG
Views:	1
Size:	48.4 KB
ID:	1129972Click image for larger version

Name:	Tank26.JPG
Views:	1
Size:	55.1 KB
ID:	1129973

                                Current Suspension Setup (this is the same for all 14 suspension spots):
                                MMTSuspension Stack Component, Static Mesh for physics, MMTFriction Component, Static Mesh for the visual of the wheel
                                Click image for larger version

Name:	Tank27.JPG
Views:	1
Size:	101.8 KB
ID:	1129974Click image for larger version

Name:	Tank28.JPG
Views:	1
Size:	89.4 KB
ID:	1129975Click image for larger version

Name:	Tank29.JPG
Views:	1
Size:	88.0 KB
ID:	1129976Click image for larger version

Name:	Tank30.JPG
Views:	1
Size:	84.6 KB
ID:	1129977

                                Track Animation Left: (right Y value for Track Spline Point Locations for me is 144)
                                Click image for larger version

Name:	Tank31.JPG
Views:	1
Size:	72.1 KB
ID:	1129979Click image for larger version

Name:	Tank32.JPG
Views:	1
Size:	96.8 KB
ID:	1129980

                                At this point the suspension works and the tracks move correctly, however the wheels did not move up and down with the suspension. So I looked for inspiration in the 4TrackedVehicle and moved over the UpdateWheelPosition function and combined all 14 of them into a UpdateWheelPositions function..
                                Click image for larger version

Name:	Tank33.JPG
Views:	1
Size:	89.7 KB
ID:	1129981Click image for larger version

Name:	Tank34.JPG
Views:	1
Size:	88.6 KB
ID:	1129982Click image for larger version

Name:	Tank35.JPG
Views:	1
Size:	79.7 KB
ID:	1129983

                                At this point I only have one slight problem, the wheels sit inside of the track when I drive as such, any advise as to what to adjust would be helpful:
                                Click image for larger version

Name:	Tank36.JPG
Views:	1
Size:	88.2 KB
ID:	1129984

                                UPDATE: Fixed the wheel alignment problem by updating the physics mesh to the other available front/back facing styles, now the wheels align property:
                                Click image for larger version

Name:	Tank37.JPG
Views:	1
Size:	84.6 KB
ID:	1129986

                                The only issue is that this seems to cause me to get stuck a bit going up steep inclines as such:
                                Click image for larger version

Name:	Tank38.JPG
Views:	1
Size:	92.6 KB
ID:	1129987
                                Last edited by kensai01; 06-20-2017, 12:46 PM.

                                Comment

                                Working...
                                X