Add VRIS-prototype

This commit is contained in:
Kenneth Jao 2024-10-24 02:26:07 -04:00
commit 182c435e1e
17 changed files with 346 additions and 0 deletions

1
VRIS-prototype/.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
VRISprototype.sdf filter=lfs diff=lfs merge=lfs -text

5
VRIS-prototype/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
Intermediate/
Saved/
VRISprototype.sdf
VRISprototype.sln
VRISprototype.suo

View File

@ -0,0 +1,5 @@
[EditoronlyBP]
bAllowClassAndBlueprintPinMatching=true
bReplaceBlueprintWithClass=true
bDontLoadBlueprintOutsideEditor=true
bBlueprintIsNotBlueprintType=true

View File

@ -0,0 +1,60 @@
[URL]
[/Script/EngineSettings.GameMapsSettings]
EditorStartupMap=/Game/StarterContent/Maps/Minimal_Default
GameDefaultMap=/Game/StarterContent/Maps/Minimal_Default
[/Script/Engine.UserInterfaceSettings]
RenderFocusRule=NavigationOnly
DefaultCursor=None
TextEditBeamCursor=None
CrosshairsCursor=None
GrabHandCursor=None
GrabHandClosedCursor=None
SlashedCircleCursor=None
ApplicationScale=1.000000
UIScaleRule=ShortestSide
CustomScalingRuleClass=None
UIScaleCurve=(EditorCurveData=(PreInfinityExtrap=RCCE_Constant,PostInfinityExtrap=RCCE_Constant,Keys=((Time=480.000000,Value=0.444000),(Time=720.000000,Value=0.666000),(Time=1080.000000,Value=1.000000),(Time=8640.000000,Value=8.000000))),ExternalCurve=None)
[/Script/Engine.RendererSettings]
r.MobileHDR=True
r.MobileNumDynamicPointLights=4
r.MobileDynamicPointLightsUseStaticBranch=True
r.AllowOcclusionQueries=True
r.MinScreenRadiusForLights=0.030000
r.MinScreenRadiusForDepthPrepass=0.030000
r.PrecomputedVisibilityWarning=False
r.TextureStreaming=True
Compat.UseDXT5NormalMaps=False
r.AllowStaticLighting=True
r.NormalMapsForStaticLighting=False
r.GenerateMeshDistanceFields=False
r.GenerateLandscapeGIData=True
r.TessellationAdaptivePixelsPerTriangle=48.000000
r.SeparateTranslucency=True
r.TranslucentSortPolicy=0
TranslucentSortAxis=(X=0.000000,Y=-1.000000,Z=0.000000)
r.CustomDepth=1
r.DefaultFeature.Bloom=True
r.DefaultFeature.AmbientOcclusion=True
r.DefaultFeature.AmbientOcclusionStaticFraction=True
r.DefaultFeature.AutoExposure=True
r.DefaultFeature.MotionBlur=True
r.DefaultFeature.LensFlare=True
r.DefaultFeature.AntiAliasing=2
r.EarlyZPass=3
r.EarlyZPassMovable=False
r.DBuffer=False
r.ClearSceneMethod=1
r.BasePassOutputsVelocity=False
r.WireframeCullThreshold=5.000000
UIScaleRule=ShortestSide
UIScaleCurve=(EditorCurveData=(PreInfinityExtrap=RCCE_Constant,PostInfinityExtrap=RCCE_Constant,Keys=),ExternalCurve=None)
[/Script/HardwareTargeting.HardwareTargetingSettings]
TargetedHardwareClass=Desktop
AppliedTargetedHardwareClass=Desktop
DefaultGraphicsPerformance=Maximum
AppliedDefaultGraphicsPerformance=Maximum

View File

