初始化提交

This commit is contained in:
Redstone1024 2023-10-28 21:30:28 +08:00
commit 4de07e1988
20 changed files with 822 additions and 0 deletions

15
.gitignore vendored Normal file
View File

@ -0,0 +1,15 @@
Binaries
DerivedDataCache
Intermediate
Saved
Build
.vscode
.vs
*.VC.db
*.opensdf
*.opendb
*.sdf
*.sln
*.suo
*.xcodeproj
*.xcworkspace

13
.vsconfig Normal file
View File

@ -0,0 +1,13 @@
{
"version": "1.0",
"components": [
"Microsoft.Net.Component.4.6.2.TargetingPack",
"Microsoft.VisualStudio.Component.VC.14.36.17.6.x86.x64",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
"Microsoft.VisualStudio.Component.Windows10SDK.22000",
"Microsoft.VisualStudio.Workload.CoreEditor",
"Microsoft.VisualStudio.Workload.ManagedDesktop",
"Microsoft.VisualStudio.Workload.NativeDesktop",
"Microsoft.VisualStudio.Workload.NativeGame"
]
}

0
Config/DefaultEditor.ini Normal file
View File

207
Config/DefaultEngine.ini Normal file
View File

@ -0,0 +1,207 @@
[/Script/EngineSettings.GameMapsSettings]
GameDefaultMap=/Game/Level.Level
EditorStartupMap=/Game/Level.Level
[/Script/WindowsTargetPlatform.WindowsTargetSettings]
DefaultGraphicsRHI=DefaultGraphicsRHI_DX12
-D3D12TargetedShaderFormats=PCD3D_SM5
+D3D12TargetedShaderFormats=PCD3D_SM6
-D3D11TargetedShaderFormats=PCD3D_SM5
+D3D11TargetedShaderFormats=PCD3D_SM5
Compiler=Default
AudioSampleRate=48000
AudioCallbackBufferFrameSize=1024
AudioNumBuffersToEnqueue=1
AudioMaxChannels=0
AudioNumSourceWorkers=4
SpatializationPlugin=
SourceDataOverridePlugin=
ReverbPlugin=
OcclusionPlugin=
CompressionOverrides=(bOverrideCompressionTimes=False,DurationThreshold=5.000000,MaxNumRandomBranches=0,SoundCueQualityIndex=0)
CacheSizeKB=65536
MaxChunkSizeOverrideKB=0
bResampleForDevice=False
MaxSampleRate=48000.000000
HighSampleRate=32000.000000
MedSampleRate=24000.000000
LowSampleRate=12000.000000
MinSampleRate=8000.000000
CompressionQualityModifier=1.000000
AutoStreamingThreshold=0.000000
SoundCueCookQualityIndex=-1
[/Script/HardwareTargeting.HardwareTargetingSettings]
TargetedHardwareClass=Desktop
AppliedTargetedHardwareClass=Desktop
DefaultGraphicsPerformance=Scalable
AppliedDefaultGraphicsPerformance=Scalable
[/Script/Engine.RendererSettings]
r.Mobile.ShadingPath=0
r.Mobile.SupportGPUScene=False
r.Mobile.AntiAliasing=1
r.Mobile.FloatPrecisionMode=0
r.Mobile.AllowDitheredLODTransition=False
r.Mobile.VirtualTextures=False
r.DiscardUnusedQuality=False
r.Shaders.CompressionFormat=2
r.AllowOcclusionQueries=True
r.MinScreenRadiusForLights=0.030000
r.MinScreenRadiusForDepthPrepass=0.030000
r.MinScreenRadiusForCSMDepth=0.010000
r.PrecomputedVisibilityWarning=False
r.TextureStreaming=True
Compat.UseDXT5NormalMaps=False
r.VirtualTextures=False
r.VT.EnableAutoImport=True
r.VirtualTexturedLightmaps=False
r.VT.AnisotropicFiltering=False
bEnableVirtualTextureOpacityMask=False
r.VT.TileSize=128
r.VT.TileBorderSize=4
r.vt.FeedbackFactor=16
WorkingColorSpaceChoice=sRGB
RedChromaticityCoordinate=(X=0.640000,Y=0.330000)
GreenChromaticityCoordinate=(X=0.300000,Y=0.600000)
BlueChromaticityCoordinate=(X=0.150000,Y=0.060000)
WhiteChromaticityCoordinate=(X=0.312700,Y=0.329000)
r.ClearCoatNormal=False
r.DynamicGlobalIlluminationMethod=1
r.ReflectionMethod=1
r.ReflectionCaptureResolution=128
r.ReflectionEnvironmentLightmapMixBasedOnRoughness=True
r.Lumen.HardwareRayTracing=False
r.Lumen.HardwareRayTracing.LightingMode=0
r.Lumen.TranslucencyReflections.FrontLayer.EnableForProject=False
r.Lumen.TraceMeshSDFs=1
r.Shadow.Virtual.Enable=1
r.RayTracing=False
r.RayTracing.Shadows=False
r.RayTracing.Skylight=False
r.RayTracing.UseTextureLod=False
r.PathTracing=True
r.GenerateMeshDistanceFields=True
r.DistanceFields.DefaultVoxelDensity=0.200000
r.Nanite.ProjectEnabled=True
r.AllowStaticLighting=True
r.NormalMapsForStaticLighting=False
r.ForwardShading=False
r.VertexFoggingForOpaque=True
r.SeparateTranslucency=True
r.TranslucentSortPolicy=0
TranslucentSortAxis=(X=0.000000,Y=-1.000000,Z=0.000000)
vr.VRS.HMDFixedFoveationLevel=0
vr.VRS.HMDFixedFoveationDynamic=False
r.CustomDepth=1
r.CustomDepthTemporalAAJitter=True
r.PostProcessing.PropagateAlpha=0
r.DefaultFeature.Bloom=True
r.DefaultFeature.AmbientOcclusion=True
r.DefaultFeature.AmbientOcclusionStaticFraction=True
r.DefaultFeature.AutoExposure=False
r.DefaultFeature.AutoExposure.Method=0
r.DefaultFeature.AutoExposure.Bias=1.000000
r.DefaultFeature.AutoExposure.ExtendDefaultLuminanceRange=True
r.DefaultFeature.MotionBlur=False
r.DefaultFeature.LensFlare=False
r.TemporalAA.Upsampling=True
r.AntiAliasingMethod=0
r.MSAACount=4
r.DefaultFeature.LightUnits=1
r.DefaultBackBufferPixelFormat=4
r.Shadow.UnbuiltPreviewInGame=True
r.StencilForLODDither=False
r.EarlyZPass=3
r.EarlyZPassOnlyMaterialMasking=False
r.Shadow.CSMCaching=False
r.DBuffer=True
r.ClearSceneMethod=1
r.VelocityOutputPass=1
r.Velocity.EnableVertexDeformation=2
r.SelectiveBasePassOutputs=False
bDefaultParticleCutouts=False
fx.GPUSimulationTextureSizeX=1024
fx.GPUSimulationTextureSizeY=1024
r.AllowGlobalClipPlane=False
r.GBufferFormat=1
r.MorphTarget.Mode=True
r.GPUCrashDebugging=False
vr.InstancedStereo=False
r.MobileHDR=True
vr.MobileMultiView=False
r.Mobile.UseHWsRGBEncoding=False
vr.RoundRobinOcclusion=False
r.MeshStreaming=False
r.HeterogeneousVolumes=True
r.WireframeCullThreshold=5.000000
r.SupportStationarySkylight=True
r.SupportLowQualityLightmaps=True
r.SupportPointLightWholeSceneShadows=True
r.SupportSkyAtmosphere=True
r.SupportSkyAtmosphereAffectsHeightFog=True
r.SupportCloudShadowOnForwardLitTranslucent=False
r.Shadow.TranslucentPerObject.ProjectEnabled=False
r.Water.SingleLayerWater.SupportCloudShadow=False
r.Substrate=False
r.Substrate.OpaqueMaterialRoughRefraction=False
r.Substrate.Debug.AdvancedVisualizationShaders=False
r.Material.RoughDiffuse=False
r.Material.EnergyConservation=False
r.OIT.SortedPixels=False
r.SkinCache.CompileShaders=False
r.SkinCache.SkipCompilingGPUSkinVF=False
r.SkinCache.DefaultBehavior=1
r.SkinCache.SceneMemoryLimitInMB=128.000000
r.Mobile.EnableStaticAndCSMShadowReceivers=True
r.Mobile.EnableMovableLightCSMShaderCulling=True
r.Mobile.Forward.EnableLocalLights=True
r.Mobile.Forward.EnableClusteredReflections=False
r.Mobile.EnableNoPrecomputedLightingCSMShader=False
r.Mobile.AllowDistanceFieldShadows=True
r.Mobile.AllowMovableDirectionalLights=True
r.Mobile.EnableMovableSpotlightsShadow=False
r.GPUSkin.Support16BitBoneIndex=False
r.GPUSkin.Limit2BoneInfluences=False
r.SupportDepthOnlyIndexBuffers=True
r.SupportReversedIndexBuffers=True
r.Mobile.AmbientOcclusion=False
r.GPUSkin.UnlimitedBoneInfluences=False
r.GPUSkin.UnlimitedBoneInfluencesThreshold=8
DefaultBoneInfluenceLimit=(Default=0,PerPlatform=())
MaxSkinBones=(Default=65536,PerPlatform=(("Mobile", 256)))
r.Mobile.PlanarReflectionMode=0
r.Mobile.SupportsGen4TAA=True
bStreamSkeletalMeshLODs=(Default=False,PerPlatform=())
bDiscardSkeletalMeshOptionalLODs=(Default=False,PerPlatform=())
VisualizeCalibrationColorMaterialPath=/Engine/EngineMaterials/PPM_DefaultCalibrationColor.PPM_DefaultCalibrationColor
VisualizeCalibrationCustomMaterialPath=None
VisualizeCalibrationGrayscaleMaterialPath=/Engine/EngineMaterials/PPM_DefaultCalibrationGrayscale.PPM_DefaultCalibrationGrayscale
[/Script/WorldPartitionEditor.WorldPartitionEditorSettings]
CommandletClass=Class'/Script/UnrealEd.WorldPartitionConvertCommandlet'
[/Script/Engine.UserInterfaceSettings]
bAuthorizeAutomaticWidgetVariableCreation=False
[/Script/Engine.Engine]
+ActiveGameNameRedirects=(OldGameName="TP_Blank",NewGameName="/Script/MecanumVehicle")
+ActiveGameNameRedirects=(OldGameName="/Script/TP_Blank",NewGameName="/Script/MecanumVehicle")
+ActiveClassRedirects=(OldClassName="TP_BlankGameModeBase",NewClassName="MecanumVehicleGameModeBase")
[/Script/AndroidFileServerEditor.AndroidFileServerRuntimeSettings]
bEnablePlugin=True
bAllowNetworkConnection=True
SecurityToken=81D630CB419CCE7C987D8C9AF30709C2
bIncludeInShipping=False
bAllowExternalStartInShipping=False
bCompileAFSProject=False
bUseCompression=False
bLogFiles=False
bReportStats=False
ConnectionType=USBOnly
bUseManualIPAddress=False
ManualIPAddress=

