def setUpClass(cls): config = Config() config.set_param('logger', 'lidapy.ConsoleLogger') config.set_param('ipc', 'lidapy.LocalCommunicationProxy') config.set_param('rate_in_hz', '10') lidapy.init(config=config, process_name='test')
def __init__(self): print "initializing" pygame.init() self.screen = self.make_screen() self.screenrect = self.screen.get_rect() resources.images = resources.load_all_images() pygame.display.set_icon(resources.images.icon) self.submenu = game_submenu(self, self.screenrect) self.submenu.draw_all(self.screen) pygame.display.flip() self.tochangeto = '' self.run = True lidapy.init(process_name='Environment') self.image_topic = lidapy.Topic('images', msg_type=CompressedImage, queue_size=1) self.action_topic = lidapy.Topic('actions', queue_size=1) self.mainloop()
def setUpClass(cls): config = Config() config.set_param('logger', 'lidapy.ConsoleLogger') config.set_param('ipc', 'lidapy.LocalCommunicationProxy') config.set_param('rate_in_hz', 10) lidapy.init(config=config, process_name='test')
def setUp(self): config = Config() config.set_param('logger', 'lidapy.ConsoleLogger') config.set_param('ipc_proxy', 'lidapy.RosCommunicationProxy') self._var = lidapy.init(process_name='test')
def setUpClass(cls): config = Config() config.set_param('logger', 'lidapy.ConsoleLogger') config.set_param('ipc_proxy', 'lidapy.RosCommunicationProxy') lidapy.init(process_name='test')
if not action: action = STOP wheel_cmd = WheelCommand() wheel_cmd.angle = action.angle wheel_cmd.force = action.direction * float( lidapy.get_param('wheel_force', section='action_execution')) ACTUATOR.send(wheel_cmd) # Sleep to let wheel command execution occur for the expected duration before # changing commands sleep(action.duration) # Initialize the lidapy framework lidapy.init(Config(file_path=argv[1], use_param_service=True), log_level=lidapy.LOG_LEVEL_DEBUG) processes = [ LIDAProcess('action_execution', [Task('action_execution', execute_action)]), LIDAProcess('action_selection', [Task('action_selector', determine_action)]), LIDAProcess('stuck_detector', [Task('stuck_detector', detect_stuck)]), LIDAProcess('path_detection', [Task('path_detector', detect_path)]) ] for p in processes: p.start() sleep(1)
return 0 <= move < 9 and self._board.is_blank(move) def update(self): if self._is_end(): pain_topics[self._board.looser].send(PAIN) self._turn = self._board.winner self._board.reset() if self._turn == PLAYER1: move = self._player1(), PLAYER1 else: move = self._player2( ), PLAYER2 # receive_action should be bound to an instance if self.move_possible(move[0]) and self._turn == move[1]: if self._make_move(move[0]): self._turn = PLAYER2 if self._turn == PLAYER1 else PLAYER1 lidapy.loginfo(self.board_string()) print('running') if __name__ == '__main__': agent_config = Config() agent_config.set_param('rate_in_hz', 1) lidapy.init(config=agent_config) ox_env = OXPlayerEnvironment() ox_env.start()
#! /usr/bin/env python import random from sys import argv from lidapy import Config from lidapy import LIDAThread from lidapy import Topic from lidapy import init, loginfo # Shared Talker/Listener Topic topic = Topic('tl_topic') # Method invoked by talker def talk(): topic.send(str(random.randint(0, 1000000))) # Method invoked by listener def listen(): loginfo('Received message: {}'.format(topic.receive())) # Initialize the lidapy framework init(config=Config(argv[1]), process_name='talker_listener') LIDAThread(name='talker', callback=talk).start() LIDAThread(name='listener', callback=listen).start()
def execute_action(): action = SELECTED_ACTIONS.receive(timeout=0.25) if not action: action = STOP wheel_cmd = WheelCommand() wheel_cmd.angle = action.angle wheel_cmd.force = action.direction * float(lidapy.get_param('wheel_force', section='action_execution')) ACTUATOR.send(wheel_cmd) # Sleep to let wheel command execution occur for the expected duration before # changing commands sleep(action.duration) # Initialize the lidapy framework lidapy.init(Config(file_path=argv[1], use_param_service=True), log_level=lidapy.LOG_LEVEL_DEBUG) processes = [ LIDAProcess('action_execution', [Task('action_execution', execute_action)]), LIDAProcess('action_selection', [Task('action_selector', determine_action)]), LIDAProcess('stuck_detector', [Task('stuck_detector', detect_stuck)]), LIDAProcess('path_detection', [Task('path_detector', detect_path)]) ] for p in processes: p.start() sleep(1)
#! /usr/bin/env python from PIL import Image from StringIO import StringIO from sys import argv import lidapy from lidapy import LIDAThread, Config from sensor_msgs.msg import CompressedImage image_topic = lidapy.Topic('images', msg_type=CompressedImage) def receive_image(): msg = image_topic.receive() # type: CompressedImage if msg: # TODO: Create the pixel layer from this image's data image = Image.open(StringIO(msg.data)) # Initialize the lidapy framework lidapy.init(config=Config(argv[1]), process_name='sensory_memory') LIDAThread(name='sensory_memory', callback=receive_image).start()
def setUpClass(cls): config = Config() config.set_param('logger', 'lidapy.ConsoleLogger') config.set_param('ipc', 'lidapy.LocalCommunicationProxy') lidapy.init(config=config)