Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/

#pragma once

#include "SimulationInterfacesTypeIds.h"
#include <AzCore/Outcome/Outcome.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/string/string.h>
#include <SimulationInterfaces/Resource.h>
#include <SimulationInterfaces/Result.h>
#include <SimulationInterfaces/TagFilter.h>

#include "WorldResource.h"
#include <AzCore/EBus/EBus.h>
#include <AzCore/Interface/Interface.h>
#include <AzCore/std/containers/unordered_set.h>
#include <simulation_interfaces/msg/simulator_features.hpp>

namespace SimulationInterfaces
{
//! @see <a
//! href="https://github.com/ros-simulation/simulation_interfaces/blob/main/srv/GetAvailableWorlds.srv">GetAvailableWorlds.srv</a>
struct GetWorldsRequest
{
// Optional sources (local or remote) where simulator should look for worlds
AZStd::vector<AZStd::string> additionalSources;
TagFilter filter; // A filter to match against world tags
bool offlineOnly = false; // Whether to limit search to only offline resources
bool continueOnError = false; // By default fail in case of missing asset
};

//! @see <a
//! href="https://github.com/ros-simulation/simulation_interfaces/blob/main/srv/LoadWorld.srv">LoadWorld.srv</a>
struct LoadWorldRequest
{
Resource levelResource; // which level needs to be loaded
bool failOnUnsupportedElement = false; // By default just skip failed elements
bool ignoreMissingOrUnsupportedAssets = false; // Whether search should be continue on some noncritical fails
};

using WorldResourcesList = AZStd::vector<WorldResource>;

class LevelManagerRequests
{
public:
AZ_RTTI(LevelManagerRequests, LevelManagerRequestsTypeId);
virtual ~LevelManagerRequests() = default;

//! Returns vector with all worlds available in the simulator
virtual AZ::Outcome<WorldResourcesList, FailedResult> GetAvailableWorlds(const GetWorldsRequest& request) = 0;
//! Returns currently loaded world. If no world is loaded, error is returned
virtual AZ::Outcome<WorldResource, FailedResult> GetCurrentWorld() = 0;
//! Loads world based on provided resources
virtual AZ::Outcome<WorldResource, FailedResult> LoadWorld(const LoadWorldRequest& request) = 0;
//! Unloads currently loaded level
virtual AZ::Outcome<void, FailedResult> UnloadWorld() = 0;
//! Reloads current level
virtual void ReloadLevel() = 0;
};

class LevelManagerRequestBusTraits : public AZ::EBusTraits
{
public:
//////////////////////////////////////////////////////////////////////////
// EBusTraits overrides
static constexpr AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
static constexpr AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
//////////////////////////////////////////////////////////////////////////
};

using LevelManagerRequestBus = AZ::EBus<LevelManagerRequests, LevelManagerRequestBusTraits>;

} // namespace SimulationInterfaces
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/

#pragma once
#include <AzCore/std/string/string.h>

namespace SimulationInterfaces
{
//! A message type to represent simulation Resource
//! @see <a href="https://github.com/ros-simulation/simulation_interfaces/blob/main/msg/Resource.msg">Resource.msg</a>
struct Resource
{
Resource() = default;
Resource(AZStd::string uri, AZStd::string resourceString)
: m_uri(uri)
, m_resourceString(resourceString)
{
}
AZStd::string m_uri;
AZStd::string m_resourceString;
};
} // namespace SimulationInterfaces
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ namespace SimulationInterfaces

//! Reset the simulation to begin.
//! This will revert the entire simulation to the initial state.
virtual void ResetAllEntitiesToInitialState() = 0;
virtual AZ::Outcome<void, FailedResult> ResetAllEntitiesToInitialState() = 0;
};

class SimulationInterfacesBusTraits : public AZ::EBusTraits
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ namespace SimulationInterfaces
inline constexpr const char* NamedPoseManagerTypeId = "{0F100078-C297-482C-BA56-644AB09F053F}";
inline constexpr const char* NamedPoseManagerEditorTypeId = "{9E91A513-E1A5-43F0-B7B1-A759EEC23174}";

inline constexpr const char* LevelManagerTypeId = "{A9D5953D-F266-46D4-AD08-82CF10F426F7}";
inline constexpr const char* LevelManagerEditorTypeId = "{16C16216-279D-4215-9DF8-8AB4F15AC4C8}";
// Module derived classes TypeIds
inline constexpr const char* SimulationInterfacesModuleInterfaceTypeId = "{675797BF-E5D5-438A-BF86-4B4554F09CEF}";
inline constexpr const char* SimulationInterfacesModuleTypeId = "{8D6741FD-3105-4CB0-9700-152123B6D135}";
Expand All @@ -41,5 +43,6 @@ namespace SimulationInterfaces
inline constexpr const char* NamedPoseTypeId = "{C6B4A8BE-F39A-46ED-82E8-05BC260A1F31}";
inline constexpr const char* NamedPoseComponentTypeId = "{A294B840-79CA-402D-A250-B5C3D958B518}";
inline constexpr const char* NamedPoseEditorComponentTypeId = "{867002FC-ECA9-4CAE-A7B4-D2CA6FA14EF6}";
inline constexpr const char* LevelManagerRequestsTypeId = "{88519292-D032-4A2F-B323-FEDFE2E277EA}";

} // namespace SimulationInterfaces
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include "SimulationInterfacesTypeIds.h"
#include <AzCore/Outcome/Outcome.h>

#include "Result.h"
#include <AzCore/EBus/EBus.h>
Expand All @@ -30,7 +31,7 @@ namespace SimulationInterfaces
using ReloadLevelCallback = AZStd::function<void(void)>;

//! Reload level and remove all spawned simulation entities.
virtual void ReloadLevel(ReloadLevelCallback completionCallback) = 0;
virtual AZ::Outcome<void, FailedResult> ResetSimulation(ReloadLevelCallback completionCallback) = 0;

//! Set the simulation to paused or unpaused,
//! expect always to succeed
Expand Down Expand Up @@ -61,6 +62,9 @@ namespace SimulationInterfaces
//! https://github.com/ros-simulation/simulation_interfaces/blob/main/msg/SimulationState.msg
//! @return outcome indicating if setting state succeed. In case of failure error message with error code is returned
virtual AZ::Outcome<void, FailedResult> SetSimulationState(SimulationState stateToSet) = 0;
//! Check if it possible to work with entities. These operations should be possible only if world is loaded
//! @return bool indicating if simulator is ready for taking requests related to spawning/despawning setting entity state etc
virtual bool EntitiesOperationsPossible() = 0;
};

class SimulationMangerRequestBusTraits : public AZ::EBusTraits
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/

#pragma once
#include "Resource.h"
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/string/string.h>

namespace SimulationInterfaces
{
//! A message type to represent simulation Resource
//! @see <a href="https://github.com/ros-simulation/simulation_interfaces/blob/main/msg/WorldResource.msg">Resource.msg</a>
struct WorldResource
{
WorldResource() = default;
WorldResource(AZStd::string name, Resource resource, AZStd::string description, AZStd::vector<AZStd::string> tags)
: m_name(name)
, m_worldResource(resource)
, m_description(description)
, m_tags(tags)
{
}
AZStd::string m_name;
Resource m_worldResource;
AZStd::string m_description;
AZStd::vector<AZStd::string> m_tags;
};
} // namespace SimulationInterfaces
Loading