Revision b1f38b27

View differences:

.gitignore
1
build
2
.dep
3
*.tmp
4
*.backup
5

  
6
# Eclipse files
7
*eclipse*
8

  
9
# QtCreator files
10
*.includes
11
*.files
12
*.config
13
*.creator
14
*.creator.user
15

  
16
# Shadow files
17
*kate-swp
18
*~
19

  
20
# Backup files
21
*backup*
22
*Backup*
.gitmodules
1
[submodule "os/AMiRo-OS"]
2
	path = os/AMiRo-OS
3
	url = http://openresearch.cit-ec.de/git/amiro-os.amiro-os.git
4
[submodule "middleware/uRtWare"]
5
	path = middleware/uRtWare
6
	url = http://openresearch.cit-ec.de/git/amiro-os.urtware.git
README.txt
1
AMiRo-Apps is a collection of applications and configurations for the Autonomous
2
Mini Robot (AMiRo) [1]. It is tightly coupled to the AMiRo-OS and uRtWare
3
projects, which provide a sophisticated operating system (based on ChibiOS) amd
4
a real-time middleware for embedded devices.
5

  
6
Copyright (C) 2018..2018  Thomas Schöpping et al.
7
(a complete list of all authors is given below)
8

  
9
This program is free software: you can redistribute it and/or modify
10
it under the terms of the GNU General Public License as published by
11
the Free Software Foundation, either version 3 of the License, or (at
12
your option) any later version.
13

  
14
This program is distributed in the hope that it will be useful, but
15
WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
General Public License for more details.
18

  
19
You should have received a copy of the GNU General Public License
20
along with this program.  If not, see <http://www.gnu.org/licenses/>.
21

  
22
This research/work was supported by the Cluster of Excellence
23
Cognitive Interaction Technology 'CITEC' (EXC 277) at Bielefeld
24
University, which is funded by the German Research Foundation (DFG).
25

  
26
Authors:
27
 - Thomas Schöpping          <tschoepp[at]cit-ec.uni-bielefeld.de>
28
 - Marc Rothmann
29

  
30
References:
31
 [1] S. Herbrechtsmeier, T. Korthals, T. Schopping and U. Rückert, "AMiRo: A
32
     modular & customizable open-source mini robot platform," 2016 20th
33
     International Conference on System Theory, Control and Computing (ICSTCC),
34
     Sinaia, 2016, pp. 687-692.
35

  
36

  
37

  
38
################################################################################
39
#                                                                              #
40
#        RRRRRRRR   EEEEEEEE     AAA     DDDDDDDD   MM     MM  EEEEEEEE        #
41
#        RR     RR  EE          AA AA    DD     DD  MMM   MMM  EE              #
42
#        RR     RR  EE         AA   AA   DD     DD  MMMM MMMM  EE              #
43
#        RRRRRRRR   EEEEEE    AA     AA  DD     DD  MM MMM MM  EEEEEE          #
44
#        RR   RR    EE        AAAAAAAAA  DD     DD  MM     MM  EE              #
45
#        RR    RR   EE        AA     AA  DD     DD  MM     MM  EE              #
46
#        RR     RR  EEEEEEEE  AA     AA  DDDDDDDD   MM     MM  EEEEEEEE        #
47
#                                                                              #
48
################################################################################
49

  
50
This file will help you to setup all required software on your system, compile
51
the source code, and flash it to the AMiRo modules.
52

  
53
================================================================================
54

  
55
CONTENTS:
56

  
57
  1  Required software
58
  3  Building and flashing
59

  
60
================================================================================
61

  
62

  
63

  
64
1 - REQUIRED SOFTWARE
65
---------------------
66

  
67
Since AMiRo-Apps depends on the AMiRo-OS and uRtWare projects, both are included
68
as Git submodules. Use the provided ./setup.sh script to initialize those. When
69
AMiRo-OS is fully configured, there is no additional software required by
70
AMiRo-Apps. For further details about the initialization follow the instructions
71
in the script and refer to the README.txt file of AMiRo-OS and uRtWare
72
respectively.
73

  
74

  
75

  
76
2 - BUILDING AND FLASHING
77
-------------------------
78

  
79
For building and flashing a specific setup, you must first define a
80
configuration in the ./configurations folder (e.g. ./configurations/MyConf).
81
Such a configuration must consist of a Makefile and a C header file with the
82
name "osconf.h". Please copy the provided template files from the
83
./configurations/template directory and modify them as required in order to
84
minimize the risk of errors and for the sake of consistency. As a result you can
85
build and flash all software using the Makefile.
86

  
87
================================================================================
88

  
license.html
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
<!-- saved from url=(0051)http://www.gnu.org/licenses/gpl-3.0-standalone.html -->
3
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4
 
5
 <title>GNU General Public License v3.0 - GNU Project - Free Software Foundation (FSF)</title>
6
 <link rel="alternate" type="application/rdf+xml" href="http://www.gnu.org/licenses/gpl-3.0.rdf"> 
7
</head>
8
<body>
9

  
10
<h3 style="text-align: center;">GNU GENERAL PUBLIC LICENSE</h3>
11
<p style="text-align: center;">Version 3, 29 June 2007</p>
12

  
13
<p>Copyright © 2007 Free Software Foundation, Inc.
14
 &lt;<a href="http://fsf.org/">http://fsf.org/</a>&gt;</p><p>
15
 Everyone is permitted to copy and distribute verbatim copies
16
 of this license document, but changing it is not allowed.</p>
17

  
18
<h3><a name="preamble"></a>Preamble</h3>
19

  
20
<p>The GNU General Public License is a free, copyleft license for
21
software and other kinds of works.</p>
22

  
23
<p>The licenses for most software and other practical works are designed
24
to take away your freedom to share and change the works.  By contrast,
25
the GNU General Public License is intended to guarantee your freedom to
26
share and change all versions of a program--to make sure it remains free
27
software for all its users.  We, the Free Software Foundation, use the
28
GNU General Public License for most of our software; it applies also to
29
any other work released this way by its authors.  You can apply it to
30
your programs, too.</p>
31

  
32
<p>When we speak of free software, we are referring to freedom, not
33
price.  Our General Public Licenses are designed to make sure that you
34
have the freedom to distribute copies of free software (and charge for
35
them if you wish), that you receive source code or can get it if you
36
want it, that you can change the software or use pieces of it in new
37
free programs, and that you know you can do these things.</p>
38

  
39
<p>To protect your rights, we need to prevent others from denying you
40
these rights or asking you to surrender the rights.  Therefore, you have
41
certain responsibilities if you distribute copies of the software, or if
42
you modify it: responsibilities to respect the freedom of others.</p>
43

  
44
<p>For example, if you distribute copies of such a program, whether
45
gratis or for a fee, you must pass on to the recipients the same
46
freedoms that you received.  You must make sure that they, too, receive
47
or can get the source code.  And you must show them these terms so they
48
know their rights.</p>
49

  
50
<p>Developers that use the GNU GPL protect your rights with two steps:
51
(1) assert copyright on the software, and (2) offer you this License
52
giving you legal permission to copy, distribute and/or modify it.</p>
53

  
54
<p>For the developers' and authors' protection, the GPL clearly explains
55
that there is no warranty for this free software.  For both users' and
56
authors' sake, the GPL requires that modified versions be marked as
57
changed, so that their problems will not be attributed erroneously to
58
authors of previous versions.</p>
59

  
60
<p>Some devices are designed to deny users access to install or run
61
modified versions of the software inside them, although the manufacturer
62
can do so.  This is fundamentally incompatible with the aim of
63
protecting users' freedom to change the software.  The systematic
64
pattern of such abuse occurs in the area of products for individuals to
65
use, which is precisely where it is most unacceptable.  Therefore, we
66
have designed this version of the GPL to prohibit the practice for those
67
products.  If such problems arise substantially in other domains, we
68
stand ready to extend this provision to those domains in future versions
69
of the GPL, as needed to protect the freedom of users.</p>
70

  
71
<p>Finally, every program is threatened constantly by software patents.
72
States should not allow patents to restrict development and use of
73
software on general-purpose computers, but in those that do, we wish to
74
avoid the special danger that patents applied to a free program could
75
make it effectively proprietary.  To prevent this, the GPL assures that
76
patents cannot be used to render the program non-free.</p>
77

  
78
<p>The precise terms and conditions for copying, distribution and
79
modification follow.</p>
80

  
81
<h3><a name="terms"></a>TERMS AND CONDITIONS</h3>
82

  
83
<h4><a name="section0"></a>0. Definitions.</h4>
84

  
85
<p>“This License” refers to version 3 of the GNU General Public License.</p>
86

  
87
<p>“Copyright” also means copyright-like laws that apply to other kinds of
88
works, such as semiconductor masks.</p>
89
 
