Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Gems/ROS2/Code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS)
Gem::Atom_Feature_Common.Public
)


# By default, we will specify that the above target ROS2 would be used by
# Tool and Builder type targets when this gem is enabled. If you don't want it
# active in Tools or Builders by default, delete one or both of the following lines:
Expand Down
7 changes: 3 additions & 4 deletions Gems/ROS2/Code/Include/ROS2/Clock/ROS2Clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#pragma once

#include "ITimeSource.h"
#include <AzCore/Outcome/Outcome.h>
#include <AzCore/std/chrono/chrono.h>
#include <AzCore/std/smart_ptr/unique_ptr.h>
#include <AzCore/std/string/string.h>
#include <rclcpp/publisher.hpp>
#include <rosgraph_msgs/msg/clock.hpp>
#include <AzCore/Outcome/Outcome.h>
#include <AzCore/std/string/string.h>

namespace ROS2
{
Expand All @@ -23,7 +23,6 @@ namespace ROS2
//! the /use_sim_time parameter set to true.
class ROS2Clock
{

public:
ROS2Clock();
ROS2Clock(AZStd::unique_ptr<ITimeSource> timeSource, bool publishClock);
Expand All @@ -37,7 +36,7 @@ namespace ROS2
//! Sets the time source to the given time.
//! @param time The time to set the time source to.
//! @return An outcome indicating success or failure.
AZ::Outcome<void, AZStd::string> AdjustTime(const builtin_interfaces::msg::Time & time) const;
AZ::Outcome<void, AZStd::string> AdjustTime(const builtin_interfaces::msg::Time& time) const;

//! Update time in the ROS 2 ecosystem.
//! This will publish current time to the ROS 2 `/clock` topic, if Clock is configured to do it.
Expand Down
74 changes: 37 additions & 37 deletions Gems/SimulationInterfaces/Code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -261,26 +261,26 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
)

ly_add_target(
NAME ${gem_name}.TestApp ${PAL_TRAIT_TEST_TARGET_TYPE}
NAMESPACE Gem
FILES_CMAKE
NAME ${gem_name}.TestApp ${PAL_TRAIT_TEST_TARGET_TYPE}
NAMESPACE Gem
FILES_CMAKE
simulationinterfaces_editor_app_test.cmake
INCLUDE_DIRECTORIES
INCLUDE_DIRECTORIES
PRIVATE
Tests
Source
Include
BUILD_DEPENDENCIES
Tests
Source
Include
BUILD_DEPENDENCIES
PRIVATE
AZ::AzTest
AZ::AzTestShared
AZ::AzToolsFramework
Legacy::CryCommon
Legacy::EditorCommon
Legacy::Editor.Headers
AZ::AzManipulatorTestFramework.Static
Gem::${gem_name}.API
Gem::${gem_name}.Editor.Private.Object
AZ::AzTest
AZ::AzTestShared
AZ::AzToolsFramework
Legacy::CryCommon
Legacy::EditorCommon
Legacy::Editor.Headers
AZ::AzManipulatorTestFramework.Static
Gem::${gem_name}.API
Gem::${gem_name}.Editor.Private.Object
)

# Add ${gem_name}.Editor.Tests to googletest
Expand All @@ -289,29 +289,29 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED)
)

