From adec8c846f2101371b0523e82393e39462b381ef Mon Sep 17 00:00:00 2001 From: Lucas Chiesa Date: Wed, 20 Nov 2013 06:41:04 -0800 Subject: [PATCH 1/2] Read all the width as reported by the laser Previously only a fixed angle was asked from the laser. We now use the maximum angle as reported by the laser. --- .../rosjava/rosjava_extras/hokuyo/LaserScanPublisher.java | 7 ++++++- .../rosjava/rosjava_extras/hokuyo/scip20/Device.java | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/hokuyo/src/main/java/com/github/rosjava/rosjava_extras/hokuyo/LaserScanPublisher.java b/hokuyo/src/main/java/com/github/rosjava/rosjava_extras/hokuyo/LaserScanPublisher.java index f96077e..92525ff 100644 --- a/hokuyo/src/main/java/com/github/rosjava/rosjava_extras/hokuyo/LaserScanPublisher.java +++ b/hokuyo/src/main/java/com/github/rosjava/rosjava_extras/hokuyo/LaserScanPublisher.java @@ -105,11 +105,16 @@ sensor_msgs.LaserScan toLaserScanMessage(String laserFrame, LaserScan scan, "Number of scans in configuration does not match received range measurements (%d > %d).", numberOfConfiguredRanges, scan.getRanges().length)); float[] ranges = new float[numberOfConfiguredRanges]; + int scannedRanges = scan.getRanges().length; for (int i = 0; i < numberOfConfiguredRanges; i++) { int step = i + configuration.getFirstStep(); // Select only the configured range measurements and convert from // millimeters to meters. - ranges[i] = (float) (scan.getRanges()[step] / 1000.0); + if(step>=scannedRanges) { + ranges[i] = 0; + } else { + ranges[i] = (float) (scan.getRanges()[step] / 1000.0); + } } result.setRanges(ranges); result.setTimeIncrement(configuration.getTimeIncrement()); diff --git a/hokuyo/src/main/java/com/github/rosjava/rosjava_extras/hokuyo/scip20/Device.java b/hokuyo/src/main/java/com/github/rosjava/rosjava_extras/hokuyo/scip20/Device.java index b2b0524..0b03ade 100644 --- a/hokuyo/src/main/java/com/github/rosjava/rosjava_extras/hokuyo/scip20/Device.java +++ b/hokuyo/src/main/java/com/github/rosjava/rosjava_extras/hokuyo/scip20/Device.java @@ -117,6 +117,8 @@ private void waitUntilReady() { boolean ready = false; while (!ready) { ready = true; + // NOTE(Julian Cerruti) At this moment, the sent command does not matter much. + // Currently fixed to (0; 768) write("MD0000076800001"); try { checkMdmsStatus(); @@ -260,8 +262,9 @@ public void startScanning(final LaserScanListener listener) { @Override public void run() { while (true) { - String command = "MD00000768000%02d"; - write(String.format(command, 99)); + String command = String.format("MD%04d%04d000%02d", configuration.getFirstStep(), + configuration.getLastStep(), 99); + write(command); checkMdmsStatus(); checkTerminator(); String scansRemaining = "99"; From 0564a05ebff2d4cd86c16f934ef2ea16db83afe0 Mon Sep 17 00:00:00 2001 From: Lucas Chiesa Date: Mon, 17 Feb 2014 09:52:01 -0300 Subject: [PATCH 2/2] Remove unnecessary name in comment. --- .../com/github/rosjava/rosjava_extras/hokuyo/scip20/Device.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hokuyo/src/main/java/com/github/rosjava/rosjava_extras/hokuyo/scip20/Device.java b/hokuyo/src/main/java/com/github/rosjava/rosjava_extras/hokuyo/scip20/Device.java index 0b03ade..04dda27 100644 --- a/hokuyo/src/main/java/com/github/rosjava/rosjava_extras/hokuyo/scip20/Device.java +++ b/hokuyo/src/main/java/com/github/rosjava/rosjava_extras/hokuyo/scip20/Device.java @@ -117,7 +117,7 @@ private void waitUntilReady() { boolean ready = false; while (!ready) { ready = true; - // NOTE(Julian Cerruti) At this moment, the sent command does not matter much. + // NOTE: At this moment, the sent command does not matter much. // Currently fixed to (0; 768) write("MD0000076800001"); try {