90
<p>“The Program” refers to any copyrightable work licensed under this
91
License.  Each licensee is addressed as “you”.  “Licensees” and
92
“recipients” may be individuals or organizations.</p>
93

  
94
<p>To “modify” a work means to copy from or adapt all or part of the work
95
in a fashion requiring copyright permission, other than the making of an
96
exact copy.  The resulting work is called a “modified version” of the
97
earlier work or a work “based on” the earlier work.</p>
98

  
99
<p>A “covered work” means either the unmodified Program or a work based
100
on the Program.</p>
101

  
102
<p>To “propagate” a work means to do anything with it that, without
103
permission, would make you directly or secondarily liable for
104
infringement under applicable copyright law, except executing it on a
105
computer or modifying a private copy.  Propagation includes copying,
106
distribution (with or without modification), making available to the
107
public, and in some countries other activities as well.</p>
108

  
109
<p>To “convey” a work means any kind of propagation that enables other
110
parties to make or receive copies.  Mere interaction with a user through
111
a computer network, with no transfer of a copy, is not conveying.</p>
112

  
113
<p>An interactive user interface displays “Appropriate Legal Notices”
114
to the extent that it includes a convenient and prominently visible
115
feature that (1) displays an appropriate copyright notice, and (2)
116
tells the user that there is no warranty for the work (except to the
117
extent that warranties are provided), that licensees may convey the
118
work under this License, and how to view a copy of this License.  If
119
the interface presents a list of user commands or options, such as a
120
menu, a prominent item in the list meets this criterion.</p>
121

  
122
<h4><a name="section1"></a>1. Source Code.</h4>
123

  
124
<p>The “source code” for a work means the preferred form of the work
125
for making modifications to it.  “Object code” means any non-source
126
form of a work.</p>
127

  
128
<p>A “Standard Interface” means an interface that either is an official
129
standard defined by a recognized standards body, or, in the case of
130
interfaces specified for a particular programming language, one that
131
is widely used among developers working in that language.</p>
132

  
133
<p>The “System Libraries” of an executable work include anything, other
134
than the work as a whole, that (a) is included in the normal form of
135
packaging a Major Component, but which is not part of that Major
136
Component, and (b) serves only to enable use of the work with that
137
Major Component, or to implement a Standard Interface for which an
138
implementation is available to the public in source code form.  A
139
“Major Component”, in this context, means a major essential component
140
(kernel, window system, and so on) of the specific operating system
141
(if any) on which the executable work runs, or a compiler used to
142
produce the work, or an object code interpreter used to run it.</p>
143

  
144
<p>The “Corresponding Source” for a work in object code form means all
145
the source code needed to generate, install, and (for an executable
146
work) run the object code and to modify the work, including scripts to
147
control those activities.  However, it does not include the work's
148
System Libraries, or general-purpose tools or generally available free
149
programs which are used unmodified in performing those activities but
150
which are not part of the work.  For example, Corresponding Source
151
includes interface definition files associated with source files for
152
the work, and the source code for shared libraries and dynamically
153
linked subprograms that the work is specifically designed to require,
154
such as by intimate data communication or control flow between those
155
subprograms and other parts of the work.</p>
156

  
157
<p>The Corresponding Source need not include anything that users
158
can regenerate automatically from other parts of the Corresponding
159
Source.</p>
160

  
161
<p>The Corresponding Source for a work in source code form is that
162
same work.</p>
163

  
164
<h4><a name="section2"></a>2. Basic Permissions.</h4>
165

  
166
<p>All rights granted under this License are granted for the term of
167
copyright on the Program, and are irrevocable provided the stated
168
conditions are met.  This License explicitly affirms your unlimited
169
permission to run the unmodified Program.  The output from running a
170
covered work is covered by this License only if the output, given its
171
content, constitutes a covered work.  This License acknowledges your
172
rights of fair use or other equivalent, as provided by copyright law.</p>
173

  
174
<p>You may make, run and propagate covered works that you do not
175
convey, without conditions so long as your license otherwise remains
176
in force.  You may convey covered works to others for the sole purpose
177
of having them make modifications exclusively for you, or provide you
178
with facilities for running those works, provided that you comply with
179
the terms of this License in conveying all material for which you do
180
not control copyright.  Those thus making or running the covered works
181
for you must do so exclusively on your behalf, under your direction
182
and control, on terms that prohibit them from making any copies of
183
your copyrighted material outside their relationship with you.</p>
184

  
185
<p>Conveying under any other circumstances is permitted solely under
186
the conditions stated below.  Sublicensing is not allowed; section 10
187
makes it unnecessary.</p>
188

  
189
<h4><a name="section3"></a>3. Protecting Users' Legal Rights From Anti-Circumvention Law.</h4>
190

  
191
<p>No covered work shall be deemed part of an effective technological
192
measure under any applicable law fulfilling obligations under article
193
11 of the WIPO copyright treaty adopted on 20 December 1996, or
194
similar laws prohibiting or restricting circumvention of such
195
measures.</p>
196

  
197
<p>When you convey a covered work, you waive any legal power to forbid
198
circumvention of technological measures to the extent such circumvention
199
is effected by exercising rights under this License with respect to
200
the covered work, and you disclaim any intention to limit operation or
201
modification of the work as a means of enforcing, against the work's
202
users, your or third parties' legal rights to forbid circumvention of
203
technological measures.</p>
204

  
205
<h4><a name="section4"></a>4. Conveying Verbatim Copies.</h4>
206

  
207
<p>You may convey verbatim copies of the Program's source code as you
208
receive it, in any medium, provided that you conspicuously and
209
appropriately publish on each copy an appropriate copyright notice;
210
keep intact all notices stating that this License and any
211
non-permissive terms added in accord with section 7 apply to the code;
212
keep intact all notices of the absence of any warranty; and give all
213
recipients a copy of this License along with the Program.</p>
214

  
215
<p>You may charge any price or no price for each copy that you convey,
216
and you may offer support or warranty protection for a fee.</p>
217

  
218
<h4><a name="section5"></a>5. Conveying Modified Source Versions.</h4>
219

  
220
<p>You may convey a work based on the Program, or the modifications to
221
produce it from the Program, in the form of source code under the
222
terms of section 4, provided that you also meet all of these conditions:</p>
223

  
224
<ul>
225
<li>a) The work must carry prominent notices stating that you modified
226
    it, and giving a relevant date.</li>
