Exemple #1
0
    def pytest_runtest_setup(self):
        # This function needs to do the same things that RobotBase.main does,
        # plus some extra things needed for testing

        import networktables
        networktables.NetworkTable.setTestMode()

        self._fake_time.reset()
        hal_impl.functions.reset_hal()

        self._test_controller = TestController(self._fake_time)

        import wpilib
        wpilib.RobotBase.initializeHardwareConfiguration()

        # The DS task causes too many problems, do it ourselves instead
        wpilib.DriverStation.getInstance().release()
        notify_new_ds_data()

        self._test_controller._robot = self.robot_class()

        # TODO: Remove after 2016
        getattr(self._test_controller._robot, 'prestart', lambda: True)()

        assert hasattr(self._test_controller._robot, '_RobotBase__initialized'), \
                       "If your robot class has an __init__ function, it must call super().__init__()!"
 def pytest_runtest_setup(self):
     # This function needs to do the same things that RobotBase.main does,
     # plus some extra things needed for testing
     
     import networktables
     networktables.NetworkTable.setTestMode()
     
     self._fake_time.reset()
     hal_impl.functions.reset_hal()
     
     self._test_controller = TestController(self._fake_time)
     
     import wpilib
     wpilib.RobotBase.initializeHardwareConfiguration()
     
     # The DS task causes too many problems, do it ourselves instead
     wpilib.DriverStation.getInstance().release()
     notify_new_ds_data()
     
     self._test_controller._robot = self.robot_class()
     
     # TODO: Remove after 2016
     getattr(self._test_controller._robot, 'prestart', lambda: True)()
     
     assert hasattr(self._test_controller._robot, '_RobotBase__initialized'), \
                    "If your robot class has an __init__ function, it must call super().__init__()!"
Exemple #3
0
    def on_joystick(self, idx, msg: Joystick):

        logger.info("joystick! %s", msg)
        js = hal_data['joysticks'][idx]
        buttons = js['buttons']
        axes = js['axes']
        js['has_source'] = True

        # super inefficient, but could be worse..
        # -> probably will be bit by race conditions here
        for i, (a, _) in enumerate(zip(msg.axes, axes)):
            axes[i] = a

        for i, (b, _) in enumerate(zip(msg.buttons, buttons)):
            buttons[i] = b

        mode_helpers.notify_new_ds_data()
    def on_joystick(self, idx, msg):
        
        js = hal_data['joysticks'][idx]
        buttons = js['buttons']
        axes = js['axes']
        js['has_source'] = True
        
        msg = Joystick.FromString(msg)
        
        # super inefficient, but could be worse..
        # -> probably will be bit by race conditions here 
        for i, (a, _) in enumerate(zip(msg.axes, axes)):
            axes[i] = a
            
        for i, (b, _) in enumerate(zip(msg.buttons, buttons)):
            buttons[i] = b

        mode_helpers.notify_new_ds_data()
Exemple #5
0
    def _ds_thread(self):

        # TODO: This needs to be fixed, breaks things when paused in IterativeRobot
        while True:
            time.sleep(0.020)
            mode_helpers.notify_new_ds_data()
Exemple #6
0
 def terrible_hack(self):
     # This terrible hack allows the DS thread to receive new joystick data
     while True:
         mode_helpers.notify_new_ds_data()
         time.sleep(0.02)
 def _ds_thread(self):
     
     # TODO: This needs to be fixed, breaks things when paused in IterativeRobot
     while True:
         time.sleep(0.020)
         mode_helpers.notify_new_ds_data()
Exemple #8
0
 def terrible_hack(self):
     # This terrible hack allows the DS thread to receive new joystick data
     while True:
         mode_helpers.notify_new_ds_data()
         time.sleep(0.02)