Applying 'hover' forces

Hello

I’m getting a ‘quadcopter’ model to hover by applying forces in the locations of the motors in the direction of the Y axis (relative to the quadcopter). The copter is modeled (for now) by a single body with rigidBodyControl. When I apply equal forces to all motors the copter hovers … sortof. But when I increase one motor ever so slightly the thing dives to one side immediately which is not correct behavior. I’ve tried with tpf and without , result is about the same.

public void prePhysicsTick(PhysicsSpace space, float tpf) {
    System.out.println("Dir: " + getUAVDirectionY().toString());
    UAV_phy.applyForce(getUAVDirectionY().mult(2.45f * tpf), getMotorLocation(1));
    UAV_phy.applyForce(getUAVDirectionY().mult(2.45f * tpf), getMotorLocation(2));
    UAV_phy.applyForce(getUAVDirectionY().mult(2.45f * tpf), getMotorLocation(3));
    UAV_phy.applyForce(getUAVDirectionY().mult(2.45f * tpf), getMotorLocation(4));
}

Here are my getMotorLocation() and getUAVDirectionY(). functions:

private Vector3f getUAVDirectionY() {
Quaternion quat = UAV_phy.getPhysicsRotation();
Vector3f v = Vector3f.UNIT_Y;
quat.mult(v, v);
return v.normalizeLocal(); // LOCAL?
}

private Vector3f getMotorLocation(int num) {
    return UAVNode.getChild("motor" + num).getLocalTranslation();
}

and part of the initialization:

    UAVNode = new Node();
    UAVNode.setLocalTranslation(arenaSize / 2, 1.5f, arenaSize / 2);

    // Physics
    bulletAppState = new BulletAppState();
    stateManager.attach(bulletAppState);
    bulletAppState.getPhysicsSpace().addTickListener(this);

Am I approaching this the right way?
I’m pretty sure that the direction of the applied forces is wrong because as soon as the orientation of the quadcopter deviates from zero then it looks like it’s being pulled by a force originated from some unknown location.

You are modifying the UNIT_Y constant.

Once more, the java problem :

I printed out the values and it does indeed turn out that it was being modified so thanks for that.
I improved it by writing :

Vector3f v = new Vector3f(0, 1.0f, 0); 

instead of

Vector3f v = Vector3f.UNIT_Y

but I’m still getting some wierd behavior (as if the wind suddenly starts blowing from the side) when I increase one of the motor outputs by just a very slight amount as soon as the orientation deviates from zero.
I tried drawing the vector output of the direction of the UAV (as in the tutorial on vector operations) but it requires some
include .org library and I’ve searched for about half an hour and could not find where to get it.

I think this issue is already beeing treated in another thread of yours here right ?

Lets follow it there. Its an interesting issue, I guess maybe normen can help you on that, he knows more bullet then me for sure.

Thats a different topic where I am having trouble putting together one rigid body out of several.
Here however I have issues with force directions that are not being applied correctly.

It’s hard to tell what’s going wrong just from your description… because of course if a drone tips to the side it’s going to start drifting sideways.

…which is what you described. So either your description is missing something or… ?