227

  
228
<li>b) The work must carry prominent notices stating that it is
229
    released under this License and any conditions added under section
230
    7.  This requirement modifies the requirement in section 4 to
231
    “keep intact all notices”.</li>
232

  
233
<li>c) You must license the entire work, as a whole, under this
234
    License to anyone who comes into possession of a copy.  This
235
    License will therefore apply, along with any applicable section 7
236
    additional terms, to the whole of the work, and all its parts,
237
    regardless of how they are packaged.  This License gives no
238
    permission to license the work in any other way, but it does not
239
    invalidate such permission if you have separately received it.</li>
240

  
241
<li>d) If the work has interactive user interfaces, each must display
242
    Appropriate Legal Notices; however, if the Program has interactive
243
    interfaces that do not display Appropriate Legal Notices, your
244
    work need not make them do so.</li>
245
</ul>
246

  
247
<p>A compilation of a covered work with other separate and independent
248
works, which are not by their nature extensions of the covered work,
249
and which are not combined with it such as to form a larger program,
250
in or on a volume of a storage or distribution medium, is called an
251
“aggregate” if the compilation and its resulting copyright are not
252
used to limit the access or legal rights of the compilation's users
253
beyond what the individual works permit.  Inclusion of a covered work
254
in an aggregate does not cause this License to apply to the other
255
parts of the aggregate.</p>
256

  
257
<h4><a name="section6"></a>6. Conveying Non-Source Forms.</h4>
258

  
259
<p>You may convey a covered work in object code form under the terms
260
of sections 4 and 5, provided that you also convey the
261
machine-readable Corresponding Source under the terms of this License,
262
in one of these ways:</p>
263

  
264
<ul>
265
<li>a) Convey the object code in, or embodied in, a physical product
266
    (including a physical distribution medium), accompanied by the
267
    Corresponding Source fixed on a durable physical medium
268
    customarily used for software interchange.</li>
269

  
270
<li>b) Convey the object code in, or embodied in, a physical product
271
    (including a physical distribution medium), accompanied by a
272
    written offer, valid for at least three years and valid for as
273
    long as you offer spare parts or customer support for that product
274
    model, to give anyone who possesses the object code either (1) a
275
    copy of the Corresponding Source for all the software in the
276
    product that is covered by this License, on a durable physical
277
    medium customarily used for software interchange, for a price no
278
    more than your reasonable cost of physically performing this
279
    conveying of source, or (2) access to copy the
280
    Corresponding Source from a network server at no charge.</li>
281

  
282
<li>c) Convey individual copies of the object code with a copy of the
283
    written offer to provide the Corresponding Source.  This
284
    alternative is allowed only occasionally and noncommercially, and
285
    only if you received the object code with such an offer, in accord
286
    with subsection 6b.</li>
287

  
288
<li>d) Convey the object code by offering access from a designated
289
    place (gratis or for a charge), and offer equivalent access to the
290
    Corresponding Source in the same way through the same place at no
291
    further charge.  You need not require recipients to copy the
292
    Corresponding Source along with the object code.  If the place to
293
    copy the object code is a network server, the Corresponding Source
294
    may be on a different server (operated by you or a third party)
295
    that supports equivalent copying facilities, provided you maintain
296
    clear directions next to the object code saying where to find the
297
    Corresponding Source.  Regardless of what server hosts the
298
    Corresponding Source, you remain obligated to ensure that it is
299
    available for as long as needed to satisfy these requirements.</li>
300

  
301
<li>e) Convey the object code using peer-to-peer transmission, provided
302
    you inform other peers where the object code and Corresponding
303
    Source of the work are being offered to the general public at no
304
    charge under subsection 6d.</li>
305
</ul>
306

  
307
<p>A separable portion of the object code, whose source code is excluded
308
from the Corresponding Source as a System Library, need not be
309
included in conveying the object code work.</p>
310

  
311
<p>A “User Product” is either (1) a “consumer product”, which means any
312
tangible personal property which is normally used for personal, family,
313
or household purposes, or (2) anything designed or sold for incorporation
314
into a dwelling.  In determining whether a product is a consumer product,
315
doubtful cases shall be resolved in favor of coverage.  For a particular
316
product received by a particular user, “normally used” refers to a
317
typical or common use of that class of product, regardless of the status
318
of the particular user or of the way in which the particular user
319
actually uses, or expects or is expected to use, the product.  A product
320
is a consumer product regardless of whether the product has substantial
321
commercial, industrial or non-consumer uses, unless such uses represent
322
the only significant mode of use of the product.</p>
323

  
324
<p>“Installation Information” for a User Product means any methods,
325
procedures, authorization keys, or other information required to install
326
and execute modified versions of a covered work in that User Product from
327
a modified version of its Corresponding Source.  The information must
328
suffice to ensure that the continued functioning of the modified object
329
code is in no case prevented or interfered with solely because
330
modification has been made.</p>
331

  
332
<p>If you convey an object code work under this section in, or with, or
333
specifically for use in, a User Product, and the conveying occurs as
334
part of a transaction in which the right of possession and use of the
335
User Product is transferred to the recipient in perpetuity or for a
336
fixed term (regardless of how the transaction is characterized), the
337
Corresponding Source conveyed under this section must be accompanied
338
by the Installation Information.  But this requirement does not apply
339
if neither you nor any third party retains the ability to install
340
modified object code on the User Product (for example, the work has
341
been installed in ROM).</p>
342

  
343
<p>The requirement to provide Installation Information does not include a
344
requirement to continue to provide support service, warranty, or updates
345
for a work that has been modified or installed by the recipient, or for
346
the User Product in which it has been modified or installed.  Access to a
347
network may be denied when the modification itself materially and
348
adversely affects the operation of the network or violates the rules and
349
protocols for communication across the network.</p>
350

  
351
<p>Corresponding Source conveyed, and Installation Information provided,
352
in accord with this section must be in a format that is publicly
353
documented (and with an implementation available to the public in
354
source code form), and must require no special password or key for
355
unpacking, reading or copying.</p>
356

  
357
<h4><a name="section7"></a>7. Additional Terms.</h4>
358

  
359
<p>“Additional permissions” are terms that supplement the terms of this
360
License by making exceptions from one or more of its conditions.
361
Additional permissions that are applicable to the entire Program shall
362
be treated as though they were included in this License, to the extent
363
that they are valid under applicable law.  If additional permissions
364
apply only to part of the Program, that part may be used separately
365
under those permissions, but the entire Program remains governed by
366
this License without regard to the additional permissions.</p>
367

  
368
<p>When you convey a copy of a covered work, you may at your option
369
remove any additional permissions from that copy, or from any part of
370
it.  (Additional permissions may be written to require their own
371
removal in certain cases when you modify the work.)  You may place
372
additional permissions on material, added by you to a covered work,
373
for which you have or can give appropriate copyright permission.</p>
374

  
375
<p>Notwithstanding any other provision of this License, for material you
376
add to a covered work, you may (if authorized by the copyright holders of
377
that material) supplement the terms of this License with terms:</p>
378

  
379
<ul>
380
<li>a) Disclaiming warranty or limiting liability differently from the
381
    terms of sections 15 and 16 of this License; or</li>
