|
From: <gb...@us...> - 2010-05-10 03:38:17
|
Revision: 494
http://gearbox.svn.sourceforge.net/gearbox/?rev=494&view=rev
Author: gbiggs
Date: 2010-05-10 03:38:09 +0000 (Mon, 10 May 2010)
Log Message:
-----------
Added useful utility from Luiz Mirisola
Modified Paths:
--------------
gearbox/trunk/src/hokuyo_aist/CMakeLists.txt
Added Paths:
-----------
gearbox/trunk/src/hokuyo_aist/getid/
gearbox/trunk/src/hokuyo_aist/getid/96-hokuyo.rules
gearbox/trunk/src/hokuyo_aist/getid/CMakeLists.txt
gearbox/trunk/src/hokuyo_aist/getid/doc.dox
gearbox/trunk/src/hokuyo_aist/getid/getid.cpp
Modified: gearbox/trunk/src/hokuyo_aist/CMakeLists.txt
===================================================================
--- gearbox/trunk/src/hokuyo_aist/CMakeLists.txt 2010-04-05 00:47:38 UTC (rev 493)
+++ gearbox/trunk/src/hokuyo_aist/CMakeLists.txt 2010-05-10 03:38:09 UTC (rev 494)
@@ -28,6 +28,8 @@
GBX_ADD_HEADERS (${libName} ${hdrs})
+ add_subdirectory (getid)
+
if (GBX_BUILD_TESTS)
add_subdirectory (test)
endif (GBX_BUILD_TESTS)
Added: gearbox/trunk/src/hokuyo_aist/getid/96-hokuyo.rules
===================================================================
--- gearbox/trunk/src/hokuyo_aist/getid/96-hokuyo.rules (rev 0)
+++ gearbox/trunk/src/hokuyo_aist/getid/96-hokuyo.rules 2010-05-10 03:38:09 UTC (rev 494)
@@ -0,0 +1 @@
+ACTION=="add|change", KERNEL=="ttyACM*", ATTRS{idVendor}=="15d1", PROGRAM="/usr/local/bin/hokuyo_aist_getid -o type=serial,timeout=1,device=%N", SYMLINK+="hokuyo_%c"
Added: gearbox/trunk/src/hokuyo_aist/getid/CMakeLists.txt
===================================================================
--- gearbox/trunk/src/hokuyo_aist/getid/CMakeLists.txt (rev 0)
+++ gearbox/trunk/src/hokuyo_aist/getid/CMakeLists.txt 2010-05-10 03:38:09 UTC (rev 494)
@@ -0,0 +1,5 @@
+INCLUDE (${GBX_CMAKE_DIR}/UseBasicRules.cmake)
+
+GBX_ADD_EXECUTABLE(hokuyo_aist_getid getid.cpp)
+TARGET_LINK_LIBRARIES (hokuyo_aist_getid hokuyo_aist flexiport)
+
Added: gearbox/trunk/src/hokuyo_aist/getid/doc.dox
===================================================================
--- gearbox/trunk/src/hokuyo_aist/getid/doc.dox (rev 0)
+++ gearbox/trunk/src/hokuyo_aist/getid/doc.dox 2010-05-10 03:38:09 UTC (rev 494)
@@ -0,0 +1,37 @@
+/*!
+
+@ingroup gbx_libs
+@ingroup gbx_hardware
+@ingroup gbx_cpp
+@defgroup gbx_library_hokuyo_aist libhokuyo_aist
+@brief Utility to get the serial number of an Hokuyo laser scanner driver.
+
+This code is a stripped down version of the hokuyo_aist_example that just connects to the device, prints out its serial number, and closes the device.
+
+It is useful to write udev scripts to create permanent symlinks to your lasers, in the case you have more than one laser.
+Acutally iy would be easier if the serial number were provided by hardware as a udev attribute, but it is not. So, this small soft must be called to find the serial number, in order to discriminate between various laser scanners.
+
+The file 96-hokuyo.rules should be copied to /etc/udev/rules.d, and then the udev deamon should be restarted with:
+
+sudo /etc/init.d/udev stop
+sudo /etc/init.d/udev start
+
+Attention: use stop and start instead of only restart. It appears that the restart script does not reload the rules. You should see a message about reloading hardware drivers when the start command is issued.
+
+Afterwards when a hokuyo is plugged, the device /dev/ttyACM* will be generated as before, but besides that a symbolic link called hokuyo_XXXXXX will be generated, where XXXXX is the laser serial number.
+
+@par Responsible Developer
+ Luiz Mirisola
+
+@par License
+ LGPL
+
+@par Dependencies
+ @ref Flexiport
+
+@par Known issues
+ - When the user plugs the hokuyo, the udev rules call this program, that will connect to the laser. This process is quite slow.
+ - When the rule fires, there is no /dev/ttyACM* yet. Therefore, the %N tag in the rule returns the name of a temporary device in order that the software may connect to the laser. This solves the chicken-egg problem.
+
+*/
+
Added: gearbox/trunk/src/hokuyo_aist/getid/getid.cpp
===================================================================
--- gearbox/trunk/src/hokuyo_aist/getid/getid.cpp (rev 0)
+++ gearbox/trunk/src/hokuyo_aist/getid/getid.cpp 2010-05-10 03:38:09 UTC (rev 494)
@@ -0,0 +1,86 @@
+/*
+ * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics
+ * http://gearbox.sf.net/
+ * Copyright (c) 2008 Geoffrey Biggs
+ *
+ * hokuyo_aist Hokuyo URG laser scanner driver.
+ *
+ * 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: H22PRO-1086.
+ *
+ * This file is part of hokuyo_aist.
+ *
+ * This software is licensed under the Eclipse Public License -v 1.0 (EPL). See
+ * http://www.opensource.org/licenses/eclipse-1.0.txt
+ */
+
+#include <stdio.h>
+#include <math.h>
+#include <iostream>
+using namespace std;
+
+#include <hokuyo_aist/hokuyo_aist.h>
+
+int main(int argc, char **argv)
+{
+ string portOptions = "type=serial,device=/dev/ttyACM0,timeout=1";
+ bool verbose = false;
+
+#if defined (WIN32)
+ portOptions = "type=serial,device=COM3,timeout=1";
+#else
+ int opt;
+ // Get some options from the command line
+ while ((opt = getopt(argc, argv, "b:c:e:f:il:m:no:s:vh")) != -1)
+ {
+ switch (opt)
+ {
+ case 'o':
+ portOptions = optarg;
+ break;
+ case 'v':
+ verbose = true;
+ break;
+ case '?':
+ case 'h':
+ default:
+ cout << "Usage: " << argv[0] << " [options]" << endl << endl;
+ cout << "-o options\tPort options (see flexiport library)." << endl;
+ cout << "-v\t\tPut the hokuyo_aist library into verbose mode." << endl;
+ return 1;
+ }
+ }
+#endif // defined (WIN32)
+
+ try
+ {
+ hokuyo_aist::HokuyoLaser laser; // Laser scanner object
+ // Set the laser to verbose mode (so we see more information in the console)
+ if (verbose)
+ laser.SetVerbose (true);
+
+ // Open the laser
+ laser.Open (portOptions);
+ // Turn the laser on
+ laser.SetPower (true);
+
+ // Get some laser info
+ //cout << "Laser sensor information:" << endl;
+ hokuyo_aist::HokuyoSensorInfo info;
+ laser.GetSensorInfo (&info);
+ cout << info.serial << endl;
+
+ // Close the laser
+ laser.Close ();
+ }
+ catch (hokuyo_aist::HokuyoError e)
+ {
+ cerr << "Caught exception: (" << e.Code () << ") " << e.what () << endl;
+ return 1;
+ }
+
+ return 0;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|