Jump to content

Kinematic Joint Error Message


SpiderPig
 Share

Recommended Posts

The code below gives 3 different error messages (if you press ignore each time).  Here's the first one;

KinematicJointError_001.jpg.2a4fc9a3c81a1be8691b50936f1a3523.jpg

Only get the errors in debug mode.  In release mode the object is shot away at speed.

#include "UltraEngine.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    auto displays = GetDisplays();
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    auto framebuffer = CreateFramebuffer(window);
    auto world = CreateWorld();

    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125);
    camera->SetPosition(0, 0, -8);
    camera->SetDebugPhysicsMode(true);

    auto light = CreateDirectionalLight(world);
    light->SetRotation(35, 35, 0);

    auto box = CreateCylinder(world, 0.5f, 1.8f);
    box->SetMass(1.0f);
    box->SetColor(0, 1, 0);

    auto floor = CreateBox(world, 10, .1, 10);
    floor->SetPosition(0, -2, 0);

    auto joint = CreateKinematicJoint(box->position, box);
    joint->SetMaxForce(100);
    joint->SetMaxTorque(100);

    auto pivot = CreatePivot(nullptr);
    
    float a = 0, y = 0;
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        pivot->AlignToVector(Vec3(0, 0, -1));
        auto quat = pivot->GetQuaternion();

        joint->SetPose(Vec3(0, y, 0),  quat);

        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

Link to comment
Share on other sites

It seems to be because the target rotation is 180 degrees away from the current orientation. Maybe the solver can't decide which way to turn?

Line 337 of dgCustomKinematicController.cpp:

dAssert(lateralDir.DotProduct3(lateralDir) > 1.0e-6f);

Simplified example:

#include "UltraEngine.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    auto displays = GetDisplays();
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    auto framebuffer = CreateFramebuffer(window);
    auto world = CreateWorld();

    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125);
    camera->SetPosition(0, 0, -8);
    camera->SetDebugPhysicsMode(true);

    auto light = CreateDirectionalLight(world);
    light->SetRotation(35, 35, 0);

    auto box = CreateCylinder(world, 0.5f, 1.8f);
    box->SetMass(1.0f);
    
    auto joint = CreateKinematicJoint(box->position, box);
    
    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        joint->SetPose(Vec3(0, 0, 0), Vec3(0,180,0));
        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

I tried commenting out the assert statement. In my code below, any rotation closer to 180 causes the joint to just not react. I suppose this is better than crashing, but still not ideal.

#include "UltraEngine.h"

using namespace UltraEngine;

int main(int argc, const char* argv[])
{
    auto displays = GetDisplays();
    auto window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[0], WINDOW_CENTER | WINDOW_TITLEBAR);
    auto framebuffer = CreateFramebuffer(window);
    auto world = CreateWorld();

    auto camera = CreateCamera(world);
    camera->SetClearColor(0.125);
    camera->SetPosition(0, 0, -4);
    camera->SetDebugPhysicsMode(true);

    auto light = CreateDirectionalLight(world);
    light->SetRotation(35, 35, 0);

    auto box = CreateCylinder(world, 0.5f, 1.8f);
    box->SetMass(1.0f);

    auto joint = CreateKinematicJoint(box->position, box);

    while (window->Closed() == false and window->KeyDown(KEY_ESCAPE) == false)
    {
        if (window->KeyHit(KEY_SPACE))
        {
            joint->SetPose(Vec3(0, 0, 0), Vec3(0, 178.6, 0));
        }
        world->Update();
        world->Render(framebuffer);
    }
    return 0;
}

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

As I suspected there is no perfect solution when the target rotation is 180 degrees opposite from the current rotation, because one degree of freedom is lost. I'm not sure at this point what should be done or if this is just the way things work.

  • Thanks 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...