-
Notifications
You must be signed in to change notification settings - Fork 10
/
testies
executable file
·53 lines (46 loc) · 1.45 KB
/
testies
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import py_trees
import py_trees_ros_tutorials
import rclpy
import rcl_interfaces.srv as rcl_srvs
import time
behaviour = py_trees_ros_tutorials.behaviours.ScanContext(
name="ContextSwitch"
)
rclpy.init()
print("create node")
node = rclpy.create_node("scan_context")
# time.sleep(1.0)
# print("Create client")
# client = node.create_client(
# rcl_srvs.GetParameters,
# '/safety_sensors/get_parameters'
# )
# ready = client.wait_for_service(timeout_sec=3.0)
# if not ready:
# raise RuntimeError('Wait for service timed out')
#
# print("Create request")
# request = rcl_srvs.GetParameters.Request()
# request.names.append("enabled")
# future = client.call_async(request)
# print("Future: %s" % future.__dict__)
# rclpy.spin_until_future_complete(node, future)
# print("Retrieived")
# if future.result() is not None:
# node.get_logger().info(
# 'Result of /safety_sensors/enabled: {}'.format(future.result().enabled)
# )
# feedback_message = "retrieved the safety sensors context"
# cached_context = future.result().enabled
# else:
# feedback_message = "failed to retrieve the safety sensors context"
# node.get_logger().error(feedback_message)
# node.get_logger().info('Service call failed %r' % (future.exception(),))
behaviour.setup(node=node)
behaviour.initialise()
print("Initialised")
time.sleep(5.0)
behaviour.terminate(new_status=py_trees.common.Status.INVALID)
rclpy.shutdown()