3
Config/DefaultGame.ini Normal file
View File

@ -0,0 +1,3 @@
[/Script/EngineSettings.GeneralProjectSettings]
ProjectID=EE6145CD461B3A171C8C0AA1AE145861

85
Config/DefaultInput.ini Normal file
View File

@ -0,0 +1,85 @@
[/Script/Engine.InputSettings]
-AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.25,Exponent=1.f,Sensitivity=1.f))
-AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
-AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
-AxisConfig=(AxisKeyName="Mouse2D",AxisProperties=(DeadZone=0.f,Exponent=1.f,Sensitivity=0.07f))
+AxisConfig=(AxisKeyName="Gamepad_LeftX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_LeftY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_RightX",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_RightY",AxisProperties=(DeadZone=0.250000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MouseX",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MouseY",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Mouse2D",AxisProperties=(DeadZone=0.000000,Sensitivity=0.070000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MouseWheelAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_LeftTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_RightTriggerAxis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_Special_Left_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Gamepad_Special_Left_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Vive_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Vive_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Vive_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Vive_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Vive_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="Vive_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="MixedReality_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Left_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Right_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="OculusTouch_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Grip_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Left_Trackpad_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Grip_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Grip_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Trigger_Axis",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Thumbstick_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Thumbstick_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_X",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_Y",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
+AxisConfig=(AxisKeyName="ValveIndex_Right_Trackpad_Force",AxisProperties=(DeadZone=0.000000,Sensitivity=1.000000,Exponent=1.000000,bInvert=False))
bAltEnterTogglesFullscreen=True
bF11TogglesFullscreen=True
bUseMouseForTouch=False
bEnableMouseSmoothing=True
bEnableFOVScaling=True
bCaptureMouseOnLaunch=True
bEnableLegacyInputScales=True
bEnableMotionControls=True
bFilterInputByPlatformUser=False
bShouldFlushPressedKeysOnViewportFocusLost=True
bAlwaysShowTouchInterface=False
bShowConsoleOnFourFingerTap=True
bEnableGestureRecognizer=False
bUseAutocorrect=False
DefaultViewportMouseCaptureMode=CapturePermanently_IncludingInitialMouseDown
DefaultViewportMouseLockMode=LockOnCapture
FOVScale=0.011110
DoubleClickTime=0.200000
DefaultPlayerInputClass=/Script/EnhancedInput.EnhancedPlayerInput
DefaultInputComponentClass=/Script/EnhancedInput.EnhancedInputComponent
DefaultTouchInterface=/Engine/MobileResources/HUD/DefaultVirtualJoysticks.DefaultVirtualJoysticks
-ConsoleKeys=Tilde
+ConsoleKeys=Tilde
+ConsoleKeys=Caret

BIN
Content/BP_Master.uasset Normal file

Binary file not shown.

BIN
Content/Level.umap Normal file

Binary file not shown.

BIN
Content/UMG_Master.uasset Normal file

Binary file not shown.

171
MecanumVehicle.py Normal file
View File

@ -0,0 +1,171 @@
#!/usr/bin/env python3
import time
import struct
import socket
import RPi.GPIO as GPIO
def clamp(n, a, b):
if n < a:
return a
elif n > b:
return b
else:
return n
interval = 0.001
udp_addr = ("192.168.1.1", 6000)
GPIO.setmode(GPIO.BCM)
motor_pins = [4, 18, 17, 27, 23, 22, 24, 25]
motor_pwms = []
def init_motor():
GPIO.setup(motor_pins, GPIO.OUT)
for motor_index in range(0, 8):
motor_pwms.append(GPIO.PWM(motor_pins[motor_index], 500))
motor_pwms[motor_index].start(0)
motor_LF_forward = 0
motor_LF_reverse = 1
motor_RF_forward = 3
motor_RF_reverse = 2
motor_LR_forward = 5
motor_LR_reverse = 4
motor_RR_forward = 6
motor_RR_reverse = 7
def stop_motor():
for motor_index in range(0, 8):
motor_pwms[motor_index].ChangeDutyCycle(0.0)
def set_motor(motor, speed, is_brake = False):
motor_forward = -1
motor_reverse = -1
if motor == "LF":
motor_forward = motor_LF_forward
motor_reverse = motor_LF_reverse
elif motor == "RF":
motor_forward = motor_RF_forward
motor_reverse = motor_RF_reverse
elif motor == "LR":
motor_forward = motor_LR_forward
motor_reverse = motor_LR_reverse
else: # motor == "RR"
motor_forward = motor_RR_forward
motor_reverse = motor_RR_reverse
if is_brake == True:
motor_pwms[motor_forward].ChangeDutyCycle(100.0)
motor_pwms[motor_reverse].ChangeDutyCycle(100.0)
elif speed < 0:
motor_pwms[motor_forward].ChangeDutyCycle(0.0)
motor_pwms[motor_reverse].ChangeDutyCycle(-speed * 100.0)
elif speed > 0:
motor_pwms[motor_forward].ChangeDutyCycle(speed * 100.0)
motor_pwms[motor_reverse].ChangeDutyCycle(0.0)
else:
motor_pwms[motor_forward].ChangeDutyCycle(0.0)
motor_pwms[motor_reverse].ChangeDutyCycle(0.0)
sock = socket.socket()
lasttime = 0
def init_udp():
global sock
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(("0.0.0.0", 6000))
sock.setblocking(False)
def hand_udp():
global sock
global udp_addr
global lasttime
try:
(data, source) = sock.recvfrom(1024)
udp_addr = source
if len(data) == 6:
seq, speed_LF, speed_RF, speed_LR, speed_RR, is_brake = struct.unpack("!Bbbbb?", data)
set_motor("LF", clamp(speed_LF / 128, -1.0, 1.0), is_brake)
set_motor("RF", clamp(speed_RF / 128, -1.0, 1.0), is_brake)
set_motor("LR", clamp(speed_LR / 128, -1.0, 1.0), is_brake)
set_motor("RR", clamp(speed_RR / 128, -1.0, 1.0), is_brake)
sock.sendto(struct.pack("!B", seq), udp_addr)
lasttime = time.time()
except socket.error:
pass
if time.time() - lasttime >= 0.5:
set_motor("LF", 0.0, True)
set_motor("RF", 0.0, True)
set_motor("LR", 0.0, True)
set_motor("RR", 0.0, True)
try:
init_motor()
init_udp()
while True:
hand_udp()
time.sleep(interval)
except KeyboardInterrupt:
print("\nKeyboardInterrupt")
finally:
stop_motor()
GPIO.cleanup()
print("Exit")

22
MecanumVehicle.uproject Normal file
View File

@ -0,0 +1,22 @@
{
"FileVersion": 3,
"EngineAssociation": "5.3",
"Category": "",
"Description": "",
"Modules": [
{
"Name": "MecanumVehicle",
"Type": "Runtime",
"LoadingPhase": "Default"
}
],
"Plugins": [
{
"Name": "ModelingToolsEditorMode",
"Enabled": true,
"TargetAllowList": [
"Editor"
]
}
]
}

View File

@ -0,0 +1,32 @@
[/Script/HoloLensPlatformEditor.HoloLensTargetSettings]
bBuildForEmulation=False
bBuildForDevice=True
bUseNameForLogo=True
bBuildForRetailWindowsStore=False
bAutoIncrementVersion=False
bShouldCreateAppInstaller=False
AppInstallerInstallationURL=
HoursBetweenUpdateChecks=0
bEnablePIXProfiling=False
TileBackgroundColor=(B=64,G=0,R=0,A=255)
SplashScreenBackgroundColor=(B=64,G=0,R=0,A=255)
+PerCultureResources=(CultureId="",Strings=(PackageDisplayName="",PublisherDisplayName="",PackageDescription="",ApplicationDisplayName="",ApplicationDescription=""),Images=())
TargetDeviceFamily=Windows.Holographic
MinimumPlatformVersion=10.0.18362.0
MaximumPlatformVersionTested=10.0.19041.0
MaxTrianglesPerCubicMeter=500.000000
SpatialMeshingVolumeSize=20.000000
CompilerVersion=Default
Windows10SDKVersion=10.0.18362.0
+CapabilityList=internetClientServer
+CapabilityList=privateNetworkClientServer
+Uap2CapabilityList=spatialPerception
bSetDefaultCapabilities=False
SpatializationPlugin=
SourceDataOverridePlugin=
ReverbPlugin=
OcclusionPlugin=
SoundCueCookQualityIndex=-1

15
README.md Normal file
View File

@ -0,0 +1,15 @@
### MecanumVehicle
> 这是 2023 年山东理工大学 秋名山机器人竞速大赛 的小车
MecanumVehicle.py - 树莓派车入口
MecanumVehicle.uproject - 控制端入口
基于树莓派的简单网络遥控车实现方案。
支持使用主流游戏手柄操作,电机功率差速补偿,远程操作。
网络协议基于 UDP ,车作为服务端,控制端作为客户端接入。
客户端基于 Unreal Engine 5 ,其中控制端在 Windows 11 平台上测试通过。

View File

@ -0,0 +1,15 @@
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
using System.Collections.Generic;
public class MecanumVehicleTarget : TargetRules
{
public MecanumVehicleTarget( TargetInfo Target) : base(Target)
{
Type = TargetType.Game;
DefaultBuildSettings = BuildSettingsVersion.V2;
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_1;
ExtraModuleNames.Add("MecanumVehicle");
}
}

View File

@ -0,0 +1,31 @@
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class MecanumVehicle : ModuleRules
{
public MecanumVehicle(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
"Engine",
"InputCore" ,
"CoreUObject",
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
"RHI",
"Sockets",
"Networking",
"RenderCore",
}
);
}
}