ly_add_target(
NAME ${gem_name}.ROS2Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
NAMESPACE Gem
FILES_CMAKE
NAME ${gem_name}.ROS2Tests ${PAL_TRAIT_TEST_TARGET_TYPE}
NAMESPACE Gem
FILES_CMAKE
ros2_simulationinterfaces_tests_files.cmake
INCLUDE_DIRECTORIES
INCLUDE_DIRECTORIES
PRIVATE
Tests
Source
Include
BUILD_DEPENDENCIES
Tests
Source
Include
BUILD_DEPENDENCIES
PRIVATE
AZ::AzTest
AZ::AzTestShared
AZ::AzToolsFramework
Legacy::CryCommon
Legacy::EditorCommon
Legacy::Editor.Headers
AZ::AzManipulatorTestFramework.Static
Gem::${gem_name}.API
Gem::${gem_name}.Editor.Private.Object
Gem::SimulationInterfaces.API
Gem::ROS2.Static
Gem::${gem_name}.Editor.Private.Object
AZ::AzTest
AZ::AzTestShared
AZ::AzToolsFramework
Legacy::CryCommon
Legacy::EditorCommon
Legacy::Editor.Headers
AZ::AzManipulatorTestFramework.Static
Gem::${gem_name}.API
Gem::${gem_name}.Editor.Private.Object
Gem::SimulationInterfaces.API
Gem::ROS2.Static
Gem::${gem_name}.Editor.Private.Object
)

# Add ${gem_name}.Editor.Tests to googletest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ namespace ROS2SimulationInterfaces
inline constexpr const char* ROS2SimulationInterfacesEditorModuleTypeId = ROS2SimulationInterfacesModuleTypeId;

// API TypeIds
inline constexpr const char* ROS2SimulationInterfacesRequestBusTypeId = "{00d08870-e329-4bd7-bb8c-f67fe369de92}";
inline constexpr const char* ROS2SimulationInterfacesRequestBusTypeId = "{00D08870-E329-4BD7-BB8C-F67FE369DE92}";
} // namespace ROS2SimulationInterfaces
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace SimulationInterfaces
{
//! Result codes to be used in the Result message
//! @see <a href="https://github.com/ros-simulation/simulation_interfaces/blob/main/msg/Result.msg">Result.msg</a>
//! @see <a href="https://github.com/ros-simulation/simulation_interfaces/blob/main/msg/Result.msg">Result.msg</a>
using ErrorCodeType = simulation_interfaces::msg::Result::_result_type;

//! A message type to represent the result of a failed operation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ namespace SimulationInterfaces
AZ::Transform m_boundsPose{ AZ::Transform::CreateIdentity() };
};

//! @see <a href="https://github.com/ros-simulation/simulation_interfaces/blob/main/msg/EntityState.msg">EntityState.msg</a>
//! @see <a href="https://github.com/ros-simulation/simulation_interfaces/blob/main/msg/EntityState.msg">EntityState.msg</a>
struct EntityState
{
AZ::Transform m_pose; //! The pose of the entity
AZ::Vector3 m_twistLinear; //! The linear velocity of the entity (in the entity frame)
AZ::Vector3 m_twistAngular; //! The angular velocity of the entity (in the entity frame)
};

