コード例 #1
0
  @Override
  public void writeAfterController(long timestamp) {
    jointCommand.clear();

    jointCommand.putLong(estimatorTicksPerControlTick);
    jointCommand.putLong(timestamp);
    jointCommand.putLong(estimatorFrequencyInHz);

    for (int i = 0; i < joints.size(); i++) {
      OneDoFJoint joint = joints.get(i);

      if (fingerJointMap == null || !fingerJointMap.containsKey(joint.getName())) {
        if (joint.isUnderPositionControl()) jointCommand.putDouble(joint.getqDesired());
        else jointCommand.putDouble(joint.getTau());
      } else
        jointCommand.putDouble(
            fingerJointMap
                .get(joint.getName())
                .getqDesired()); // fingers are always position controlled
    }

    jointCommand.flip();

    try {
      while (jointCommand.hasRemaining()) {
        channel.write(jointCommand);
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
 /** ID Robot --> SCS Robot Copy the torques from the IDRobot to the SCSRobot. */
 public void updateTorquesSCSrobot() // Remember! the body joint is NOT actuated
     {
   for (OneDoFJoint idJoint : idToSCSLegJointMap.keySet()) {
     OneDegreeOfFreedomJoint scsJoint = idToSCSLegJointMap.get(idJoint);
     scsJoint.setTau(idJoint.getTau());
   }
 }
  @Override
  public void write() {
    for (int i = 0; i < revoluteJoints.size(); i++) {
      ImmutablePair<OneDegreeOfFreedomJoint, OneDoFJoint> jointPair = revoluteJoints.get(i);
      OneDegreeOfFreedomJoint pinJoint = jointPair.getLeft();
      OneDoFJoint revoluteJoint = jointPair.getRight();

      pinJoint.setTau(revoluteJoint.getTau());
    }
  }
  public void process(long timestamp) {
    for (WandererJoint joint : WandererJoint.values) {
      AcsellJointState jointState = state.getJointState(joint);
      OneDoFJoint oneDoFJoint = jointMap.get(joint);
      RawJointSensorDataHolder rawSensor = rawSensors.get(oneDoFJoint);

      oneDoFJoint.setQ(jointState.getQ());
      oneDoFJoint.setQd(jointState.getQd());
      state.updateRawSensorData(joint, rawSensor);
    }

    AcsellXSensState xSensState = state.getXSensState();
    xSensState.getQuaternion(rotation);
    //      rootJoint.setRotation(rotation);
    rootJoint.updateFramesRecursively();
    if (!initialized) {
      controller.initialize(timestamp);
      initialized = true;
    }

    controller.doControl(timestamp);

    if (controller.turnOutputOn()) {
      command.enableActuators();
    }

    for (WandererJoint joint : WandererJoint.values) {
      OneDoFJoint oneDoFJoint = jointMap.get(joint);
      RawJointSensorDataHolder rawSensor = rawSensors.get(oneDoFJoint);

      AcsellJointCommand jointCommand = command.getAcsellJointCommand(joint);
      jointCommand.setTauDesired(oneDoFJoint.getTau(), 0.0, rawSensor);
      jointCommand.setDamping(oneDoFJoint.getKd());
    }

    outputWriter.write();

    if (visualizer != null) {
      visualizer.update(timestamp);
    }
  }