Ros2TestBase#
-
class Ros2TestBase#
Base test fixture class that provides common setup and utilities for ROS2 bridge tests.
This class reduces boilerplate code by providing:
Factory loading with error handling
Context and node creation helpers
Default QoS profile creation
Standard skip-if-no-factory pattern
Public Functions
-
inline explicit Ros2TestBase(const std::string &distro = "humble")#
Constructor that loads the ROS2 factory for the specified distribution.
- Parameters:
distro – ROS2 distribution name (default: “humble”)
-
inline virtual ~Ros2TestBase()#
Destructor that cleans up resources.
-
inline bool isFactoryAvailable() const#
Check if the factory was loaded successfully.
- Returns:
true if factory is available, false otherwise
- inline std::shared_ptr<isaacsim::ros2::core::Ros2Factory> getFactory(
Get the ROS2 factory instance.
- Returns:
Shared pointer to the factory, or nullptr if not available
-
inline bool skipIfNoFactory() const#
Skip test if factory is not available (use this in test cases)
- Returns:
true if test should be skipped, false if it can proceed
-
inline bool createContext()#
Create and initialize a ROS2 context.
- Returns:
true if successful, false otherwise
- inline bool createNode(
- const std::string &nodeName,
- const std::string &nodeNamespace = "test",
Create a ROS2 node handle.
- Parameters:
nodeName – Name of the node
nodeNamespace – Namespace for the node (default: “test”)
- Returns:
true if successful, false otherwise
- inline bool setupContextAndNode(
- const std::string &nodeName,
- const std::string &nodeNamespace = "test",
Create context and node in one call for convenience.
- Parameters:
nodeName – Name of the node
nodeNamespace – Namespace for the node (default: “test”)
- Returns:
true if both context and node were created successfully
- inline std::shared_ptr<isaacsim::ros2::core::Ros2ContextHandle> getContext(
Get the current context handle.
- Returns:
Shared pointer to context, or nullptr if not created
- inline std::shared_ptr<isaacsim::ros2::core::Ros2NodeHandle> getNode(
Get the current node handle.
- Returns:
Shared pointer to node, or nullptr if not created
-
inline void shutdown(const std::string &reason = "test-cleanup")#
Shutdown the ROS2 context if active.
- Parameters:
reason – Reason for shutdown (default: “test-cleanup”)
Public Static Functions
- static inline std::shared_ptr<isaacsim::ros2::core::Ros2Factory> loadRos2Factory(
- const std::string &distro,
Helper function to load a ROS2 bridge factory for a specific distro.
- Parameters:
distro – The ROS2 distribution to load (e.g., “humble”)
- Returns:
std::shared_ptr<isaacsim::ros2::core::Ros2Factory> Pointer to the factory or nullptr if loading failed
-
static inline isaacsim::ros2::core::Ros2QoSProfile createDefaultQoS()#
Create a default QoS profile for testing.
- Returns:
Default QoS profile with reliable delivery, volatile durability, depth 10
- static inline isaacsim::ros2::core::Ros2QoSProfile createBestEffortQoS(
Create a best-effort QoS profile for testing.
- Returns:
Best-effort QoS profile suitable for sensor data
- static inline isaacsim::ros2::core::Ros2QoSProfile createTransientLocalQoS(
Create a transient local QoS profile for testing.
- Returns:
Transient local QoS profile suitable for configuration data