File tree Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Expand file tree Collapse file tree 2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change 2626# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2727# POSSIBILITY OF SUCH DAMAGE.
2828import logging
29+ import time
2930
3031import rclpy
3132from controller_manager_msgs .srv import ListControllers , SwitchController
@@ -207,7 +208,14 @@ class ControllerManagerInterface(
207208 initial_services = {"switch_controller" : SwitchController },
208209 services = {"list_controllers" : ListControllers },
209210):
210- pass
211+ def wait_for_controller (self , controller_name , target_state = "active" ):
212+ while True :
213+ controllers = self .list_controllers ().controller
214+ for controller in controllers :
215+ if (controller .name == controller_name ) and (controller .state == target_state ):
216+ return
217+
218+ time .sleep (1 )
211219
212220
213221class IoStatusInterface (
Original file line number Diff line number Diff line change 4040
4141sys .path .append (os .path .dirname (__file__ ))
4242from test_common import ( # noqa: E402
43- ControllerManagerInterface ,
4443 DashboardInterface ,
4544 IoStatusInterface ,
4645 generate_driver_test_description ,
46+ ControllerManagerInterface ,
4747)
4848
4949ROBOT_IP = "192.168.56.101"
@@ -92,14 +92,7 @@ def setUp(self):
9292 time .sleep (1 )
9393 self .assertTrue (self ._io_status_controller_interface .resend_robot_program ().success )
9494
95- io_controller_running = False
96-
97- while not io_controller_running :
98- time .sleep (1 )
99- response = self ._controller_manager_interface .list_controllers ()
100- for controller in response .controller :
101- if controller .name == "io_and_status_controller" :
102- io_controller_running = controller .state == "active"
95+ self ._controller_manager_interface .wait_for_controller ("io_and_status_controller" )
10396
10497 def test_set_io (self ):
10598 """Test setting an IO using a direct program call."""
You can’t perform that action at this time.
0 commit comments