382

  
383
<li>b) Requiring preservation of specified reasonable legal notices or
384
    author attributions in that material or in the Appropriate Legal
385
    Notices displayed by works containing it; or</li>
386

  
387
<li>c) Prohibiting misrepresentation of the origin of that material, or
388
    requiring that modified versions of such material be marked in
389
    reasonable ways as different from the original version; or</li>
390

  
391
<li>d) Limiting the use for publicity purposes of names of licensors or
392
    authors of the material; or</li>
393

  
394
<li>e) Declining to grant rights under trademark law for use of some
395
    trade names, trademarks, or service marks; or</li>
396

  
397
<li>f) Requiring indemnification of licensors and authors of that
398
    material by anyone who conveys the material (or modified versions of
399
    it) with contractual assumptions of liability to the recipient, for
400
    any liability that these contractual assumptions directly impose on
401
    those licensors and authors.</li>
402
</ul>
403

  
404
<p>All other non-permissive additional terms are considered “further
405
restrictions” within the meaning of section 10.  If the Program as you
406
received it, or any part of it, contains a notice stating that it is
407
governed by this License along with a term that is a further
408
restriction, you may remove that term.  If a license document contains
409
a further restriction but permits relicensing or conveying under this
410
License, you may add to a covered work material governed by the terms
411
of that license document, provided that the further restriction does
412
not survive such relicensing or conveying.</p>
413

  
414
<p>If you add terms to a covered work in accord with this section, you
415
must place, in the relevant source files, a statement of the
416
additional terms that apply to those files, or a notice indicating
417
where to find the applicable terms.</p>
418

  
419
<p>Additional terms, permissive or non-permissive, may be stated in the
420
form of a separately written license, or stated as exceptions;
421
the above requirements apply either way.</p>
422

  
423
<h4><a name="section8"></a>8. Termination.</h4>
424

  
425
<p>You may not propagate or modify a covered work except as expressly
426
provided under this License.  Any attempt otherwise to propagate or
427
modify it is void, and will automatically terminate your rights under
428
this License (including any patent licenses granted under the third
429
paragraph of section 11).</p>
430

  
431
<p>However, if you cease all violation of this License, then your
432
license from a particular copyright holder is reinstated (a)
433
provisionally, unless and until the copyright holder explicitly and
434
finally terminates your license, and (b) permanently, if the copyright
435
holder fails to notify you of the violation by some reasonable means
436
prior to 60 days after the cessation.</p>
437

  
438
<p>Moreover, your license from a particular copyright holder is
439
reinstated permanently if the copyright holder notifies you of the
440
violation by some reasonable means, this is the first time you have
441
received notice of violation of this License (for any work) from that
442
copyright holder, and you cure the violation prior to 30 days after
443
your receipt of the notice.</p>
444

  
445
<p>Termination of your rights under this section does not terminate the
446
licenses of parties who have received copies or rights from you under
447
this License.  If your rights have been terminated and not permanently
448
reinstated, you do not qualify to receive new licenses for the same
449
material under section 10.</p>
450

  
451
<h4><a name="section9"></a>9. Acceptance Not Required for Having Copies.</h4>
452

  
453
<p>You are not required to accept this License in order to receive or
454
run a copy of the Program.  Ancillary propagation of a covered work
455
occurring solely as a consequence of using peer-to-peer transmission
456
to receive a copy likewise does not require acceptance.  However,
457
nothing other than this License grants you permission to propagate or
458
modify any covered work.  These actions infringe copyright if you do
459
not accept this License.  Therefore, by modifying or propagating a
460
covered work, you indicate your acceptance of this License to do so.</p>
461

  
462
<h4><a name="section10"></a>10. Automatic Licensing of Downstream Recipients.</h4>
463

  
464
<p>Each time you convey a covered work, the recipient automatically
465
receives a license from the original licensors, to run, modify and
466
propagate that work, subject to this License.  You are not responsible
467
for enforcing compliance by third parties with this License.</p>
468

  
469
<p>An “entity transaction” is a transaction transferring control of an
470
organization, or substantially all assets of one, or subdividing an
471
organization, or merging organizations.  If propagation of a covered
472
work results from an entity transaction, each party to that
473
transaction who receives a copy of the work also receives whatever
474
licenses to the work the party's predecessor in interest had or could
475
give under the previous paragraph, plus a right to possession of the
476
Corresponding Source of the work from the predecessor in interest, if
477
the predecessor has it or can get it with reasonable efforts.</p>
478

  
479
<p>You may not impose any further restrictions on the exercise of the
480
rights granted or affirmed under this License.  For example, you may
481
not impose a license fee, royalty, or other charge for exercise of
482
rights granted under this License, and you may not initiate litigation
483
(including a cross-claim or counterclaim in a lawsuit) alleging that
484
any patent claim is infringed by making, using, selling, offering for
485
sale, or importing the Program or any portion of it.</p>
486

  
487
<h4><a name="section11"></a>11. Patents.</h4>
488

  
489
<p>A “contributor” is a copyright holder who authorizes use under this
490
License of the Program or a work on which the Program is based.  The
491
work thus licensed is called the contributor's “contributor version”.</p>
492

  
493
<p>A contributor's “essential patent claims” are all patent claims
494
owned or controlled by the contributor, whether already acquired or
495
hereafter acquired, that would be infringed by some manner, permitted
496
by this License, of making, using, or selling its contributor version,
497
but do not include claims that would be infringed only as a
498
consequence of further modification of the contributor version.  For
499
purposes of this definition, “control” includes the right to grant
500
patent sublicenses in a manner consistent with the requirements of
501
this License.</p>
502

  
503
<p>Each contributor grants you a non-exclusive, worldwide, royalty-free
504
patent license under the contributor's essential patent claims, to
505
make, use, sell, offer for sale, import and otherwise run, modify and
506
propagate the contents of its contributor version.</p>
507

  
508
<p>In the following three paragraphs, a “patent license” is any express
509
agreement or commitment, however denominated, not to enforce a patent
510
(such as an express permission to practice a patent or covenant not to
511
sue for patent infringement).  To “grant” such a patent license to a
512
party means to make such an agreement or commitment not to enforce a
513
patent against the party.</p>
514

  
515
<p>If you convey a covered work, knowingly relying on a patent license,
516
and the Corresponding Source of the work is not available for anyone
517
to copy, free of charge and under the terms of this License, through a
518
publicly available network server or other readily accessible means,
519
then you must either (1) cause the Corresponding Source to be so
520
available, or (2) arrange to deprive yourself of the benefit of the
521
patent license for this particular work, or (3) arrange, in a manner
522
consistent with the requirements of this License, to extend the patent
523
license to downstream recipients.  “Knowingly relying” means you have
524
actual knowledge that, but for the patent license, your conveying the
525
covered work in a country, or your recipient's use of the covered work
526
in a country, would infringe one or more identifiable patents in that
527
country that you have reason to believe are valid.</p>
528
  
