Skip to content

Commit

Permalink
Formatted code
Browse files Browse the repository at this point in the history
Signed-off-by: Mateusz Wasilewski <[email protected]>
  • Loading branch information
MateuszWasilewski committed Jul 31, 2024
1 parent 2bf527a commit 5ef2246
Show file tree
Hide file tree
Showing 39 changed files with 251 additions and 258 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace LevelModificationTools
return;
}

const auto assetIter = m_config.m_prefabVariants.begin()+variantId;
const auto assetIter = m_config.m_prefabVariants.begin() + variantId;
AZ_Warning(
"PrefabVariantComponent", assetIter != m_config.m_prefabVariants.end(), "Prefab variant with id %d not found.", variantId);
if (assetIter != m_config.m_prefabVariants.end())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace LevelModificationTools
public:
AZ_COMPONENT(PrefabVariantComponent, "{018f8611-85fc-7e0f-a879-b3a0ff793535}", AZ::Component);
PrefabVariantComponent() = default;
explicit PrefabVariantComponent(PrefabVariantConfig config);
explicit PrefabVariantComponent(PrefabVariantConfig config);
~PrefabVariantComponent() override = default;

// Component overrides
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
#pragma once

#include <AzCore/Component/EntityId.h>
#include <AzCore/RTTI/RTTI.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/std/string/string.h>
#include <ROS2/Communication/TopicConfiguration.h>
#include <AzCore/Component/EntityId.h>
namespace ROS2PoseControl {
namespace ROS2PoseControl
{
//! A structure for a single ROS2 topic, a part of publisher or subscriber configuration.
struct ROS2PoseControlConfiguration {
struct ROS2PoseControlConfiguration
{
public:
AZ_TYPE_INFO(ROS2PoseControlConfiguration, "{4f7686d5-f44e-43a6-a1b8-f404065c6430}");

static void Reflect(AZ::ReflectContext *context);
static void Reflect(AZ::ReflectContext* context);

AZ::Crc32 isTrackingModeTF2Visibility() const;

AZ::Crc32 isTrackingModePoseMessagesVisibility() const;


AZ::Crc32 isGroudOffsetVisible() const;

enum class TrackingMode {
enum class TrackingMode
{
PoseMessages,
TF2
};
Expand All @@ -38,4 +40,4 @@ namespace ROS2PoseControl {

AZStd::string m_startOffsetTag;
};
} // namespace ROS2
} // namespace ROS2PoseControl
11 changes: 3 additions & 8 deletions Gems/ROS2PoseControl/Code/Source/Clients/ROS2PoseControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,10 @@ namespace ROS2PoseControl
geometry_msgs::msg::TransformStamped transformStamped;
std::string errorString;
if (m_tf_buffer->canTransform(
m_configuration.m_referenceFrame.c_str(),
m_configuration.m_targetFrame.c_str(),
tf2::TimePointZero,
&errorString))
m_configuration.m_referenceFrame.c_str(), m_configuration.m_targetFrame.c_str(), tf2::TimePointZero, &errorString))
{
transformStamped = m_tf_buffer->lookupTransform(
m_configuration.m_referenceFrame.c_str(),
m_configuration.m_targetFrame.c_str(),
tf2::TimePointZero);
m_configuration.m_referenceFrame.c_str(), m_configuration.m_targetFrame.c_str(), tf2::TimePointZero);
m_tf2WarningShown = false;
}
else
Expand Down Expand Up @@ -363,7 +358,7 @@ namespace ROS2PoseControl
request.m_distance = maxDistance;

AzPhysics::SceneQueryHits result = sceneInterface->QueryScene(sceneHandle, &request);
if(!m_groundNotFoundWarningShown)
if (!m_groundNotFoundWarningShown)
{
AZ_Warning("ROS2PoseControl", hitPosition.has_value(), "No ground found for the entity");
m_groundNotFoundWarningShown = !hitPosition.has_value();
Expand Down
4 changes: 1 addition & 3 deletions Gems/ROS2PoseControl/Code/Source/Clients/ROS2PoseControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ namespace ROS2PoseControl
void SetIsTracking(bool isTracking);

private:

//! Obtains the transform in the world tagged with the given tag name.
//! @param tagName The name of the tag to search for.
//! @return The transform of the entity with the given tag name, if it exists.
Expand All @@ -68,7 +67,7 @@ namespace ROS2PoseControl

AZ::Transform RemoveTilt(AZ::Transform transform) const;

AZStd::optional<AZ::Vector3> QueryGround(const AZ::Vector3& location, const AZ::Vector3& gravityDirection, float maxDistance);
AZStd::optional<AZ::Vector3> QueryGround(const AZ::Vector3& location, const AZ::Vector3& gravityDirection, float maxDistance);

void ApplyTransform(const AZ::Transform& transform);

Expand All @@ -88,6 +87,5 @@ namespace ROS2PoseControl
bool m_tf2WarningShown = false;
bool m_groundNotFoundWarningShown = false;
bool m_startingOffsetNotFoundWarningShown = false;

};
} // namespace ROS2PoseControl
Original file line number Diff line number Diff line change
@@ -1,74 +1,83 @@
#include <AzCore/Serialization/EditContext.h>
#include <ROS2PoseControl/ROS2PoseControlConfiguration.h>

