RapyutaSimulationPlugins
RobotVehicleMovementComponent.h
Go to the documentation of this file.
1 
13 #pragma once
14 
15 
16 
17 // System
18 
19 #include <random>
20 
21 
22 
23 // UE
24 
25 #include "CoreMinimal.h"
26 
27 #include "GameFramework/PawnMovementComponent.h"
28 
29 
30 
31 // RapyutaSimulationPlugins
32 
34 
35 
36 
37 //Thirdparty
38 
39 #include "filter.hpp"
40 
41 
42 
43 #include "RobotVehicleMovementComponent.generated.h"
44 
45 
46 
47 class ARRBaseRobot;
48 
50 
51 
52 
90 class RAPYUTASIMULATIONPLUGINS_API URobotVehicleMovementComponent : public UPawnMovementComponent
91 
92 {
93 
94 
95 
96 private:
97 
98  // For Elevator management
99 
101 
102 
107  AActor* MovingPlatform = nullptr;
108 
109 
110 
111 
116  FVector LastPlatformLocation = FVector::ZeroVector;
117 
118 
119 
120 
125  FQuat LastPlatformRotation = FQuat::Identity;
126 
127 
128 
130 
132 
133 
134 
135 
140  TArray<USceneComponent*> ContactPoints;
141 
142 
143 
144 public:
145 
146 
151  ARRBaseRobot* OwnerVehicle = nullptr;
152 
153 
154 
155 
160  TObjectPtr<URRFloatingMovementComponent> AIMovementComp = nullptr;
161 
162 
163 
175  void InitAIMovementComp();
176 
177 
178 
191  virtual void SetUpdatedComponent(USceneComponent* InNewUpdatedComponent) override;
192 
193 
194 
196 
197 
202  FVector AngularVelocity = FVector::ZeroVector;
203 
204 
205 
207 
209 
211 
212 
217  FVector DesiredMovement = FVector::ZeroVector;
218 
219 
220 
222 
223 
228  FQuat DesiredRotation = FQuat::Identity;
229 
230 
231 
232  // For slopes, complex floors, free fall
233 
234 
235 
237 
238 
243  float RayOffsetUp = 10.f;
244 
245 
246 
248 
250 
251 
256  float RayOffsetDown = 20.f;
257 
258 
259 
261 
262 
267  bool bAdaptToSurfaceBelow = true;
268 
269 
270 
284  virtual void Initialize();
285 
286 
287 
301  virtual void InitVelFilters();
302 
303 
304 
306 
307 
312  int8 InversionFactor = 1;
313 
314 
315 
331  virtual void InitData();
332 
333 
334 
335 
340  void SetMovingPlatform(AActor* platform);
341 
342 
343 
344 
349  bool IsOnMovingPlatform();
350 
351 
352 
353 
358  void RemoveMovingPlatform();
359 
360 
361 
362  // For slopes, complex floors, free fall
363 
364 
365 
367 
368 
373  float MinDistanceToFloor = 0.f;
374 
375 
376 
378 
379 
384  float FallingSpeed = 100.f;
385 
386 
387 
389 
390 
395  URRBaseOdomComponent* OdomComponent = nullptr;
396 
397 
398 
400 
401 
406  FVector LinearVelFilterTau = FVector::ZeroVector;
407 
408 
409 
411 
412 
417  FVector AngVelFilterTau = FVector::ZeroVector;
418 
419 
420 
421 protected:
422 
423  virtual bool IsSupportedForNetworking() const override
424 
425  {
426 
427  return true;
428 
429  }
430 
431 
432 
453  virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
454 
455 
456 
489  virtual void UpdateMovement(float InDeltaTime);
490 
491 
492 
494 
495 
500  float LogLastHit = 0.f;
501 
502 
503 
505 
506  TStaticArray<FirstOrderSystem, 3> LinearVelFilter;
507 
508 
509 
511 
512  TStaticArray<FirstOrderSystem, 3> AngVelFilter;
513 
514 };
515 
URobotVehicleMovementComponent
Base Robot vehicle movement class which is used as part of ARobotVehicle.
Definition: RobotVehicleMovementComponent.h:90
URobotVehicleMovementComponent::LinearVelFilter
TStaticArray< FirstOrderSystem, 3 > LinearVelFilter
Linear Velocity Filter.
Definition: RobotVehicleMovementComponent.h:506
URRBaseOdomComponent
Base Odom Component which provide actor pose changes.
Definition: RRBaseOdomComponent.h:85
URobotVehicleMovementComponent::AngVelFilter
TStaticArray< FirstOrderSystem, 3 > AngVelFilter
Angular Velocity Filter.
Definition: RobotVehicleMovementComponent.h:512
URobotVehicleMovementComponent::IsSupportedForNetworking
virtual bool IsSupportedForNetworking() const override
Definition: RobotVehicleMovementComponent.h:423
URobotVehicleMovementComponent::ContactPoints
TArray< USceneComponent * > ContactPoints
List all scene components on the pawn. that have the tag "ContactPoint". This is used to adapt the ro...
Definition: RobotVehicleMovementComponent.h:140
RRBaseOdomComponent.h
Base Odom Component which provides actor pose changes.
URRFloatingMovementComponent
Base Robot floating movement class.
Definition: RRFloatingMovementComponent.h:50
ARRBaseRobot
Base Robot class. Other robot class should inherit from this class.
Definition: RRBaseRobot.h:161