529
<p>If, pursuant to or in connection with a single transaction or
530
arrangement, you convey, or propagate by procuring conveyance of, a
531
covered work, and grant a patent license to some of the parties
532
receiving the covered work authorizing them to use, propagate, modify
533
or convey a specific copy of the covered work, then the patent license
534
you grant is automatically extended to all recipients of the covered
535
work and works based on it.</p>
536

  
537
<p>A patent license is “discriminatory” if it does not include within
538
the scope of its coverage, prohibits the exercise of, or is
539
conditioned on the non-exercise of one or more of the rights that are
540
specifically granted under this License.  You may not convey a covered
541
work if you are a party to an arrangement with a third party that is
542
in the business of distributing software, under which you make payment
543
to the third party based on the extent of your activity of conveying
544
the work, and under which the third party grants, to any of the
545
parties who would receive the covered work from you, a discriminatory
546
patent license (a) in connection with copies of the covered work
547
conveyed by you (or copies made from those copies), or (b) primarily
548
for and in connection with specific products or compilations that
549
contain the covered work, unless you entered into that arrangement,
550
or that patent license was granted, prior to 28 March 2007.</p>
551

  
552
<p>Nothing in this License shall be construed as excluding or limiting
553
any implied license or other defenses to infringement that may
554
otherwise be available to you under applicable patent law.</p>
555

  
556
<h4><a name="section12"></a>12. No Surrender of Others' Freedom.</h4>
557

  
558
<p>If conditions are imposed on you (whether by court order, agreement or
559
otherwise) that contradict the conditions of this License, they do not
560
excuse you from the conditions of this License.  If you cannot convey a
561
covered work so as to satisfy simultaneously your obligations under this
562
License and any other pertinent obligations, then as a consequence you may
563
not convey it at all.  For example, if you agree to terms that obligate you
564
to collect a royalty for further conveying from those to whom you convey
565
the Program, the only way you could satisfy both those terms and this
566
License would be to refrain entirely from conveying the Program.</p>
567

  
568
<h4><a name="section13"></a>13. Use with the GNU Affero General Public License.</h4>
569

  
570
<p>Notwithstanding any other provision of this License, you have
571
permission to link or combine any covered work with a work licensed
572
under version 3 of the GNU Affero General Public License into a single
573
combined work, and to convey the resulting work.  The terms of this
574
License will continue to apply to the part which is the covered work,
575
but the special requirements of the GNU Affero General Public License,
576
section 13, concerning interaction through a network will apply to the
577
combination as such.</p>
578

  
579
<h4><a name="section14"></a>14. Revised Versions of this License.</h4>
580

  
581
<p>The Free Software Foundation may publish revised and/or new versions of
582
the GNU General Public License from time to time.  Such new versions will
583
be similar in spirit to the present version, but may differ in detail to
584
address new problems or concerns.</p>
585

  
586
<p>Each version is given a distinguishing version number.  If the
587
Program specifies that a certain numbered version of the GNU General
588
Public License “or any later version” applies to it, you have the
589
option of following the terms and conditions either of that numbered
590
version or of any later version published by the Free Software
591
Foundation.  If the Program does not specify a version number of the
592
GNU General Public License, you may choose any version ever published
593
by the Free Software Foundation.</p>
594

  
595
<p>If the Program specifies that a proxy can decide which future
596
versions of the GNU General Public License can be used, that proxy's
597
public statement of acceptance of a version permanently authorizes you
598
to choose that version for the Program.</p>
599

  
600
<p>Later license versions may give you additional or different
601
permissions.  However, no additional obligations are imposed on any
602
author or copyright holder as a result of your choosing to follow a
603
later version.</p>
604

  
605
<h4><a name="section15"></a>15. Disclaimer of Warranty.</h4>
606

  
607
<p>THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
608
APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
609
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY
610
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
611
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
612
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
613
IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
614
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.</p>
615

  
616
<h4><a name="section16"></a>16. Limitation of Liability.</h4>
617

  
618
<p>IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
619
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
620
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
621
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
622
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
623
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
624
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
625
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
626
SUCH DAMAGES.</p>
627

  
628
<h4><a name="section17"></a>17. Interpretation of Sections 15 and 16.</h4>
629

  
630
<p>If the disclaimer of warranty and limitation of liability provided
631
above cannot be given local legal effect according to their terms,
632
reviewing courts shall apply local law that most closely approximates
633
an absolute waiver of all civil liability in connection with the
634
Program, unless a warranty or assumption of liability accompanies a
635
copy of the Program in return for a fee.</p>
636

  
637
<p>END OF TERMS AND CONDITIONS</p>
638

  
639
<h3><a name="howto"></a>How to Apply These Terms to Your New Programs</h3>
640

  
641
<p>If you develop a new program, and you want it to be of the greatest
642
possible use to the public, the best way to achieve this is to make it
643
free software which everyone can redistribute and change under these terms.</p>
644

  
645
<p>To do so, attach the following notices to the program.  It is safest
646
to attach them to the start of each source file to most effectively
647
state the exclusion of warranty; and each file should have at least
648
the “copyright” line and a pointer to where the full notice is found.</p>
649

  
650
<pre>    &lt;one line to give the program's name and a brief idea of what it does.&gt;
651
    Copyright (C) &lt;year&gt;  &lt;name of author&gt;
652

  
653
    This program is free software: you can redistribute it and/or modify
654
    it under the terms of the GNU General Public License as published by
655
    the Free Software Foundation, either version 3 of the License, or
656
    (at your option) any later version.
657

  
658
    This program is distributed in the hope that it will be useful,
659
    but WITHOUT ANY WARRANTY; without even the implied warranty of
660
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
661
    GNU General Public License for more details.
662

  
663
    You should have received a copy of the GNU General Public License
664
    along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
665
</pre>
666

  
667
<p>Also add information on how to contact you by electronic and paper mail.</p>
668

  
669
<p>If the program does terminal interaction, make it output a short
670
notice like this when it starts in an interactive mode:</p>
671

  
672
<pre>    &lt;program&gt;  Copyright (C) &lt;year&gt;  &lt;name of author&gt;
673
    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
674
    This is free software, and you are welcome to redistribute it
