RapyutaSimulationPlugins
RRJointComponent.h
Go to the documentation of this file.
1 
13 #pragma once
14 
15 
16 
17 // UE
18 
19 #include "Components/ActorComponent.h"
20 
21 #include "CoreMinimal.h"
22 
23 
24 
25 // RapyutaSimulationPlugins
26 
28 
30 
31 
32 
33 #include "RRJointComponent.generated.h"
34 
35 
36 
37 #define RAPYUTA_JOINT_DEBUG (0)
38 
39 
40 
41 DECLARE_DYNAMIC_DELEGATE(FJointCallback);
42 
43 
44 
45 
50 enum class ERRJointControlType : uint8
51 
52 {
53 
54  POSITION ,
55 
56  VELOCITY ,
57 
58  EFFORT ,
59 
60 };
61 
62 
63 
81 class RAPYUTASIMULATIONPLUGINS_API URRJointComponent : public USceneComponent
82 
83 {
84 
85 
86 
87 public:
88 
89  // Sets default values for this component's properties
90 
92 
93 
94 
95 protected:
96 
97  virtual void PoseFromArray(const TArray<float>& InPose, FVector& OutPosition, FRotator& OutOrientation);
98 
99  virtual void VelocityFromArray(const TArray<float>& InVelocity, FVector& OutLinearVelocity, FVector& OutAngularVelocity);
100 
101 
102 
103 public:
104 
105  virtual bool IsValid();
106 
107 
108 
123  virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
124 
125 
126 
135  virtual void InitializeComponent() override;
136 
137 
138 
156  virtual void SetVelocity(const FVector& InLinearVelocity, const FVector& InAngularVelocity);
157 
158 
159 
177  virtual void SetVelocityTarget(const FVector& InLinearVelocity, const FVector& InAngularVelocity);
178 
179 
180 
198  virtual void SetSingleLinearVelocityTarget(const float Input);
199 
200 
201 
219  virtual void SetSingleAngularVelocityTarget(const float Input);
220 
221 
222 
250  virtual void SetVelocityTargetWithDelegates(const FVector& InLinearVelocity,
251 
252  const FVector& InAngularVelocity,
253 
254  const FJointCallback& InOnControlSuccessDelegate,
255 
256  const FJointCallback& InOnControlFailDelegate,
257 
258  const float InLinearTolerance = -1.0,
259 
260  const float InAngularTolerance = -1.0,
261 
262  const float InTimeOut = -1.0);
263 
264 
265 
293  virtual void SetSingleLinearVelocityTargetWithDelegates(const float Input,
294 
295  const FJointCallback& InOnControlSuccessDelegate,
296 
297  const FJointCallback& InOnControlFailDelegate,
298 
299  const float InLinearTolerance = -1.0,
300 
301  const float InTimeOut = -1.0);
302 
303 
304 
332  virtual void SetSingleAngularVelocityTargetWithDelegates(const float Input,
333 
334  const FJointCallback& InOnControlSuccessDelegate,
335 
336  const FJointCallback& InOnControlFailDelegate,
337 
338  const float InAngularTolerance = -1.0,
339 
340  const float InTimeOut = -1.0);
341 
342 
343 
361  virtual void SetVelocityWithArray(const TArray<float>& InVelocity);
362 
363 
364 
382  virtual void SetVelocityTargetWithArray(const TArray<float>& InVelocity);
383 
384 
385 
413  virtual void SetVelocityTargetWithArrayWithDelegates(const TArray<float>& InVelocity,
414 
415  const FJointCallback& InOnControlSuccessDelegate,
416 
417  const FJointCallback& InOnControlFailDelegate,
418 
419  const float InLinearTolerance = -1.0,
420 
421  const float InAngularTolerance = -1.0,
422 
423  const float InTimeOut = -1.0);
424 
425 
426 
440  virtual bool HasReachedVelocityTarget(const float InLinearTolerance = -1.f, const float InAngularTolerance = -1.f);
441 
442 
443 
461  virtual void SetPose(const FVector& InPosition, const FRotator& InOrientation);
462 
463 
464 
482  virtual void SetPoseTarget(const FVector& InPosition, const FRotator& InOrientation);
483 
484 
485 
503  virtual void SetSinglePositionTarget(const float Input);
504 
505 
506 
524  virtual void SetSingleOrientationTarget(const float Input);
525 
526 
527 
555  virtual void SetPoseTargetWithDelegates(const FVector& InPosition,
556 
557  const FRotator& InOrientation,
558 
559  const FJointCallback& InOnControlSuccessDelegate,
560 
561  const FJointCallback& InOnControlFailDelegate,
562 
563  const float InPositionTolerance = -1.0,
564 
565  const float InOrientationTolerance = -1.0,
566 
567  const float InTimeOut = -1.0);
568 
569 
570 
596  virtual void SetSinglePositionTargetWithDelegates(const float Input,
597 
598  const FJointCallback& InOnControlSuccessDelegate,
599 
600  const FJointCallback& InOnControlFailDelegate,
601 
602  const float InPositionTolerance = -1.0,
603 
604  const float InTimeOut = -1.0);
605 
606 
607 
633  virtual void SetSingleOrientationTargetWithDelegates(const float Input,
634 
635  const FJointCallback& InOnControlSuccessDelegate,
636 
637  const FJointCallback& InOnControlFailDelegate,
638 
639  const float InOrientationTolerance = -1.0,
640 
641  const float InTimeOut = -1.0);
642 
643 
644 
660  virtual bool HasReachedPoseTarget(const float InPositionTolerance = -1.f, const float InOrientationTolerance = -1.f);
661 
662 
663 
681  virtual void SetPoseWithArray(const TArray<float>& InPose);
682 
683 
684 
702  virtual void SetPoseTargetWithArray(const TArray<float>& InPose);
703 
704 
705 
727  virtual void SetPoseTargetWithArrayWithDelegates(const TArray<float>& InPose,
728 
729  const FJointCallback& InOnControlSuccessDelegate,
730 
731  const FJointCallback& InOnControlFailDelegate,
732 
733  const float InPositionTolerance = -1.0,
734 
735  const float InOrientationTolerance = -1.0,
736 
737  const float InTimeOut = -1.0);
738 
739 
740 
754  virtual void Teleport(const FVector& InPosition, const FRotator& InOrientation);
755 
756 
757 
758 
763  virtual void MoveToInitPose();
764 
765 
766 
767 
772  FVector LinearVelocity = FVector::ZeroVector;
773 
774 
775 
776 
781  FVector AngularVelocity = FVector::ZeroVector;
782 
783 
784 
785 
790  FVector LinearVelocityTarget = FVector::ZeroVector;
791 
792 
793 
794 
799  FVector AngularVelocityTarget = FVector::ZeroVector;
800 
801 
802 
803 
808  FVector PositionTarget = FVector::ZeroVector;
809 
810 
811 
812 
817  FRotator OrientationTarget = FRotator::ZeroRotator;
818 
819 
820 
821 
826  FVector Position = FVector::ZeroVector;
827 
828 
829 
830 
835  FRotator Orientation = FRotator::ZeroRotator;
836 
837 
838 
840 
841 
846  float PositionTolerance = 1.f;
847 
848 
849 
851 
852 
857  float OrientationTolerance = 1.f;
858 
859 
860 
862 
863 
868  float LinearVelocityTolerance = 10.f;
869 
870 
871 
873 
874 
879  float AngularVelocityTolerance = 10.f;
880 
881 
882 
883 
888  UStaticMeshComponent* ParentLink;
889 
890 
891 
892 
897  UStaticMeshComponent* ChildLink;
898 
899 
900 
901 
907 
908 
909 
911 
912 
917  uint8 LinearDOF = 0;
918 
919 
920 
922 
923 
928  uint8 RotationalDOF = 1;
929 
930 
931 
933 
935 
936 
941  FVector PositionMax = FVector(1000, 1000, 1000);
942 
943 
944 
946 
947 
952  FVector PositionMin = FVector(-1000, -1000, -1000);
953 
954 
955 
957 
958 
963  FRotator OrientationMax = FRotator(180.f);
964 
965 
966 
968 
969 
974  FRotator OrientationMin = FRotator(-180, -180, -180);
975 
976 
977 
979 
981 
982 
987  FVector LinearVelMax = FVector(1000, 1000, 1000);
988 
989 
990 
992 
993 
998  FVector AngularVelMax = FVector(180.f);
999 
1000 
1001 
1002 
1007  bool bLimitRoll = true;
1008 
1009 
1010 
1011 
1016  bool bLimitPitch = true;
1017 
1018 
1019 
1020 
1025  bool bLimitYaw = true;
1026 
1027 
1028 
1029 
1034  FVector InitialPosition = FVector::ZeroVector;
1035 
1036 
1037 
1038 
1043  FRotator InitialOrientation = FRotator::ZeroRotator;
1044 
1045 
1046 
1047 
1052  FTransform GetJointToChildLink()
1053 
1054  {
1055 
1056  return JointToChildLink;
1057 
1058  }
1059 
1060 
1061 
1062 
1068 
1069  {
1070 
1071  return ParentLinkToJoint;
1072 
1073  }
1074 
1075 
1076 
1077 protected:
1078 
1079 
1084  virtual void UpdateState(const float DeltaTime);
1085 
1086 
1087 
1088 
1093  virtual void UpdateControl(const float DeltaTime);
1094 
1095 
1096 
1097 
1102  FTransform JointToChildLink = FTransform::Identity;
1103 
1104 
1105 
1106 
1111  FTransform ParentLinkToJoint = FTransform::Identity;
1112 
1113 
1114 
1116 
1117 
1122  bool bMovingToTargetPose = false;
1123 
1124 
1125 
1127 
1128 
1133  bool bMovingToTargetVelocity = false;
1134 
1135 
1136 
1155  virtual void SetDelegates(const FJointCallback& InOnControlSuccessDelegate,
1156 
1157  const FJointCallback& InOnControlFailDelegate,
1158 
1159  const float InPositionTolerance = -1.0,
1160 
1161  const float InOrientationTolerance = -1.0,
1162 
1163  const float InLinearTolerance = -1.0,
1164 
1165  const float InAngularTolerance = -1.0,
1166 
1167  const float InTimeOut = -1.0f);
1168 
1169 
1170 
1172 
1173 
1179 
1180 
1181 
1183 
1184 
1189  FJointCallback OnControlFailDelegate;
1190 
1191 
1192 
1194 
1195  float ControlStartTime = 0.f;
1196 
1197 
1198 
1200 
1202 
1204 
1205 
1210  float ControlTimeout = -1.0f;
1211 
1212 
1213 
1214 
1219  virtual void ResetControl();
1220 
1221 };
1222 
ERRJointControlType::VELOCITY
@ VELOCITY
UMETA(DisplayName = "Velocity"),.
ERRJointControlType::POSITION
@ POSITION
UMETA(DisplayName = "Position"),.
ERRJointControlType
ERRJointControlType
Definition: RRJointComponent.h:50
DECLARE_DYNAMIC_DELEGATE
DECLARE_DYNAMIC_DELEGATE(FJointCallback)
URRJointComponent::GetJointToChildLink
FTransform GetJointToChildLink()
Definition: RRJointComponent.h:1052
URRJointComponent::ParentLink
UStaticMeshComponent * ParentLink
Definition: RRJointComponent.h:888
URRJointComponent::OnControlFailDelegate
FJointCallback OnControlFailDelegate
Delegate which is called whenjoint failed to reach target vel/pose.
Definition: RRJointComponent.h:1189
URRJointComponent
Base Joints class. Other joint class should inherit from this class.
Definition: RRJointComponent.h:81
ERRJointControlType::EFFORT
@ EFFORT
UMETA(DisplayName = "Effort")
RRStaticMeshComponent.h
static mesh component
URRJointComponent::ChildLink
UStaticMeshComponent * ChildLink
Definition: RRJointComponent.h:897
URRJointComponent::OnControlSuccessDelegate
FJointCallback OnControlSuccessDelegate
Delegate which is called when joint reach target vel/pose.
Definition: RRJointComponent.h:1178
URRJointComponent::GetParentLinkToJoint
FTransform GetParentLinkToJoint()
Definition: RRJointComponent.h:1067
RRROS2TFPublisher.h
TF publisher class.