Go to the documentation of this file.00001 package com.github.c77.base_driver.husky;
00002
00003 import com.github.c77.base_driver.AbstractOdometryStatus;
00004
00005 import java.nio.ByteBuffer;
00006 import java.nio.ByteOrder;
00007
00011 public class HuskyOdometryStatus extends AbstractOdometryStatus {
00012
00013
00014 private static final double WIDTH = 0.55;
00015
00016 public HuskyOdometryStatus() {
00017 super(WIDTH);
00018 }
00019
00020 public void update(byte[] encoderData) {
00021 if(encoderData.length != 13) {
00022 throw new RuntimeException("wrong size encoder data = " + encoderData.length);
00023 }
00024
00025
00026
00027
00028 ByteBuffer buffer = ByteBuffer.wrap(encoderData);
00029 buffer.order(ByteOrder.LITTLE_ENDIAN);
00030
00031
00032
00033 byte nEncoders = buffer.get();
00034
00035 int leftTravel = buffer.getInt(1);
00036
00037 int rightTravel = buffer.getInt(5);
00038
00039 short leftSpeed = buffer.getShort(9);
00040
00041 short rightSpeed = buffer.getShort(11);
00042
00043
00044 calculateAndUpdate(leftTravel, rightTravel, rightSpeed, leftSpeed);
00045 }
00046 }