PUMA with gravity works

main
Benjamin Kraft 2 years ago
parent 0f5975aeb9
commit 0280aad4db
  1. BIN
      Content/Blueprints/BP_Puma.uasset
  2. BIN
      Content/Blueprints/BP_TestBot.uasset
  3. BIN
      Content/Blueprints/BP_TestCube.uasset
  4. BIN
      Content/Levels/Main.umap
  5. BIN
      Content/Models/puma_link1.uasset
  6. BIN
      Content/Models/puma_link2.uasset
  7. BIN
      Content/Models/puma_link3.uasset
  8. BIN
      Content/Models/puma_link4.uasset
  9. BIN
      Content/Models/puma_link5.uasset
  10. BIN
      Content/Models/puma_link7.uasset
  11. BIN
      Content/Models/robot.uasset
  12. BIN
      Content/Models/test_arm.uasset
  13. BIN
      Content/Models/test_arm_onejoint.uasset
  14. BIN
      Content/Models/test_arm_twojoints.uasset
  15. 27
      Source/PBDRobotics/Joint.cpp
  16. 3
      Source/PBDRobotics/Link.h

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -48,9 +48,13 @@ void UJoint::SolvePosition(const double H) const{
const double W1 = L1->GetPositionalInverseMass(R1, N);
const double W2 = L2->GetPositionalInverseMass(R2, N);
constexpr double A = 0; //1. / 10000000; // Compliance (inverse of stiffness)
const Vector3d P = -C / (W1 + W2 + A / (H * H)) * N;
constexpr double A = 0; //1. / 100000000; // Compliance (inverse of stiffness)
const double Denominator = W1 + W2 + A / (H * H);
Vector3d P;
if (Denominator == 0)
P = Vector3d::Zero();
else
P = N * -C / Denominator;
L1->Position += P / M1;
L2->Position -= P / M2;
@ -61,15 +65,20 @@ void UJoint::SolvePosition(const double H) const{
const Quaterniond Add2 = Quaterniond(0, T2.x(), T2.y(), T2.z()) * L2->Orientation * 0.5;
L1->Orientation = (L1->Orientation + Add1).normalized();
L2->Orientation = (L2->Orientation - Add2).normalized();
// UE_LOG(LogTemp, Log, TEXT("%f"), P.norm());
}
// Rotational Constraints
{
Vector3d Q;
if (L2->IsEffector){
const Quaterniond Tq = L1->Orientation * L2->Orientation.inverse();
Q = 2 * Tq.vec();
} else{
const Vector3d A1 = GetFirstWorldAxis();
const Vector3d A2 = GetSecondWorldAxis();
assert(A1.norm() == A2.norm() == 1);
const Vector3d Q = A1.cross(A2);
Q = A1.cross(A2);
}
const Vector3d N = Q.normalized();
const double Theta = UKismetMathLibrary::Asin(Q.norm());// * 180. / PI;
@ -80,7 +89,12 @@ void UJoint::SolvePosition(const double H) const{
const double W2 = L2->GetRotationalInverseMass(N);
constexpr double A = 0; //1. / 100000000;
const Vector3d P = Theta / (W1 + W2 + A / (H * H)) * N;
const double Denominator = W1 + W2 + A / (H * H);
Vector3d P;
if (Denominator == 0)
P = Vector3d::Zero();
else
P = N * Theta / Denominator;
Vector3d T1 = I1.inverse() * P;
Vector3d T2 = I2.inverse() * P;
@ -88,7 +102,6 @@ void UJoint::SolvePosition(const double H) const{
const Quaterniond Add2 = Quaterniond(0, T2.x(), T2.y(), T2.z()) * L2->Orientation * 0.5;
L1->Orientation = (L1->Orientation + Add1).normalized();
L2->Orientation = (L2->Orientation - Add2).normalized();
// UE_LOG(LogTemp, Log, TEXT("%f"), Add2.norm());
}
}

@ -47,6 +47,9 @@ public:
double GetRotationalInverseMass(const Vector3d N) const;
void Setup();
UPROPERTY(EditAnywhere)
bool IsEffector = false;
private:
UPROPERTY(EditAnywhere)
bool IsBase = false;

Loading…
Cancel
Save