public void updateRobotConfigurationBasedOnFullRobotModel() {
    for (int i = 0; i < revoluteJoints.size(); i++) {
      ImmutablePair<OneDegreeOfFreedomJoint, OneDoFJoint> jointPair = revoluteJoints.get(i);
      OneDegreeOfFreedomJoint pinJoint = jointPair.getLeft();
      OneDoFJoint revoluteJoint = jointPair.getRight();

      pinJoint.setQ(revoluteJoint.getQ());
    }

    FloatingJoint floatingJoint = rootJointPair.getLeft();
    FloatingInverseDynamicsJoint sixDoFJoint = rootJointPair.getRight();

    RigidBodyTransform transform = sixDoFJoint.getJointTransform3D();
    floatingJoint.setRotationAndTranslation(transform);
  }
  @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());
    }
  }
Ejemplo n.º 3
0
  @Override
  public ImmutablePair<String, JSONObject> generate(
      JSONObject constraints, YodaEnvironment yodaEnvironment) {
    String hasQualityRole;
    String prepositionClassString;
    JSONObject child;
    List<String> keys =
        (List<String>)
            constraints.keySet().stream().map(x -> (String) x).collect(Collectors.toList());
    keys.remove("class");
    hasQualityRole = keys.get(0);
    JSONObject prepositionContent = (JSONObject) constraints.get(hasQualityRole);
    prepositionClassString = (String) prepositionContent.get("class");
    child =
        SemanticsModel.parseJSON(
            ((JSONObject) prepositionContent.get(YodaSkeletonOntologyRegistry.inRelationTo.name))
                .toJSONString());

    QualityDegree prepositionClass = Ontology.qualityDegreeNameMap.get(prepositionClassString);
    String ppString = null;
    try {
      ppString =
          yodaEnvironment
              .lex
              .getPOSForClass(
                  prepositionClass, Lexicon.LexicalEntry.PART_OF_SPEECH.PREPOSITION, false)
              .stream()
              .findAny()
              .get();
    } catch (Lexicon.NoLexiconEntryException e) {
      ppString = "of";
    }

    JSONObject ansJSON = SemanticsModel.parseJSON("{\"class\":\"" + prepositionClass.name + "\"}");
    SemanticsModel.wrap(
        ansJSON, YodaSkeletonOntologyRegistry.unknownThingWithRoles.name, hasQualityRole);

    ImmutablePair<String, JSONObject> nestedPhrase =
        NaturalLanguageGenerator.getAppropriatePhraseGenerationRoutine(child)
            .generate(child, yodaEnvironment);

    SemanticsModel.putAtPath(
        ansJSON,
        hasQualityRole + "." + YodaSkeletonOntologyRegistry.inRelationTo.name,
        nestedPhrase.getRight());
    String ansString = ppString + " " + nestedPhrase.getLeft();

    return new ImmutablePair<>(ansString, ansJSON);
  }
 public boolean isCurrentTimeInSchedule() {
   DateTime now = DateTime.now();
   if (dayOfWeekRange != null && !dayOfWeekRange.contains(now.getDayOfWeek())) {
     return false;
   }
   if (dayOfMonthRange != null && !dayOfMonthRange.contains(now.getDayOfMonth())) {
     return false;
   }
   if (timeRange != null) {
     Interval interval =
         new Interval(
             timeRange.getLeft().toDateTimeToday(), timeRange.getRight().toDateTimeToday());
     if (!interval.contains(now)) {
       return false;
     }
   }
   return true;
 }
Ejemplo n.º 5
0
  protected void updateEntityActionState() {
    super.updateEntityActionState();

    if (!this.worldObj.isRemote) {
      int i;
      int j;
      int k;
      int i1;

      if (this.allySummonCooldown > 0) {
        --this.allySummonCooldown;

        if (this.allySummonCooldown == 0) {
          i = MathHelper.floor_double(this.posX);
          j = MathHelper.floor_double(this.posY);
          k = MathHelper.floor_double(this.posZ);
          boolean flag = false;

          for (int l = 0; !flag && l <= 5 && l >= -5; l = l <= 0 ? 1 - l : 0 - l) {
            for (i1 = 0; !flag && i1 <= 10 && i1 >= -10; i1 = i1 <= 0 ? 1 - i1 : 0 - i1) {
              for (int j1 = 0; !flag && j1 <= 10 && j1 >= -10; j1 = j1 <= 0 ? 1 - j1 : 0 - j1) {
                if (this.worldObj.getBlock(i + i1, j + l, k + j1) == Blocks.monster_egg) {
                  if (!this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing")) {
                    int k1 = this.worldObj.getBlockMetadata(i + i1, j + l, k + j1);
                    ImmutablePair immutablepair = BlockSilverfish.func_150197_b(k1);
                    this.worldObj.setBlock(
                        i + i1,
                        j + l,
                        k + j1,
                        (Block) immutablepair.getLeft(),
                        ((Integer) immutablepair.getRight()).intValue(),
                        3);
                  } else {
                    this.worldObj.func_147480_a(i + i1, j + l, k + j1, false);
                  }

                  Blocks.monster_egg.onBlockDestroyedByPlayer(
                      this.worldObj, i + i1, j + l, k + j1, 0);

                  if (this.rand.nextBoolean()) {
                    flag = true;
                    break;
                  }
                }
              }
            }
          }
        }
      }

      if (this.entityToAttack == null && !this.hasPath()) {
        i = MathHelper.floor_double(this.posX);
        j = MathHelper.floor_double(this.posY + 0.5D);
        k = MathHelper.floor_double(this.posZ);
        int l1 = this.rand.nextInt(6);
        Block block =
            this.worldObj.getBlock(
                i + Facing.offsetsXForSide[l1],
                j + Facing.offsetsYForSide[l1],
                k + Facing.offsetsZForSide[l1]);
        i1 =
            this.worldObj.getBlockMetadata(
                i + Facing.offsetsXForSide[l1],
                j + Facing.offsetsYForSide[l1],
                k + Facing.offsetsZForSide[l1]);

        if (BlockSilverfish.func_150196_a(block)) {
          this.worldObj.setBlock(
              i + Facing.offsetsXForSide[l1],
              j + Facing.offsetsYForSide[l1],
              k + Facing.offsetsZForSide[l1],
              Blocks.monster_egg,
              BlockSilverfish.func_150195_a(block, i1),
              3);
          this.spawnExplosionParticle();
          this.setDead();
        } else {
          this.updateWanderPath();
        }
      } else if (this.entityToAttack != null && !this.hasPath()) {
        this.entityToAttack = null;
      }
    }
  }