Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
3689e36f
A
apollo
项目概览
Pinoxchio
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3689e36f
编写于
9月 21, 2018
作者:
Y
yaoweifeng01
提交者:
Zhongjun Ni
9月 22, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
framework:1.fix record time error 2.add qosdepth param
上级
bdfb088f
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
30 addition
and
19 deletion
+30
-19
framework/python/cybertron/cybertron.py
framework/python/cybertron/cybertron.py
+3
-2
framework/python/examples/talker.py
framework/python/examples/talker.py
+1
-1
framework/python/test/test_node.py
framework/python/test/test_node.py
+1
-1
framework/python/wrapper/cyber_node_wrap.cpp
framework/python/wrapper/cyber_node_wrap.cpp
+12
-9
framework/python/wrapper/cyber_record_wrap.cpp
framework/python/wrapper/cyber_record_wrap.cpp
+1
-1
framework/python/wrapper/py_node.h
framework/python/wrapper/py_node.h
+11
-4
framework/python/wrapper/test/test_node.cpp
framework/python/wrapper/test/test_node.cpp
+1
-1
未找到文件。
framework/python/cybertron/cybertron.py
浏览文件 @
3689e36f
...
...
@@ -173,7 +173,7 @@ class Node(object):
desc_str
=
proto
.
SerializeToString
()
_CYBER_NODE
.
PyNode_register_message
(
self
.
node
,
desc_str
)
def
create_writer
(
self
,
name
,
data_type
):
def
create_writer
(
self
,
name
,
data_type
,
qos_depth
=
1
):
"""
create a topic writer for send message to topic.
@param self
...
...
@@ -182,7 +182,8 @@ class Node(object):
"""
self
.
register_message
(
data_type
.
DESCRIPTOR
.
file
)
datatype
=
data_type
.
DESCRIPTOR
.
full_name
writer
=
_CYBER_NODE
.
PyNode_create_writer
(
self
.
node
,
name
,
datatype
)
writer
=
_CYBER_NODE
.
PyNode_create_writer
(
self
.
node
,
name
,
datatype
,
qos_depth
)
self
.
list_writer
.
append
(
writer
)
return
Writer
(
name
,
writer
,
datatype
)
...
...
framework/python/examples/talker.py
浏览文件 @
3689e36f
...
...
@@ -37,7 +37,7 @@ def test_talker_class():
g_count
=
1
writer
=
test_node
.
create_writer
(
"channel/chatter"
,
chatter_pb2
.
Chatter
)
chatter_pb2
.
Chatter
,
6
)
while
not
cybertron
.
is_shutdown
():
time
.
sleep
(
1
)
g_count
=
g_count
+
1
...
...
framework/python/test/test_node.py
浏览文件 @
3689e36f
...
...
@@ -56,7 +56,7 @@ class TestNode(unittest.TestCase):
self
.
assertTrue
(
cybertron
.
ok
())
test_node
=
cybertron
.
Node
(
"node_name1"
)
writer
=
test_node
.
create_writer
(
"channel/chatter"
,
chatter_pb2
.
Chatter
)
writer
=
test_node
.
create_writer
(
"channel/chatter"
,
chatter_pb2
.
Chatter
,
7
)
self
.
assertEqual
(
writer
.
name
,
"channel/chatter"
)
self
.
assertEqual
(
writer
.
data_type
,
"apollo.cybertron.proto.Chatter"
)
self
.
assertTrue
(
writer
.
write
(
msg
))
...
...
framework/python/wrapper/cyber_node_wrap.cpp
浏览文件 @
3689e36f
...
...
@@ -61,11 +61,12 @@ T PyObjectToPtr(PyObject *pyobj, const std::string &type_ptr) {
PyObject
*
cyber_new_PyWriter
(
PyObject
*
self
,
PyObject
*
args
)
{
char
*
channel_name
=
nullptr
;
char
*
data_type
=
nullptr
;
uint32_t
qos_depth
=
1
;
apollo
::
cybertron
::
Node
*
node
=
nullptr
;
PyObject
*
node_pyobj
=
nullptr
;
if
(
!
PyArg_ParseTuple
(
args
,
const_cast
<
char
*>
(
"ssO:new_PyWriter"
),
&
channel_name
,
&
data_type
,
&
node_pyobj
))
{
if
(
!
PyArg_ParseTuple
(
args
,
const_cast
<
char
*>
(
"ss
I
O:new_PyWriter"
),
&
channel_name
,
&
data_type
,
&
qos_depth
,
&
node_pyobj
))
{
return
Py_None
;
}
...
...
@@ -76,9 +77,9 @@ PyObject *cyber_new_PyWriter(PyObject *self, PyObject *args) {
return
Py_None
;
}
apollo
::
cybertron
::
PyWriter
*
writer
=
new
apollo
::
cybertron
::
PyWriter
((
std
::
string
const
&
)
*
channel_nam
e
,
(
std
::
string
const
&
)
*
data_type
,
node
);
apollo
::
cybertron
::
PyWriter
*
writer
=
new
apollo
::
cybertron
::
PyWriter
(
(
std
::
string
const
&
)
*
channel_name
,
(
std
::
string
const
&
)
*
data_typ
e
,
qos_depth
,
node
);
PyObject
*
pyobj_writer
=
PyCapsule_New
(
writer
,
"apollo_cybertron_pywriter"
,
NULL
);
return
pyobj_writer
;
...
...
@@ -419,12 +420,13 @@ PyObject *cyber_delete_PyNode(PyObject *self, PyObject *args) {
}
PyObject
*
cyber_PyNode_create_writer
(
PyObject
*
self
,
PyObject
*
args
)
{
PyObject
*
pyobj_node
=
nullptr
;
char
*
channel_name
=
nullptr
;
char
*
type_name
=
nullptr
;
PyObject
*
pyobj_node
=
nullptr
;
int
qos_depth
=
1
;
if
(
!
PyArg_ParseTuple
(
args
,
const_cast
<
char
*>
(
"Oss:PyNode_create_writer"
),
&
pyobj_node
,
&
channel_name
,
&
type_name
))
{
if
(
!
PyArg_ParseTuple
(
args
,
const_cast
<
char
*>
(
"Oss
I
:PyNode_create_writer"
),
&
pyobj_node
,
&
channel_name
,
&
type_name
,
&
qos_depth
))
{
AINFO
<<
"cyber_PyNode_create_writer:PyArg_ParseTuple failed!"
;
return
Py_None
;
}
...
...
@@ -438,7 +440,8 @@ PyObject *cyber_PyNode_create_writer(PyObject *self, PyObject *args) {
apollo
::
cybertron
::
PyWriter
*
writer
=
(
apollo
::
cybertron
::
PyWriter
*
)(
node
->
create_writer
(
(
std
::
string
const
&
)
channel_name
,
(
std
::
string
const
&
)
type_name
));
(
std
::
string
const
&
)
channel_name
,
(
std
::
string
const
&
)
type_name
,
qos_depth
));
PyObject
*
pyobj_writer
=
PyCapsule_New
(
writer
,
"apollo_cybertron_pywriter"
,
NULL
);
...
...
framework/python/wrapper/cyber_record_wrap.cpp
浏览文件 @
3689e36f
...
...
@@ -405,7 +405,7 @@ PyObject *cyber_PyRecordWriter_WriteMessage(PyObject *self, PyObject *args) {
Py_ssize_t
len
=
0
;
uint64_t
time
=
0
;
if
(
!
PyArg_ParseTuple
(
args
,
const_cast
<
char
*>
(
"Oss#
i
:cyber_PyRecordWriter_WriteMessage"
),
args
,
const_cast
<
char
*>
(
"Oss#
K
:cyber_PyRecordWriter_WriteMessage"
),
&
pyobj_rec_writer
,
&
channel_name
,
&
rawmessage
,
&
len
,
&
time
))
{
AINFO
<<
"cyber_PyRecordWriter_WriteMessage parsetuple failed!"
;
Py_RETURN_FALSE
;
...
...
framework/python/wrapper/py_node.h
浏览文件 @
3689e36f
...
...
@@ -63,8 +63,11 @@ bool py_OK() { return apollo::cybertron::OK(); }
class
PyWriter
{
public:
PyWriter
(
const
std
::
string
&
channel
,
const
std
::
string
&
type
,
apollo
::
cybertron
::
Node
*
node
)
:
channel_name_
(
channel
),
data_type_
(
type
),
node_
(
node
)
{
uint32_t
qos_depth
,
apollo
::
cybertron
::
Node
*
node
)
:
channel_name_
(
channel
),
data_type_
(
type
),
qos_depth_
(
qos_depth
),
node_
(
node
)
{
std
::
string
proto_desc
(
""
);
message
::
ProtobufFactory
::
Instance
()
->
GetDescriptorString
(
type
,
&
proto_desc
);
...
...
@@ -76,6 +79,8 @@ class PyWriter {
role_attr
.
set_channel_name
(
channel_name_
);
role_attr
.
set_message_type
(
data_type_
);
role_attr
.
set_proto_desc
(
proto_desc
);
auto
qos_profile
=
role_attr
.
mutable_qos_profile
();
qos_profile
->
set_depth
(
qos_depth_
);
writer_
=
node_
->
CreateWriter
<
apollo
::
cybertron
::
message
::
PyMessageWrap
>
(
role_attr
);
}
...
...
@@ -93,6 +98,7 @@ class PyWriter {
apollo
::
cybertron
::
Node
*
node_
;
std
::
string
channel_name_
;
std
::
string
data_type_
;
uint32_t
qos_depth_
;
std
::
shared_ptr
<
apollo
::
cybertron
::
Writer
<
apollo
::
cybertron
::
message
::
PyMessageWrap
>>
writer_
;
...
...
@@ -282,9 +288,10 @@ class PyNode {
AINFO
<<
"PyNode "
<<
node_name_
<<
" exit."
;
}
PyWriter
*
create_writer
(
const
std
::
string
&
channel
,
const
std
::
string
&
type
)
{
PyWriter
*
create_writer
(
const
std
::
string
&
channel
,
const
std
::
string
&
type
,
uint32_t
qos_depth
=
1
)
{
if
(
node_
)
{
return
new
PyWriter
(
channel
,
type
,
node_
.
get
());
return
new
PyWriter
(
channel
,
type
,
qos_depth
,
node_
.
get
());
}
AINFO
<<
"Py_Node: node_ is null, new PyWriter failed!"
;
return
nullptr
;
...
...
framework/python/wrapper/test/test_node.cpp
浏览文件 @
3689e36f
...
...
@@ -50,7 +50,7 @@ TEST(CyberNodeTest, create_writer) {
auto
msgChat
=
std
::
make_shared
<
apollo
::
cybertron
::
proto
::
Chatter
>
();
apollo
::
cybertron
::
PyNode
node
(
"talker"
);
apollo
::
cybertron
::
PyWriter
*
pw
=
node
.
create_writer
(
"channel/chatter"
,
msgChat
->
GetTypeName
());
node
.
create_writer
(
"channel/chatter"
,
msgChat
->
GetTypeName
()
,
10
);
EXPECT_TRUE
(
pw
!=
nullptr
);
EXPECT_TRUE
(
apollo
::
cybertron
::
OK
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录