675
    under certain conditions; type `show c' for details.
676
</pre>
677

  
678
<p>The hypothetical commands `show w' and `show c' should show the appropriate
679
parts of the General Public License.  Of course, your program's commands
680
might be different; for a GUI interface, you would use an “about box”.</p>
681

  
682
<p>You should also get your employer (if you work as a programmer) or school,
683
if any, to sign a “copyright disclaimer” for the program, if necessary.
684
For more information on this, and how to apply and follow the GNU GPL, see
685
&lt;<a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>&gt;.</p>
686

  
687
<p>The GNU General Public License does not permit incorporating your program
688
into proprietary programs.  If your program is a subroutine library, you
689
may consider it more useful to permit linking proprietary applications with
690
the library.  If this is what you want to do, use the GNU Lesser General
691
Public License instead of this License.  But first, please read
692
&lt;<a href="http://www.gnu.org/philosophy/why-not-lgpl.html">http://www.gnu.org/philosophy/why-not-lgpl.html</a>&gt;.</p>
693

  
694

  
695
</body></html>
middleware/middleware.mk
1
################################################################################
2
# AMiRo-Apps is a collection of applications for the Autonomous Mini Robot     #
3
# (AMiRo) platform.                                                            #
4
# Copyright (C) 2018..2018  Thomas Schöpping et al.                            #
5
#                                                                              #
6
# This program is free software: you can redistribute it and/or modify         #
7
# it under the terms of the GNU General Public License as published by         #
8
# the Free Software Foundation, either version 3 of the License, or            #
9
# (at your option) any later version.                                          #
10
#                                                                              #
11
# This program is distributed in the hope that it will be useful,              #
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
14
# GNU General Public License for more details.                                 #
15
#                                                                              #
16
# You should have received a copy of the GNU General Public License            #
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.        #
18
#                                                                              #
19
# This research/work was supported by the Cluster of Excellence Cognitive      #
20
# Interaction Technology 'CITEC' (EXC 277) at Bielefeld University, which is   #
21
# funded by the German Research Foundation (DFG).                              #
22
################################################################################
23

  
24

  
25

  
26
# absolute path to this directory
27
MIDDLEWARE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
28

  
29
include $(MIDDLEWARE_DIR)uRtWare/Makefile
30

  
31
# include paths
32
MIDDLEWAREINC = $(URTWARE_INC)
33

  
34
# C source files
35
MIDDLEWARECSRC = $(URTWARE_CSRC)
36

  
37
# C++ source files
38
MIDDLEWARECPPSRC = $(URTWARE_CPPSRC)
39

  
40

  
41

  
middleware/middlewaresetup.sh
1
################################################################################
2
# AMiRo-Apps is a collection of applications for the Autonomous Mini Robot     #
3
# (AMiRo) platform.                                                            #
4
# Copyright (C) 2018..2018  Thomas Schöpping et al.                            #
5
#                                                                              #
6
# This program is free software: you can redistribute it and/or modify         #
7
# it under the terms of the GNU General Public License as published by         #
8
# the Free Software Foundation, either version 3 of the License, or            #
9
# (at your option) any later version.                                          #
10
#                                                                              #
11
# This program is distributed in the hope that it will be useful,              #
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
14
# GNU General Public License for more details.                                 #
15
#                                                                              #
16
# You should have received a copy of the GNU General Public License            #
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.        #
18
#                                                                              #
19
# This research/work was supported by the Cluster of Excellence Cognitive      #
20
# Interaction Technology 'CITEC' (EXC 277) at Bielefeld University, which is   #
21
# funded by the German Research Foundation (DFG).                              #
22
################################################################################
23

  
24
#!/bin/bash
25

  
26
################################################################################
27
# GENERIC FUNCTIONS                                                            #
28
################################################################################
29

  
30
### print an error message #####################################################
31
# Prints a error <message> to standard output.
32
#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
33
#
34
# usage:      printError <message>
35
# arguments:  <message>
36
#                 Message string to print.
37
# return:     n/a
38
#
39
function printError {
40
  local string="ERROR:   $1"
41
  # if a log file is specified
42
  if [ -n "$LOG_FILE" ]; then
43
    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
44
  fi
45
  printf "$(tput setaf 1)>>> $string$(tput sgr 0)" 1>&2
46
}
47

  
48
### print a warning message ####################################################
49
# Prints a warning <message> to standard output.
50
#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
51
#
52
# usage:      printMessage <message>
53
# arguments:  <message>
54
#                 Message string to print.
55
# return:     n/a
56
#
57
function printWarning {
58
  local string="WARNING: $1"
59
  # if a log file is specified
60
  if [ -n "$LOG_FILE" ]; then
61
    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
62
  fi
63
  printf "$(tput setaf 3)>>> $string$(tput sgr 0)"
64
}
65

  
66
### print an information message ###############################################
67
# Prints an information <message> to standard output.
68
#If variable 'LOG_FILE' is specified, the message is also appended to the given file.
69
#
70
# usage:      printInfo <message>
71
# arguments:  <message>
72
#                 Message string to print.
73
# return:     n/a
74
#
75
function printInfo {
76
  local string="INFO:    $1"
77
  # if a log file is specified
78
  if [ -n "$LOG_FILE" ]; then
79
    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
80
  fi
81
  printf "$(tput setaf 2)>>> $string$(tput sgr 0)"
82
}
83

  
84
### print a message to file ####################################################
85
# Appends a <message> to a log file, specified by the variable 'LOG_FILE'.
86
#
87
# usage       printLog <message>
88
# arguments:  <message>
89
#                 Message string to print.
90
# return:     n/a
91
#
92
function printLog {
93
  local string="LOG:     $1"
94
  # if a log file is specified
95
  if [ -n "$LOG_FILE" ]; then
96
    printf "[$(date '+%Y-%m-%d %H:%M:%S')] $string" >> $LOG_FILE
97
  fi
98
}
99

  
100
### exit the script normally ###################################################
101
# Prints a delimiter and exits the script normally (returns 0).
102
#
103
# usage:      quitScript
104
# arguments:  n/a
105
# return:     0
106
#                 No error or warning occurred.
107
#
108
function quitScript {
109
  printInfo "exiting $(realpath ${BASH_SOURCE[0]})\n"
110
  printf "\n"
111
  printf "######################################################################\n"
112
  exit 0
113
}
114

  
115
### read a user input ##########################################################
116
# Reads a single character user input from a set up <options> and stores it in
117
# a given <return> variable.
118
#
119
# usage:      readUserInput <options> <return>
120
# arguments:  <options>
121
#                 String definiing the set of valid characters.
122
#                 If the string is empty, the user can input any character.
123
#             <return>
124
#                 Variable to store the selected character to.
125
# return:     n/a
126
#
127
function readUserInput {
128
  local input=""
129
  # read user input
130
  while [ -z $input ] || ( [ -n "$1" ] && [[ ! $input =~ ^[$1]$ ]] ); do
131
    read -p "your selection: " -n 1 -e input
132
    if [ -z $input ] || ( [ -n "$1" ] && [[ ! $input =~ ^[$1]$ ]] ); then
133
      printWarning "[$input] is no valid action\n"
134
    fi
135
  done
136
  printLog "[$input] has been selected\n"
137
  eval $2="$input"
138
}
139

  
140
### check whether argument is an option ########################################
141
# Checks a <string> whether it is an option.
142
# Options are defined to either start with '--' followed by any string, or
143
# to start with a single '-' followed by a single character, or
144
# to start with a single '-' followed by a single character, a '=' and any string.
145
# Examples: '--option', '--option=arg', '-o', '-o=arg', '--'
146
#
147
# usage:      parseIsOption <string>
148
# arguments:  <string>
149
#                 A string to check whether it is an option.
150
# return:     0
151
#                 <string> is an option.
152
#             -1
153
#                 <string> is not an option.
154
#
155
function parseIsOption {
156
  if [[ "$1" =~ ^-(.$|.=.*) ]] || [[ "$1" =~ ^--.* ]]; then
157
    return 0
158
  else
159
    return -1
160
  fi
161
}
162

  
163
### set the log file ###########################################################
164
# Sets a specified <infile> as log file and checks whether it already exists.
165
# If so, the log may either be appended to the file, its content can be cleared,
166
# or no log is generated at all.
167
# The resulting path is stored in <outvar>.
168
#
169
# usage:      setLogFile [--option=<option>] [--quiet] <infile> <outvar>
170
# arguments:  --option=<option>
171
#                 Select what to do if <file> already exists.
172
#                 Possible values are 'a', 'c', 'r' and 'n'.
173
#                 - a: append (starts with a separator)
174
#                 - c: continue (does not insert a seperator)
175
#                 - r: delete and restart
176
#                 - n: no log
177
#                 If no option is secified but <file> exists, an interactive selection is provided.
178
#             --quiet
179
#                 Suppress all messages.
180
#             <infile>
181
#                 Path of the wanted log file.
182
#             <outvar>
183
#                 Variable to store the path of the log file to.
184
# return:     0
185
#                 No error or warning occurred.
186
#             -1
187
#                 Error: invalid input
188
#
189
function setLogFile {
190
  local filepath=""
191
  local option=""
192
  local quiet=false
193

  
194
  # parse arguments
195
  local otherargs=()
196
  while [ $# -gt 0 ]; do
197
    if ( parseIsOption $1 ); then
198
      case "$1" in
199
        -o=*|--option=*)
200
          option=${1#*=}; shift 1;;
201
        -o*|--option*)
202
          option="$2"; shift 2;;
203
        -q|--quiet)
