RoveSoSimulator
Loading...
Searching...
No Matches
RoverVehiclePawn.h
1#pragma once
2
3#include <iterator>
4#include "Components/ChildActorComponent.h"
5#include "Core/RoverInterface.h"
6#include "Containers/Map.h"
7#include "HAL/Platform.h"
8#include "Templates/Tuple.h"
9#include "Templates/UniquePtr.h"
10#include "WheeledVehiclePawn.h"
11#include "RoverVehiclePawn.generated.h"
12
13class ARoveSoSimulatorPlayerController;
14class URoveCommPacketWrapper;
16
17class UChaosWheeledVehicleMovementComponent;
18class USpringArmComponent;
19class UCameraComponent;
20class USplineComponent;
21class USplineMeshComponent;
22class UTextRenderComponent;
23
24class AGeoReferencingSystem;
25
26class ITalos2025Interface;
27
28/**
29 * @brief Custom WheeledVehiclePawn subclass which integrates many required pieces of logic for the rover's function
30 */
31UCLASS()
32class ROVESOSIMULATOR_API ARoverVehiclePawn : public AWheeledVehiclePawn
33{
34 GENERATED_BODY()
35
36public:
37 ARoverVehiclePawn();
38
39protected:
40 virtual void BeginPlay() override;
41 virtual void Tick(float DeltaTime) override;
42 void SetupPlayerInput();
43 void OnControlStateChange();
44 void OnCameraStateChange();
45 void OnAttachmentStateChange();
46 void ZeroRoverMovement();
47 void ApplyTorque(TArray<int32> wheelIndices, float throttle);
48 void RotateCamera(float yaw, float pitch);
49 void SplineDrawTick();
50 void UpdateBackPanel();
51 void SendCompassTelemetry();
52 void SendRoveCommTelemetry();
53
54 uint8 ControlState;
55 uint8 CameraState;
56 uint8 AttachmentState;
57 float TranslationThrottle;
58 float RotationDelta;
59 float LeftThrottle;
60 float RightThrottle;
61
62 FVector SavedSpawnPoint;
63 FRotator SavedSpawnRotation;
64
65 bool DoSplineDrawing;
66 FVector LastSplineLocation;
67
68 bool PointcloudVisible;
69
70 // -- Pointers --
71
72 ARoveSoSimulatorPlayerController* PlayerController;
73 UChaosWheeledVehicleMovementComponent* VehicleMovement;
74 TUniquePtr<IRoverInterface> RoverInterface;
75 URoveCommUDPWrapper* UDPWrapper;
76 AGeoReferencingSystem* GeoRefSystem;
77
78 FTimerHandle RoveCommTimerHandle;
79 URoveCommPacketWrapper* GPSTelemetryPacket;
80 URoveCommPacketWrapper* AccuracyTelemetryPacket;
81 FTimerHandle CompassTimerHandle;
82 URoveCommPacketWrapper* CompassTelemetryPacket;
83
84 USpringArmComponent* CameraSpringArm;
85 UCameraComponent* Camera;
86
87 UStaticMeshComponent* BackPanel;
88 UMaterialInstanceDynamic* BackPanelMaterial;
89
90 USplineComponent* Spline;
91 TArray<USplineMeshComponent*> SplineMeshes;
92
93 TWeakObjectPtr<UStaticMeshComponent> AutoHead;
94 TWeakObjectPtr<UChildActorComponent> Arm;
95
96 USpringArmComponent* ZEDSpringArm;
97 TSubclassOf<AActor> ZED2iStereoCamera;
98 UChildActorComponent* FrontZEDCamera;
99 UChildActorComponent* RearZEDCamera;
100
101 // --- ROVER SETUP ---
102
103 UPROPERTY(EditDefaultsOnly, Category="Rover Setup")
104 ERoverInterfaceSubclasses RoverInterfaceSubclass;
105
106 UPROPERTY(EditDefaultsOnly, Category="Rover Setup")
107 bool HasRearZED;
108 // Distance the rover must travel before another point is added to the trail
109 UPROPERTY(EditDefaultsOnly, Category="Rover Setup")
110 float SplineTrailDistance;
111 // Static mesh for the trail to be drawn with
112 UPROPERTY(EditDefaultsOnly, Category="Rover Setup")
113 UStaticMesh* SplineTrailMesh;
114 // Material for the trail to recieve
115 UPROPERTY(EditDefaultsOnly, Category="Rover Setup")
116 UMaterial* SplineTrailMaterial;
117
118 // Location the rover spawns at and resets to
119 UPROPERTY(EditDefaultsOnly, Category="Rover Setup")
120 FVector RoverResetLocation;
121
122 // Motor max torque in N*m
123 UPROPERTY(EditAnywhere, Category = "Rover Setup")
124 float MotorMaxTorque;
125 // Motor power in watts
126 UPROPERTY(EditAnywhere, Category = "Rover Setup")
127 float MotorPower;
128 // Final gear ratio between motor and wheel (Higher Ratio = Lower Torque & Higher RPM)
129 UPROPERTY(EditAnywhere, Category = "Rover Setup")
130 float FinalGearRatio;
131 // Final mechanical efficiency from motor to wheel (float 0-1)
132 UPROPERTY(EditAnywhere, Category = "Rover Setup")
133 float FinalMechanicalEfficiency;
134
135 // List of indicies of left-side wheels in the Chaos wheel setup
136 UPROPERTY(EditAnywhere, Category = "Rover Setup")
137 TArray<int32> LeftWheelIndices;
138 // List of indicies of right-side wheels in the Chaos wheel setup
139 UPROPERTY(EditAnywhere, Category = "Rover Setup")
140 TArray<int32> RightWheelIndices;
141
142public:
143 void RoveCommDriveCallback();
144 void RoveCommBackpanelCallback();
145
146 void SetSpawnPointCallback();
147 void GotoSpawnPointCallback();
148 void ResetSplineCallback();
149 void ToggleSplineCallback();
150 void TogglePointcloudCallback();
151 void ResetRoverCallback();
152 void FlipRoverCallback();
153
154 friend class ITalos2025Interface;
155};
Custom WheeledVehiclePawn subclass which integrates many required pieces of logic for the rover's fun...
Definition RoverVehiclePawn.h:33
Blueprintable wrapper class for RoveCommUDP to allow usage in Unreal Engine Blueprints.
Definition RoveCommUDPWrapper.h:25