コード例 #1
0
  @Override
  public void agentCreated() {
    hs = new HelloService(getExternalAccess());
    ps = new SendPositionService(getExternalAccess());

    addDirectService(hs);
    addDirectService(ps);

    String host = (String) getArgument("host");
    Integer port = (Integer) getArgument("port");
    Integer robotIdx = (Integer) getArgument("robId");
    Integer devIdx = (Integer) getArgument("devIndex");
    Boolean hasLaser = (Boolean) getArgument("laser");
    Boolean hasLocalize = (Boolean) getArgument("localize");

    /** Device list */
    CopyOnWriteArrayList<Device> devList = new CopyOnWriteArrayList<Device>();
    devList.add(new Device(IDevice.DEVICE_POSITION2D_CODE, host, port, devIdx));
    devList.add(new Device(IDevice.DEVICE_RANGER_CODE, host, port, devIdx));
    devList.add(new Device(IDevice.DEVICE_SONAR_CODE, host, port, devIdx));
    devList.add(new Device(IDevice.DEVICE_SIMULATION_CODE, host, port, -1));

    if (hasLocalize == true) {
      devList.add(new Device(IDevice.DEVICE_PLANNER_CODE, host, port + 1, devIdx));
      devList.add(new Device(IDevice.DEVICE_LOCALIZE_CODE, host, port + 1, devIdx));
    }

    /** Optional laser ranger */
    if (hasLaser == true)
      devList.add(new Device(IDevice.DEVICE_RANGER_CODE, host, port, devIdx + 1));

    /** Host list */
    CopyOnWriteArrayList<Host> hostList = new CopyOnWriteArrayList<Host>();
    hostList.add(new Host(host, port));

    /** Optional planner device */
    if (hasLocalize == true) hostList.add(new Host(host, port + 1));

    /** Get the device node */
    setDeviceNode(
        new DeviceNode(
            hostList.toArray(new Host[hostList.size()]),
            devList.toArray(new Device[devList.size()])));
    getDeviceNode().runThreaded();

    setRobot(new Pioneer(getDeviceNode().getDeviceListArray()));
    getRobot().setRobotId("r" + robotIdx);

    /** Check if a particular position is set */
    Position setPose =
        new Position(
            (Double) getArgument("X"), (Double) getArgument("Y"), (Double) getArgument("Angle"));

    if (setPose.equals(new Position(0, 0, 0)) == false) getRobot().setPosition(setPose);

    sendHello();
  }
コード例 #2
0
 public void finishVerification(
     ActionListener<VerifyResponse> listener,
     List<DiscoveryNode> nodes,
     CopyOnWriteArrayList<VerificationFailure> errors) {
   listener.onResponse(
       new RepositoriesService.VerifyResponse(
           nodes.toArray(new DiscoveryNode[nodes.size()]),
           errors.toArray(new VerificationFailure[errors.size()])));
 }
コード例 #3
0
 @Override
 public synchronized Object[] toArray(final Object[] a) {
   return copyOnWriteArrayList.toArray(a);
 }
コード例 #4
0
 @Override
 public Object[] toArray() {
   return copyOnWriteArrayList.toArray();
 }