RLPark 1.0.0
Reinforcement Learning Framework in Java

IRobotDiscoConnection.java

Go to the documentation of this file.
00001 package rlpark.plugin.irobot.internal.irobot;
00002 
00003 import java.io.IOException;
00004 
00005 import rlpark.plugin.irobot.internal.descriptors.DropDescriptors;
00006 import rlpark.plugin.irobot.internal.descriptors.IRobotObservationReceiver;
00007 import rlpark.plugin.robot.internal.disco.DiscoConnection;
00008 import rlpark.plugin.robot.internal.disco.drops.Drop;
00009 import rlpark.plugin.robot.internal.disco.drops.DropByteArray;
00010 
00011 public class IRobotDiscoConnection extends DiscoConnection implements IRobotObservationReceiver {
00012   private final Drop commandDrop = DropDescriptors.newCommandSerialDrop();
00013   private final DropByteArray commandData = (DropByteArray) commandDrop.dropDatas()[0];
00014 
00015   public IRobotDiscoConnection(String hostname, int port, Drop sensorDrop) {
00016     super(hostname, port, sensorDrop);
00017   }
00018 
00019   @Override
00020   public void sendMessage(byte[] bytes) {
00021     commandData.setPascalStringValue(bytes);
00022     send();
00023   }
00024 
00025   private void send() {
00026     try {
00027       socket.send(commandDrop);
00028     } catch (IOException e) {
00029       e.printStackTrace();
00030       close();
00031     }
00032   }
00033 }
 All Classes Namespaces Files Functions Variables Enumerations
Zephyr
RLPark