parent
de37637337
commit
3106c65f98
12 changed files with 140 additions and 3 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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…
Reference in new issue