204
          quiet=true; shift 1;;
205
        *)
206
          printError "invalid option: $1\n"; shift 1;;
207
      esac
208
    else
209
      otherargs+=("$1")
210
      shift 1
211
    fi
212
  done
213
  filepath=$(realpath ${otherargs[0]})
214

  
215
  # if file already exists
216
  if [ -e $filepath ]; then
217
    # if no option was specified, ask what to do
218
    if [ -z "$option" ]; then
219
      printWarning "log file $filepath already esists\n"
220
      local userinput=""
221
      printf "Select what to do:\n"
222
      printf "  [A] - append log\n"
223
      printf "  [R] - restart log (delete existing file)\n"
224
      printf "  [N] - no log\n"
225
      readUserInput "AaRrNn" userinput
226
      option=${userinput,,}
227
    fi
228
    # evaluate option
229
    case "$option" in
230
      a|c)
231
        if [ $quiet = false ]; then
232
          printInfo "appending log to $filepath\n"
233
        fi
234
        if [ $option != c ]; then
235
          printf "\n" >> $filepath
236
          printf "######################################################################\n" >> $filepath
237
          printf "\n" >> $filepath
238
        fi
239
        ;;
240
      r)
241
        echo -n "" > $filepath
242
        if [ $quiet = false ]; then
243
          printInfo "content of $filepath wiped\n"
244
        fi
245
        ;;
246
      n)
247
        if [ $quiet = false ]; then
248
          printInfo "no log file will be generated\n"
249
        fi
250
        filepath=""
251
        ;;
252
      *) # sanity check (return error)
253
        printError "unexpected argument: $option\n"; return -1;;
254
    esac
255
  else
256
    if [ $quiet = false ]; then
257
      printInfo "log file set to $filepath\n"
258
    fi
259
  fi
260

  
261
  eval ${otherargs[1]}="$filepath"
262

  
263
  return 0
264
}
265

  
266
################################################################################
267
# SPECIFIC FUNCTIONS                                                           #
268
################################################################################
269

  
270
### print welcome text #########################################################
271
# Prints a welcome message to standard out.
272
#
273
# usage:      printWelcomeText
274
# arguments:  n/a
275
# return:     n/a
276
#
277
function printWelcomeText {
278
  printf "######################################################################\n"
279
  printf "#                                                                    #\n"
280
  printf "#              Welcome to the uRtWare submodule setup!               #\n"
281
  printf "#                                                                    #\n"
282
  printf "######################################################################\n"
283
  printf "#                                                                    #\n"
284
  printf "# Copyright (c) 2018..2018  Thomas Schöpping                         #\n"
285
  printf "#                                                                    #\n"
286
  printf "# This is free software; see the source for copying conditions.      #\n"
287
  printf "# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR  #\n"
288
  printf "# A PARTICULAR PURPOSE. The development of this software was         #\n"
289
  printf "# supported by the Excellence Cluster EXC 227 Cognitive Interaction  #\n"
290
  printf "# Technology. The Excellence Cluster EXC 227 is a grant of the       #\n"
291
  printf "# Deutsche Forschungsgemeinschaft (DFG) in the context of the German #\n"
292
  printf "# Excellence Initiative.                                             #\n"
293
  printf "#                                                                    #\n"
294
  printf "######################################################################\n"
295
}
296

  
297
### print help #################################################################
298
# Prints a help text to standard out.
299
#
300
# usage:      printHelp
301
# arguments:  n/a
302
# return:     n/a
303
#
304
function printHelp {
305
  printInfo "printing help text\n"
306
  printf "usage:    $(basename ${BASH_SOURCE[0]}) [-h|--help] [-i|--init] [-s|--setup] [-w|--wipe] [-q|--quit] [--log=<file>]\n"
307
  printf "options:  -h, --help\n"
308
  printf "              Print this help text.\n"
309
  printf "          -i, --init\n"
310
  printf "              Initialize the uRtWare submodule.\n"
311
  printf "          -w, --wipe\n"
312
  printf "              Wipe the entire uRtWare submodule.\n"
313
  printf "          -q, --quit\n"
314
  printf "              Quit the script.\n"
315
  printf "          --log=<file> \n"
316
  printf "              Specify a log file.\n"
317
}
318

  
319
### initialize uRtWare submodule ###############################################
320
# Initialize the uRtWare submodule.
321
#
322
# usage:      initUrtware
323
# arguments:  n/a
324
# return:     0
325
#                 No error or warning occurred.
326
#             1
327
#                 Warning: Arborted by user.
328
#             -1
329
#                 Error: Unexpected user input.
330
#
331
function initUrtware {
332
  printInfo "initializing uRtWare submodule...\n"
333
  local userdir=$(pwd)
334
  local middlewaredir=$(dirname $(realpath ${BASH_SOURCE[0]}))
335
  local urtwaredir=${middlewaredir}/uRtWare
336

  
337
  # if the uRtWare folder is not empty
338
  if [ ! -z "$(ls -A $urtwaredir)" ]; then
339
    printWarning "$(realpath $urtwaredir) is not empty. Delete and reinitialize? [y/n]\n"
340
    local userinput=""
341
    readUserInput "YyNn" userinput
342
    case $userinput in
343
      Y|y)
344
        wipeUrtware
345
        ;;
346
      N|n)
347
        printWarning "uRtWare initialization aborted by user\n"
348
        return 1
349
        ;;
350
      *) # sanity check (return error)
351
        printError "unexpected input: $userinput\n"; return -1;;
352
    esac
353
  fi
354

  
355
  # initialize submodule to default branch
356
  cd $middlewaredir
357
  git submodule update --init $urtwaredir 2>&1 | tee -a $LOG_FILE
358
  while [ ${PIPESTATUS[0]} -ne 0 ]; do
359
    printWarning "initialitaion failed. Retry? [y/n]\n"
360
    local userinput=""
361
    readUserInput "YyNn" userinput
362
    case "$userinput" in
363
      Y|y)
364
        git submodule update --init $urtwaredir 2>&1 | tee -a $LOG_FILE;;
365
      N|n)
366
        printWarning "uRtWare initialization aborted by user\n"
367
        cd $userdir
368
        return 1
369
        ;;
370
      *) # sanity check (return error)
371
        printError "unexpected input: $userinput\n"; return -1;;
372
    esac
373
  done
374
  cd $userdir
375

  
376
  return 0
