Revision dd065971
Fixed sonar out of range bug. Max range now at 9.144 m.
scout/scoutsim/src/scout.cpp | ||
---|---|---|
268 | 268 |
if (d_x < 0 || d_x >= walls_image.GetWidth() || |
269 | 269 |
d_y < 0 || d_y >= walls_image.GetHeight()) |
270 | 270 |
{ |
271 |
return d;
|
|
271 |
break;
|
|
272 | 272 |
} |
273 | 273 |
|
274 | 274 |
// Max range |
275 |
if (d > scoutsim::SONAR_MAX_RANGE) |
|
275 |
if (d > scoutsim::SONAR_MAX_RANGE_PIX)
|
|
276 | 276 |
{ |
277 |
return d;
|
|
277 |
break;
|
|
278 | 278 |
} |
279 | 279 |
|
280 | 280 |
// Get the sonar reading at the current position of the sonar |
... | ... | |
284 | 284 |
|
285 | 285 |
reading = rgb_to_grey(r, g, b); |
286 | 286 |
|
287 |
|
|
288 | 287 |
d++; |
289 | 288 |
} |
290 | 289 |
/// @todo Consider using different cutoffs for different features |
... | ... | |
324 | 323 |
} |
325 | 324 |
|
326 | 325 |
// Convert from pixels to mm and return |
327 |
return (unsigned int) (1000 * d / PIX_PER_METER);
|
|
326 |
return (unsigned int) ((1000 / PIX_PER_METER) * d);
|
|
328 | 327 |
} |
329 | 328 |
|
330 | 329 |
// x and y is current position of the sonar |
Also available in: Unified diff