SOLVED!Velocity and friction=1 Objects sliding by Move start

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
piotre_005
Posts: 7
Joined: Wed Nov 20, 2013 7:16 pm

SOLVED!Velocity and friction=1 Objects sliding by Move start

Post by piotre_005 »

Hello,

we think about to use the Bepuphsics in a Simulation for industrial plants.
So for Example we want to Simulate Conveyor. They have, like in the Reality some motors on it maybe for
moving the complete Conveyer on the X-Axel ore Turn it around.
Also they have a motor to move the things they have on here back.
The PLC Tell use when the Motor needs to be active ore not and some of them also give a speed value for driving.
The Problem that we have now is that we maybe do something totaly wrong.
We createt Entitys and Move them with the for Example the LinearVelocity ore AngularVelocity.
But now the Problem is that all that stuff that the Conveyer has on his back is a little bit sliding first when the motor
starts to turn for example. We settet a Mass for it of 180kg and also the friction we try in 1. But still
the Stuff don't wan't stand still on it and doe the same rotation like the moving conveyer..

We realy wanted to use Bepu because it's realy some exceptionally great enrichment.
I build a little Demo to show my problem...
I realy thing that mabye the way i try to do it is wrong, and realy hope that somebody can help me...
THX.. :wink: .

Code: Select all

using BEPUphysics;
using BEPUphysics.Entities;
using BEPUphysics.Entities.Prefabs;
using BEPUphysics.Materials;
using BEPUphysicsDrawer.Models;
using BEPUutilities;
using BEPUphysics.BroadPhaseEntries.Events;
using BEPUphysics.BroadPhaseEntries.MobileCollidables;
using BEPUphysics.BroadPhaseEntries;
using BEPUphysics.NarrowPhaseSystems.Pairs;
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;


namespace BEPUphysicsDemos.Demos
{
    class FrictionTest : StandardDemo
    {
        private Box payload;
        private Box conveyor;

        /// <summary>
        /// Constructs a new demo.
        /// </summary>
        /// <param name="game">Game owning this demo.</param>
        public FrictionTest(DemosGame game)
            : base(game)
        {
            Console.Clear();

            Entity ground = new Box(new Vector3(0, 0, 0), 50f, 1f, 50f);
            ground.CollisionInformation.Tag = "ground";
            Space.Add(ground);
            
            // Conveyer
            conveyor = new Box(new Vector3(-5f, 0f, 10), 30, 2f, 10f);
            conveyor.CollisionInformation.Tag = "conveyor_1";
            conveyor.Material = new Material(1,1,0);
            // Payload
            payload = new Box(new Vector3(-14f, 6, 10), 10, 1f, 1f, 10);
            payload.Material = new Material(0, 0, 0);
            payload.CollisionInformation.Tag = "payload_1";
            payload.Material = new Material(1,1,0);
            Space.Add(payload);
            Space.Add(conveyor);
            game.Camera.Position = new Vector3(-8, 20, 35);
        }

        public override void Update(float dt)
        {
            base.Update(dt);
            // Emulate Start Turn - (From the PLC later)
            if (Game.KeyboardInput.IsKeyDown(Keys.Up))
                conveyor.AngularVelocity = new Vector3(0, -1, 0);
            // Emulate Start Turn + (From the PLC later)
            if (Game.KeyboardInput.IsKeyDown(Keys.Down))
                conveyor.AngularVelocity = new Vector3(0, 1,0);
           
            // Emulate STOP Turn 0 (From the PLC later)
            if (Game.KeyboardInput.IsKeyDown(Keys.Space))
                conveyor.AngularVelocity = new Vector3(0, 0, 0);
        }

        /// <summary>
        /// Gets the name of the simulation.
        /// </summary>
        public override string Name
        {
            get { return "FrictionTest"; }
        }
    }
}
Last edited by piotre_005 on Wed Nov 20, 2013 8:57 pm, edited 1 time in total.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Velocity and friction=1 Objects sliding by Move start

Post by Norbo »

Coefficients of friction are only restricted to nonnegative values. Any number 0 or higher is physically acceptable. Try setting the friction to something larger, like 10.

Also, if you aren't already using it, I would recommend moving to the latest main (dependency free) version. It contains a fix for a pretty nasty bug with friction that was present in v1.2.0 and other old branches.
piotre_005
Posts: 7
Joined: Wed Nov 20, 2013 7:16 pm

Re: Velocity and friction=1 Objects sliding by Move start

Post by piotre_005 »

Oh my good thanks for your reply.. that realy saved my day..
I'm soory that i was to stupid with the friction amount i thought the max is 1 ...
Now it works ...!
Post Reply