namespace ROS2PoseControl {
AZ::Crc32 ROS2PoseControlConfiguration::isTrackingModeTF2Visibility() const {
return m_tracking_mode == TrackingMode::TF2
? AZ::Edit::PropertyVisibility::Show
: AZ::Edit::PropertyVisibility::Hide;
namespace ROS2PoseControl
{
AZ::Crc32 ROS2PoseControlConfiguration::isTrackingModeTF2Visibility() const
{
return m_tracking_mode == TrackingMode::TF2 ? AZ::Edit::PropertyVisibility::Show : AZ::Edit::PropertyVisibility::Hide;
}

AZ::Crc32 ROS2PoseControlConfiguration::isTrackingModePoseMessagesVisibility() const {
return m_tracking_mode == TrackingMode::PoseMessages
? AZ::Edit::PropertyVisibility::Show
: AZ::Edit::PropertyVisibility::Hide;
AZ::Crc32 ROS2PoseControlConfiguration::isTrackingModePoseMessagesVisibility() const
{
return m_tracking_mode == TrackingMode::PoseMessages ? AZ::Edit::PropertyVisibility::Show : AZ::Edit::PropertyVisibility::Hide;
}

AZ::Crc32 ROS2PoseControlConfiguration::isGroudOffsetVisible() const {
return m_clampToGround ? AZ::Edit::PropertyVisibility::Show
: AZ::Edit::PropertyVisibility::Hide;
AZ::Crc32 ROS2PoseControlConfiguration::isGroudOffsetVisible() const
{
return m_clampToGround ? AZ::Edit::PropertyVisibility::Show : AZ::Edit::PropertyVisibility::Hide;
}

void ROS2PoseControlConfiguration::Reflect(AZ::ReflectContext *context) {
if (auto serializeContext = azrtti_cast<AZ::SerializeContext *>(context)) {
void ROS2PoseControlConfiguration::Reflect(AZ::ReflectContext* context)
{
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<ROS2PoseControlConfiguration>()
->Version(1)
->Field("m_tracking_mode", &ROS2PoseControlConfiguration::m_tracking_mode)
->Field("m_poseTopicConfiguration", &ROS2PoseControlConfiguration::m_poseTopicConfiguration)
->Field("m_targetFrame", &ROS2PoseControlConfiguration::m_targetFrame)
->Field("m_referenceFrame", &ROS2PoseControlConfiguration::m_referenceFrame)
->Field("lockZAxis", &ROS2PoseControlConfiguration::m_lockZAxis)
->Field("startOffsetTag", &ROS2PoseControlConfiguration::m_startOffsetTag)
->Field("m_clampToGround", &ROS2PoseControlConfiguration::m_clampToGround)
->Field("m_groundOffset", &ROS2PoseControlConfiguration::m_groundOffset);
->Version(1)
->Field("m_tracking_mode", &ROS2PoseControlConfiguration::m_tracking_mode)
->Field("m_poseTopicConfiguration", &ROS2PoseControlConfiguration::m_poseTopicConfiguration)
->Field("m_targetFrame", &ROS2PoseControlConfiguration::m_targetFrame)
->Field("m_referenceFrame", &ROS2PoseControlConfiguration::m_referenceFrame)
->Field("lockZAxis", &ROS2PoseControlConfiguration::m_lockZAxis)
->Field("startOffsetTag", &ROS2PoseControlConfiguration::m_startOffsetTag)
->Field("m_clampToGround", &ROS2PoseControlConfiguration::m_clampToGround)
->Field("m_groundOffset", &ROS2PoseControlConfiguration::m_groundOffset);

if (AZ::EditContext *ec = serializeContext->GetEditContext()) {
ec->Class<ROS2PoseControlConfiguration>("ROS2PoseControlConfiguration",
"Sub configuration for ROS2PoseControl component")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->DataElement(
AZ::Edit::UIHandlers::ComboBox,
&ROS2PoseControlConfiguration::m_tracking_mode,
"Tracking Mode",
"Selects tracking mode")
->EnumAttribute(TrackingMode::PoseMessages, "Pose Messages")
->EnumAttribute(TrackingMode::TF2, "TF2")
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::EntireTree)
->DataElement(
AZ::Edit::UIHandlers::Default,
&ROS2PoseControlConfiguration::m_poseTopicConfiguration,
"Topic for control message",
"Configuration for ROS2 topic to receive control messages to")
->Attribute(AZ::Edit::Attributes::Visibility,
&ROS2PoseControlConfiguration::isTrackingModePoseMessagesVisibility)
->DataElement(AZ::Edit::UIHandlers::Default, &ROS2PoseControlConfiguration::m_targetFrame,
"Target Frame", "Frame to track eg. base_link")
->Attribute(AZ::Edit::Attributes::Visibility,
&ROS2PoseControlConfiguration::isTrackingModeTF2Visibility)
->DataElement(AZ::Edit::UIHandlers::Default, &ROS2PoseControlConfiguration::m_referenceFrame,
"Reference Frame", "Reference frame eg. map")
->Attribute(AZ::Edit::Attributes::Visibility,
&ROS2PoseControlConfiguration::isTrackingModeTF2Visibility)
->DataElement(AZ::Edit::UIHandlers::Default, &ROS2PoseControlConfiguration::m_lockZAxis,
"Lock Z Axis", "Lock Z axis")
->DataElement(AZ::Edit::UIHandlers::Default, &ROS2PoseControlConfiguration::m_startOffsetTag,
"Start Offset Tag", "Tag that will be used to set the start offset for the entity.")
->DataElement(AZ::Edit::UIHandlers::Default, &ROS2PoseControlConfiguration::m_clampToGround,
"Clamp to Ground", "Clamp to ground")
->DataElement(AZ::Edit::UIHandlers::Default, &ROS2PoseControlConfiguration::m_groundOffset, "Ground Offset",
"Offset from the ground")
->Attribute(AZ::Edit::Attributes::Visibility, &ROS2PoseControlConfiguration::isGroudOffsetVisible);
if (AZ::EditContext* ec = serializeContext->GetEditContext())
{
ec->Class<ROS2PoseControlConfiguration>("ROS2PoseControlConfiguration", "Sub configuration for ROS2PoseControl component")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->DataElement(
AZ::Edit::UIHandlers::ComboBox,
&ROS2PoseControlConfiguration::m_tracking_mode,
"Tracking Mode",
"Selects tracking mode")
->EnumAttribute(TrackingMode::PoseMessages, "Pose Messages")
->EnumAttribute(TrackingMode::TF2, "TF2")
->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::EntireTree)
->DataElement(
AZ::Edit::UIHandlers::Default,
&ROS2PoseControlConfiguration::m_poseTopicConfiguration,
"Topic for control message",
"Configuration for ROS2 topic to receive control messages to")
->Attribute(AZ::Edit::Attributes::Visibility, &ROS2PoseControlConfiguration::isTrackingModePoseMessagesVisibility)
->DataElement(
AZ::Edit::UIHandlers::Default,
&ROS2PoseControlConfiguration::m_targetFrame,
"Target Frame",
"Frame to track eg. base_link")
->Attribute(AZ::Edit::Attributes::Visibility, &ROS2PoseControlConfiguration::isTrackingModeTF2Visibility)
->DataElement(
AZ::Edit::UIHandlers::Default,
&ROS2PoseControlConfiguration::m_referenceFrame,
"Reference Frame",
"Reference frame eg. map")
->Attribute(AZ::Edit::Attributes::Visibility, &ROS2PoseControlConfiguration::isTrackingModeTF2Visibility)
->DataElement(AZ::Edit::UIHandlers::Default, &ROS2PoseControlConfiguration::m_lockZAxis, "Lock Z Axis", "Lock Z axis")
->DataElement(
AZ::Edit::UIHandlers::Default,
&ROS2PoseControlConfiguration::m_startOffsetTag,
"Start Offset Tag",
"Tag that will be used to set the start offset for the entity.")
->DataElement(
AZ::Edit::UIHandlers::Default, &ROS2PoseControlConfiguration::m_clampToGround, "Clamp to Ground", "Clamp to ground")
->DataElement(
AZ::Edit::UIHandlers::Default,
&ROS2PoseControlConfiguration::m_groundOffset,
"Ground Offset",
"Offset from the ground")
->Attribute(AZ::Edit::Attributes::Visibility, &ROS2PoseControlConfiguration::isGroudOffsetVisible);
}
}
};
} // namespace ROS2
} // namespace ROS2PoseControl
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@

#include "ROS2PoseControlSystemComponent.h"
#include <ROS2PoseControl/ROS2PoseControlTypeIds.h>
#include <ROS2PoseControlModuleInterface.h>
#include "ROS2PoseControlSystemComponent.h"

namespace ROS2PoseControl
{
class ROS2PoseControlModule
: public ROS2PoseControlModuleInterface
class ROS2PoseControlModule : public ROS2PoseControlModuleInterface
{
public:
AZ_RTTI(ROS2PoseControlModule, ROS2PoseControlModuleTypeId, ROS2PoseControlModuleInterface);
AZ_CLASS_ALLOCATOR(ROS2PoseControlModule, AZ::SystemAllocator);
};
}// namespace ROS2PoseControl
} // namespace ROS2PoseControl

AZ_DECLARE_MODULE_CLASS(Gem_ROS2PoseControl, ROS2PoseControl::ROS2PoseControlModule)
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@

namespace ROS2PoseControl
{
AZ_COMPONENT_IMPL(ROS2PoseControlSystemComponent, "ROS2PoseControlSystemComponent",
ROS2PoseControlSystemComponentTypeId);
AZ_COMPONENT_IMPL(ROS2PoseControlSystemComponent, "ROS2PoseControlSystemComponent", ROS2PoseControlSystemComponentTypeId);

void ROS2PoseControlSystemComponent::Reflect(AZ::ReflectContext* context)
{
ROS2PoseControlConfiguration::Reflect(context);
if (auto serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
{
serializeContext->Class<ROS2PoseControlSystemComponent, AZ::Component>()
->Version(0)
;
serializeContext->Class<ROS2PoseControlSystemComponent, AZ::Component>()->Version(0);
}
}

Expand Down Expand Up @@ -60,5 +57,4 @@ namespace ROS2PoseControl
{
}


} // namespace ROS2PoseControl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

namespace ROS2PoseControl
{
class ROS2PoseControlSystemComponent
: public AZ::Component
class ROS2PoseControlSystemComponent : public AZ::Component
{
public:
AZ_COMPONENT_DECL(ROS2PoseControlSystemComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
#include "ROS2PoseControlModuleInterface.h"
#include <AzCore/Memory/Memory.h>

#include <ROS2PoseControl/ROS2PoseControlTypeIds.h>
#include "Clients/ROS2PoseControl.h"
#include <ROS2PoseControl/ROS2PoseControlTypeIds.h>

#include <Clients/ROS2PoseControlSystemComponent.h>

namespace ROS2PoseControl
{
AZ_TYPE_INFO_WITH_NAME_IMPL(ROS2PoseControlModuleInterface,
"ROS2PoseControlModuleInterface", ROS2PoseControlModuleInterfaceTypeId);
AZ_TYPE_INFO_WITH_NAME_IMPL(ROS2PoseControlModuleInterface, "ROS2PoseControlModuleInterface", ROS2PoseControlModuleInterfaceTypeId);
AZ_RTTI_NO_TYPE_INFO_IMPL(ROS2PoseControlModuleInterface, AZ::Module);
AZ_CLASS_ALLOCATOR_IMPL(ROS2PoseControlModuleInterface, AZ::SystemAllocator);

Expand All @@ -20,10 +19,8 @@ namespace ROS2PoseControl
// Add ALL components descriptors associated with this gem to m_descriptors.
// This will associate the AzTypeInfo information for the components with the the SerializeContext, BehaviorContext and EditContext.
// This happens through the [MyComponent]::Reflect() function.
m_descriptors.insert(m_descriptors.end(), {
ROS2PoseControlSystemComponent::CreateDescriptor(),
ROS2PoseControl::CreateDescriptor()
});
m_descriptors.insert(
m_descriptors.end(), { ROS2PoseControlSystemComponent::CreateDescriptor(), ROS2PoseControl::CreateDescriptor() });
}

AZ::ComponentTypeList ROS2PoseControlModuleInterface::GetRequiredSystemComponents() const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

namespace ROS2PoseControl
{
class ROS2PoseControlModuleInterface
: public AZ::Module
class ROS2PoseControlModuleInterface : public AZ::Module
{
public:
AZ_TYPE_INFO_WITH_NAME_DECL(ROS2PoseControlModuleInterface)
Expand All @@ -21,4 +20,4 @@ namespace ROS2PoseControl
*/
AZ::ComponentTypeList GetRequiredSystemComponents() const override;
};
}// namespace ROS2PoseControl
} // namespace ROS2PoseControl
Loading

0 comments on commit 5ef2246

Please sign in to comment.