<p>Actually, there are a million reasons for which it shouldn’t work. If it gives strange results, try the following:</p>
<ol>
<li>
<p>Plot the data! Plot the input and plot the output using <code>log2pdf</code>.</p>
</li>
<li>
<p>Plot the animation! Use the procedure above and inspect the resulting videos.</p>
</li>
<li>
<p>Double-check the parameters you are using. Note that there are some like <code>max_correspondence_dist</code> which depend on the scale of your data. A value of 2m might work for a big robot making large movements, but not for a little Khepera.</p>
</li>
<li>
<p>Smooth your data – if your sensor is very noisy, like an Hokuyo, it’s worth to do simple low-pass filtering. Especially for PLICP which uses the orientation information.</p>
</li>
</ol>
<h2id='embedding_csm_in_your_programs'><spanclass='maruku_section_number'>7. </span>Embedding CSM in your programs</h2>
<h3id='linking_to_csm'><spanclass='maruku_section_number'>7.1. </span>Linking to CSM</h3>
<p>When CSM is installed, a <ahref='http://pkg-config.freedesktop.org/wiki/'>pkgconfig</a><code>csm.pc</code> file is installed as well. This makes it easy to link to CSM.</p>
<p>For example, on my system, after installing CSM, I can run <code>pkgconfig</code> to get the C preprocessors and linker flags.</p>
<p>This is what I get on my system (on yours, paths will be different, of course).</p>
<p>You can download the sources for this example in the repository (directory <code>docs/example-linking-make</code>).</p>
<p>If you use <ahref='http://www.cmake.org/'>CMake</a>— and you should! — it is reccomended that you use something like the following in your <code>CMakeLists.txt</code>.</p>
<p>You can download the sources for this example in the repository (directory <code>docs/example-linking-cmake</code>).</p>
<h3id='accessing_csm_functions_from_your_applications'><spanclass='maruku_section_number'>7.2. </span>Accessing CSM functions from your applications</h3>
<p>All functions that you would be interested in using are accessible by including one header:</p>
<p>If you are linking from C++, as opposed to C, all functions are enclosed in the <code>CSM</code> namespace. Therefore, you need something like the following.</p>
<pre><code>#include <csm/csm_all.h>
using namespace CSM;</code></pre>
<h3id='orienting_oneself_in_the_source_code'><spanclass='maruku_section_number'>7.3. </span>Orienting oneself in the source code</h3>
<p>The main function to call is the following:</p>
<p>This implements matching between two laser scans. All the applications discussed above (<code>sm1</code>, <code>sm2</code>, etc.) are essentially wrapper of <code>sm_icp</code>: they fill in the <code>params</code> structure, and read from the <code>result</code> structure.</p>
<p>The <code>sm_params</code> structure is described in the <code><csm/algos.h></code> header file. It contains parameters for both ICP and other algorithms (like HSM; however, only (PL)ICP is considered stable in CSM)</p>
<p>Note that many of the parameters greatly influence the behavior of PLICP, so it is worth reading them all. If you run <code>sm2 -help</code> you will see the default values, which are reasonable as a starting point.</p>
<p>We now briefly discuss the main parameters.</p>
<ul>
<li><code>params->laser_ref</code>: pointer of a structure of type <code>laser_data</code> (described before in this document) representing the “ref”erence scan (first scan).</li>
<li><code>params->laser_sens</code>: pointer of a structure of type <code>laser_data</code> representing the second scan.</li>
<li><code>params->first_guess</code>: first guess (x,y,theta).</li>
</ul>
<p>Parameters that influence stopping:</p>
<ul>
<li><code>max_iterations</code>: maximum number of iterations</li>
<li><code>epsilon_xy</code>, <code>epsilon_theta</code>: stop if change below these thresholds</li>