コード例 #1
0
  @Test
  public void testGetTicksTwo() {
    double conversion = 0.5; // units of conversion per count
    SimulatedEncoder simulatedEncoder = new SimulatedEncoder(conversion);

    double jointPosition = 50.0;

    int expecetedTicks = 25;
    simulatedEncoder.setActualPosition(jointPosition);

    assertEquals(expecetedTicks, simulatedEncoder.getEncoderTicks());

    jointPosition = 0.0;

    expecetedTicks = 0;
    simulatedEncoder.setActualPosition(jointPosition);

    assertEquals(expecetedTicks, simulatedEncoder.getEncoderTicks());
  }
コード例 #2
0
  @Test
  public void testGetTicksThree() {
    double conversion = 0.5; // units of ticks per length
    SimulatedEncoder simulatedEncoder = new SimulatedEncoder(conversion);

    double jointPosition = 0.9;

    int expecetedTicks = 0;
    simulatedEncoder.setActualPosition(jointPosition);

    assertEquals(expecetedTicks, simulatedEncoder.getEncoderTicks());

    jointPosition = 1.1;

    expecetedTicks = 1;
    simulatedEncoder.setActualPosition(jointPosition);

    assertEquals(expecetedTicks, simulatedEncoder.getEncoderTicks());
  }
コード例 #3
0
  public void testGetPositionFromEncoder() {
    double conversion = 0.5; // units of ticks per length
    SimulatedEncoder simulatedEncoder = new SimulatedEncoder(conversion);

    double jointPosition = 0.9;

    int expecetedTicks = 0;
    double expectedPosition = expecetedTicks / conversion;
    simulatedEncoder.setActualPosition(jointPosition);

    assertEquals(expectedPosition, simulatedEncoder.getPositionFromEncoder());

    jointPosition = 1.1;

    expecetedTicks = 1;
    expectedPosition = expecetedTicks / conversion;
    simulatedEncoder.setActualPosition(jointPosition);

    assertEquals(expectedPosition, simulatedEncoder.getPositionFromEncoder());
  }
コード例 #4
0
  @Test
  public void testGetTicksFour() {
    double ticksPerPosition = 10.0; // units of conversion per count
    SimulatedEncoder simulatedEncoder = new SimulatedEncoder(ticksPerPosition);

    double jointPosition = 0.5;

    int expecetedTicks = 5;
    simulatedEncoder.setActualPosition(jointPosition);

    assertEquals(expecetedTicks, simulatedEncoder.getEncoderTicks());
  }
コード例 #5
0
  @Test
  public void testGetPositionFromEncoderFour() {
    double conversion = 100; // units of ticks per length
    SimulatedEncoder simulatedEncoder = new SimulatedEncoder(conversion);

    double jointPosition = 5.0;

    double expectedPosition = 5.0;
    simulatedEncoder.setActualPosition(jointPosition);

    assertEquals(expectedPosition, simulatedEncoder.getPositionFromEncoder());
  }