Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
71597d95
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,体验更适合开发者的 AI 搜索 >>
提交
71597d95
编写于
10月 18, 2018
作者:
D
dengchengliang
提交者:
Jiangtao Hu
12月 13, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Drivers: add gnss parser cli tool
上级
e8846b4b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
33 addition
and
133 deletion
+33
-133
modules/drivers/gnss/test/BUILD
modules/drivers/gnss/test/BUILD
+1
-14
modules/drivers/gnss/test/parser_cli.cc
modules/drivers/gnss/test/parser_cli.cc
+32
-17
modules/drivers/gnss/test/test_monitor.cc
modules/drivers/gnss/test/test_monitor.cc
+0
-102
未找到文件。
modules/drivers/gnss/test/BUILD
.test
→
modules/drivers/gnss/test/BUILD
浏览文件 @
71597d95
...
...
@@ -2,26 +2,13 @@ load("//tools:cpplint.bzl", "cpplint")
package
(
default_visibility
=
[
"//visibility:public"
])
cc_binary
(
name
=
"parser_cli"
,
srcs
=
[
"parser_cli.cc"
],
deps
=
[
"//modules/drivers/gnss/stream:gnss_stream"
,
"//external:gflags"
,
"//modules/common"
,
"@ros//:ros_common"
,
],
)
cc_binary
(
name
=
"test_monitor"
,
srcs
=
[
"test_monitor.cc"
],
deps
=
[
"//modules/drivers/gnss/stream:gnss_stream"
,
"//external:gflags"
,
"//framework:cybertron"
,
"//cybertron"
,
"@ros//:ros_common"
,
],
)
...
...
modules/drivers/gnss/test/parser_cli.cc
浏览文件 @
71597d95
/******************************************************************************
* Copyright 201
7
The Apollo Authors. All Rights Reserved.
* Copyright 201
8
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.
...
...
@@ -23,14 +23,16 @@
#include <iostream>
#include <memory>
#include "
modules/common/adapters/adapter_manager
.h"
#include "
modules/common/util/file
.h"
#include "modules/drivers/gnss/gnss_gflags.h"
#include "
cybertron/cybertron
.h"
#include "
cybertron/record/record_reader
.h"
#include "modules/drivers/gnss/parser/data_parser.h"
#include "modules/drivers/gnss/proto/config.pb.h"
#include "modules/drivers/gnss/stream/stream.h"
#include "ros/include/rosbag/bag.h"
#include "ros/include/rosbag/view.h"
#include "ros/include/std_msgs/String.h"
namespace
apollo
{
namespace
drivers
{
...
...
@@ -44,8 +46,7 @@ void ParseBin(const char* filename, DataParser* parser) {
char
b
[
BUFFER_SIZE
];
while
(
f
)
{
f
.
read
(
b
,
BUFFER_SIZE
);
std_msgs
::
StringPtr
msg
(
new
std_msgs
::
String
);
msg
->
data
.
assign
(
reinterpret_cast
<
const
char
*>
(
b
),
f
.
gcount
());
std
::
string
msg
(
reinterpret_cast
<
const
char
*>
(
b
),
f
.
gcount
());
parser
->
ParseRawData
(
msg
);
}
}
...
...
@@ -59,26 +60,42 @@ void ParseBag(const char* filename, DataParser* parser) {
for
(
auto
const
m
:
view
)
{
std_msgs
::
String
::
ConstPtr
msg
=
m
.
instantiate
<
std_msgs
::
String
>
();
if
(
msg
!=
nullptr
)
{
parser
->
ParseRawData
(
msg
);
parser
->
ParseRawData
(
msg
->
data
);
}
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
2
));
}
}
void
ParseRecord
(
const
char
*
filename
,
DataParser
*
parser
)
{
cybertron
::
record
::
RecordReader
reader
(
filename
);
cybertron
::
record
::
RecordMessage
message
;
while
(
reader
.
ReadMessage
(
&
message
))
{
if
(
message
.
channel_name
==
"/apollo/sensor/gnss/raw_data"
)
{
apollo
::
drivers
::
gnss
::
RawData
msg
;
msg
.
ParseFromString
(
message
.
content
);
parser
->
ParseRawData
(
msg
.
data
());
}
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
2
));
}
}
void
Parse
(
const
char
*
filename
,
const
char
*
file_type
)
{
void
Parse
(
const
char
*
filename
,
const
char
*
file_type
,
const
std
::
shared_ptr
<::
apollo
::
cybertron
::
Node
>&
node
)
{
std
::
string
type
=
std
::
string
(
file_type
);
config
::
Config
config
;
if
(
!
common
::
util
::
GetProtoFromFile
(
if
(
!
apollo
::
cybertron
::
common
::
GetProtoFromFile
(
std
::
string
(
"/apollo/modules/drivers/gnss/conf/gnss_conf.pb.txt"
),
&
config
))
{
std
::
cout
<<
"Unable to load gnss conf file"
;
}
DataParser
*
parser
=
new
DataParser
(
config
);
DataParser
*
parser
=
new
DataParser
(
config
,
node
);
parser
->
Init
();
if
(
type
==
"bag"
)
{
ParseBag
(
filename
,
parser
);
}
else
if
(
type
==
"bin"
)
{
ParseBin
(
filename
,
parser
);
}
else
if
(
type
==
"record"
)
{
ParseRecord
(
filename
,
parser
);
}
else
{
std
::
cout
<<
"unknown file type"
;
}
...
...
@@ -91,14 +108,12 @@ void Parse(const char* filename, const char* file_type) {
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
<
3
)
{
std
::
cout
<<
"Usage: "
<<
argv
[
0
]
<<
" filename [
bag
|bin]"
<<
std
::
endl
;
std
::
cout
<<
"Usage: "
<<
argv
[
0
]
<<
" filename [
record
|bin]"
<<
std
::
endl
;
return
0
;
}
ros
::
init
(
argc
,
argv
,
"parser_cli"
);
ros
::
Time
::
init
();
ros
::
Time
::
now
();
apollo
::
common
::
adapter
::
AdapterManager
::
Init
(
FLAGS_adapter_config_filename
);
::
apollo
::
drivers
::
gnss
::
Parse
(
argv
[
1
],
argv
[
2
]);
::
apollo
::
cybertron
::
Init
(
"parser_cli"
);
std
::
shared_ptr
<::
apollo
::
cybertron
::
Node
>
parser_node
(
::
apollo
::
cybertron
::
CreateNode
(
"parser_cli"
));
::
apollo
::
drivers
::
gnss
::
Parse
(
argv
[
1
],
argv
[
2
],
parser_node
);
return
0
;
}
modules/drivers/gnss/test/test_monitor.cc
已删除
100644 → 0
浏览文件 @
e8846b4b
/******************************************************************************
* 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.
*****************************************************************************/
#include <ros/ros.h>
#include <std_msgs/String.h>
#include <cmath>
#include <memory>
#include "modules/drivers/gnss/proto/gnss_status.pb.h"
#include "modules/drivers/gnss/proto/ins.pb.h"
void
ins_status_callback
(
const
apollo
::
drivers
::
gnss_status
::
InsStatus
&
ins_status
)
{
switch
(
ins_status
.
type
())
{
case
apollo
::
drivers
::
gnss_status
::
InsStatus
::
GOOD
:
fprintf
(
stdout
,
"INS status is GOOD.
\r\n
"
);
break
;
case
apollo
::
drivers
::
gnss_status
::
InsStatus
::
CONVERGING
:
fprintf
(
stdout
,
"INS status is CONVERGING.
\r\n
"
);
break
;
case
apollo
::
drivers
::
gnss_status
::
InsStatus
::
INVALID
:
default:
fprintf
(
stdout
,
"INS status is INVALID.
\r\n
"
);
break
;
}
}
void
ins_stat_callback
(
const
::
apollo
::
drivers
::
gnss
::
InsStat
&
ins_stat
)
{
// std::cout << "INS stat: " << ins_stat.DebugString() << std::endl;
}
void
stream_status_callback
(
const
apollo
::
drivers
::
gnss_status
::
StreamStatus
&
stream_status
)
{
switch
(
stream_status
.
ins_stream_type
())
{
case
apollo
::
drivers
::
gnss_status
::
StreamStatus
::
CONNECTED
:
fprintf
(
stdout
,
"INS stream is CONNECTED.
\r\n
"
);
break
;
case
apollo
::
drivers
::
gnss_status
::
StreamStatus
::
DISCONNECTED
:
fprintf
(
stdout
,
"INS stream is DISCONNECTED.
\r\n
"
);
break
;
}
switch
(
stream_status
.
rtk_stream_in_type
())
{
case
apollo
::
drivers
::
gnss_status
::
StreamStatus
::
CONNECTED
:
fprintf
(
stdout
,
"rtk stream in is CONNECTED.
\r\n
"
);
break
;
case
apollo
::
drivers
::
gnss_status
::
StreamStatus
::
DISCONNECTED
:
fprintf
(
stdout
,
"rtk stream in is DISCONNECTED.
\r\n
"
);
break
;
}
switch
(
stream_status
.
rtk_stream_out_type
())
{
case
apollo
::
drivers
::
gnss_status
::
StreamStatus
::
CONNECTED
:
fprintf
(
stdout
,
"rtk stream out CONNECTED.
\r\n
"
);
break
;
case
apollo
::
drivers
::
gnss_status
::
StreamStatus
::
DISCONNECTED
:
fprintf
(
stdout
,
"rtk stream out DISCONNECTED.
\r\n
"
);
break
;
}
}
void
gnss_status_callback
(
const
apollo
::
drivers
::
gnss_status
::
GnssStatus
&
gnss_status
)
{
// std::cout << "GNSS status: " << gnss_status.DebugString() << std::endl;
}
int
main
(
int
argc
,
char
*
argv
[])
{
ros
::
init
(
argc
,
argv
,
std
::
string
(
"gnss_monitor_test"
));
ros
::
NodeHandle
nh
;
ros
::
Subscriber
ins_status_sub
;
ros
::
Subscriber
gnss_status_sub
;
ros
::
Subscriber
stream_status_sub
;
ros
::
Subscriber
ins_stat_sub
;
ins_status_sub
=
nh
.
subscribe
(
"/apollo/sensor/gnss/ins_status"
,
16
,
ins_status_callback
);
gnss_status_sub
=
nh
.
subscribe
(
"/apollo/sensor/gnss/gnss_status"
,
16
,
gnss_status_callback
);
stream_status_sub
=
nh
.
subscribe
(
"/apollo/sensor/gnss/stream_status"
,
16
,
stream_status_callback
);
ins_stat_sub
=
nh
.
subscribe
(
"/apollo/sensor/gnss/ins_stat"
,
16
,
ins_stat_callback
);
ros
::
spin
();
ROS_ERROR
(
"Exit"
);
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录