inertia stuff

main
Benjamin Kraft 2 years ago
parent de37637337
commit 3106c65f98
  1. 8
      Config/DefaultEngine.ini
  2. BIN
      Content/Blueprints/BP_Link.uasset
  3. BIN
      Content/Blueprints/BP_Puma.uasset
  4. BIN
      Content/Blueprints/BP_Robot.uasset
  5. BIN
      Content/Levels/Main.umap
  6. BIN
      Content/Materials/M_Effector.uasset
  7. BIN
      Content/Materials/M_Link.uasset
  8. 5
      PBDRobotics.uproject
  9. 43
      Source/PBDRobotics/Link.cpp
  10. 34
      Source/PBDRobotics/Link.h
  11. 27
      Source/PBDRobotics/Robot.cpp
  12. 26
      Source/PBDRobotics/Robot.h

@ -1,8 +1,9 @@
[/Script/EngineSettings.GameMapsSettings] [/Script/EngineSettings.GameMapsSettings]
GameDefaultMap=/Engine/Maps/Templates/Template_Default.Template_Default GameDefaultMap=/Game/Levels/Main.Main
EditorStartupMap=/Game/Levels/Main.Main
GlobalDefaultGameMode=/Script/PBDRobotics.PBDRoboticsGameModeBase
[/Script/HardwareTargeting.HardwareTargetingSettings] [/Script/HardwareTargeting.HardwareTargetingSettings]
TargetedHardwareClass=Desktop TargetedHardwareClass=Desktop
@ -15,3 +16,6 @@ AppliedDefaultGraphicsPerformance=Maximum
+ActiveGameNameRedirects=(OldGameName="/Script/TP_Blank",NewGameName="/Script/PBDRobotics") +ActiveGameNameRedirects=(OldGameName="/Script/TP_Blank",NewGameName="/Script/PBDRobotics")
+ActiveClassRedirects=(OldClassName="TP_BlankGameModeBase",NewClassName="PBDRoboticsGameModeBase") +ActiveClassRedirects=(OldClassName="TP_BlankGameModeBase",NewClassName="PBDRoboticsGameModeBase")
[/Script/Engine.RendererSettings]
r.DefaultFeature.AutoExposure=False

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -7,7 +7,10 @@
{ {
"Name": "PBDRobotics", "Name": "PBDRobotics",
"Type": "Runtime", "Type": "Runtime",
"LoadingPhase": "Default" "LoadingPhase": "Default",
"AdditionalDependencies": [
"Engine"
]
} }
] ]
} }

@ -0,0 +1,43 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Link.h"
#include <iostream>
#include "Eigen/Dense"
Eigen::Matrix3d ULink::GetMomentOfInertia() const {
const FVector FI = this->GetInertiaTensor();
// Inertial tensor of rotation
const Eigen::Vector3d I(FI.X, FI.Y, FI.Z);
// Moment of inertia
const Eigen::Matrix3d I0;// = R.transpose() * I * R;
return I0;
}
Eigen::Matrix3d ULink::GetRotationMatrix() const{
const FQuat fq = this->GetRelativeRotation().Quaternion();
const Eigen::Vector3d q(fq.X, fq.Y, fq.Z);
const double w = fq.W;
Eigen::Matrix3d q_hat;
q_hat << 0, -q.z(), q.y(),
q.z(), 0, -q.x(),
-q.y(), q.x(), 0;
const Eigen::Matrix3d R = (w * w - q.dot(q)) * Eigen::Matrix3d::Identity() + 2 * q * q.transpose() + 2 * w * q_hat;
return R;
}
void ULink::BeginPlay(){
const FVector t = this->GetInertiaTensor();
inertia_tensor = Eigen::Vector3d(t.X, t.Y, t.Z);
const double M = this->CalculateMass();
Eigen::Vector3d v;
v << 3, 5, 7;
UE_LOG(LogTemp, Log, TEXT("%f"), M);
}

@ -0,0 +1,34 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/StaticMeshComponent.h"
#include "Eigen/Dense"
#include "Link.generated.h"
/**
*
*/
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class PBDROBOTICS_API ULink : public UStaticMeshComponent
{
GENERATED_BODY()
public:
Eigen::Vector3d CenterOfMass;
Eigen::Vector3d Position;
Eigen::Vector3d Velocity;
double Mass;
Eigen::Quaterniond Orientation;
Eigen::Vector3d AngleVelocity;
Eigen::Matrix3d Inertia;
private:
Eigen::Vector3d inertia_tensor;
Eigen::Matrix3d GetMomentOfInertia() const;
Eigen::Matrix3d GetRotationMatrix() const;
protected:
virtual void BeginPlay() override;
};

@ -0,0 +1,27 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Robot.h"
// Sets default values
ARobot::ARobot()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void ARobot::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ARobot::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}

@ -0,0 +1,26 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Robot.generated.h"
UCLASS()
class PBDROBOTICS_API ARobot : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ARobot();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
Loading…
Cancel
Save