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,发现更多精彩内容 >>
提交
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")
...
@@ -2,26 +2,13 @@ load("//tools:cpplint.bzl", "cpplint")
package
(
default_visibility
=
[
"//visibility:public"
])
package
(
default_visibility
=
[
"//visibility:public"
])
cc_binary
(
cc_binary
(
name
=
"parser_cli"
,
name
=
"parser_cli"
,
srcs
=
[
"parser_cli.cc"
],
srcs
=
[
"parser_cli.cc"
],
deps
=
[
deps
=
[
"//modules/drivers/gnss/stream:gnss_stream"
,
"//modules/drivers/gnss/stream:gnss_stream"
,
"//external:gflags"
,
"//external:gflags"
,
"//modules/common"
,
"//cybertron"
,
"@ros//:ros_common"
,
],
)
cc_binary
(
name
=
"test_monitor"
,
srcs
=
[
"test_monitor.cc"
],
deps
=
[
"//modules/drivers/gnss/stream:gnss_stream"
,
"//external:gflags"
,
"//framework:cybertron"
,
"@ros//:ros_common"
,
"@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");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -23,14 +23,16 @@
...
@@ -23,14 +23,16 @@
#include <iostream>
#include <iostream>
#include <memory>
#include <memory>
#include "
modules/common/adapters/adapter_manager
.h"
#include "
cybertron/cybertron
.h"
#include "
modules/common/util/file
.h"
#include "
cybertron/record/record_reader
.h"
#include "modules/drivers/gnss/gnss_gflags.h"
#include "modules/drivers/gnss/parser/data_parser.h"
#include "modules/drivers/gnss/parser/data_parser.h"
#include "modules/drivers/gnss/proto/config.pb.h"
#include "modules/drivers/gnss/proto/config.pb.h"
#include "modules/drivers/gnss/stream/stream.h"
#include "modules/drivers/gnss/stream/stream.h"
#include "ros/include/rosbag/bag.h"
#include "ros/include/rosbag/bag.h"
#include "ros/include/rosbag/view.h"
#include "ros/include/rosbag/view.h"
#include "ros/include/std_msgs/String.h"
namespace
apollo
{
namespace
apollo
{
namespace
drivers
{
namespace
drivers
{
...
@@ -44,8 +46,7 @@ void ParseBin(const char* filename, DataParser* parser) {
...
@@ -44,8 +46,7 @@ void ParseBin(const char* filename, DataParser* parser) {
char
b
[
BUFFER_SIZE
];
char
b
[
BUFFER_SIZE
];
while
(
f
)
{
while
(
f
)
{
f
.
read
(
b
,
BUFFER_SIZE
);
f
.
read
(
b
,
BUFFER_SIZE
);
std_msgs
::
StringPtr
msg
(
new
std_msgs
::
String
);
std
::
string
msg
(
reinterpret_cast
<
const
char
*>
(
b
),
f
.
gcount
());
msg
->
data
.
assign
(
reinterpret_cast
<
const
char
*>
(
b
),
f
.
gcount
());
parser
->
ParseRawData
(
msg
);
parser
->
ParseRawData
(
msg
);
}
}
}
}
...
@@ -59,26 +60,42 @@ void ParseBag(const char* filename, DataParser* parser) {
...
@@ -59,26 +60,42 @@ void ParseBag(const char* filename, DataParser* parser) {
for
(
auto
const
m
:
view
)
{
for
(
auto
const
m
:
view
)
{
std_msgs
::
String
::
ConstPtr
msg
=
m
.
instantiate
<
std_msgs
::
String
>
();
std_msgs
::
String
::
ConstPtr
msg
=
m
.
instantiate
<
std_msgs
::
String
>
();
if
(
msg
!=
nullptr
)
{
if
(
msg
!=
nullptr
)
{
parser
->
ParseRawData
(
msg
);
parser
->
ParseRawData
(
msg
->
data
);
}
}
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
2
));
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
2
));
}
}
}
}
void
Parse
(
const
char
*
filename
,
const
char
*
file_type
)
{
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
,
const
std
::
shared_ptr
<::
apollo
::
cybertron
::
Node
>&
node
)
{
std
::
string
type
=
std
::
string
(
file_type
);
std
::
string
type
=
std
::
string
(
file_type
);
config
::
Config
config
;
config
::
Config
config
;
if
(
!
common
::
util
::
GetProtoFromFile
(
if
(
!
apollo
::
cybertron
::
common
::
GetProtoFromFile
(
std
::
string
(
"/apollo/modules/drivers/gnss/conf/gnss_conf.pb.txt"
),
std
::
string
(
"/apollo/modules/drivers/gnss/conf/gnss_conf.pb.txt"
),
&
config
))
{
&
config
))
{
std
::
cout
<<
"Unable to load gnss conf file"
;
std
::
cout
<<
"Unable to load gnss conf file"
;
}
}
DataParser
*
parser
=
new
DataParser
(
config
);
DataParser
*
parser
=
new
DataParser
(
config
,
node
);
parser
->
Init
();
parser
->
Init
();
if
(
type
==
"bag"
)
{
if
(
type
==
"bag"
)
{
ParseBag
(
filename
,
parser
);
ParseBag
(
filename
,
parser
);
}
else
if
(
type
==
"bin"
)
{
}
else
if
(
type
==
"bin"
)
{
ParseBin
(
filename
,
parser
);
ParseBin
(
filename
,
parser
);
}
else
if
(
type
==
"record"
)
{
ParseRecord
(
filename
,
parser
);
}
else
{
}
else
{
std
::
cout
<<
"unknown file type"
;
std
::
cout
<<
"unknown file type"
;
}
}
...
@@ -91,14 +108,12 @@ void Parse(const char* filename, const char* file_type) {
...
@@ -91,14 +108,12 @@ void Parse(const char* filename, const char* file_type) {
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
<
3
)
{
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
;
return
0
;
}
}
::
apollo
::
cybertron
::
Init
(
"parser_cli"
);
ros
::
init
(
argc
,
argv
,
"parser_cli"
);
std
::
shared_ptr
<::
apollo
::
cybertron
::
Node
>
parser_node
(
ros
::
Time
::
init
();
::
apollo
::
cybertron
::
CreateNode
(
"parser_cli"
));
ros
::
Time
::
now
();
::
apollo
::
drivers
::
gnss
::
Parse
(
argv
[
1
],
argv
[
2
],
parser_node
);
apollo
::
common
::
adapter
::
AdapterManager
::
Init
(
FLAGS_adapter_config_filename
);
::
apollo
::
drivers
::
gnss
::
Parse
(
argv
[
1
],
argv
[
2
]);
return
0
;
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录