View File

@ -0,0 +1,6 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "MecanumVehicle.h"
#include "Modules/ModuleManager.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, MecanumVehicle, "MecanumVehicle" );

View File

@ -0,0 +1,6 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"

View File

@ -0,0 +1,127 @@
#include "MecanumVehicleAdapter.h"
#include "Sockets.h"
#include "Networking.h"
#include "Misc/Timespan.h"
#include "SocketSubsystem.h"
AMecanumVehicleAdapter::AMecanumVehicleAdapter(const FObjectInitializer& ObjectInitializer)
{
PrimaryActorTick.bCanEverTick = true;
}
void AMecanumVehicleAdapter::BeginPlay()
{
Super::BeginPlay();
SocketSubsystem = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM);
UDPSocket = SocketSubsystem->CreateSocket(NAME_DGram, TEXT("Raspberry Socket"), FNetworkProtocolTypes::IPv4);
UDPBuffer.SetNumUninitialized(1024);
PingTime = 1024.0;
for (int32 Index = 0; Index < MAX_uint8; ++Index)
{
UDPRecvTime[Index] = FDateTime(0);
}
UpdataSocket(TEXT("192.168.1.1"));
}
void AMecanumVehicleAdapter::UpdataCompensation(const TArray<double>& Value)
{
if (Value.Num() != 8) return;
SpeedCompensationMax[0] = Value[0];
SpeedCompensationMax[1] = Value[1];
SpeedCompensationMax[2] = Value[2];
SpeedCompensationMax[3] = Value[3];
SpeedCompensationMin[0] = Value[4];
SpeedCompensationMin[1] = Value[5];
SpeedCompensationMin[2] = Value[6];
SpeedCompensationMin[3] = Value[7];
}
void AMecanumVehicleAdapter::UpdataSocket(const FString& IP, const int32 Port)
{
int32 BytesNum = 0;
Addr = SocketSubsystem->CreateInternetAddr();
bool bIsValid;
Addr->SetIp(TEXT("192.168.1.1"), bIsValid);
Addr->SetIp(*IP, bIsValid);
Addr->SetPort(Port);
}
void AMecanumVehicleAdapter::UpdataInput(const FVector Value, const bool bIsBrake)
{
++UDPSequenceIndex;
UDPSequenceIndex %= MAX_uint8;
UDPRecvTime[UDPSequenceIndex] = FDateTime::UtcNow();
double SpeedLF = 0.0f;
double SpeedRF = 0.0f;
double SpeedLR = 0.0f;
double SpeedRR = 0.0f;
SpeedLF += Value.X;
SpeedRF += Value.X;
SpeedLR += Value.X;
SpeedRR += Value.X;
SpeedLF += Value.Y;
SpeedRF -= Value.Y;
SpeedLR -= Value.Y;
SpeedRR += Value.Y;
SpeedLF += Value.Z;
SpeedRF -= Value.Z;
SpeedLR += Value.Z;
SpeedRR -= Value.Z;
UDPBuffer[0] = UDPSequenceIndex;
UDPBuffer[1] = (int8)(FMath::Clamp(FMath::Sign(SpeedLF) * FMath::Lerp(SpeedCompensationMin[0], SpeedCompensationMax[0], FMath::Abs(SpeedLF)) * 128.0, MIN_int8, MAX_int8));
UDPBuffer[2] = (int8)(FMath::Clamp(FMath::Sign(SpeedRF) * FMath::Lerp(SpeedCompensationMin[1], SpeedCompensationMax[1], FMath::Abs(SpeedRF)) * 128.0, MIN_int8, MAX_int8));
UDPBuffer[3] = (int8)(FMath::Clamp(FMath::Sign(SpeedLR) * FMath::Lerp(SpeedCompensationMin[2], SpeedCompensationMax[2], FMath::Abs(SpeedLR)) * 128.0, MIN_int8, MAX_int8));
UDPBuffer[4] = (int8)(FMath::Clamp(FMath::Sign(SpeedRR) * FMath::Lerp(SpeedCompensationMin[3], SpeedCompensationMax[3], FMath::Abs(SpeedRR)) * 128.0, MIN_int8, MAX_int8));
UDPBuffer[5] = bIsBrake;
int32 BytesNum = 0;
UDPSocket->SendTo(UDPBuffer.GetData(), 6, BytesNum, *Addr);
}
void AMecanumVehicleAdapter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
int32 BytesNum = 0;
TSharedRef<FInternetAddr> Source = SocketSubsystem->CreateInternetAddr();
uint32 PendingDataSize;
while (UDPSocket->HasPendingData(PendingDataSize))
{
UDPSocket->RecvFrom(UDPBuffer.GetData(), UDPBuffer.Num(), BytesNum, *Source);
if (BytesNum == 1)
{
uint8 Index = UDPBuffer[0];
PingTime = (FDateTime::UtcNow() - UDPRecvTime[Index]).GetTotalMilliseconds();
}
else continue;
UDPLastTime = FDateTime::UtcNow();
}
PingTime = FMath::Max(PingTime, (FDateTime::UtcNow() - UDPLastTime).GetTotalMilliseconds());
}
void AMecanumVehicleAdapter::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
Super::EndPlay(EndPlayReason);
}

