Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: NED offset in linear velocity (wrong use of toLocalNed() in updateKinematics()) #1585

Closed
Lotjeotje opened this issue Nov 28, 2018 · 2 comments
Assignees
Labels

Comments

@Lotjeotje
Copy link

In the updateKinematics function in PawnSimApi (line 485 - 500), the linear twist is being transformed using the toLocalNed function from NedTransform.cpp (line 29 - 34). This function subtracts a ned_offset from the position, but in the updateKinematics function, the velocity is the input to toLocalNed(position). Since I have an Ned offset of {X=5690.00000 Y=-350.000000 Z=18.9090881 }, my linear velocity is having this offset (scaled with 1/100) when playing the game.

Question: I'm trying to fix this by having the originGeoPoint and PlayerStart in the settings such that there is no ned offset in the code now. Is there any other way that I can get a correct linear velocity? Maybe making a toLocalNed function for transforming velocity (only scaling and not translating?).

void PawnSimApi::updateKinematics(float dt)
{
    const auto last_kinematics = kinematics_;

    kinematics_.pose = getPose();

    kinematics_.twist.linear = getNedTransform().toLocalNed(getPawn()->GetVelocity());
    kinematics_.twist.angular = msr::airlib::VectorMath::toAngularVelocity(
        kinematics_.pose.orientation, last_kinematics.pose.orientation, dt);

    kinematics_.accelerations.linear = (kinematics_.twist.linear - last_kinematics.twist.linear) / dt;
    kinematics_.accelerations.angular = (kinematics_.twist.angular - last_kinematics.twist.angular) / dt;

    //TODO: update other fields?

}
NedTransform::Vector3r NedTransform::toLocalNed(const FVector& position) const
{
    return NedTransform::toVector3r(position - local_ned_offset_,
        1 / world_to_meters_, true);
}
@Lotjeotje Lotjeotje changed the title Question/bug: NED offset in linear velocity (wrong use of toLocalNed() in updateKinematics()) Bug: NED offset in linear velocity (wrong use of toLocalNed() in updateKinematics()) Nov 28, 2018
@Lotjeotje
Copy link
Author

I solved it by using this toLocalNedVel(const FVector& velocity) function in the line where kinematics_.twist.linear is updated.

NedTransform::Vector3r NedTransform::toLocalNedVel(const FVector& velocity) const
{
	return NedTransform::toVector3r(velocity,
		1 / world_to_meters_, true);
}

@ironclownfish
Copy link
Contributor

May be relevant:

#2292
#2299

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants