Agrarsense
TransformSensor.h
Go to the documentation of this file.
1// Copyright (c) 2023 FrostBit Software Lab at the Lapland University of Applied Sciences
2//
3// This work is licensed under the terms of the MIT license.
4// For a copy, see <https://opensource.org/licenses/MIT>.
5
6#pragma once
7
8#include "CoreMinimal.h"
11
12#include "ROSIntegration/Public/geometry_msgs/Transform.h"
13#include "ROSIntegration/Public/std_msgs/String.h"
14
15#include "TransformSensor.generated.h"
16
17class AGeoReferencingSystem;
18
19/*
20* This Sensor publishes target Actor World transform
21* and GNSS (Latitude, Longitude and Altitude) to ROS topic.
22*/
23UCLASS()
24class AGRARSENSE_API ATransformSensor : public ASensor
25{
26 GENERATED_BODY()
27
28public:
29
30 ATransformSensor(const FObjectInitializer& ObjectInitializer);
31
32 void Init(AActor* TransformActor, bool SimulateSensor = true);
33
38 virtual ESensorTypes GetSensorType() const override
39 {
41 }
42
43protected:
44
45 virtual void BeginPlay() override;
46
47 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
48
49 virtual void CreateROSTopic() override;
50
51 virtual void DestroyROSTopic() override;
52
53private:
54
55 void TickParallel(float DeltaTime);
56
57 void SendTransformDataToROS(const FVector& Translation, const FQuat& Rotation);
58
59 void SendGnssDataToROS(const FVector& ActorPosition);
60
61 TSharedPtr<ROSMessages::geometry_msgs::Transform> TransformMessage;
62
63 TSharedPtr<ROSMessages::std_msgs::String> GnssMessageString;
64
65 TWeakObjectPtr<AActor> Target;
66
67 UPROPERTY()
68 FVector PreviousActorPosition = FVector(0.0f, 0.0f, 0.0f);
69
70 UPROPERTY()
71 FTickEntry TickEntry;
72
73 UPROPERTY()
74 UTopic* GnssTopic = nullptr;
75
76 UPROPERTY()
77 AGeoReferencingSystem* GeoReferencingSystem = nullptr;
78
79};
ESensorTypes
Definition: SensorTypes.h:15
Definition: Sensor.h:44
virtual ESensorTypes GetSensorType() const override
TSharedPtr< ROSMessages::std_msgs::String > GnssMessageString
TSharedPtr< ROSMessages::geometry_msgs::Transform > TransformMessage
TWeakObjectPtr< AActor > Target