HuskyOdometryStatus.java
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     // TODO: Allow setting (and load from ROS param in node)
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         // Parse buffer into encoder travels and speeds
00027         // --------------------------------
00028         ByteBuffer buffer = ByteBuffer.wrap(encoderData);
00029         buffer.order(ByteOrder.LITTLE_ENDIAN);
00030 
00031         // Number of encoders
00032         // TODO: Verify it's two encoders
00033         byte nEncoders = buffer.get();
00034         // Left encoder travel
00035         int leftTravel = buffer.getInt(1);
00036         // Right encoder travel
00037         int rightTravel = buffer.getInt(5);
00038         // Left encoder speed
00039         short leftSpeed = buffer.getShort(9);
00040         // Right encoder speed
00041         short rightSpeed = buffer.getShort(11);
00042 
00043         // Update the current estimated pose
00044         calculateAndUpdate(leftTravel, rightTravel, rightSpeed, leftSpeed);
00045     }
00046 }


android_base_controller
Author(s):
autogenerated on Fri Aug 28 2015 10:04:47