-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlifecycle_node.py
More file actions
54 lines (44 loc) · 1.79 KB
/
lifecycle_node.py
File metadata and controls
54 lines (44 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# ur5e_navigation/ur5e_navigation/lifecycle_node.py
import rclpy
from rclpy.node import Node
from rclpy.lifecycle import LifecycleNode
from rclpy.lifecycle import State
from rclpy.lifecycle import TransitionCallbackReturn
class UR5eLifecycleNode(LifecycleNode):
def __init__(self):
super().__init__('ur5e_lifecycle_node')
self.get_logger().info('Lifecycle node initialized')
def on_configure(self, state: State) -> TransitionCallbackReturn:
self.get_logger().info('Configuring...')
# Add configuration code here
return TransitionCallbackReturn.SUCCESS
def on_activate(self, state: State) -> TransitionCallbackReturn:
self.get_logger().info('Activating...')
# Add activation code here
return TransitionCallbackReturn.SUCCESS
def on_deactivate(self, state: State) -> TransitionCallbackReturn:
self.get_logger().info('Deactivating...')
# Add deactivation code here
return TransitionCallbackReturn.SUCCESS
def on_cleanup(self, state: State) -> TransitionCallbackReturn:
self.get_logger().info('Cleaning up...')
# Add cleanup code here
return TransitionCallbackReturn.SUCCESS
def on_shutdown(self, state: State) -> TransitionCallbackReturn:
self.get_logger().info('Shutting down...')
# Add shutdown code here
return TransitionCallbackReturn.SUCCESS
def main(args=None):
rclpy.init(args=args)
lifecycle_node = UR5eLifecycleNode()
executor = rclpy.executors.SingleThreadedExecutor()
executor.add_node(lifecycle_node)
try:
executor.spin()
except (KeyboardInterrupt, rclpy.executors.ExternalShutdownException):
pass
finally:
lifecycle_node.destroy_node()
rclpy.shutdown()
if __name__ == '__main__':
main()