6
6
*
7
7
*/
8
8
9
- #include < AzCore/Math/Matrix4x4.h>
10
9
#include " ROS2GNSSSensorComponent.h"
10
+ #include < AzCore/Math/Matrix4x4.h>
11
11
#include < ROS2/Frame/ROS2FrameComponent.h>
12
12
#include < ROS2/ROS2GemUtilities.h>
13
13
#include < ROS2/Utilities/ROS2Names.h>
14
14
15
- #include " GNSSFormatConversions.h"
15
+ #include " Georeference/GNSSFormatConversions.h"
16
+ #include < ROS2/Georeference/GeoreferenceBus.h>
16
17
17
18
namespace ROS2
18
19
{
@@ -23,12 +24,9 @@ namespace ROS2
23
24
24
25
void ROS2GNSSSensorComponent::Reflect (AZ::ReflectContext* context)
25
26
{
26
- GNSSSensorConfiguration::Reflect (context);
27
-
28
27
if (auto * serialize = azrtti_cast<AZ::SerializeContext*>(context))
29
28
{
30
- serialize->Class <ROS2GNSSSensorComponent, SensorBaseType>()->Version (3 )->Field (
31
- " gnssSensorConfiguration" , &ROS2GNSSSensorComponent::m_gnssConfiguration);
29
+ serialize->Class <ROS2GNSSSensorComponent, SensorBaseType>()->Version (4 );
32
30
33
31
if (auto * editContext = serialize->GetEditContext ())
34
32
{
@@ -38,11 +36,6 @@ namespace ROS2
38
36
->Attribute (AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE (" Game" ))
39
37
->Attribute (AZ::Edit::Attributes::Icon, " Editor/Icons/Components/ROS2GNSSSensor.svg" )
40
38
->Attribute (AZ::Edit::Attributes::ViewportIcon, " Editor/Icons/Components/Viewport/ROS2GNSSSensor.svg" )
41
- ->DataElement (
42
- AZ::Edit::UIHandlers::Default,
43
- &ROS2GNSSSensorComponent::m_gnssConfiguration,
44
- " GNSS sensor configuration" ,
45
- " GNSS sensor configuration" )
46
39
->Attribute (AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly);
47
40
}
48
41
}
@@ -57,9 +50,7 @@ namespace ROS2
57
50
m_sensorConfiguration.m_publishersConfigurations .insert (AZStd::make_pair (GNSSMsgType, pc));
58
51
}
59
52
60
- ROS2GNSSSensorComponent::ROS2GNSSSensorComponent (
61
- const SensorConfiguration& sensorConfiguration, const GNSSSensorConfiguration& gnssConfiguration)
62
- : m_gnssConfiguration(gnssConfiguration)
53
+ ROS2GNSSSensorComponent::ROS2GNSSSensorComponent (const SensorConfiguration& sensorConfiguration)
63
54
{
64
55
m_sensorConfiguration = sensorConfiguration;
65
56
}
@@ -95,25 +86,23 @@ namespace ROS2
95
86
96
87
void ROS2GNSSSensorComponent::FrequencyTick ()
97
88
{
98
- const AZ::Vector3 currentPosition = GetCurrentPose ().GetTranslation ();
99
- const AZ::Vector3 currentPositionECEF = GNSS::ENUToECEF (
100
- { m_gnssConfiguration.m_originLatitudeDeg , m_gnssConfiguration.m_originLongitudeDeg , m_gnssConfiguration.m_originAltitude },
101
- currentPosition);
102
- const AZ::Vector3 currentPositionWGS84 = GNSS::ECEFToWGS84 (currentPositionECEF);
103
89
104
- m_gnssMsg.latitude = currentPositionWGS84.GetX ();
105
- m_gnssMsg.longitude = currentPositionWGS84.GetY ();
106
- m_gnssMsg.altitude = currentPositionWGS84.GetZ ();
90
+ AZ::Vector3 currentPosition{ 0 .0f };
91
+ AZ::TransformBus::EventResult (currentPosition, GetEntityId (), &AZ::TransformBus::Events::GetWorldTranslation);
92
+
93
+ WGS::WGS84Coordinate currentPositionWGS84;
94
+ ROS2::GeoreferenceRequestsBus::BroadcastResult (
95
+ currentPositionWGS84, &GeoreferenceRequests::ConvertFromLevelToWSG84, currentPosition);
96
+
97
+ m_gnssMsg.latitude = currentPositionWGS84.m_latitude ;
98
+ m_gnssMsg.longitude = currentPositionWGS84.m_longitude ;
99
+ m_gnssMsg.altitude = currentPositionWGS84.m_altitude ;
107
100
108
101
m_gnssMsg.status .status = sensor_msgs::msg::NavSatStatus::STATUS_SBAS_FIX;
109
- m_gnssMsg.status .service = sensor_msgs::msg::NavSatStatus::SERVICE_GALILEO ;
102
+ m_gnssMsg.status .service = sensor_msgs::msg::NavSatStatus::SERVICE_GPS ;
110
103
111
104
m_gnssPublisher->publish (m_gnssMsg);
112
105
}
113
106
114
- AZ::Transform ROS2GNSSSensorComponent::GetCurrentPose () const
115
- {
116
- auto * ros2Frame = Utils::GetGameOrEditorComponent<ROS2FrameComponent>(GetEntity ());
117
- return ros2Frame->GetFrameTransform ();
118
- }
107
+
119
108
} // namespace ROS2
0 commit comments