<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>GearBox Project</title> <link rel="icon" href="gbx_icon_cardbox_sky.png" type="image/png"> <link rel="shortcut icon" href="gbx_icon_cardbox_sky.png" type="image/png"> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> <!-- Google Analytics --> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> var pageTracker = _gat._getTracker("UA-3583782-1"); pageTracker._initData(); pageTracker._trackPageview(); </script> <!-- Returning you to your regular programming --> </head><body> <!-- Header --> <table border="0" cellspacing="0" cellpadding="0"> <tr><!-- create row --> <!-- spacer cell --> <!-- #CC CC CC --> <td rowspan="1" colspan="1" bgcolor="#EEEEEE"> </td> <!-- menu cell --> <td width="170" rowspan="1" colspan="1" align="left" valign="top" bgcolor="#EEEEEE"> <p> </p> <p align="center"><a href="index.html"><img src="gbx_logo_cardbox_sky_150x150.png"></a></p><br> <strong>INTRODUCTION</strong><br> <strong><a href="gbx_doc_overview.html" style="text-decoration:none">Overview</a></strong><br> <strong><a href="gbx_doc_getting.html" style="text-decoration:none">Download and Install</a></strong><br> <!-- <strong><a href="gbx_doc_quickstart.html" style="text-decoration:none">Quick Start</a></strong><br> --> <strong><a href="gbx_doc_documentation.html" style="text-decoration:none">Documentation</a></strong><br> <strong><a href="gbx_doc_publications.html" style="text-decoration:none">Publications</a></strong><br> <br> <strong>REPOSITORY</strong><br> <strong><a href="group__gbx__libs.html" style="text-decoration:none">Libraries</a></strong><br> <!-- <strong><a href="group__gbx__utils.html" style="text-decoration:none">Utilities</a></strong><br> --> <br> <strong>DEVELOPER</strong><br> <!--<strong><a href="gbx_doc_tutorials.html" style="text-decoration:none">Tutorials</a></strong><br> <strong><a href="group__gbx__examples.html" style="text-decoration:none">Examples</a></strong><br>--> <strong><a href="gbx_doc_devguide.html" style="text-decoration:none">Dev Guide</a></strong><br> <!-- <strong><a href="gbx_doc_faq.html" style="text-decoration:none">FAQ</a></strong><br> --> <strong><a href="http://cdash.acfr.usyd.edu.au/index.php?project=Gearbox" style="text-decoration:none">Dashboard</a></strong><br> <!--<strong><a href="http://wiki2.cas.edu.au/orca">Wiki</a></strong><br> login/pass: orca/orca<br>--> <br> <strong>PEOPLE</strong><br> <strong><a href="gbx_doc_contributors.html" style="text-decoration:none">Contributors</a></strong><br> <strong><a href="gbx_doc_users.html" style="text-decoration:none">Users</a></strong><br> <br> <a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=216468&type=2" width="125" height="37" border="0" alt="SourceForge.net Logo" /></a><br> <strong><a href="http://sourceforge.net/projects/gearbox">Project</a></strong><br> <strong><a href="http://sourceforge.net/project/showfiles.php?group_id=216468">Download</a></strong><br> <!--<strong><a href="http://sourceforge.net/tracker/?group_id=216468">Bugs/Feedback</a></strong><br>--> <strong><a href="http://sourceforge.net/mail/?group_id=216468">Mailing lists</a></strong></p> <p> </p> </td><!-- /menu cell --> <!-- one grey spacer cells --> <td rowspan="1" colspan="1" bgcolor="#EEEEEE"> </td> <!-- one white spacer cells --> <td rowspan="1" colspan="1"> </td> <!-- main content cell --> <td rowspan="1" colspan="1" align="left" valign="top"> <!-- Generated by Doxygen 1.6.2-20100208 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="dir_b8ba9ebcb71a95a44c4fd60b7d348fe1.html">src</a> » <a class="el" href="dir_e6faee39d20d45fac309cc35f2ddb285.html">gbxsickacfr</a> </div> </div> <div class="contents"> <h1>gbxsickacfr/driver.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics</span> <a name="l00003"></a>00003 <span class="comment"> * http://gearbox.sf.net/</span> <a name="l00004"></a>00004 <span class="comment"> * Copyright (c) 2004-2008 Alex Brooks</span> <a name="l00005"></a>00005 <span class="comment"> *</span> <a name="l00006"></a>00006 <span class="comment"> * This distribution is licensed to you under the terms described in</span> <a name="l00007"></a>00007 <span class="comment"> * the LICENSE file included in this distribution.</span> <a name="l00008"></a>00008 <span class="comment"> *</span> <a name="l00009"></a>00009 <span class="comment"> */</span> <a name="l00010"></a>00010 <a name="l00011"></a>00011 <span class="preprocessor">#ifndef GBX_SICK_ACFR_H</span> <a name="l00012"></a>00012 <span class="preprocessor"></span><span class="preprocessor">#define GBX_SICK_ACFR_H</span> <a name="l00013"></a>00013 <span class="preprocessor"></span> <a name="l00014"></a>00014 <span class="preprocessor">#include <gbxsickacfr/serialhandler.h></span> <a name="l00015"></a>00015 <span class="preprocessor">#include <gbxutilacfr/tracer.h></span> <a name="l00016"></a>00016 <span class="preprocessor">#include <gbxutilacfr/status.h></span> <a name="l00017"></a>00017 <span class="preprocessor">#include <memory></span> <a name="l00018"></a>00018 <a name="l00019"></a>00019 <span class="keyword">namespace </span>gbxsickacfr { <a name="l00020"></a>00020 <a name="l00022"></a><a class="code" href="classgbxsickacfr_1_1Config.html">00022</a> <span class="keyword">class </span><a class="code" href="classgbxsickacfr_1_1Config.html" title="Configuration structure.">Config</a> <a name="l00023"></a>00023 { <a name="l00024"></a>00024 <span class="keyword">public</span>: <a name="l00025"></a>00025 <a class="code" href="classgbxsickacfr_1_1Config.html" title="Configuration structure.">Config</a>(); <a name="l00026"></a>00026 <span class="keywordtype">bool</span> isValid() <span class="keyword">const</span>; <a name="l00027"></a>00027 std::string toString() <span class="keyword">const</span>; <a name="l00028"></a>00028 <span class="keywordtype">bool</span> operator==( <span class="keyword">const</span> <a class="code" href="classgbxsickacfr_1_1Config.html" title="Configuration structure.">Config</a> & other ); <a name="l00029"></a>00029 <span class="keywordtype">bool</span> operator!=( <span class="keyword">const</span> <a class="code" href="classgbxsickacfr_1_1Config.html" title="Configuration structure.">Config</a> & other ); <a name="l00030"></a>00030 <a name="l00032"></a><a class="code" href="classgbxsickacfr_1_1Config.html#aeb914e240e36d2d53a14b6ea56cc458b">00032</a> std::string <a class="code" href="classgbxsickacfr_1_1Config.html#aeb914e240e36d2d53a14b6ea56cc458b" title="Serial device. e.g. &quot;/dev/ttyS0&quot;.">device</a>; <a name="l00034"></a><a class="code" href="classgbxsickacfr_1_1Config.html#a56d702ba0c2be101469437f6a688255e">00034</a> <span class="keywordtype">int</span> <a class="code" href="classgbxsickacfr_1_1Config.html#a56d702ba0c2be101469437f6a688255e" title="Baud rate.">baudRate</a>; <a name="l00036"></a><a class="code" href="classgbxsickacfr_1_1Config.html#a21ebc692a13f3a1883a35ffd811e4613">00036</a> <span class="keywordtype">double</span> <a class="code" href="classgbxsickacfr_1_1Config.html#a21ebc692a13f3a1883a35ffd811e4613" title="minimum range [m]">minRange</a>; <a name="l00038"></a><a class="code" href="classgbxsickacfr_1_1Config.html#a087bac092cc0360a118b75ca8eb79ed5">00038</a> <span class="keywordtype">double</span> <a class="code" href="classgbxsickacfr_1_1Config.html#a087bac092cc0360a118b75ca8eb79ed5" title="maximum range [m]">maxRange</a>; <a name="l00040"></a><a class="code" href="classgbxsickacfr_1_1Config.html#ad53c9d5bd44765c8d3ee372cbe852e23">00040</a> <span class="keywordtype">double</span> <a class="code" href="classgbxsickacfr_1_1Config.html#ad53c9d5bd44765c8d3ee372cbe852e23" title="field of viewe [rad]">fieldOfView</a>; <a name="l00042"></a><a class="code" href="classgbxsickacfr_1_1Config.html#a8f27f816dd6bc3204abf50b2a3d6b8d4">00042</a> <span class="keywordtype">double</span> <a class="code" href="classgbxsickacfr_1_1Config.html#a8f27f816dd6bc3204abf50b2a3d6b8d4" title="starting angle [rad]">startAngle</a>; <a name="l00044"></a><a class="code" href="classgbxsickacfr_1_1Config.html#a678e02360efbde1989e891a307c26be0">00044</a> <span class="keywordtype">int</span> <a class="code" href="classgbxsickacfr_1_1Config.html#a678e02360efbde1989e891a307c26be0" title="number of samples in a scan">numberOfSamples</a>; <a name="l00045"></a>00045 }; <a name="l00046"></a>00046 <a name="l00048"></a><a class="code" href="classgbxsickacfr_1_1Data.html">00048</a> <span class="keyword">class </span><a class="code" href="classgbxsickacfr_1_1Data.html" title="Data structure returned by read().">Data</a> <a name="l00049"></a>00049 { <a name="l00050"></a>00050 <span class="keyword">public</span>: <a name="l00051"></a>00051 <a class="code" href="classgbxsickacfr_1_1Data.html" title="Data structure returned by read().">Data</a>() <a name="l00052"></a>00052 : haveWarnings(<span class="keyword">false</span>) <a name="l00053"></a>00053 {} <a name="l00054"></a>00054 <a name="l00055"></a>00055 <span class="keywordtype">float</span> *ranges; <a name="l00056"></a>00056 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *intensities; <a name="l00057"></a>00057 <span class="keywordtype">int</span> timeStampSec; <a name="l00058"></a>00058 <span class="keywordtype">int</span> timeStampUsec; <a name="l00059"></a>00059 <span class="keywordtype">bool</span> haveWarnings; <a name="l00061"></a><a class="code" href="classgbxsickacfr_1_1Data.html#abf6d708fd91b701552b87a413950de67">00061</a> std::string <a class="code" href="classgbxsickacfr_1_1Data.html#abf6d708fd91b701552b87a413950de67" title="if &#39;haveWarnings&#39; is set, &#39;warnings&#39; will contain diagnostic information...">warnings</a>; <a name="l00062"></a>00062 }; <a name="l00063"></a>00063 <a name="l00065"></a><a class="code" href="classgbxsickacfr_1_1Driver.html">00065</a> <span class="keyword">class </span><a class="code" href="classgbxsickacfr_1_1Driver.html" title="SICK driver.">Driver</a> <a name="l00066"></a>00066 { <a name="l00067"></a>00067 <a name="l00068"></a>00068 <span class="keyword">public</span>: <a name="l00069"></a>00069 <a name="l00075"></a>00075 <a class="code" href="classgbxsickacfr_1_1Driver.html#a030b0d8c4dddef8e0ad546c187a7fb6f">Driver</a>( <span class="keyword">const</span> <a class="code" href="classgbxsickacfr_1_1Config.html" title="Configuration structure.">Config</a> &config, <a name="l00076"></a>00076 <a class="code" href="classgbxutilacfr_1_1Tracer.html" title="Local and remote tracing.">gbxutilacfr::Tracer</a> &tracer, <a name="l00077"></a>00077 <a class="code" href="classgbxutilacfr_1_1Status.html" title="Local interface to component status.">gbxutilacfr::Status</a> &status ); <a name="l00078"></a>00078 <a name="l00086"></a>00086 <span class="keywordtype">void</span> <a class="code" href="classgbxsickacfr_1_1Driver.html#a20ac4152fb833afa1a559dd719a4a299">read</a>( <a class="code" href="classgbxsickacfr_1_1Data.html" title="Data structure returned by read().">Data</a> &data ); <a name="l00087"></a>00087 <a name="l00088"></a>00088 <span class="keyword">private</span>: <a name="l00089"></a>00089 <a name="l00090"></a>00090 <span class="comment">// Waits up to maxWaitMs for a response of a particular type.</span> <a name="l00091"></a>00091 <span class="comment">// Returns true iff it got the response it wanted.</span> <a name="l00092"></a>00092 <span class="keywordtype">bool</span> waitForResponseType( uChar type, TimedLmsResponse &response, <span class="keywordtype">int</span> maxWaitMs ); <a name="l00093"></a>00093 <span class="comment">// Returns: true if ack or nack received.</span> <a name="l00094"></a>00094 <span class="comment">// (and sets receivedAck: true = ACK, false=NACK)</span> <a name="l00095"></a>00095 <span class="keywordtype">bool</span> waitForAckOrNack( <span class="keywordtype">bool</span> &receivedAck ); <a name="l00096"></a>00096 <a name="l00097"></a>00097 LmsResponse askLaserForStatusData(); <a name="l00098"></a>00098 LmsResponse askLaserForConfigData(); <a name="l00099"></a>00099 <a name="l00100"></a>00100 LmsConfigurationData desiredConfiguration(); <a name="l00101"></a>00101 <span class="keywordtype">bool</span> isAsDesired( <span class="keyword">const</span> LmsConfigurationData &lmsConfig ); <a name="l00102"></a>00102 <a name="l00103"></a>00103 <span class="keywordtype">int</span> guessLaserBaudRate(); <a name="l00104"></a>00104 <a name="l00105"></a>00105 <span class="comment">// Connects to the laser, sets params, and starts continuous mode.</span> <a name="l00106"></a>00106 <span class="keywordtype">void</span> initLaser(); <a name="l00107"></a>00107 <a name="l00108"></a>00108 TimedLmsResponse sendAndExpectResponse( <span class="keyword">const</span> std::vector<uChar> &commandAndData, <a name="l00109"></a>00109 <span class="keywordtype">bool</span> ignoreErrorConditions=<span class="keyword">false</span> ); <a name="l00110"></a>00110 <a name="l00111"></a>00111 std::string errorConditions(); <a name="l00112"></a>00112 <a name="l00113"></a>00113 uChar desiredMeasuredValueUnit(); <a name="l00114"></a>00114 uint16_t desiredAngularResolution(); <a name="l00115"></a>00115 <a name="l00116"></a>00116 <span class="keywordtype">void</span> setBaudRate( <span class="keywordtype">int</span> baudRate ); <a name="l00117"></a>00117 <a name="l00118"></a>00118 <a class="code" href="classgbxsickacfr_1_1Config.html" title="Configuration structure.">Config</a> config_; <a name="l00119"></a>00119 <a name="l00120"></a>00120 std::auto_ptr<SerialHandler> serialHandler_; <a name="l00121"></a>00121 <a name="l00122"></a>00122 std::vector<uChar> commandAndData_; <a name="l00123"></a>00123 std::vector<uChar> telegramBuffer_; <a name="l00124"></a>00124 <a name="l00125"></a>00125 <a class="code" href="classgbxutilacfr_1_1Tracer.html" title="Local and remote tracing.">gbxutilacfr::Tracer</a>& tracer_; <a name="l00126"></a>00126 <a class="code" href="classgbxutilacfr_1_1Status.html" title="Local interface to component status.">gbxutilacfr::Status</a>& status_; <a name="l00127"></a>00127 }; <a name="l00128"></a>00128 <a name="l00129"></a>00129 } <span class="comment">// namespace</span> <a name="l00130"></a>00130 <a name="l00131"></a>00131 <span class="preprocessor">#endif</span> </pre></div></div> </td> <td colspan="1"> </td> </tr> </table> <!-- end of table --> <hr size="1"><address style="align: right;"><small>Generated for GearBox by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.5 </small></address> </body> </html>