Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
src
mavros
__init__.py
Go to the documentation of this file.
1
# -*- coding: utf-8 -*-
2
# vim:set ts=4 sw=4 et:
3
4
__all__ = (
5
'get_namespace'
,
6
'set_namespace'
,
7
'get_topic'
,
8
'DEFAULT_NAMESPACE'
9
)
10
11
DEFAULT_NAMESPACE =
'mavros'
12
13
# global namespace storage
14
_mavros_ns =
None
15
_mavros_ns_update = []
16
17
18
def
get_namespace
():
19
"""
20
Returns mavros node namespace
21
"""
22
global
_mavros_ns
23
if
_mavros_ns
is
None
:
24
raise
RuntimeError(
"mavros namespace is uninitialized! "
25
"Call mavros.set_namespace() first!"
)
26
return
_mavros_ns
27
28
29
def
set_namespace
(ns=DEFAULT_NAMESPACE):
30
"""
31
Sets namespace of mavros node
32
"""
33
global
_mavros_ns, _mavros_ns_update
34
_mavros_ns = ns
35
36
for
cb
in
_mavros_ns_update:
37
if
callable(cb):
38
cb()
39
40
41
def
register_on_namespace_update
(cb):
42
"""
43
Call callback after namespace update
44
"""
45
global
_mavros_ns_update
46
_mavros_ns_update.append(cb)
47
48
49
def
get_topic
(*args):
50
"""
51
Create topic name for mavros node
52
"""
53
return
'/'
+
'/'
.join((
get_namespace
(), ) + args)
mavros.get_topic
def get_topic(args)
Definition:
__init__.py:49
mavros.register_on_namespace_update
def register_on_namespace_update(cb)
Definition:
__init__.py:41
mavros.get_namespace
def get_namespace()
Definition:
__init__.py:18
mavros.set_namespace
def set_namespace(ns=DEFAULT_NAMESPACE)
Definition:
__init__.py:29
mavros
Author(s): Vladimir Ermakov
autogenerated on Mon Jul 8 2019 03:20:10