Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
b34dd0c7
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,发现更多精彩内容 >>
提交
b34dd0c7
编写于
12月 29, 2017
作者:
Y
yangkairui
提交者:
Dong Li
12月 29, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tools: added realtime acc test (#2227)
上级
d9c70d20
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
99 addition
and
0 deletion
+99
-0
modules/tools/plot_control/realtime_test.py
modules/tools/plot_control/realtime_test.py
+99
-0
未找到文件。
modules/tools/plot_control/realtime_test.py
0 → 100644
浏览文件 @
b34dd0c7
#!/usr/bin/env python
###############################################################################
# Copyright 2017 The Apollo Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
###############################################################################
"""Real Time ACC Calculate Test Tool Based on Speed"""
import
argparse
import
rospy
import
sys
import
os
import
datetime
from
modules.localization.proto
import
localization_pb2
from
modules.canbus.proto
import
chassis_pb2
SmoothParam
=
9
class
RealTimeTest
(
object
):
def
__init__
(
self
):
self
.
last_t
=
None
self
.
last_speed
=
None
self
.
last_acc
=
None
self
.
acc
=
None
self
.
accs
=
[]
self
.
buff
=
[]
self
.
count
=
0
self
.
acclimit
=
0
def
chassis_callback
(
self
,
chassis_pb2
):
"""Calculate ACC from Chassis Speed"""
speedmps
=
chassis_pb2
.
speed_mps
t
=
chassis_pb2
.
header
.
timestamp_sec
speedkmh
=
speedmps
*
3.6
self
.
buff
.
append
(
speedmps
)
if
len
(
self
.
buff
)
<
SmoothParam
:
return
if
self
.
last_t
is
not
None
:
self
.
count
+=
1
deltt
=
t
-
self
.
last_t
deltv
=
sum
(
self
.
buff
)
/
len
(
self
.
buff
)
-
self
.
last_speed
if
deltt
<=
1e-10
:
deltt
=
0.000000000001
print
"delt=0 "
,
t
,
","
,
self
.
last_t
self
.
acc
=
deltv
/
deltt
self
.
accs
.
append
(
self
.
acc
)
if
abs
(
self
.
acc
)
>
self
.
acclimit
:
print
t
,
"
\t
"
,
(
sum
(
self
.
buff
)
/
len
(
self
.
buff
))
*
3.6
,
"
\t
"
,
\
self
.
acc
,
"
\t
"
,
self
.
count
,
"
\t
"
,
self
.
acclimit
self
.
last_acc
=
self
.
acc
self
.
last_t
=
t
self
.
last_speed
=
sum
(
self
.
buff
)
/
len
(
self
.
buff
)
self
.
buff
=
[]
def
main
(
argv
):
"""Main function"""
parser
=
argparse
.
ArgumentParser
(
description
=
"Test car realtime status."
,
prog
=
"RealTimeTest.py"
)
parser
.
add_argument
(
"--acc"
,
type
=
int
,
required
=
False
,
default
=
2
,
help
=
"Acc limit default must > 0"
)
args
=
parser
.
parse_args
()
if
args
.
acc
<
0
:
print
"acc must >0"
return
rttest
=
RealTimeTest
()
rttest
.
acclimit
=
args
.
acc
rospy
.
init_node
(
'RealTimeTest'
,
anonymous
=
True
)
rospy
.
Subscriber
(
'/apollo/canbus/chassis'
,
chassis_pb2
.
Chassis
,
rttest
.
chassis_callback
)
rospy
.
spin
()
if
__name__
==
'__main__'
:
main
(
sys
.
argv
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录