use of aima.core.robotics.impl.datatypes.AbstractRangeReading in project aima-java by aimacode.
the class MonteCarloLocalizationApp method initialize.
/**
* Creates a {@link GenericMonteCarloLocalization2DApp} and stores it in {@code app}.<br/>
* In addition the corresponding {@link IRobotGui} is created and stored in {@code robotGui}. The function {@code robotGui.destructRobot()} will be called when the application window closes to allow closing any open connections gracefully.
*/
protected void initialize() {
SimpleSettingsListener settingsListener = new SimpleSettingsListener(settingsGui);
settingsListener.createSettings();
AnglePanel angles = new AnglePanel(RANGE_READING_ANGLES_TITLE);
settingsGui.registerSpecialSetting(RANGE_READING_ANGLES_KEY, angles);
MclCartesianPlot2D<SimplePose, SimpleMove, AbstractRangeReading> map = new MclCartesianPlot2D<SimplePose, SimpleMove, AbstractRangeReading>(new SVGGroupParser(), new SVGGroupParser(), new SimplePoseFactory(), new SimpleRangeReadingFactory());
VirtualRobot robot = new VirtualRobot(map);
robotGui = new VirtualRobotGui(robot);
MonteCarloLocalization<SimplePose, Angle, SimpleMove, AbstractRangeReading> mcl = new MonteCarloLocalization<SimplePose, Angle, SimpleMove, AbstractRangeReading>(map, new JavaRandomizer());
app = new GenericMonteCarloLocalization2DApp<SimplePose, SimpleMove, SimpleRangeReading>(mcl, map, robot, robotGui, settingsGui);
angles.setChangeListener((ChangeListener) robotGui);
settingsListener.setMap(map);
settingsListener.setMcl(mcl);
settingsListener.setRobot(robot);
}
use of aima.core.robotics.impl.datatypes.AbstractRangeReading in project aima-java by aimacode.
the class SimpleRangeReading method calculateWeight.
@Override
public double calculateWeight(AbstractRangeReading secondRange) {
final AbstractRangeReading firstRange = addRangeNoise();
if (firstRange.getValue() < 0 || secondRange.getValue() < 0)
return 0;
if (Double.isInfinite(firstRange.getValue()) && Double.isInfinite(secondRange.getValue()))
return 1;
final double firstRangeValue;
if (Double.isInfinite(firstRange.getValue()) || firstRange.getValue() > SENSOR_RANGE)
firstRangeValue = SENSOR_RANGE;
else
firstRangeValue = firstRange.getValue();
final double secondRangeValue;
if (Double.isInfinite(secondRange.getValue()) || secondRange.getValue() > SENSOR_RANGE)
secondRangeValue = SENSOR_RANGE;
else
secondRangeValue = secondRange.getValue();
final double delta = Math.abs(firstRangeValue - secondRangeValue);
if (delta > BAD_DELTA)
return 0.0f;
return (float) (1.0d - delta / BAD_DELTA);
}
Aggregations