Skip to content

Instantly share code, notes, and snippets.

@madhephaestus
Created December 15, 2014 00:04
Show Gist options
  • Save madhephaestus/d5eb9897035f6827636d to your computer and use it in GitHub Desktop.
Save madhephaestus/d5eb9897035f6827636d to your computer and use it in GitHub Desktop.
package com.neuronrobotics.addons.driving;
import gnu.io.NRSerialPort;
import java.util.ArrayList;
import com.neuronrobotics.addons.driving.virtual.ObsticleType;
public class HokuyoTest implements ISensorListener {
private SimpleDisplay display = new SimpleDisplay();
private long start;
private HokuyoTest(){
LaserRangeSensor range = new LaserRangeSensor(new NRSerialPort("/dev/ttyACM1", 115200));
range.addSensorListener(this);
start=System.currentTimeMillis();
range.StartSweep(-90, 90, .5);
// try {
// Thread.sleep(10000);
// } catch (InterruptedException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
}
public static void main(String [] args){
new HokuyoTest();
}
@Override
public void onRangeSensorEvent(AbstractSensor source,ArrayList<DataPoint> data, long timeStamp) {
System.out.println("Range Sensor Event "+(System.currentTimeMillis()-start));
display.setUserDefinedData(data,ObsticleType.USERDEFINED);
start=System.currentTimeMillis();
source.StartSweep(-90, 90, .5);
}
@Override
public void onLineSensorEvent(AbstractSensor source, Integer left,Integer middle, Integer right, long timeStamp) {
//unused
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment