Back to project page base_controller.
The source code is released under:
Apache License
If you think the Android project base_controller listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.github.c77.base_driver.kobuki; //from w w w . ja v a 2s .com import com.github.c77.base_driver.AbstractOdometryStatus; import com.github.c77.base_driver.BaseStatus; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * @author jcerruti@willowgarage.com (Julian Cerruti) */ public class KobukiOdometryStatus extends AbstractOdometryStatus { private short lastTimestamp; private static final double WIDTH = 0.280; // in m Log log = LogFactory.getLog(KobukiOdometryStatus.class); public KobukiOdometryStatus() { super(WIDTH); } void update(BaseStatus baseStatus) { //log.info("Updating odometry. Left Ticks = " + baseStatus.getLeftDistance() + // ", Right Ticks = " + baseStatus.getRightDistance()); if (baseStatus.getTimestamp() == lastTimestamp) { return; } // Approximate speed using last known distance and time lapsed int timeLapsed = baseStatus.getTimestamp() - lastTimestamp; double leftSpeed = haveLastTravel ? (baseStatus.getLeftDistance() - lastLeftTravel) / timeLapsed : 0; double rightSpeed = haveLastTravel ? (baseStatus.getRightDistance() - lastRightTravel) / timeLapsed : 0; // Calculate new robot pose calculateAndUpdate(baseStatus.getLeftDistance(), baseStatus.getRightDistance(), leftSpeed, rightSpeed); lastTimestamp = baseStatus.getTimestamp(); } }