Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Richardvdketterij committed Feb 16, 2024
1 parent e420cb3 commit 41923ff
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions smach_ros/test/introspection_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ def test_introspection(self):
node = rclpy.create_node("sm_node")
node.get_logger().set_level(rclpy.logging.LoggingSeverity.DEBUG)
executor = SingleThreadedExecutor()
def spin():
rclpy.spin(node, executor=executor)

# Construct state machine
sm = StateMachine(['done'])
Expand All @@ -67,13 +65,22 @@ def spin():
# Run introspector
intro_server = IntrospectionServer('intro_test', sm, '/intro_test')
intro_server.get_logger().set_level(rclpy.logging.LoggingSeverity.DEBUG)
server_thread = threading.Thread(target=intro_server.start)
server_thread.start()
intro_server.start()

intro_client = IntrospectionClient()
intro_client.get_logger().set_level(rclpy.logging.LoggingSeverity.DEBUG)
servers = intro_client.get_servers()

executor.add_node(node)
executor.add_node(intro_server)
executor.add_node(intro_client)

def spin(executor):
executor.spin()

spinner = threading.Thread(target=spin, args=(executor,))
spinner.start()

rate = intro_client.create_rate(10)
while '/intro_test' not in servers and rclpy.ok():
servers = intro_client.get_servers()
Expand All @@ -93,9 +100,6 @@ def spin():

assert init_set

spinner = threading.Thread(target=spin)
spinner.start()

outcome = sm.execute()

assert outcome == 'done'
Expand Down

0 comments on commit 41923ff

Please sign in to comment.