//! @see <a href="https://github.com/ros-simulation/simulation_interfaces/blob/main/msg/Spawnable.msg">Spawnable.msg</a>
struct Spawnable
{
AZStd::string m_uri;
Expand All @@ -64,16 +65,15 @@ namespace SimulationInterfaces
//! Supported filters:
//! - name : a posix regular expression to match against entity names
//! - bounds : a shape to use for filtering entities, null means no bounds filtering
//! @see <a href="https://github.com/ros-simulation/simulation_interfaces/blob/main/srv/GetEntities.srv">GetEntities.srv</a>
//! @see <a href="https://github.com/ros-simulation/simulation_interfaces/blob/main/srv/GetEntities.srv">GetEntities.srv</a>
virtual AZ::Outcome<EntityNameList, FailedResult> GetEntities(const EntityFilters& filter) = 0;

//! Get the state of an entity.
//! @see <a href="https://github.com/ros-simulation/simulation_interfaces/blob/main/srv/GetEntityState.srv">GetEntityState.srv</a>
//! @see <a href="https://github.com/ros-simulation/simulation_interfaces/blob/main/srv/GetEntityState.srv">GetEntityState.srv</a>
virtual AZ::Outcome<EntityState, FailedResult> GetEntityState(const AZStd::string& name) = 0;

//! Get the state of all entities that match the filter.
//! @see <a
//! href="https://github.com/ros-simulation/simulation_interfaces/blob/main/srv/GetEntitiesStates.srv">GetEntitiesStates.srv</a>
//! @see <a href="https://github.com/ros-simulation/simulation_interfaces/blob/main/srv/GetEntitiesStates.srv">GetEntitiesStates.srv</a>
virtual AZ::Outcome<MultipleEntitiesStates, FailedResult> GetEntitiesStates(const EntityFilters& filter) = 0;

//! Set the state of an entity.
Expand All @@ -92,7 +92,7 @@ namespace SimulationInterfaces
virtual AZ::Outcome<SpawnableList, FailedResult> GetSpawnables() = 0;

//! Callback for when an entity has been spawned and registered. The string is the name of the entity in the simulation interface.
//! Note : The names is empty, if the entity could not be registered (e.g. prefab has no simulated entities)
//! Note: The names are empty, if the entity could not be registered (e.g. prefab has no simulated entities)
virtual void SpawnEntity(
const AZStd::string& name,
const AZStd::string& uri,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace SimulationInterfaces
inline constexpr const char* SimulationManagerEditorTypeId = "{2CC8D67B-CFD3-4E89-AAF0-8935640B51C1}";

inline constexpr const char* SimulationFeaturesAggregatorTypeId = "{5c5ae765-1776-4ba0-8e32-b66c8f4edafe}";
inline constexpr const char* SimulationFeaturesAggregatorEditorTypeId = "{504a86ef-df0a-45ec-b69d-315ff4ec8121}";
inline constexpr const char* SimulationFeaturesAggregatorEditorTypeId = "{504A86EF-DF0A-45EC-B69D-315FF4EC8121}";

// Module derived classes TypeIds
inline constexpr const char* SimulationInterfacesModuleInterfaceTypeId = "{675797BF-E5D5-438A-BF86-4B4554F09CEF}";
Expand All @@ -30,7 +30,7 @@ namespace SimulationInterfaces
// Interface TypeIds
inline constexpr const char* SimulationInterfacesRequestsTypeId = "{6818E5E3-BBF5-41BD-96BB-7AF57CCC7528}";
inline constexpr const char* SimulationManagerRequestsTypeId = "{056477BA-8153-4901-9401-0146A5E3E9ED}";
inline constexpr const char* SimulationFeaturesAggregatorRequestsTypeId = "{099fd08b-b0e2-4705-9c35-cc09c8e45076}";
inline constexpr const char* SimulationManagerNotificationsTypeId = "{0201067b-9d52-4ab7-9a45-284287f53b00}";
inline constexpr const char* SimulationFeaturesAggregatorRequestsTypeId = "{099FD08B-B0E2-4705-9C35-CC09C8E45076}";
inline constexpr const char* SimulationManagerNotificationsTypeId = "{0201067B-9D52-4AB7-9A45-284287F53B00}";

} // namespace SimulationInterfaces
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace SimulationInterfaces
{
//! Structure to design a filter for tags
//! @see <a href="https://github.com/ros-simulation/simulation_interfaces/blob/main/msg/TagsFilter.msg">TagsFilter.msg</a>
//! @see <a href="https://github.com/ros-simulation/simulation_interfaces/blob/main/msg/TagsFilter.msg">TagsFilter.msg</a>
using TagFilterMode = uint8_t;

struct TagFilter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace ROS2SimulationInterfaces
{
SimulationInterfaces::SimulationManagerRequestBus::Broadcast(
&SimulationInterfaces::SimulationManagerRequests::CancelStepSimulation);
m_isCancelled = true;
m_cancelAction = true;
return rclcpp_action::CancelResponse::ACCEPT;
}

Expand All @@ -80,15 +80,15 @@ namespace ROS2SimulationInterfaces
m_goalHandle.reset();
return;
}
m_isCancelled = false;
m_cancelAction = false;
AZ::TickBus::Handler::BusConnect();
SimulationInterfaces::SimulationManagerRequestBus::Broadcast(
&SimulationInterfaces::SimulationManagerRequests::StepSimulation, m_goalSteps);
}

