Skip to content

Commit

Permalink
code review: cache list of sensor hooks
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Hanca <[email protected]>
  • Loading branch information
jhanca-robotecai committed Sep 19, 2023
1 parent 54ded8b commit 469a582
Show file tree
Hide file tree
Showing 9 changed files with 1,373 additions and 776 deletions.
6 changes: 5 additions & 1 deletion Gems/ROS2/Code/Include/ROS2/RobotImporter/RobotImporterBus.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
*/
#pragma once

#include <AzCore/EBus/EBus.h>
#include <AzCore/EBus/Policies.h>
#include <AzCore/std/string/string.h>
#include <AzCore/EBus/EBus.h>
#include <ROS2/RobotImporter/SDFormatSensorImporterHook.h>

namespace ROS2
{
Expand All @@ -24,6 +25,9 @@ namespace ROS2
//! @param importAssetWithUrdf If true, the assets referenced in the urdf file will be imported
//! @param useArticulation If true, the prefab will be generated with articulation
virtual bool GeneratePrefabFromFile(const AZStd::string_view filePath, bool importAssetWithUrdf, bool useArticulation) = 0;

//! Return the reference to the list of sensor importer hooks
virtual const SDFormat::SensorImporterHooksStorage& GetSensorHooks() const = 0;
};

using RobotImporterRequestBus = AZ::EBus<RobotImporterRequest>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,7 @@ namespace ROS2::SDFormat
using ConvertSDFSensorCallback = AZStd::function<ConvertSensorOutcome(AZ::Entity&, const sdf::Sensor&)>;
ConvertSDFSensorCallback m_sdfSensorToComponentCallback;
};

//! Buffer for SensorImporterHook data
using SensorImporterHooksStorage = AZStd::vector<ROS2::SDFormat::SensorImporterHook>;
} // namespace ROS2::SDFormat

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <AzCore/std/string/string.h>
#include <AzToolsFramework/Entity/EditorEntityContextBus.h>
#include <ROS2/RobotImporter/RobotImporterBus.h>
#include <ROS2/RobotImporter/SDFormatSensorImporterHook.h>
#include <RobotImporter/Utils/SourceAssetsStorage.h>
namespace ROS2
{
Expand Down Expand Up @@ -42,8 +43,12 @@ namespace ROS2

// RobotImporterRequestsBus::Handler overrides ..
bool GeneratePrefabFromFile(const AZStd::string_view filePath, bool importAssetWithUrdf, bool useArticulation) override;
const SDFormat::SensorImporterHooksStorage& GetSensorHooks() const override;

// Timeout for loop waiting for assets to be built
static constexpr AZStd::chrono::seconds assetLoopTimeout = AZStd::chrono::seconds(30);

// Cache for storing sensor importer hooks (read only once)
SDFormat::SensorImporterHooksStorage m_sensorHooks;
};
} // namespace ROS2
Loading

0 comments on commit 469a582

Please sign in to comment.