super().__init__() @Module.asyncloop(1) async def run(self): print("sent test case") pub.sendMessage("gamepad", message={ "logLevel": "warning", "Ricky": "dehydrtion" }) if __name__ == "__main__": Logger = Logger(Print=True, log=False, topics="gamepad, command") Logger.start(1) __Test_Case_Send__ = __Test_Case_Send__() __Test_Case_Send__.start(1) AsyncModuleManager = AsyncModuleManager() AsyncModuleManager.register_modules(Logger, __Test_Case_Send__) try: AsyncModuleManager.run_forever() except KeyboardInterrupt: pass except BaseException: pass finally: print("Closing Loop") AsyncModuleManager.stop_all()
print("message: ", message["Thruster_message"]) #print("time: ", time.time()) def run(self): initial = time.time() #print("initial: ", initial) pub.sendMessage("command.movement", message = {"command_message": (0,1,0,1,0,0)}) if __name__ == "__main__": import time from itertools import combinations from Gamepad import Gamepad from ControlProfile import ControlProfile AsyncModuleManager = AsyncModuleManager() Gamepad = Gamepad() Gamepad.start(240) ControlProfile = ControlProfile() ControlProfile.start(1) Thruster_Power = Thruster_Power() #__Test_Case_Combo__ = __Test_Case_Combo__() __Test_Case_Single__ = __Test_Case_Single__() #__Test_Case_Single__.start(10) #__Test_Case_Combo__.start(1) AsyncModuleManager.register_modules(Thruster_Power, __Test_Case_Single__) try: AsyncModuleManager.run_forever()
from Module_Loader import Loader import sys from Module_Base_Async import AsyncModuleManager AsyncModuleManager = AsyncModuleManager() config_name = "config.yaml" if len(sys.argv) > 1: config_name = sys.argv[1] nodes = Loader.load_all(config_name) for n in nodes: n["node"].start(n["frequency"]) try: AsyncModuleManager.register_module(n["node"]) except BaseException: pass try: AsyncModuleManager.run_forever() except KeyboardInterrupt: pass except BaseException: pass finally: print("Closing Loop") AsyncModuleManager.stop_all()
def run(self): pub.sendMessage("gamepad.EM1", message={"EM_R": 0}) def Listener(self, message): print(message) if __name__ == "__main__": from Gamepad import Gamepad EM1 = EM("EM1", '0x31') EM2 = EM("EM2", '0x32') EM1.start(1) EM2.start(1) Gamepad = Gamepad() #Gamepad.start(10) __Test_Case_Send__ = __Test_Case_Send__() __Test_Case_Send__.start(1) AsyncModuleManager = AsyncModuleManager() AsyncModuleManager.register_modules(Gamepad, EM1, EM2, __Test_Case_Send__) try: AsyncModuleManager.run_forever() except KeyboardInterrupt: pass except BaseException: pass finally: #print("Closing Loop") AsyncModuleManager.stop_all()
import time def debug_listener_movement(message): print(message["gamepad_message"]) def debug_listener_profile(message): print("\t\t\t\t\t", message["Profile_Dict"]) #time.sleep(1) def debug_listener_EM1(message): print("EM1: ", message) def debug_listener_EM2(message): print("EM2: ", message) debug = Gamepad() debug.start(120) pub.subscribe(debug_listener_movement, 'gamepad.movement') pub.subscribe(debug_listener_profile, 'gamepad.profile') pub.subscribe(debug_listener_EM1, 'gamepad.EM1') pub.subscribe(debug_listener_EM2, 'gamepad.EM2') AsyncModuleManager = AsyncModuleManager() AsyncModuleManager.register_modules(debug) try: AsyncModuleManager.run_forever() except KeyboardInterrupt: pass except BaseException: pass finally: print("Closing Loop") AsyncModuleManager.stop_all()
def run(self): pub.sendMessage( "Thruster.Power", message={"Thruster_message": [[0.0001, 0, 0, 0, 0, 0]]}) self.stop_all() if __name__ == "__main__": from Gamepad import Gamepad #Gamepad = Gamepad() #Gamepad.start(1) Thrusters = Thrusters() Thrusters.start(1) __test_case_send__ = __Test_Case_Send__() __test_case_send__.start(1) AsyncModuleManager = AsyncModuleManager() AsyncModuleManager.register_modules(__test_case_send__, Thrusters) try: AsyncModuleManager.run_forever() except KeyboardInterrupt: pass except BaseException: pass finally: print("Closing Loop") AsyncModuleManager.stop_all()
def logger_sent(message): print("log.sent: ", message) def logger_error(message): print("log.error: ", message) def logger_receive(message): print("can.receive: ", message["data"], "can.extra: ", message["extra"]) pub.subscribe(logger_sent, "log.sent") pub.subscribe(logger_error, "log.error") pub.subscribe(logger_receive, "can.receive") can_handler = CAN_Handler() can_handler.start(1) test_case_send = __Test_Case_Send__() test_case_send.start(1) AsyncModuleManager = AsyncModuleManager() AsyncModuleManager.register_modules(test_case_send, can_handler) try: AsyncModuleManager.run_forever() except KeyboardInterrupt: pass except BaseException: pass finally: print("Closing Loop") AsyncModuleManager.stop_all()
super().__init__() pub.subscribe(self.command_movement_listener, "command.movement") def command_movement_listener(self, message): print(message["command_message"]) def run(self): pub.sendMessage("gamepad.movement", message={"gamepad_message": (0.2, 0, 0, 0, 0, 0)}) pub.sendMessage("gamepad.profile", message={"Profile_Dict": 'A'}) if __name__ == "__main__": from Gamepad import Gamepad AsyncModuleManager = AsyncModuleManager() Gamepad = Gamepad() #Gamepad.start(100) __test_case_send__ = __Test_Case_Send__() __test_case_send__.start(1) ControlProfileA = ControlProfile(100, 0.0001, 'A') ControlProfileB = ControlProfile(70, 0.0001, 'B') ControlProfileC = ControlProfile(50, 0.0001, 'C') ControlProfileD = ControlProfile(30, 0.0001, 'D') AsyncModuleManager.register_modules(__test_case_send__, ControlProfileA, ControlProfileB, ControlProfileC, ControlProfileD)
print(message["gamepad_message"]) def debug_listener_EM1(message): print("EM1: ", message) def debug_listener_EM2(message): print("EM2: ", message) def debug_listener_gripper(message): print("gripper: ", message) pub.subscribe(debug_listener_profile, 'gamepad.profile') joystick = Joystick() joystick.start(50) pub.subscribe(debug_listener_gripper, "gamepad.gripper") #pub.subscribe(debug_listener_movement, 'gamepad.movement') pub.subscribe(debug_listener_EM1, 'gamepad.EM1') pub.subscribe(debug_listener_EM2, 'gamepad.EM2') pub.subscribe(debug_listener_profile, 'gamepad.profile') AsyncModuleManager.register_module(joystick) try: AsyncModuleManager.run_forever() except KeyboardInterrupt: print("keyboard interrupt") except BaseException: pass finally: print("Closing Loop") AsyncModuleManager.stop_all()
pub.sendMessage('gamepad.EM{}'.format(random.randint(1, 2)), message={ "EM_L": random.randint(0, 1), "EM_R": random.randint(0, 1) }) @Module.loop(0.002) def run5(self): flip = random.randint(0, 1) if flip: self.invert = not self.invert pub.sendMessage('gamepad.invert', message={"invert": self.invert}) if __name__ == "__main__": test_case_send = TestCaseSend() gui = GUI() test_case_send.start(50) gui.start(30) AsyncModuleManager.register_modules(gui, test_case_send) try: AsyncModuleManager.run_forever() except KeyboardInterrupt: pass except BaseException: pass finally: print("Closing Loop") AsyncModuleManager.stop_all()