Small changes

main
Benjamin Kraft 2 years ago
parent e91dc13878
commit 0f5975aeb9
  1. BIN
      Content/Blueprints/BP_TestBot.uasset
  2. BIN
      Content/Blueprints/BP_TestCube.uasset
  3. BIN
      Content/Levels/Main.umap
  4. BIN
      Content/Models/puma_link3.uasset
  5. BIN
      Content/Models/test_arm.uasset
  6. BIN
      Content/Models/test_base.uasset
  7. 12
      Source/PBDRobotics/Joint.cpp
  8. 4
      Source/PBDRobotics/Joint.h
  9. 2
      Source/PBDRobotics/Robot.cpp

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -48,7 +48,7 @@ void UJoint::SolvePosition(const double H) const{
const double W1 = L1->GetPositionalInverseMass(R1, N); const double W1 = L1->GetPositionalInverseMass(R1, N);
const double W2 = L2->GetPositionalInverseMass(R2, N); const double W2 = L2->GetPositionalInverseMass(R2, N);
constexpr double A = 1. / 10000000; // Compliance (inverse of stiffness) constexpr double A = 0; //1. / 10000000; // Compliance (inverse of stiffness)
const Vector3d P = -C / (W1 + W2 + A / (H * H)) * N; const Vector3d P = -C / (W1 + W2 + A / (H * H)) * N;
@ -61,7 +61,7 @@ void UJoint::SolvePosition(const double H) const{
const Quaterniond Add2 = Quaterniond(0, T2.x(), T2.y(), T2.z()) * L2->Orientation * 0.5; const Quaterniond Add2 = Quaterniond(0, T2.x(), T2.y(), T2.z()) * L2->Orientation * 0.5;
L1->Orientation = (L1->Orientation + Add1).normalized(); L1->Orientation = (L1->Orientation + Add1).normalized();
L2->Orientation = (L2->Orientation - Add2).normalized(); L2->Orientation = (L2->Orientation - Add2).normalized();
UE_LOG(LogTemp, Log, TEXT("%f | %f | %f"), C, P.norm(), R2.cross(P).norm()); // UE_LOG(LogTemp, Log, TEXT("%f"), P.norm());
} }
// Rotational Constraints // Rotational Constraints
@ -79,16 +79,16 @@ void UJoint::SolvePosition(const double H) const{
const double W1 = L1->GetRotationalInverseMass(N); const double W1 = L1->GetRotationalInverseMass(N);
const double W2 = L2->GetRotationalInverseMass(N); const double W2 = L2->GetRotationalInverseMass(N);
constexpr double A = 0; //1. / 10000000; constexpr double A = 0; //1. / 100000000;
const Vector3d P = Theta / (W1 + W2 + A / (H * H)) * N; const Vector3d P = Theta / (W1 + W2 + A / (H * H)) * N;
Vector3d T1 = I1.inverse() * P; Vector3d T1 = I1.inverse() * P;
Vector3d T2 = I2.inverse() * P; Vector3d T2 = I2.inverse() * P;
const Quaterniond Add1 = Quaterniond(0, T1.x(), T1.y(), T1.z()) * L1->Orientation * 0.5; const Quaterniond Add1 = Quaterniond(0, T1.x(), T1.y(), T1.z()) * L1->Orientation * 0.5;
const Quaterniond Add2 = Quaterniond(0, T2.x(), T2.y(), T2.z()) * L2->Orientation * 0.5; const Quaterniond Add2 = Quaterniond(0, T2.x(), T2.y(), T2.z()) * L2->Orientation * 0.5;
//L1->Orientation = (L1->Orientation + Add1).normalized(); L1->Orientation = (L1->Orientation + Add1).normalized();
//L2->Orientation = (L2->Orientation - Add2).normalized(); L2->Orientation = (L2->Orientation - Add2).normalized();
//UE_LOG(LogTemp, Log, TEXT("%f | %f | %f | %f"), N.norm(), W1, W2, Q.norm()); // UE_LOG(LogTemp, Log, TEXT("%f"), Add2.norm());
} }
} }

@ -39,11 +39,13 @@ public:
// First - Second in World-Space // First - Second in World-Space
Vector3d GetConnection() const; Vector3d GetConnection() const;
//
Vector3d FirstRotateAxis; Vector3d FirstRotateAxis;
Vector3d SecondRotateAxis; Vector3d SecondRotateAxis;
// World Axis, around which the First Link wants to rotate
Vector3d GetFirstWorldAxis() const; Vector3d GetFirstWorldAxis() const;
// World Axis, around which the Second Link wants to rotate
Vector3d GetSecondWorldAxis() const; Vector3d GetSecondWorldAxis() const;
void SolvePosition(const double H) const; void SolvePosition(const double H) const;

@ -27,7 +27,7 @@ void ARobot::BeginPlay(){
void ARobot::Tick(const float DeltaTime){ void ARobot::Tick(const float DeltaTime){
Super::Tick(DeltaTime); Super::Tick(DeltaTime);
constexpr int SubSteps = 10; constexpr int SubSteps = 30;
const double h = DeltaTime / SubSteps; const double h = DeltaTime / SubSteps;
for (int i = 0; i < SubSteps; i++){ for (int i = 0; i < SubSteps; i++){
for (auto* Link : Parts) for (auto* Link : Parts)

Loading…
Cancel
Save