Kuon  1.1.3
RoadNarrows Robotics Large Outdoor Mobile Robot Project
kuon.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: kuon
4 //
5 // Library: libkuon
6 //
7 // File: kuon.h
8 //
9 /*! \file
10  *
11  * $LastChangedDate: 2011-01-13 11:05:37 -0700 (Thu, 13 Jan 2011) $
12  * $Rev: 657 $
13  *
14  * \brief RoadNarrows Kuon robot top-level header file.
15  *
16  * \author Robin Knight (robin.knight@roadnarrows.com)
17  * \author Rob Shiely (rob@roadnarrows.com)
18  * \author Daniel Packard (daniel@roadnarrows.com)
19  *
20  * \copyright
21  * \h_copy 2010-2017. RoadNarrows LLC.\n
22  * http://www.roadnarrows.com\n
23  * All Rights Reserved
24  */
25 /*
26  * @EulaBegin@
27 // Permission is hereby granted, without written agreement and without
28 // license or royalty fees, to use, copy, modify, and distribute this
29 // software and its documentation for any purpose, provided that
30 // (1) The above copyright notice and the following two paragraphs
31 // appear in all copies of the source code and (2) redistributions
32 // including binaries reproduces these notices in the supporting
33 // documentation. Substantial modifications to this software may be
34 // copyrighted by their authors and need not follow the licensing terms
35 // described here, provided that the new terms are clearly indicated in
36 // all files where they apply.
37 //
38 // IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY MEMBERS/EMPLOYEES
39 // OF ROADNARROW LLC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
40 // PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
41 // DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
42 // EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
43 // THE POSSIBILITY OF SUCH DAMAGE.
44 //
45 // THE AUTHOR AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
46 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
47 // FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
48 // "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
49 // PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
50  * @EulaBegin@
51  */
52 ////////////////////////////////////////////////////////////////////////////////
53 
54 #ifndef _KUON_H
55 #define _KUON_H
56 
57 #include "rnr/rnrconfig.h"
58 #include "rnr/units.h"
59 #include "rnr/log.h"
60 
61 /*!
62  * \brief The \h_kuon namespace encapsulates all \h_kuon related
63  * constructs.
64  */
65 #ifndef SWIG
66 namespace kuon
67 {
68 #endif // SWIG
69 
70  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
71 
72  /*!
73  * \ingroup kuon_h
74  * \defgroup kuon_ecodes Kuon Error Codes
75  *
76  * Kuon package-wide error codes.
77  *
78  * \{
79  */
80  static const int KUON_OK = 0; ///< not an error, success
81 
82  static const int KUON_ECODE_GEN = 1; ///< general, unspecified error
83  static const int KUON_ECODE_SYS = 2; ///< system (errno) error
84  static const int KUON_ECODE_INTERNAL = 3; ///< internal error (bug)
85  static const int KUON_ECODE_BAD_VAL = 4; ///< bad value general error
86  static const int KUON_ECODE_TOO_BIG = 5; ///< value/list/size too big
87  static const int KUON_ECODE_TOO_SMALL = 6; ///< value/list/size too small
88  static const int KUON_ECODE_RANGE = 7; ///< value out-of-range
89  static const int KUON_ECODE_BAD_OP = 8; ///< invalid operation error
90  static const int KUON_ECODE_TIMEDOUT = 9; ///< operation timed out error
91  static const int KUON_ECODE_NO_DEV = 10; ///< device not found error
92  static const int KUON_ECODE_NO_RSRC = 11; ///< no resource available error
93  static const int KUON_ECODE_BUSY = 12; ///< resource busy error
94  static const int KUON_ECODE_NO_EXEC = 13; ///< cannot execute error
95  static const int KUON_ECODE_PERM = 14; ///< no permissions error
96  static const int KUON_ECODE_MOTOR = 15; ///< motor error
97  static const int KUON_ECODE_MOT_CTLR = 16; ///< motor controller error
98  static const int KUON_ECODE_BATT = 17; ///< battery error
99  static const int KUON_ECODE_FORMAT = 18; ///< bad format
100  static const int KUON_ECODE_BOTSENSE = 19; ///< botsense error
101  static const int KUON_ECODE_NO_FILE = 20; ///< file not found
102  static const int KUON_ECODE_XML = 21; ///< XML error
103  static const int KUON_ECODE_ALARMED = 22; ///< robot is alarmed
104  static const int KUON_ECODE_INTR = 23; ///< operation interrupted
105  static const int KUON_ECODE_COLLISION = 24; ///< robot link(s) in collision
106  static const int KUON_ECODE_ESTOP = 25; ///< robot emergency stopped
107 
108  static const int KUON_ECODE_BADEC = 26; ///< bad error code
109 
110  static const int KUON_ECODE_NUMOF = 27; ///< number of error codes
111  /*! \} */
112 
113  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
114 
115  /*!
116  * \ingroup kuon_h
117  * \defgroup kuon_alarms Kuon Alarm Bits and Masks
118  * \{
119  */
120  static const int KUON_ALARM_NONE = 0x00; ///< no alarms
121  static const int KUON_ALARM_VOLTAGE = 0x01; ///< under/over voltage
122  static const int KUON_ALARM_TEMP = 0x02; ///< under/over temperature
123  static const int KUON_ALARM_COMM = 0x04; ///< communication
124 
125  /*! \} */
126 
127  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
128 
129  /*!
130  *
131  * \ingroup kuon_h
132  * \defgroup kuon_prod Kuon Product Identifiers
133  *
134  * \h_kuon product ids, names, and descriptions.
135  *
136  * \{
137  */
138 
139  //
140  // Product Ids and Names
141  //
142  const char* const KuonProdFamily = "Kuon"; ///< product family name
143 
144  static const int KuonProdIdUnknown = 0; ///< unknown/undefined product id
145  static const int KuonProdIdStd = 1; ///< standard Kuon product id
146  static const int KuonProdIdNarrow = 2; ///< narrow Kuon product id
147 
148  const char* const KuonProdModelStd = "Standard"; ///< standard model
149  const char* const KuonProdModelNarrow = "Narrow"; ///< narrow model
150 
151  /*!
152  * \brief Convert version triplet to integer equivalent.
153  *
154  * \param major Major version number.
155  * \param minor Minor version number.
156  * \param revision Revision number.
157  */
158  #define KUON_VERSION(major, minor, revision) \
159  ((((major)&0xff)<<24) | (((minor)&0xff)<<16) | ((revision)&0xffff))
160 
161  /*!
162  * \brief Get version major number from version.
163  *
164  * \param ver Version number.
165  *
166  * \return Major number.
167  */
168  #define KUON_VER_MAJOR(ver) (((ver)>>24) &0xff)
169 
170  /*!
171  * \brief Get version minor number from version.
172  *
173  * \param ver Version number.
174  *
175  * \return Minor number.
176  */
177  #define KUON_VER_MINOR(ver) (((ver)>>16) &0xff)
178 
179  /*!
180  * \brief Get revision number from version.
181  *
182  * \param ver Version number.
183  *
184  * \return Revision number.
185  */
186  #define KUON_VER_REV(ver) ((ver) & 0xffff)
187  /*! \} */
188 
189  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
190 
191  /*!
192  *
193  * \ingroup kuon_h
194  * \defgroup kuon_env Kuon Environment
195  *
196  * Kuon directories and files.
197  *
198  * \{
199  */
200 
201  //
202  // Images directory.
203  //
204  #ifdef KUON_IMAGE_DIR
205  const char* const KuonImageDir = KUON_IMAGE_DIR; ///< image directory
206  #else
207  const char* const KuonImageDir = "/usr/local/share/Kuon/images";
208  ///< image directory
209  #endif
210 
211  //
212  // Icons directory.
213  //
214  #ifdef KUON_ICON_DIR
215  const char* const KuonIconDir = KUON_ICON_DIR; ///< icon directory
216  #else
217  const char* const KuonIconDir = "/usr/local/share/Kuon/images/icons";
218  ///< icon directory
219  #endif
220 
221  //
222  // Top-level configuration file.
223  //
224  #ifdef KUON_ETC_CFG
225  const char* const KuonEtcCfg = KUON_ETC_CFG; /// xml configuration file
226  #else
227  const char* const KuonEtcCfg = "/etc/kuon/kuon.conf";
228  /// xml configuration file
229  #endif
230 
231  //
232  // XML stylesheet URL
233  //
234  #ifdef KUON_XSL_URL
235  const char* const KuonXslUrl = KUON_XSL_URL; ///< xml stylesheet url
236  #else
237  const char* const KuonXslUrl =
238  "http://roadnarrows.com/xml/Kuon/1.0/kuon.xsl";
239  ///< xml stylesheet url
240  #endif
241 
242  //
243  // XML schema instance URL
244  //
245  #ifdef KUON_XSI_URL
246  const char* const KuonXsiUrl = KUON_XSI_URL; ///< xml schema instance url
247  #else
248  const char* const KuonXsiUrl =
249  "http://roadnarrows.com/xml/Kuon/1.0/kuon.xsd";
250  ///< xml schema instance url
251  #endif
252 
253  //
254  // Motor controller 0 USB serial default device name.
255  //
256  #ifdef KUON_DEV_MOTOR_CTLR_0
257  const char* const KuonDevMotorCtlr0 = KUON_DEV_MOTOR_CTLR_0;
258  ///< motor controller 0 device name
259  #else
260  const char* const KuonDevMotorCtlr0 = "/dev/kmot0";
261  ///< motor controller 0 device name
262  #endif
263 
264  //
265  // Motor controller 1 USB serial default device name.
266  //
267  #ifdef KUON_DEV_MOTOR_CTLR_1
268  const char* const KuonDevMotorCtlr1 = KUON_DEV_MOTOR_CTLR_1;
269  ///< motor controller 1 device name
270  #else
271  const char* const KuonDevMotorCtlr1 = "/dev/kmot1";
272  ///< motor controller 1 device name
273  #endif
274 
275  //
276  // Motor controllers default baud rate.
277  //
278  #ifdef KUON_BAUDRATE_MOTOR_CTLR
279  const int KuonBaudRateMotorCtlr = KUON_BAUDRATE_MOTOR_CTLR;
280  ///< motor controllers baud rate
281  #else
282  const int KuonBaudRateMotorCtlr = 38400;
283  ///< motor controllers baud rate
284  #endif
285 
286  /*! \} */
287 
288  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
289 
290  /*!
291  * \ingroup kuon_spec
292  *
293  * \defgroup kuon_common_spec Kuon Common Specs
294  *
295  * \h_kuon common specifications.
296  *
297  * \{
298  */
299 
300  // motor/wheel ids
301  static const int KuonMotorIdNone = -1; ///< no motor id
302  static const int KuonMotorIdLF = 0; ///< left front
303  static const int KuonMotorIdRF = 1; ///< right front
304  static const int KuonMotorIdLR = 2; ///< left rear
305  static const int KuonMotorIdRR = 3; ///< right rear
306 
307  // motor controllers
308  static const int KuonMotorCtlrIdNone = -1; ///< no motor controller id
309  static const int KuonMotorCtlrId0 = 0; ///< motor controller id 0
310  static const int KuonMotorCtlrId1 = 1; ///< motor controller id 1
311 
312  // motor rotation
313  static const int KuonMotorDirUnknown = 0; ///< unknown
314  static const int KuonMotorDirCcw = 1; ///< counter-clockwise
315  static const int KuonMotorDirCw = -1; ///< clockwise
316  /*! \} */
317 
318 
319  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
320 
321  /*!
322  *
323  * \ingroup kuon_h
324  * \defgroup kuon_types Kuon Common Simple Types
325  *
326  * Common types used to control and report robot information.
327  * fields.
328  *
329  * \{
330  */
331 
332  /*!
333  * \brief \h_kuon tri-state type.
334  *
335  * Basically, a tri-state value is either unknown, 0, or 1.
336  */
338  {
339  // unknown
340  KuonTriStateUnknown = -1, ///< unknown state
341 
342  // low state synonyms
343  KuonTriStateFalse = 0, ///< false
344  KuonTriStateOff = 0, ///< off
345  KuonTriStateDisabled = 0, ///< disabled
346  KuonTriStateLow = 0, ///< low
347  KuonTriStateOpen = 0, ///< open
348  KuonTriStateDark = 0, ///< dark
349 
350  // high state synonyms
351  KuonTriStateTrue = 1, ///< true
352  KuonTriStateOn = 1, ///< on
353  KuonTriStateEnabled = 1, ///< enabled
354  KuonTriStateHigh = 1, ///< high
355  KuonTriStateClosed = 1, ///< closed
356  KuonTriStateLight = 1 ///< light
357  };
358 
359  /*!
360  * \brief \h_kuon mode of operation.
361  *
362  * Robot mode of operation.
363  */
365  {
366  KuonRobotModeUnknown = -1, ///< unknown mode state
367  KuonRobotModeManual = 1, ///< can only be operated locally, not remotely
368  KuonRobotModeAuto = 2 ///< fully available
369  };
370 
371  /*!
372  * \brief Asynchronous task state.
373  */
375  {
376  KuonAsyncTaskStateIdle = 0, ///< idle, no async task running
377  KuonAsyncTaskStateWorking = 1 ///< async task running
378  };
379 
380  /*! \} */
381 
382 
383 #ifndef SWIG
384 } // namespace kuon
385 #endif // SWIG
386 
387 
388 #endif // _KUON_H
static const int KUON_ECODE_NO_RSRC
no resource available error
Definition: kuon.h:92
static const int KuonMotorIdLR
left rear
Definition: kuon.h:304
static const int KuonMotorIdLF
left front
Definition: kuon.h:302
static const int KUON_ECODE_COLLISION
robot link(s) in collision
Definition: kuon.h:105
const char *const KuonXsiUrl
xml schema instance url
Definition: kuon.h:248
const char *const KuonImageDir
image directory
Definition: kuon.h:207
static const int KUON_ALARM_NONE
no alarms
Definition: kuon.h:120
static const int KUON_OK
not an error, success
Definition: kuon.h:80
static const int KUON_ECODE_RANGE
value out-of-range
Definition: kuon.h:88
static const int KuonMotorIdRR
right rear
Definition: kuon.h:305
const char *const KuonDevMotorCtlr1
motor controller 1 device name
Definition: kuon.h:271
idle, no async task running
Definition: kuon.h:376
static const int KUON_ECODE_BUSY
resource busy error
Definition: kuon.h:93
static const int KUON_ECODE_FORMAT
bad format
Definition: kuon.h:99
KuonAsyncTaskState
Asynchronous task state.
Definition: kuon.h:374
static const int KUON_ALARM_VOLTAGE
under/over voltage
Definition: kuon.h:121
static const int KUON_ECODE_XML
XML error.
Definition: kuon.h:102
static const int KUON_ECODE_BAD_VAL
bad value general error
Definition: kuon.h:85
static const int KuonProdIdUnknown
unknown/undefined product id
Definition: kuon.h:144
static const int KUON_ECODE_NO_EXEC
cannot execute error
Definition: kuon.h:94
KuonTriState
<b><i>Kuon</i></b> tri-state type.
Definition: kuon.h:337
The <b><i>Kuon</i></b> namespace encapsulates all <b><i>Kuon</i></b> related constructs.
Definition: kuon.h:66
const char *const KuonProdModelNarrow
narrow model
Definition: kuon.h:149
unknown mode state
Definition: kuon.h:366
async task running
Definition: kuon.h:377
static const int KUON_ECODE_INTERNAL
internal error (bug)
Definition: kuon.h:84
static const int KUON_ECODE_PERM
no permissions error
Definition: kuon.h:95
static const int KUON_ALARM_COMM
communication
Definition: kuon.h:123
static const int KUON_ECODE_NO_DEV
device not found error
Definition: kuon.h:91
can only be operated locally, not remotely
Definition: kuon.h:367
static const int KUON_ECODE_TIMEDOUT
operation timed out error
Definition: kuon.h:90
static const int KUON_ECODE_SYS
system (errno) error
Definition: kuon.h:83
KuonRobotMode
<b><i>Kuon</i></b> mode of operation.
Definition: kuon.h:364
static const int KUON_ECODE_TOO_BIG
value/list/size too big
Definition: kuon.h:86
static const int KUON_ECODE_BADEC
bad error code
Definition: kuon.h:108
static const int KuonMotorIdNone
no motor id
Definition: kuon.h:301
static const int KUON_ECODE_GEN
general, unspecified error
Definition: kuon.h:82
const int KuonBaudRateMotorCtlr
motor controllers baud rate
Definition: kuon.h:282
static const int KuonMotorDirUnknown
unknown
Definition: kuon.h:313
static const int KUON_ALARM_TEMP
under/over temperature
Definition: kuon.h:122
const char *const KuonXslUrl
xml configuration file
Definition: kuon.h:237
static const int KUON_ECODE_TOO_SMALL
value/list/size too small
Definition: kuon.h:87
static const int KUON_ECODE_MOT_CTLR
motor controller error
Definition: kuon.h:97
const char *const KuonDevMotorCtlr0
motor controller 0 device name
Definition: kuon.h:260
const char *const KuonProdModelStd
standard model
Definition: kuon.h:148
static const int KUON_ECODE_BATT
battery error
Definition: kuon.h:98
static const int KuonMotorCtlrIdNone
no motor controller id
Definition: kuon.h:308
static const int KUON_ECODE_ALARMED
robot is alarmed
Definition: kuon.h:103
static const int KuonProdIdNarrow
narrow Kuon product id
Definition: kuon.h:146
static const int KUON_ECODE_NUMOF
number of error codes
Definition: kuon.h:110
static const int KUON_ECODE_MOTOR
motor error
Definition: kuon.h:96
static const int KUON_ECODE_NO_FILE
file not found
Definition: kuon.h:101
static const int KUON_ECODE_ESTOP
robot emergency stopped
Definition: kuon.h:106
static const int KUON_ECODE_BOTSENSE
botsense error
Definition: kuon.h:100
unknown state
Definition: kuon.h:340
static const int KuonMotorCtlrId0
motor controller id 0
Definition: kuon.h:309
static const int KUON_ECODE_INTR
operation interrupted
Definition: kuon.h:104
static const int KuonProdIdStd
standard Kuon product id
Definition: kuon.h:145
static const int KUON_ECODE_BAD_OP
invalid operation error
Definition: kuon.h:89
static const int KuonMotorIdRF
right front
Definition: kuon.h:303
static const int KuonMotorCtlrId1
motor controller id 1
Definition: kuon.h:310
static const int KuonMotorDirCcw
counter-clockwise
Definition: kuon.h:314
const char *const KuonIconDir
icon directory
Definition: kuon.h:217
const char *const KuonProdFamily
product family name
Definition: kuon.h:142
static const int KuonMotorDirCw
clockwise
Definition: kuon.h:315
fully available
Definition: kuon.h:368