Skip to content

Commit db6cd45

Browse files
Merge branch 'o3de:development' into development
2 parents e9047fb + b1fc926 commit db6cd45

File tree

434 files changed

+128048
-1158
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

434 files changed

+128048
-1158
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#
32
# Git LFS (see https://git-lfs.github.com/)
43
#
@@ -130,3 +129,4 @@ Templates/Ros2FleetRobotTemplate/docs/images/*.png filter= diff= merge= -text
130129
Gems/ROS2/docs/**/*.png -filter -diff -merge
131130
Templates/Ros2ProjectTemplate/Screenshots/*.png filter= diff= merge= -text
132131
Templates/Ros2FleetRobotTemplate/Screenshots/*.png filter= diff= merge= -text
132+
*.pgm filter=lfs diff=lfs merge=lfs -text

Gems/ROS2/Code/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,6 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS)
140140
3rdParty::sdformat
141141
)
142142

143-
find_package(urdfdom)
144-
target_link_libraries(${gem_name}.Editor.Static PUBLIC urdfdom::urdfdom_model)
145-
146143
ly_add_target(
147144
NAME ${gem_name}.Editor GEM_MODULE
148145
NAMESPACE Gem

Gems/ROS2/Code/FindROS2.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55

66
# Note that this does not find any ros2 package in particular, but determines whether a distro is sourced properly
77
# Can be extended to handle supported / unsupported distros
8+
message(STATUS "Ros Distro is \"$ENV{ROS_DISTRO}\"")
89
if (NOT DEFINED ENV{ROS_DISTRO} OR NOT DEFINED ENV{AMENT_PREFIX_PATH})
910
message(WARNING, "To build ROS2 Gem a ROS distribution needs to be sourced, but none detected")
1011
set(ROS2_FOUND FALSE)
1112
return()
1213
endif()
13-
set(ROS2_FOUND TRUE)
14+
set(ROS2_FOUND TRUE)

Gems/ROS2/Code/Include/ROS2/Frame/NamespaceConfiguration.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ namespace ROS2
4141
void PopulateNamespace(bool isRoot, const AZStd::string& entityName);
4242
AZStd::string GetNamespace(const AZStd::string& parentNamespace) const;
4343

44+
//! Update namespace and strategy.
45+
//! @param ns Desired namespace.
46+
//! @param strategy Namespace strategy.
47+
void SetNamespace(const AZStd::string& ns, NamespaceStrategy strategy);
48+
4449
private:
4550
AZStd::string m_namespace;
4651
NamespaceStrategy m_namespaceStrategy = NamespaceStrategy::Default;

Gems/ROS2/Code/Include/ROS2/Frame/ROS2FrameComponent.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ namespace ROS2
7474
//! @return The name of the global frame with namespace attached. It is typically "odom", "map", "world".
7575
AZStd::string GetGlobalFrameName() const;
7676

77+
//! Updates the namespace and namespace strategy of the underlying namespace configuration
78+
//! @param ns Namespace to set.
79+
//! @param strategy Namespace strategy to use.
80+
void UpdateNamespaceConfiguration(const AZStd::string& ns, NamespaceConfiguration::NamespaceStrategy strategy);
81+
7782
private:
7883
//////////////////////////////////////////////////////////////////////////
7984
// AZ::TickBus::Handler overrides

Gems/ROS2/Code/Include/ROS2/Lidar/LidarRaycasterBus.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,9 @@ namespace ROS2
152152
AZ_Assert(false, "This Lidar Implementation does not support noise!");
153153
}
154154

155-
//! Configures Layer ignoring parameters
156-
//! @param ignoreLayer Should a specified collision layer be ignored?
157-
//! @param layerIndex Index of collision layer to be ignored.
158-
virtual void ConfigureLayerIgnoring([[maybe_unused]] bool ignoreLayer, [[maybe_unused]] AZ::u32 layerIndex)
155+
//! Configures which collision layers should be ignored.
156+
//! @param layerIndices Indices of collision layers to be ignored.
157+
virtual void ConfigureIgnoredCollisionLayers([[maybe_unused]] const AZStd::unordered_set<AZ::u32>& layerIndices)
159158
{
160159
AZ_Assert(false, "This Lidar Implementation does not support collision layer configurations!");
161160
}

Gems/ROS2/Code/Include/ROS2/Sensor/ROS2SensorComponent.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace ROS2
1818
//! Captures common behavior of ROS2 sensor Components.
1919
//! Sensors acquire data from the simulation engine and publish it to ROS2 ecosystem.
2020
//! Derive this Component to implement a new ROS2 sensor. Each sensor Component requires ROS2FrameComponent.
21+
//! For high frequency sensors also derive PhysicsCallbackHandler.
2122
class ROS2SensorComponent
2223
: public AZ::Component
2324
, public AZ::TickBus::Handler

Gems/ROS2/Code/Source/Utilities/PhysicsCallbackHandler.h renamed to Gems/ROS2/Code/Include/ROS2/Utilities/PhysicsCallbackHandler.h

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,26 @@
1313

1414
namespace ROS2::Utils
1515
{
16-
//! Helper class that register OnSceneSimulationFinishHandler and retrieve handle to Simulated Body from the Default Scene.
16+
//! A class that registers physics tick callbacks from the Default Scene.
1717
class PhysicsCallbackHandler
1818
{
1919
protected:
20-
//! Install to default physics scene callbacks, when the scene is created, the @member m_bodyHandle is populated with the handle to
21-
//! simulated body.
22-
//! @param m_entityId Entity id to get m_bodyHandle to.
23-
void InstallPhysicalCallback(AZ::EntityId m_entityId);
20+
//! Install default physics scene callbacks
21+
void InstallPhysicalCallback();
2422

2523
//! Removes all attached callbacks
2624
void RemovePhysicalCallback();
2725

2826
//! Called multiple times per frame after every inner loop of physics engine.
29-
//! It virtual version of callback AzPhysics::SceneEvents::OnSceneSimulationFinishHandler.
27+
//! It's a virtual version of callback AzPhysics::SceneEvents::OnSceneSimulationFinishHandler.
3028
//! @param sceneHandle - scene handle, only handle to Default Scene is expected
3129
//! @param deltaTime - update of simulated time in seconds.
32-
virtual void OnPhysicsSimulationFinished(AzPhysics::SceneHandle sceneHandle, float deltaTime) {};
30+
virtual void OnPhysicsSimulationFinished(AzPhysics::SceneHandle sceneHandle, float deltaTime){};
3331

34-
//! Callback called on begging of the first physical simulation.
35-
//! inner loop of physics engine.
32+
//! Callback called on beginning of the first physical simulation inner loop of physics engine.
3633
//! @param sceneHandle - scene handle, only handle to Default Scene is expected
37-
virtual void OnPhysicsInitialization(AzPhysics::SceneHandle sceneHandle) {};
34+
virtual void OnPhysicsInitialization(AzPhysics::SceneHandle sceneHandle){};
3835

39-
//! Handler to simulated physical body
40-
AzPhysics::SimulatedBodyHandle m_bodyHandle = AzPhysics::InvalidSimulatedBodyHandle;
4136
private:
4237
AzPhysics::SceneEvents::OnSceneSimulationFinishHandler m_onSceneSimulationEvent;
4338
AzPhysics::SceneEvents::OnSceneSimulationStartHandler m_onSceneSimulationStart;

Gems/ROS2/Code/Source/Camera/ROS2CameraSensorEditorComponent.cpp

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -133,57 +133,53 @@ namespace ROS2
133133
const AZ::u32 stateBefore = debugDisplay.GetState();
134134
AZ::Transform transform = GetEntity()->GetTransform()->GetWorldTM();
135135

136+
const float distance = m_cameraSensorConfiguration.m_farClipDistance * 0.1f;
137+
const float tangent = static_cast<float>(tan(0.5f * AZ::DegToRad(m_cameraSensorConfiguration.m_verticalFieldOfViewDeg)));
138+
139+
float height = distance * tangent;
140+
float width = height * m_cameraSensorConfiguration.m_width / m_cameraSensorConfiguration.m_height;
141+
142+
AZ::Vector3 farPoints[4];
143+
farPoints[0] = AZ::Vector3(width, height, distance);
144+
farPoints[1] = AZ::Vector3(-width, height, distance);
145+
farPoints[2] = AZ::Vector3(-width, -height, distance);
146+
farPoints[3] = AZ::Vector3(width, -height, distance);
147+
148+
AZ::Vector3 nearPoints[4];
149+
nearPoints[0] = farPoints[0].GetNormalizedSafe() * m_cameraSensorConfiguration.m_nearClipDistance;
150+
nearPoints[1] = farPoints[1].GetNormalizedSafe() * m_cameraSensorConfiguration.m_nearClipDistance;
151+
nearPoints[2] = farPoints[2].GetNormalizedSafe() * m_cameraSensorConfiguration.m_nearClipDistance;
152+
nearPoints[3] = farPoints[3].GetNormalizedSafe() * m_cameraSensorConfiguration.m_nearClipDistance;
153+
136154
// dimension of drawing
137-
const float arrowRise = 1.1f;
138-
const float arrowSize = 0.5f;
139-
const float frustumScale = 0.1f;
140-
141-
transform.SetUniformScale(frustumScale);
142-
debugDisplay.DepthTestOff();
143-
const float vertical = 0.5f * AZStd::tan((AZ::DegToRad(m_cameraSensorConfiguration.m_verticalFieldOfViewDeg * 0.5f)));
144-
const float horizontal = m_cameraSensorConfiguration.m_height * vertical / m_cameraSensorConfiguration.m_width;
145-
146-
// frustum drawing
147-
const AZ::Vector3 p1(-vertical, -horizontal, 1.f);
148-
const AZ::Vector3 p2(vertical, -horizontal, 1.f);
149-
const AZ::Vector3 p3(vertical, horizontal, 1.f);
150-
const AZ::Vector3 p4(-vertical, horizontal, 1.f);
151-
const AZ::Vector3 p0(0, 0, 0);
152-
const AZ::Vector3 py(0.1, 0, 0);
153-
154-
const auto pt1 = transform.TransformPoint(p1);
155-
const auto pt2 = transform.TransformPoint(p2);
156-
const auto pt3 = transform.TransformPoint(p3);
157-
const auto pt4 = transform.TransformPoint(p4);
158-
const auto pt0 = transform.TransformPoint(p0);
159-
const auto ptz = transform.TransformPoint(AZ::Vector3::CreateAxisZ(0.2f));
160-
const auto pty = transform.TransformPoint(AZ::Vector3::CreateAxisY(0.2f));
161-
const auto ptx = transform.TransformPoint(AZ::Vector3::CreateAxisX(0.2f));
155+
const float arrowRise = 0.11f;
156+
const float arrowSize = 0.05f;
157+
158+
const AZ::Vector3 pt0(0, 0, 0);
159+
const auto ptz = AZ::Vector3::CreateAxisZ(0.2f);
160+
const auto pty = AZ::Vector3::CreateAxisY(0.2f);
161+
const auto ptx = AZ::Vector3::CreateAxisX(0.2f);
162+
163+
debugDisplay.PushMatrix(transform);
162164

163165
debugDisplay.SetColor(AZ::Color(0.f, 1.f, 1.f, 1.f));
164-
debugDisplay.SetLineWidth(1);
165-
debugDisplay.DrawLine(pt1, pt2);
166-
debugDisplay.DrawLine(pt2, pt3);
167-
debugDisplay.DrawLine(pt3, pt4);
168-
debugDisplay.DrawLine(pt4, pt1);
169-
debugDisplay.DrawLine(pt1, pt0);
170-
debugDisplay.DrawLine(pt2, pt0);
171-
debugDisplay.DrawLine(pt3, pt0);
172-
debugDisplay.DrawLine(pt4, pt0);
166+
debugDisplay.DrawLine(nearPoints[0], farPoints[0]);
167+
debugDisplay.DrawLine(nearPoints[1], farPoints[1]);
168+
debugDisplay.DrawLine(nearPoints[2], farPoints[2]);
169+
debugDisplay.DrawLine(nearPoints[3], farPoints[3]);
170+
debugDisplay.DrawPolyLine(nearPoints, AZ_ARRAY_SIZE(nearPoints));
171+
debugDisplay.DrawPolyLine(farPoints, AZ_ARRAY_SIZE(farPoints));
173172

174173
// up-arrow drawing
175-
const AZ::Vector3 pa1(-arrowSize * vertical, -arrowRise * horizontal, 1.f);
176-
const AZ::Vector3 pa2(arrowSize * vertical, -arrowRise * horizontal, 1.f);
177-
const AZ::Vector3 pa3(0, (-arrowRise - arrowSize) * horizontal, 1.f);
178-
const auto pat1 = transform.TransformPoint(pa1);
179-
const auto pat2 = transform.TransformPoint(pa2);
180-
const auto pat3 = transform.TransformPoint(pa3);
174+
const AZ::Vector3 pa1(-arrowSize * height, -arrowRise * width, 1.f);
175+
const AZ::Vector3 pa2(arrowSize * height, -arrowRise * width, 1.f);
176+
const AZ::Vector3 pa3(0, (-arrowRise - arrowSize) * width, 1.f);
181177

182178
debugDisplay.SetColor(AZ::Color(0.f, 0.6f, 1.f, 1.f));
183179
debugDisplay.SetLineWidth(1);
184-
debugDisplay.DrawLine(pat1, pat2);
185-
debugDisplay.DrawLine(pat2, pat3);
186-
debugDisplay.DrawLine(pat3, pat1);
180+
debugDisplay.DrawLine(pa1, pa2);
181+
debugDisplay.DrawLine(pa2, pa3);
182+
debugDisplay.DrawLine(pa3, pa1);
187183

188184
// coordinate system drawing
189185
debugDisplay.SetColor(AZ::Color(1.f, 0.f, 0.f, 1.f));
@@ -198,6 +194,8 @@ namespace ROS2
198194
debugDisplay.SetLineWidth(2);
199195
debugDisplay.DrawLine(ptz, pt0);
200196

197+
debugDisplay.PopMatrix();
198+
201199
debugDisplay.SetState(stateBefore);
202200
}
203201

Gems/ROS2/Code/Source/Frame/NamespaceConfiguration.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ namespace ROS2
6363
return ROS2Names::GetNamespacedName(parentNamespace, m_namespace);
6464
}
6565

66+
void NamespaceConfiguration::SetNamespace(const AZStd::string& ns, NamespaceStrategy strategy)
67+
{
68+
m_namespace = ns;
69+
m_namespaceStrategy = strategy;
70+
UpdateNamespace();
71+
}
72+
6673
bool NamespaceConfiguration::IsNamespaceCustom() const
6774
{
6875
return m_namespaceStrategy == NamespaceConfiguration::NamespaceStrategy::Custom;

0 commit comments

Comments
 (0)