|
From: <gb...@us...> - 2008-08-12 02:30:31
|
Revision: 304
http://gearbox.svn.sourceforge.net/gearbox/?rev=304&view=rev
Author: gbiggs
Date: 2008-08-12 02:30:41 +0000 (Tue, 12 Aug 2008)
Log Message:
-----------
Fixed some bugs in the handling of SCIP v1 device information.
Modified Paths:
--------------
gearbox/trunk/src/flexiport/port.h
gearbox/trunk/src/hokuyo_aist/hokuyo_aist.cpp
gearbox/trunk/src/hokuyo_aist/test/example.cpp
Modified: gearbox/trunk/src/flexiport/port.h
===================================================================
--- gearbox/trunk/src/flexiport/port.h 2008-08-10 02:31:56 UTC (rev 303)
+++ gearbox/trunk/src/flexiport/port.h 2008-08-12 02:30:41 UTC (rev 304)
@@ -4,17 +4,17 @@
* Copyright (c) 2008 Geoffrey Biggs
*
* flexiport flexible hardware data communications library.
- *
- * This distribution is licensed to you under the terms described in the LICENSE file included in
+ *
+ * This distribution is licensed to you under the terms described in the LICENSE file included in
* this distribution.
*
* This work is a product of the National Institute of Advanced Industrial Science and Technology,
* Japan. Registration number: H20PRO-881
- *
+ *
* This file is part of flexiport.
*
* flexiport is free software: you can redistribute it and/or modify it under the terms of the GNU
- * Lesser General Public License as published by the Free Software Foundation, either version 3 of
+ * Lesser General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* flexiport is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
@@ -154,7 +154,7 @@
/** @brief Read a new-line terminated string of data.
A convenience function that reads until a newline character (\\n, 0x0A) is received and
- stores the received data in a caller-provided buffer, @ref buffer. Good for text-based
+ stores the received data in a caller-provided buffer, @ref buffer. Good for text-based
protocols that use newlines as message terminators. Will not read more than @ref count
bytes.
@@ -166,10 +166,10 @@
strlen ()).
@note This function makes many calls to Read, each of which has an individual timeout. The
- maximum length of time this function make take may therefore be longer than one timeout.
+ maximum length of time this function may take may therefore be longer than one timeout.
@note If the port is set to non-blocking mode (by setting the timeout to zero), this will
- effectively timeout immediatly when there is no data available, returning -1 irrespective of
+ effectively timeout immediately when there is no data available, returning -1 irrespective of
the quantity of data actually received before that point.
@return The length of the string (including the new line), or -1 if a timeout occured. */
@@ -180,7 +180,7 @@
A convenience function that reads until a newline character (\\n, 0x0A) is received and
stores the received data in a string, @buffer. Good for text-based protocols that use
newlines as message terminators.
-
+
@note This function makes many calls to Read, each of which has an individual timeout. The
maximum length of time this function make take may therefore be longer than one timeout.
@@ -268,7 +268,7 @@
/** @brief Set the timeout value. Set seconds to -1 to disable timeouts and block forever.
@note On Mac OS X, the timer is reset each time data is received, making the timeout an
- inactivity timer in that there must be no data at all for the length of the timeout for it
+ inactivity timer in that there must be no data at all for the length of the timeout for it
to trigger. This can potentially lead to very long blocking if the sender is sending data
slightly faster than the timeout. */
virtual void SetTimeout (Timeout timeout) = 0;
Modified: gearbox/trunk/src/hokuyo_aist/hokuyo_aist.cpp
===================================================================
--- gearbox/trunk/src/hokuyo_aist/hokuyo_aist.cpp 2008-08-10 02:31:56 UTC (rev 303)
+++ gearbox/trunk/src/hokuyo_aist/hokuyo_aist.cpp 2008-08-12 02:30:41 UTC (rev 304)
@@ -1165,7 +1165,7 @@
info->serial = &buffer[5];
// Get either the status line or the end of message
ReadLine (buffer);
- if (buffer[0] != '\n')
+ if (buffer[0] != '\0')
{
// Got a status line
info->sensorDiagnostic = &buffer[5];
@@ -1191,7 +1191,7 @@
}
// Now put it through sscanf and hope...
int aperture;
- int numFound = sscanf (valueStart, "%d-%d[mm],%d[deg],%d-%d[step],%d[rpm]",
+ int numFound = sscanf (valueStart, "(%d-%d[mm],%d[deg],%d-%d[step],%d[rpm]",
&info->minRange, &info->maxRange, &aperture,
&info->firstStep, &info->lastStep, &info->speed);
if (numFound != 6)
@@ -1201,19 +1201,28 @@
info->CalculateValues ();
if (_verbose)
{
- cerr << "Retrieved sensor info (hard-coded):" << endl;
+ cerr << "Retrieved sensor info (hard-coded, not enough values):" << endl;
cerr << info->AsString ();
}
}
+ else
+ {
+ // Need to calculate stuff differently since it gave us an aperture value
+ info->resolution = DTOR (static_cast<double> (aperture)) /
+ static_cast<double> (info->lastStep - info->firstStep);
+ // Assume that the range is evenly spread
+ info->scanableSteps = info->lastStep - info->firstStep + 1;
+ info->frontStep = info->scanableSteps / 2 + info->firstStep - 1;
+ info->minAngle = (static_cast<int> (info->firstStep) -
+ static_cast<int> (info->frontStep)) * info->resolution;
+ info->maxAngle = (info->lastStep - info->frontStep) * info->resolution;
- // Need to calculate stuff differently since it gave us an aperture value
- info->resolution = static_cast<double> (aperture) /
- static_cast<double> (info->lastStep - info->firstStep);
- // Assume that the range is evenly spread
- info->scanableSteps = info->lastStep - info->firstStep + 1;
- info->frontStep = info->scanableSteps / 2;
- info->minAngle = (info->firstStep - info->frontStep) * info->resolution;
- info->maxAngle = (info->lastStep - info->frontStep) * info->resolution;
+ if (_verbose)
+ {
+ cerr << "Retrieved sensor info (from FIRM line):" << endl;
+ cerr << info->AsString ();
+ }
+ }
}
else
{
Modified: gearbox/trunk/src/hokuyo_aist/test/example.cpp
===================================================================
--- gearbox/trunk/src/hokuyo_aist/test/example.cpp 2008-08-10 02:31:56 UTC (rev 303)
+++ gearbox/trunk/src/hokuyo_aist/test/example.cpp 2008-08-12 02:30:41 UTC (rev 304)
@@ -118,7 +118,14 @@
cerr << "Failed to change baud rate: (" << e.Code () << ") " << e.what () << endl;
}
// Set the motor speed
- laser.SetMotorSpeed (speed);
+ try
+ {
+ laser.SetMotorSpeed (speed);
+ }
+ catch (hokuyo_aist::HokuyoError e)
+ {
+ cerr << "Failed to set motor speed: (" << e.Code () << ") " << e.what () << endl;
+ }
// Get some laser info
cout << "Laser sensor information:" << endl;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|