377
}
378

  
379
### reset uRtWare submodule and wipe directory ####################################
380
# Resets the uRtWare Git submodule and wipes the directory.
381
#
382
# usage:      wipeUrtware
383
# arguments:  n/a
384
# return:     n/a
385
function wipeUrtware {
386
  local userdir=$(pwd)
387
  local middlewaredir=$(dirname $(realpath ${BASH_SOURCE[0]}))
388
  local urtwaredir=${middlewaredir}/uRtWare
389
  printInfo "reset and wipe Git submodule $urtwaredir\n"
390

  
391
  # if the uRtWare folder is empty
392
  if [ -z "$(ls -A $urtwaredir)" ]; then
393
    printWarning "$urtwaredir is already empty\n"
394
    return 1
395
  else
396
    # get some information from Git
397
    cd $middlewaredir
398
    local git_basehash=($(git ls-tree -d HEAD $urtwaredir)); git_basehash=${git_basehash[2]}
399
    cd $urtwaredir
400
    local git_branch_current=$(git rev-parse --abbrev-ref HEAD)
401
    local git_difftobase="$(git diff ${git_basehash}..HEAD)"
402
    local git_commits=$(git log --format=oneline ${git_basehash}..HEAD)
403
    local git_dirtyfiles=($(git ls-files -dmo --exclude-standard --exclude=/doc))
404
    cd $userdir
405
    local issues=0
406
    # if HEAD is ahead of submodule base commit
407
    if [ -n "$git_difftobase" ]; then
408
      issues=$((issues + 1))
409
      printWarning "HEAD is ahead of submodule base\n"
410
    fi
411
    # if there are untracked, modified, or deleted files
412
    if [ ${#git_dirtyfiles[@]} != 0 ]; then
413
      issues=$((issues + 1))
414
      printWarning "there are ${#git_dirtyfiles[@]} untracked, modified, or deleted files\n"
415
    fi
416
    if [ $issues -gt 0 ]; then
417
      local userinput=""
418
      printWarning "$issues issues detected. Do you want to continue? [y/n]\n"
419
      readUserInput "YyNn" userinput
420
      case "$userinput" in
421
        Y|y)
422
          ;;
423
        N|n)
424
          printfWarning "wiping uRtWare Git submodule aborted by user\n"
425
          return 2
426
          ;;
427
        *) # sanity check (return error)
428
          printError "unexpected input: $userinput\n"; return -1;;
429
      esac
430
    fi
431

  
432
    # checkout base commit and delete all local branches
433
    cd $middlewaredir
434
    git submodule update --force --checkout $urtwaredir | tee -a $LOG_FILE
435
    cd $urtwaredir
436
    local git_branches=($(git for-each-ref --format="%(refname)"))
437
    for branch in $git_branches; do
438
      if [[ $branch = *"heads/"* ]]; then
439
        git branch -D ${branch##*/} | tee -a $LOG_FILE
440
      fi
441
    done
442
    cd $userdir
443

  
444
    # deinitialize uRtWare submodule and delete any remaining files
445
    cd $middlewaredir
446
    git submodule deinit -f $urtwaredir 2>&1 | tee -a $LOG_FILE
447
    rm -rf $urtwaredir/*
448
    cd $userdir
449

  
450
    return 0
451
  fi
452
}
453

  
454
### main function of this script ###############################################
455
# Initializes or wipes the uRtWare Git submodule, and provides an entry point to
456
# its setup.
457
#
458
# usage:      see function printHelp
459
# arguments:  see function printHelp
460
# return:     0
461
#                 No error or warning occurred.
462
#
463
function main {
464
  # print welcome/info text if not suppressed
465
  if [[ $@ != *"--noinfo"* ]]; then
466
    printWelcomeText
467
  else
468
    printf "######################################################################\n"
469
  fi
470
  printf "\n"
471

  
472
  # if --help or -h was specified, print the help text and exit
473
  if [[ $@ == *"--help"* || $@ == *"-h"* ]]; then
474
    printHelp
475
    printf "\n"
476
    quitScript
477
  fi
478

  
479
  # set log file if specified
480
  if [[ $@ == *"--log"* ]] || [[ $@ == *"--LOG"* ]]; then
481
    # get the parameter (file name)
482
    local cmdidx=1
483
    while [[ ! "${!cmdidx}" = "--log"* ]] && [[ ! "${!cmdidx}" = "--LOG"* ]]; do
484
      cmdidx=$[cmdidx + 1]
485
    done
486
    local cmd="${!cmdidx}"
487
    local logfile=""
488
    if [[ "$cmd" = "--log="* ]] || [[ "$cmd" = "--LOG="* ]]; then
489
      logfile=${cmd#*=}
490
    else
491
      local filenameidx=$((cmdidx + 1))
492
      logfile="${!filenameidx}"
493
    fi
494
    # optionally force silent appending
495
    if [[ "$cmd" = "--LOG"* ]]; then
496
      setLogFile --option=c --quiet "$logfile" LOG_FILE
497
    else
498
      setLogFile "$logfile" LOG_FILE
499
      printf "\n"
500
    fi
501
  fi
502
  # log script name
503
  printLog "this is $(realpath ${BASH_SOURCE[0]})\n"
504

  
505
  # parse arguments
506
  local otherargs=()
507
  while [ $# -gt 0 ]; do
508
    if ( parseIsOption $1 ); then
509
      case "$1" in
510
        -h|--help) # already handled; ignore
511
          shift 1;;
512
        -i|--init)
513
           initUrtware; printf "\n"; shift 1;;
514
        -w|--wipe)
515
           wipeUrtware; printf "\n"; shift 1;;
516
        -q|--quit)
517
          quitScript; shift 1;;
518
        --log=*|--LOG=*) # already handled; ignore
519
          shift 1;;
520
        --log|--LOG) # already handled; ignore
521
          shift 2;;
522
        --noinfo) # already handled; ignore
523
          shift 1;;
524
        *)
525
          printError "invalid option: $1\n"; shift 1;;
526
      esac
527
    else
528
      otherargs+=("$1")
529
      shift 1
530
    fi
531
  done
532

  
533
  # interactive menu
534
  while ( true ); do
535
    # main menu info prompt and selection
536
    printInfo "Operating system setup main menu\n"
537
    printf "Please select one of the following actions:\n"
538
    printf "  [I] - initialize uRtWare submodule\n"
539
    printf "  [W] - wipe uRtWare submodule\n"
540
    printf "  [Q] - quit this setup\n"
541
    local userinput=""
542
    readUserInput "IiWwQq" userinput
543
    printf "\n"
544

  
545
    # evaluate user selection
546
    case "$userinput" in
547
      I|i)
548
        initUrtware; printf "\n";;
549
      W|w)
550
        wipeUrtware; printf "\n";;
551
      Q|q)
552
        quitScript;;
553
      *) # sanity check (exit with error)
554
        printError "unexpected argument: $userinput\n";;
555
    esac
556
  done
557

  
558
  exit 0
559
}
560

  
561
################################################################################
562
# SCRIPT ENTRY POINT                                                           #
563
################################################################################
564

  
565
main "$@"
middleware/uRtWare
1
Subproject commit 5cf365321c98e5f66cb49f4e38bd5de1d6d3ba3b
os/AMiRo-OS
1
Subproject commit e34c46f0d4b743db0d93f806a1c8395a16a71414
os/os.mk
1
################################################################################
2
# AMiRo-Apps is a collection of applications for the Autonomous Mini Robot     #
3
# (AMiRo) platform.                                                            #
4
# Copyright (C) 2016..2018  Thomas Schöpping et al.                            #
5
#                                                                              #
6
# This program is free software: you can redistribute it and/or modify         #
7
# it under the terms of the GNU General Public License as published by         #
8
# the Free Software Foundation, either version 3 of the License, or            #
9
# (at your option) any later version.                                          #
10
#                                                                              #
11
# This program is distributed in the hope that it will be useful,              #
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
14
# GNU General Public License for more details.                                 #
15
#                                                                              #
16
# You should have received a copy of the GNU General Public License            #
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.        #
18
#                                                                              #
19
# This research/work was supported by the Cluster of Excellence Cognitive      #
20
# Interaction Technology 'CITEC' (EXC 277) at Bielefeld University, which is   #
21
# funded by the German Research Foundation (DFG).                              #
22
################################################################################
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff