8
8
#pragma once
9
9
10
10
#include < AzCore/EBus/EBus.h>
11
+ #include < AzCore/EBus/Event.h>
11
12
#include < AzCore/Interface/Interface.h>
13
+ #include < ROS2/Clock/SimulationClock.h>
12
14
#include < builtin_interfaces/msg/time.hpp>
13
15
#include < geometry_msgs/msg/transform_stamped.hpp>
14
- #include < ROS2/Clock/SimulationClock.h>
15
16
#include < rclcpp/node.hpp>
16
17
17
18
namespace ROS2
@@ -24,6 +25,8 @@ namespace ROS2
24
25
class ROS2Requests
25
26
{
26
27
public:
28
+ using NodeChangedEvent = AZ::Event<std::shared_ptr<rclcpp::Node>>;
29
+
27
30
AZ_RTTI (ROS2Requests, " {a9bdbff6-e644-430d-8096-cdb53c88e8fc}" );
28
31
virtual ~ROS2Requests () = default ;
29
32
@@ -33,6 +36,12 @@ namespace ROS2
33
36
// ! @note Alternatively, you can use your own node along with an executor.
34
37
virtual std::shared_ptr<rclcpp::Node> GetNode () const = 0;
35
38
39
+ // ! Attach handler to ROS2 node change events.
40
+ // ! You can use this method to correctly initialize SystemComponents that depend on ROS2Node.
41
+ // ! @param handler which will be connected to NodeChangedEvent.
42
+ // ! @note callback is active as long as handler is not destroyed.
43
+ virtual void ConnectOnNodeChanged (NodeChangedEvent::Handler& handler) = 0;
44
+
36
45
// ! Acquire current time as ROS2 timestamp.
37
46
// ! Timestamps provide temporal context for messages such as sensor data.
38
47
// ! @code
@@ -55,7 +64,6 @@ namespace ROS2
55
64
// ! Obtains a simulation clock that is used across simulation.
56
65
// ! @returns constant reference to currently running clock.
57
66
virtual const SimulationClock& GetSimulationClock () const = 0;
58
-
59
67
};
60
68
61
69
class ROS2BusTraits : public AZ ::EBusTraits
0 commit comments