View File

@ -0,0 +1,59 @@
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MecanumVehicleAdapter.generated.h"
class FSocket;
class ISocketSubsystem;
UCLASS()
class MECANUMVEHICLE_API AMecanumVehicleAdapter : public AActor
{
GENERATED_BODY()
public:
AMecanumVehicleAdapter(const FObjectInitializer& ObjectInitializer);
UPROPERTY(BlueprintReadOnly)
double PingTime;
UFUNCTION(BlueprintCallable)
void UpdataCompensation(const TArray<double>& Value);
UFUNCTION(BlueprintCallable)
void UpdataSocket(const FString& IP, const int32 Port = 6000);
UFUNCTION(BlueprintCallable)
void UpdataInput(const FVector Value, const bool bIsBrake);
UFUNCTION(BlueprintCallable)
//~ Begin AActor Interface.
virtual void BeginPlay() override;
virtual void Tick(float DeltaSeconds) override;
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
//~ End AActor Interface.
private:
ISocketSubsystem* SocketSubsystem;
FSocket* UDPSocket;
TSharedPtr<FInternetAddr> Addr;
TArray<uint8> UDPBuffer;
int32 UDPSequenceIndex = 0;
FDateTime UDPLastTime;
FDateTime UDPRecvTime[(int32)MAX_uint8 + 1];
double SpeedCompensationMax[4] = { 1.0, 1.0, 1.0, 1.0 };
double SpeedCompensationMin[4] = { 0.0, 0.0, 0.0, 0.0 };
};

View File

@ -0,0 +1,15 @@
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
using System.Collections.Generic;
public class MecanumVehicleEditorTarget : TargetRules
{
public MecanumVehicleEditorTarget( TargetInfo Target) : base(Target)
{
Type = TargetType.Editor;
DefaultBuildSettings = BuildSettingsVersion.V2;
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_1;
ExtraModuleNames.Add("MecanumVehicle");
}
}