void SimulateStepsActionServerHandler::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time)
{
if (m_isCancelled)
if (m_cancelAction)
{
auto result = std::make_shared<Result>();
result->result.error_message = "Action has been cancelled.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace ROS2SimulationInterfaces

private:
AZ::u64 m_goalSteps{ 0 };
bool m_isCancelled{ false };
bool m_cancelAction{ false };
};

} // namespace ROS2SimulationInterfaces
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,28 @@
#include "ROS2SimulationInterfacesSystemComponent.h"

#include <Actions/SimulateStepsActionServerHandler.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <AzCore/std/string/string.h>
#include <Services/ROS2ServiceBase.h>
#include <SimulationInterfaces/ROS2SimulationInterfacesRequestBus.h>
#include <AzFramework/API/ApplicationAPI.h>

#include <ROS2/ROS2Bus.h>
#include <SimulationInterfaces/ROS2SimulationInterfacesRequestBus.h>
#include <SimulationInterfaces/ROS2SimulationInterfacesTypeIds.h>

#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/std/smart_ptr/make_shared.h>
#include <Services/DeleteEntityServiceHandler.h>
#include <Services/GetEntitiesServiceHandler.h>
#include <Services/GetEntitiesStatesServiceHandler.h>
#include <Services/GetEntityStateServiceHandler.h>
#include <Services/GetSimulationFeaturesServiceHandler.h>
#include <Services/GetSimulationStateServiceHandler.h>
#include <Services/GetSpawnablesServiceHandler.h>
#include <Services/ROS2ServiceBase.h>
#include <Services/ResetSimulationServiceHandler.h>
#include <Services/SetEntityStateServiceHandler.h>
#include <Services/SetSimulationStateServiceHandler.h>
#include <Services/SpawnEntityServiceHandler.h>
#include <Services/StepSimulationServiceHandler.h>

namespace ROS2SimulationInterfaces
{
Expand Down Expand Up @@ -67,10 +80,6 @@ namespace ROS2SimulationInterfaces
{
}

void ROS2SimulationInterfacesSystemComponent::Init()
{
}

void ROS2SimulationInterfacesSystemComponent::Activate()
{
ROS2SimulationInterfacesRequestBus::Handler::BusConnect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,14 @@
#pragma once

#include <AzCore/Component/Component.h>
#include <AzFramework/API/ApplicationAPI.h>

#include "Services/DeleteEntityServiceHandler.h"
#include "Services/GetEntitiesServiceHandler.h"
#include "Services/GetEntitiesStatesServiceHandler.h"
#include "Services/GetEntityStateServiceHandler.h"
#include "Services/GetSimulationFeaturesServiceHandler.h"
#include "Services/GetSimulationStateServiceHandler.h"
#include "Services/GetSpawnablesServiceHandler.h"
#include "Services/ROS2ServiceBase.h"
#include "Services/ResetSimulationServiceHandler.h"
#include "Services/SetEntityStateServiceHandler.h"
#include "Services/SetSimulationStateServiceHandler.h"
#include "Services/SpawnEntityServiceHandler.h"
#include "Services/StepSimulationServiceHandler.h"
#include "SimulationInterfaces/ROS2SimulationInterfacesRequestBus.h"
#include <AzCore/std/containers/unordered_map.h>
#include <AzCore/std/optional.h>
#include <AzCore/std/smart_ptr/shared_ptr.h>
#include <AzCore/std/string/string.h>
#include <AzFramework/API/ApplicationAPI.h>

#include <SimulationInterfaces/ROS2SimulationInterfacesRequestBus.h>

#include <Interfaces/IROS2HandlerBase.h>

namespace ROS2SimulationInterfaces
{
Expand All @@ -51,7 +39,6 @@ namespace ROS2SimulationInterfaces

protected:
// AZ::Component interface implementation
void Init() override;
void Activate() override;
void Deactivate() override;

Expand Down
Loading