using_mount_classes.html
14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>User guide to program with mount Python classes — Mount Control Software 1.0.0 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/classic.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css" />
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="User guide to program with celme Python classes" href="using_celme_classes.html" />
<link rel="prev" title="Communication protocols for astromecca mounts" href="communication_langage_protocol.html" />
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="using_celme_classes.html" title="User guide to program with celme Python classes"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="communication_langage_protocol.html" title="Communication protocols for astromecca mounts"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">Mount Control Software 1.0.0 documentation</a> »</li>
<li class="nav-item nav-item-this"><a href="">User guide to program with mount Python classes</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="user-guide-to-program-with-mount-python-classes">
<h1>User guide to program with mount Python classes<a class="headerlink" href="#user-guide-to-program-with-mount-python-classes" title="Permalink to this headline">¶</a></h1>
<p>This section show how to use Mount classes in a Python code.</p>
<div class="section" id="classes-and-attributes">
<h2>1. Classes and attributes<a class="headerlink" href="#classes-and-attributes" title="Permalink to this headline">¶</a></h2>
<img alt="_images/classes_mount.png" src="_images/classes_mount.png" />
<p>The mountastro module provides the class Mountastro
which contains almost all the methods to drive mounts.
Mountastro provides methods only for simulations
but all these methods call also an abstract method
for real mounts. The abstracts methods are concreted
in a dedicated class. For example, for AstroMECCA mounts
the class Mountastro_Astromecca inherits the Mountastro
methods and provides concrete methods.</p>
</div>
<div class="section" id="examples-of-python-codes-to-instanciate-the-mount">
<h2>2. Examples of Python codes to instanciate the mount<a class="headerlink" href="#examples-of-python-codes-to-instanciate-the-mount" title="Permalink to this headline">¶</a></h2>
<p>To include the mount classes in a python program, one must import
the desired classes:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">celme</span>
<span class="kn">import</span> <span class="nn">mountastro_astromecca</span>
</pre></div>
</div>
<p>Define the site where the telescope is installed:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">home</span> <span class="o">=</span> <span class="n">celme</span><span class="o">.</span><span class="n">Home</span><span class="p">(</span><span class="s2">"GPS 2.0375 E 43.6443484725 136.9"</span><span class="p">)</span>
<span class="n">site</span> <span class="o">=</span> <span class="n">celme</span><span class="o">.</span><span class="n">Site</span><span class="p">(</span><span class="n">home</span><span class="p">)</span>
</pre></div>
</div>
<p>The home geographic coordinates must be adjusted to the location of the mount.
Instanciate the class Mountastro_Astromecca:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mount1</span> <span class="o">=</span> <span class="n">mountastro</span><span class="o">.</span><span class="n">Mountastro_Astromecca</span><span class="p">(</span><span class="s2">"HADEC"</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s2">"My Mount"</span><span class="p">,</span> <span class="n">manufacturer</span><span class="o">=</span><span class="s2">"AstroMECCA"</span><span class="p">,</span> <span class="n">model</span><span class="o">=</span><span class="s2">"TM350"</span><span class="p">,</span> <span class="n">serial_number</span><span class="o">=</span><span class="s2">"beta001"</span><span class="p">,</span> <span class="n">site</span><span class="o">=</span><span class="n">site</span><span class="p">,</span> <span class="n">CONTROLLER_BASE_ID</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">CONTROLLER_POLAR_ID</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
</pre></div>
</div>
<p>HADEC stands for the fact the axes of the mount are oriented according an equatorial mount.
The protocol to communicate with the controller used for AstroMECCA mounts must be configured.
The following lines show how to get available list of serial ports and configre it:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">tools</span> <span class="o">=</span> <span class="n">mountastro</span><span class="o">.</span><span class="n">Mounttools</span><span class="p">()</span>
<span class="n">available_serial_ports</span> <span class="o">=</span> <span class="n">tools</span><span class="o">.</span><span class="n">get_available_serial_ports</span><span class="p">()</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"Avaible serial ports </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">available_serial_ports</span><span class="p">))</span>
<span class="n">port</span> <span class="o">=</span> <span class="s2">"/dev/ttySC0"</span>
<span class="n">mount1</span><span class="o">.</span><span class="n">set_channel_params</span><span class="p">(</span><span class="s2">"SERIAL"</span><span class="p">,</span> <span class="n">port</span><span class="o">=</span><span class="n">port</span><span class="p">,</span> <span class="n">baud_rate</span><span class="o">=</span><span class="mi">115200</span><span class="p">,</span> <span class="n">delay_init_chan</span><span class="o">=</span><span class="mf">0.1</span><span class="p">,</span> <span class="n">end_of_command_to_send</span><span class="o">=</span><span class="s2">"</span><span class="se">\r\n</span><span class="s2">"</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s1">'utf8'</span><span class="p">),</span> <span class="n">end_of_command_to_receive</span><span class="o">=</span><span class="s2">"</span><span class="se">\r\n</span><span class="s2">"</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s1">'utf8'</span><span class="p">),</span> <span class="n">delay_put_read</span><span class="o">=</span><span class="mf">0.06</span><span class="p">)</span>
</pre></div>
</div>
<p>The port key must be available in the list of serial ports.</p>
</div>
<div class="section" id="examples-of-python-codes-to-drive-the-mount">
<h2>3. Examples of Python codes to drive the mount<a class="headerlink" href="#examples-of-python-codes-to-drive-the-mount" title="Permalink to this headline">¶</a></h2>
<p>Prerequisite is to have instanciated an object (mount1)
as explained in the previous section.</p>
<p>To get current coordinates of the mount:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ra</span><span class="p">,</span> <span class="n">dec</span><span class="p">,</span> <span class="n">side</span> <span class="o">=</span> <span class="n">mount1</span><span class="o">.</span><span class="n">radec_coord</span><span class="p">()</span>
</pre></div>
</div>
<p>The side is where the tube lies. Side can be 1 or -1.
If side = 1 the tube is in regular position.
If side = -1 the tube is in fliped position.</p>
<p>To slew the mount to a target defined by J2000 astronomical coordinates:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mount1</span><span class="o">.</span><span class="n">radec_goto</span><span class="p">(</span><span class="s2">"3h5m56.45s"</span><span class="p">,</span><span class="s2">"+3d51m34.1s"</span><span class="p">)</span>
</pre></div>
</div>
<p>The methods radec_coord and radec_goto, it is possible to
add options as equinox or output formats.</p>
<p>Example of options to get coordinates at the equinox of the date
and outputs in decimal degrees:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ra</span><span class="p">,</span> <span class="n">dec</span><span class="p">,</span> <span class="n">side</span> <span class="o">=</span> <span class="n">mount1</span><span class="o">.</span><span class="n">radec_coord</span><span class="p">(</span><span class="s2">"deg"</span><span class="p">,</span> <span class="s2">"deg"</span><span class="p">,</span> <span class="n">equinox</span><span class="o">=</span><span class="s2">"NOW"</span><span class="p">)</span>
</pre></div>
</div>
<p>To start a move on declination axis at the rate of 2 deg/sec:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mount1</span><span class="o">.</span><span class="n">hadec_move</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
</pre></div>
</div>
<p>To stop a move motion:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mount1</span><span class="o">.</span><span class="n">hadec_move_stop</span><span class="p">()</span>
</pre></div>
</div>
<p>To stop a any motion:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mount1</span><span class="o">.</span><span class="n">hadec_stop</span><span class="p">()</span>
</pre></div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">User guide to program with mount Python classes</a><ul>
<li><a class="reference internal" href="#classes-and-attributes">1. Classes and attributes</a></li>
<li><a class="reference internal" href="#examples-of-python-codes-to-instanciate-the-mount">2. Examples of Python codes to instanciate the mount</a></li>
<li><a class="reference internal" href="#examples-of-python-codes-to-drive-the-mount">3. Examples of Python codes to drive the mount</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="communication_langage_protocol.html"
title="previous chapter">Communication protocols for astromecca mounts</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="using_celme_classes.html"
title="next chapter">User guide to program with celme Python classes</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/using_mount_classes.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="using_celme_classes.html" title="User guide to program with celme Python classes"
>next</a> |</li>
<li class="right" >
<a href="communication_langage_protocol.html" title="Communication protocols for astromecca mounts"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">Mount Control Software 1.0.0 documentation</a> »</li>
<li class="nav-item nav-item-this"><a href="">User guide to program with mount Python classes</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2021, astromecca.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.4.0.
</div>
</body>
</html>