|
|
@ -11,14 +11,17 @@ |
|
|
|
|
|
|
|
|
|
|
|
using namespace Eigen; |
|
|
|
using namespace Eigen; |
|
|
|
|
|
|
|
|
|
|
|
// Inertia tensor in world space
|
|
|
|
Matrix3d ULink::GetInertia() const { |
|
|
|
Matrix3d ULink::GetMomentOfInertia() const { |
|
|
|
return Orientation.toRotationMatrix() * Inertia_Tensor_Local; |
|
|
|
return GetRotationMatrix() * Inertia_Tensor_Local; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Matrix3d ULink::GetRotationMatrix() const{ |
|
|
|
double ULink::GetPositionalInverseMass(const Vector3d R, const Vector3d N) const{ |
|
|
|
const FQuat Q = this->GetRelativeRotation().Quaternion(); |
|
|
|
const double M = Mass; |
|
|
|
return Quaterniond(Q.W, Q.X, Q.Y, Q.Z).toRotationMatrix(); |
|
|
|
const Matrix3d I = GetInertia(); |
|
|
|
|
|
|
|
return 1 / M + R.cross(N).transpose() * I.inverse() * R.cross(N); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
double ULink::GetRotationalInverseMass() const{ |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ULink::Setup(){ |
|
|
|
void ULink::Setup(){ |
|
|
@ -28,14 +31,11 @@ void ULink::Setup(){ |
|
|
|
|
|
|
|
|
|
|
|
void ULink::SetupProperties(){ |
|
|
|
void ULink::SetupProperties(){ |
|
|
|
Inertia_Tensor_Local = ToEigen(GetInertiaTensor()).asDiagonal(); |
|
|
|
Inertia_Tensor_Local = ToEigen(GetInertiaTensor()).asDiagonal(); |
|
|
|
|
|
|
|
|
|
|
|
CenterOfMass = ToEigen(GetCenterOfMass()); |
|
|
|
|
|
|
|
Position = ToEigen(GetComponentLocation()); |
|
|
|
Position = ToEigen(GetComponentLocation()); |
|
|
|
Velocity = Vector3d::Zero(); |
|
|
|
Velocity = Vector3d::Zero(); |
|
|
|
Mass = IsBase ? INFINITY : CalculateMass(); |
|
|
|
Mass = IsBase ? INFINITY : CalculateMass(); |
|
|
|
Orientation = Quaterniond::Identity(); |
|
|
|
Orientation = Quaterniond::Identity(); |
|
|
|
AngularVelocity = Vector3d::Zero(); |
|
|
|
AngularVelocity = Vector3d::Zero(); |
|
|
|
Inertia = GetMomentOfInertia(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ULink::SetupJoints() const { |
|
|
|
void ULink::SetupJoints() const { |
|
|
@ -53,9 +53,8 @@ void ULink::SetupJoints() const { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ULink::Update(const double H){ |
|
|
|
void ULink::Update(const double H){ |
|
|
|
const Vector3d ExtTransForce = Vector3d(0, 0, -9.81 * 100) * Mass; |
|
|
|
const Vector3d ExtTransForce = Vector3d(0, 0, -9.81 * 100) * Mass * 0; |
|
|
|
|
|
|
|
|
|
|
|
Last_Position = Position; |
|
|
|
Last_Position = Position; |
|
|
|
Velocity += H * ExtTransForce / Mass; |
|
|
|
Velocity += H * ExtTransForce / Mass; |
|
|
@ -75,7 +74,7 @@ void ULink::Integrate(const double H){ |
|
|
|
AngularVelocity = DeltaOrientation.w() >= 0 ? AngularVelocity : -AngularVelocity; |
|
|
|
AngularVelocity = DeltaOrientation.w() >= 0 ? AngularVelocity : -AngularVelocity; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ULink::UpdateVisualTransform(){ |
|
|
|
void ULink::UpdateInternalTransform(){ |
|
|
|
SetWorldLocation(FromEigen(Position)); |
|
|
|
SetWorldLocation(FromEigen(Position)); |
|
|
|
SetWorldRotation(FromEigen(Orientation)); |
|
|
|
SetWorldRotation(FromEigen(Orientation)); |
|
|
|
} |
|
|
|
} |
|
|
|