grey = RGB(0.0, 0.0, 0.0) red = RGB(1.0, 0.0, 0.0) blue = RGB(0.0, 0.0, 1.0) led_commands = LEDSCommands(red, grey, blue, red, blue) # Send PWM command pwm_commands = PWMCommands(motor_left=pwm_left, motor_right=pwm_right) commands = DB20Commands(pwm_commands, led_commands) context.write('commands', commands) def finish(self, context: Context): context.info('finish()') def jpg2rgb(image_data: bytes) -> np.ndarray: """ Reads JPG bytes as RGB. """ im = Image.open(io.BytesIO(image_data)) im = im.convert('RGB') data = np.array(im) assert data.ndim == 3 assert data.dtype == np.uint8 return data if __name__ == '__main__': node = Agent() protocol = protocol_agent_DB20 wrap_direct(node=node, protocol=protocol)
def main(): node = GymDuckiebotSimulator() protocol = protocol_simulator_duckiebot1 protocol.outputs['robot_state'] = MyRobotState wrap_direct(node=node, protocol=protocol)
if dt > 60: msg = "I have been waiting for commands from the ROS part" f" since {int(dt)} s" context.error(msg) raise Exception(msg) time.sleep(0.02) dt = time.time() - t0 if dt > 2.0: context.info(f"obtained agent commands after {dt:.1f} s") time.sleep(0.2) pwm_left, pwm_right = self.agent.action self.agent.updated = False grey = RGB(0.5, 0.5, 0.5) led_commands = LEDSCommands(grey, grey, grey, grey, grey) pwm_commands = PWMCommands(motor_left=pwm_left, motor_right=pwm_right) commands = DB20Commands(pwm_commands, led_commands) context.write("commands", commands) def finish(self, context): context.info("finish()") rospy.signal_shutdown("My job here is done.") if __name__ == "__main__": node = ROSTemplateAgent() protocol = protocol_agent_DB20_timestamps wrap_direct(node=node, protocol=protocol, args=[])
def main(): node = SagemakerILAgent() protocol = protocol_agent_duckiebot1 wrap_direct(node=node, protocol=protocol)
def main(): node = PytorchRLBaseline() protocol = protocol_agent_DB20 wrap_direct(node=node, protocol=protocol)
def main(): node = PytorchRLTemplateAgent(load_model=True, model_path="model_lf.pt") protocol = protocol_agent_DB20 wrap_direct(node=node, protocol=protocol)
def main(): node = PytorchRLTemplateAgent(load_model=False, model_path=None) protocol = protocol_agent_DB20 wrap_direct(node=node, protocol=protocol)
def main(): node = SimScenarioMaker() protocol = protocol_scenario_maker protocol.outputs['scenario'] = MyScenario wrap_direct(node=node, protocol=protocol)
def main(): node = RandomAgent() protocol = protocol_agent_DB20 wrap_direct(node=node, protocol=protocol)
while not self.agent.updated: time.sleep(0.01) pwm_left, pwm_right = self.agent.action self.agent.updated = False grey = RGB(0.5, 0.5, 0.5) led_commands = LEDSCommands(grey, grey, grey, grey, grey) pwm_commands = PWMCommands(motor_left=pwm_left, motor_right=pwm_right) commands = Duckiebot1Commands(pwm_commands, led_commands) context.write("commands", commands) def finish(self, context): context.info("finish()") def jpg2rgb(image_data): """ Reads JPG bytes as RGB""" im = Image.open(io.BytesIO(image_data)) im = im.convert("RGB") data = np.array(im) assert data.ndim == 3 assert data.dtype == np.uint8 return data if __name__ == "__main__": agent = ROSTemplateAgent() wrap_direct(agent, protocol_agent_duckiebot1)
def main() -> None: node = MinimalAgent() protocol = protocol_agent_duckiebot1 wrap_direct(node=node, protocol=protocol)
def main(): node = ImitationAgent() protocol = protocol_agent_duckiebot1 wrap_direct(node=node, protocol=protocol)
def main(): node = PytorchRLTemplateAgent() protocol = protocol_agent_DB20 wrap_direct(node=node, protocol=protocol)
def main(): node = DummyImageSource() protocol = protocol_image_source wrap_direct(node=node, protocol=protocol)
def submit_aido(submission): protocol = protocol_agent_duckiebot1 wrap_direct(node=submission, protocol=protocol)
def main(): node = PytorchAgent() protocol = protocol_agent_duckiebot1 wrap_direct(node=node, protocol=protocol)
def main(): node = DummyImageFilter() protocol = protocol_image_filter wrap_direct(node=node, protocol=protocol)
def main(): node = DuckieChallenger() protocol = protocol_agent_DB20 wrap_direct(node=node, protocol=protocol)
def main(): node = TensorflowTemplateAgent() protocol = protocol_agent_duckiebot1 wrap_direct(node=node, protocol=protocol)
def main(): node = BraitenbergAgent() protocol = protocol_agent_DB20 wrap_direct(node=node, protocol=protocol)
def main(): node = DummySimulator() protocol = protocol_simulator_duckiebot1 wrap_direct(node=node, protocol=protocol)