| 1 | |
|---|
| 2 | <!DOCTYPE html |
|---|
| 3 | PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
|---|
| 4 | <html><head> |
|---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
|---|
| 6 | <!-- |
|---|
| 7 | This HTML is auto-generated from an M-file. |
|---|
| 8 | To make changes, update the M-file and republish this document. |
|---|
| 9 | --><title>CalibrateCompass</title><meta name="generator" content="MATLAB 7.9"><meta name="date" content="2009-10-07"><meta name="m-file" content="script_CalibrateCompass"> |
|---|
| 10 | <link type="text/css" rel="stylesheet" href="../../style.css"> |
|---|
| 11 | </head><body><div class="content"><h1>CalibrateCompass</h1><!--introduction--><p>Enables calibration mode of the HiTechnic compass sensor</p><!--/introduction--><h2>Contents</h2><div><ul><li><a href="#2">Syntax</a></li><li><a href="#5">Description</a></li><li><a href="#10">Example</a></li><li><a href="#14">See also</a></li><li><a href="#16">Signature</a></li></ul></div><h2>Syntax<a name="2"></a></h2><p><tt>CalibrateCompass(port, f_start)</tt></p><p><tt>CalibrateCompass(port, f_start, handle)</tt></p><h2>Description<a name="5"></a></h2><p>Calibrate the compass to reduce influence of metallic objects, especially of the NXT motor and brick on compass values. You have to calibrate a roboter only once until the design changes. During calibration the compass should make two full rotations very slowly. The compass sensor has to be opened (using <tt>OpenCompass</tt>) before execution.</p><p>Set <tt>f_start = true</tt> to start calibration mode, and <tt>f_start = false</tt> to stop it. In between those commands, the calibration (compass rotation) should occur.</p><p>The given <tt>port</tt> number specifies the connection port. The value <tt>port</tt> can be addressed by the symbolic constants <tt>SENSOR_1</tt> , <tt>SENSOR_2</tt>, <tt>SENSOR_3</tt> and <tt>SENSOR_4</tt> analog to the labeling on the NXT Brick.</p><p>The last optional argument can be a valid NXT handle. If none is specified, the default handle will be used (call <tt>COM_SetDefaultNXT</tt> to set one).</p><h2>Example<a name="10"></a></h2><pre class="codeinput"> <span class="comment">% compass must be open for calibration</span> |
|---|
| 12 | OpenCompass(SENSOR_2); |
|---|
| 13 | |
|---|
| 14 | <span class="comment">% enable calibration mode</span> |
|---|
| 15 | CalibrateCompass(SENSOR_2, true); |
|---|
| 16 | |
|---|
| 17 | <span class="comment">% compass is attached to motor A, rotate 2 full turns</span> |
|---|
| 18 | m = NXTMotor(<span class="string">'A'</span>, <span class="string">'Power'</span>, 5, <span class="string">'TachoLimit'</span>, 720) |
|---|
| 19 | m.SendToNXT(); |
|---|
| 20 | |
|---|
| 21 | m.WaitFor(); |
|---|
| 22 | |
|---|
| 23 | <span class="comment">% calibration should now be complete!</span> |
|---|
| 24 | CalibrateCompass(SENSOR_2, false); |
|---|
| 25 | </pre><h2>See also<a name="14"></a></h2><p>OpenCompass, GetCompass, CloseSensor, NXT_LSRead, NXT_LSWrite</p><h2>Signature<a name="16"></a></h2><div><ul><li><b>Author:</b> Rainer Schnitzler, Linus Atorf (see AUTHORS)</li><li><b>Date:</b> 2008/08/01</li><li><b>Copyright:</b> 2007-2009, RWTH Aachen University</li></ul></div><p class="footer"><br> |
|---|
| 26 | </p></div><!-- |
|---|
| 27 | ##### SOURCE BEGIN ##### |
|---|
| 28 | %% CalibrateCompass |
|---|
| 29 | % Enables calibration mode of the HiTechnic compass sensor |
|---|
| 30 | %% |
|---|
| 31 | %% Syntax |
|---|
| 32 | % |CalibrateCompass(port, f_start)| |
|---|
| 33 | %% |
|---|
| 34 | % |CalibrateCompass(port, f_start, handle)| |
|---|
| 35 | %% |
|---|
| 36 | %% Description |
|---|
| 37 | % Calibrate the compass to reduce influence of metallic objects, |
|---|
| 38 | % especially of the NXT motor and brick on compass values. |
|---|
| 39 | % You have to calibrate a roboter only once until the design changes. |
|---|
| 40 | % During calibration the compass should make two full rotations very slowly. |
|---|
| 41 | % The compass sensor has to be opened (using |OpenCompass|) before execution. |
|---|
| 42 | %% |
|---|
| 43 | % Set |f_start = true| to start calibration mode, and |f_start = false| to stop it. |
|---|
| 44 | % In between those commands, the calibration (compass rotation) should occur. |
|---|
| 45 | %% |
|---|
| 46 | % The given |port| number specifies the connection port. The value |port| can be |
|---|
| 47 | % addressed by the symbolic constants |SENSOR_1| , |SENSOR_2|, |SENSOR_3| and |SENSOR_4| |
|---|
| 48 | % analog to the labeling on the NXT Brick. |
|---|
| 49 | %% |
|---|
| 50 | % The last optional argument can be a valid NXT handle. If none is |
|---|
| 51 | % specified, the default handle will be used (call |COM_SetDefaultNXT| to |
|---|
| 52 | % set one). |
|---|
| 53 | %% |
|---|
| 54 | %% Example |
|---|
| 55 | %% |
|---|
| 56 | %% |
|---|
| 57 | % compass must be open for calibration |
|---|
| 58 | OpenCompass(SENSOR_2); |
|---|
| 59 | |
|---|
| 60 | % enable calibration mode |
|---|
| 61 | CalibrateCompass(SENSOR_2, true); |
|---|
| 62 | |
|---|
| 63 | % compass is attached to motor A, rotate 2 full turns |
|---|
| 64 | m = NXTMotor('A', 'Power', 5, 'TachoLimit', 720) |
|---|
| 65 | m.SendToNXT(); |
|---|
| 66 | |
|---|
| 67 | m.WaitFor(); |
|---|
| 68 | |
|---|
| 69 | % calibration should now be complete! |
|---|
| 70 | CalibrateCompass(SENSOR_2, false); |
|---|
| 71 | %% |
|---|
| 72 | %% See also |
|---|
| 73 | % OpenCompass, GetCompass, CloseSensor, NXT_LSRead, NXT_LSWrite |
|---|
| 74 | %% |
|---|
| 75 | %% Signature |
|---|
| 76 | %% |
|---|
| 77 | % * *Author:* Rainer Schnitzler, Linus Atorf (see AUTHORS) |
|---|
| 78 | % * *Date:* 2008/08/01 |
|---|
| 79 | % * *Copyright:* 2007-2009, RWTH Aachen University |
|---|
| 80 | % |
|---|
| 81 | |
|---|
| 82 | ##### SOURCE END ##### |
|---|
| 83 | --></body></html> |
|---|