@ -0,0 +1,6 @@
[/Script/EngineSettings.GeneralProjectSettings]
ProjectID=03D8975F4EA14BB07FC38BA6364CCA52
[StartupActions]
bAddPacks=True
InsertPack=(PackSource="StarterContent.upack,PackName="StarterContent")

1
VRIS-prototype/README.md Normal file
View File

@ -0,0 +1 @@
Prototype for VRIS.

View File

@ -0,0 +1,141 @@
#include "Wire.h"
/* I2Cdev and MPU6050 must be installed as libraries, or else the .cpp/.h files
* for both classes must be in the include path of your project
*/
#include "I2Cdev.h"
#include "MPU6050_6Axis_MotionApps20.h"
#define NUMBER_OF_SENSORS 3 /// YOU MAY NEED TO CHANGE THIS
// Default I2C address is 0x68
// AD0 LOW(0) = 0x68 (Default for SparkFun breakout and InvenSense evaluation board)
// AD0 HIGH(1) = 0x69
// MPU Control Variables
MPU6050 mpu;
bool dmpReady; // Set true if DMP init was successful.
uint8_t devStatus; // Return status after each device operation. (0 = success, !0 = error)
uint8_t mpuIntStatus; // Holds interrupt status byte from MPU.
uint16_t packetSize; // Expected DMP packet size. (Default is 42 bytes)
uint16_t fifoCount; // Count of all bytes currently in FIFO.
uint8_t fifoBuffer[64]; // FIFO storage buffer.
// Orientation and Motion Variables
Quaternion q; // [W, X, Y, Z] Quaternion container.
VectorFloat gravity; // [X, Y, Z] Gravity vector
float ypr[3]; // [Yaw, Pitch, Roll] array container.
//Digital Pins Reference Variables
/* Displace array beginning with 0.
* The numbers after the 0th index correspond to the pin connected to the ADO line of each sensor.
*/
int sensorPins[NUMBER_OF_SENSORS + 1] = {0, 5, 6, 7}; // {none, Sensor 1 ADO pin, Sensor 2 ADO pin,...}
// Other Variables
String finalParts[NUMBER_OF_SENSORS]; // Final output.
String final = ""; // Part of final output.
//==============================================================
void switchSensor(int sensorNumber) {
digitalWrite(sensorPins[sensorNumber], LOW); // Change one ADO line to low. (The one we are recieving from! 0x68)
}
// ================================================================
// === MAIN PROGRAM SETUP ===
// ================================================================
void setup() {
// Setup Variables
int i = 0; // For loop counter.
int dmpReadyCounter = 0; // Counts number of sensors ready.
// Set all ADO lines to default high, and configure pins.
for(i = 1; i <= NUMBER_OF_SENSORS; i++) {
pinMode(sensorPins[i], OUTPUT);
digitalWrite(sensorPins[i], HIGH);
}
Serial.begin(115200); // Initialize serial communication with baud rate.
for (i = 1; i <= NUMBER_OF_SENSORS; i++) {
/* We read data from all sensors by switching addresses one by one, only reading from the first address (0x68).
* Therefore, we select sensors by making an ADO line LOW.
*/
switchSensor(i);
Wire.begin(); // Joins I2C bus. (I2C libary doesn't do this on it's own.)
TWBR = 24; // Sets SCL higher.
mpu.initialize(); // Intialize device.
devStatus = mpu.dmpInitialize(); // Load and configure the DMP. (Digital Motion Processor)
// Check success of DMP.
if (devStatus == 0) {
mpu.setDMPEnabled(true);
dmpReadyCounter += 1; // Add one to count number of ready sensors.
packetSize = mpu.dmpGetFIFOPacketSize(); // Get expected DMP packet size for later comparison
} else {
// Error!
Serial.println("Error on sensor " + String(i));
}
digitalWrite(sensorPins[i], HIGH); // Reset current ADO pin back to high. (0x69)
Wire.endTransmission(); // End transmission for sensor.
}
if (dmpReadyCounter == NUMBER_OF_SENSORS) {
dmpReady = true; // Set DMP Ready flag. (Allows main loop to use the DMP.)
}
}
// ================================================================
// === MAIN PROGRAM LOOP ===
// ================================================================
void loop() {
// If DMP isn't ready...
if (!(dmpReady)) {
return;
}
final = ""; // Reset final to nothing.
for (int i = 1; i <= NUMBER_OF_SENSORS; i++) {
switchSensor(i);
// Check for overflow.
if (fifoCount == 1024) {
mpu.resetFIFO(); // Reset so we can continue cleanly.
} else {
fifoCount = mpu.getFIFOCount(); // Get current FIFO count.
// Wait for correct avaliable data length.
while (fifoCount < packetSize) {
fifoCount = mpu.getFIFOCount();
}
mpu.getFIFOBytes(fifoBuffer, packetSize); // Read a packet from FIFO
/* Track FIFO count in case there is more than 1 packet avaliable.
* (Read more without waiting for an interrupt.)
*/
fifoCount -= packetSize;
// Get values to process.
mpu.dmpGetQuaternion(&q, fifoBuffer);
mpu.dmpGetGravity(&gravity, &q);
mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
// Concatenate for outputting. (Displays in Euler Angles in degrees.)
finalParts[i - 1] = String(ypr[0] * 180 / M_PI) + "," + String(ypr[1] * 180 / M_PI) + "," + String(ypr[2] * 180 / M_PI) + ":";
final += finalParts[i - 1];
digitalWrite(sensorPins[i], HIGH); // Resets current ADO pin back to high. (0x69)
}
}
Serial.println(final.substring(0, final.length() - 1)); // Prints and removes extra colon.
}

View File

@ -0,0 +1,25 @@
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
using System.Collections.Generic;
public class VRISprototypeTarget : TargetRules
{
public VRISprototypeTarget(TargetInfo Target)
{
Type = TargetType.Game;
}
//
// TargetRules interface.
//
public override void SetupBinaries(
TargetInfo Target,
ref List<UEBuildBinaryConfiguration> OutBuildBinaryConfigurations,
ref List<string> OutExtraModuleNames
)
{
OutExtraModuleNames.AddRange( new string[] { "VRISprototype" } );
}
}

View File

@ -0,0 +1,12 @@
#include "VRISprototype.h"
#include "ReadFile.h"
#include "CoreMisc.h"
void UReadFile::ReadFile(FString Filename, FString& Result)
{
FFileHelper::LoadFileToString(Result, *Filename);
}

View File

@ -0,0 +1,12 @@
#pragma once
#include "Kismet/BlueprintFunctionLibrary.h"
#include "ReadFile.generated.h"
UCLASS()
class VRISPROTOTYPE_API UReadFile : public UBlueprintFunctionLibrary
{
GENERATED_BODY() public:
UFUNCTION(BlueprintCallable, meta = (DisplayName = "Read File", Keywords = "Reads from a file"), Category = Utilities)
static void ReadFile(FString Directory, FString& Value);
};

View File

@ -0,0 +1,26 @@
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
public class VRISprototype : ModuleRules
{
public VRISprototype(TargetInfo Target)
{
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
PrivateDependencyModuleNames.AddRange(new string[] { });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// if ((Target.Platform == UnrealTargetPlatform.Win32) || (Target.Platform == UnrealTargetPlatform.Win64))
// {
// if (UEBuildConfiguration.bCompileSteamOSS == true)
// {
// DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");
// }
// }
}
}

View File

@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "VRISprototype.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, VRISprototype, "VRISprototype" );

View File

@ -0,0 +1,6 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "Engine.h"

View File

@ -0,0 +1,25 @@
// Fill out your copyright notice in the Description page of Project Settings.
using UnrealBuildTool;
using System.Collections.Generic;
public class VRISprototypeEditorTarget : TargetRules
{
public VRISprototypeEditorTarget(TargetInfo Target)
{
Type = TargetType.Editor;
}
//
// TargetRules interface.
//
public override void SetupBinaries(
TargetInfo Target,
ref List<UEBuildBinaryConfiguration> OutBuildBinaryConfigurations,
ref List<string> OutExtraModuleNames
)
{
OutExtraModuleNames.AddRange( new string[] { "VRISprototype" } );
}
}

View File

@ -0,0 +1,16 @@
{
"FileVersion": 3,
"EngineAssociation": "4.9",
"Category": "",
"Description": "",
"Modules": [
{
"Name": "VRISprototype",
"Type": "Runtime",
"LoadingPhase": "Default",
"AdditionalDependencies": [
"Engine"
]
}
]
}

Binary file not shown.

Binary file not shown.