Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
b432bb79
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,发现更多精彩内容 >>
提交
b432bb79
编写于
2月 07, 2018
作者:
U
unacao
提交者:
Jiangtao Hu
2月 14, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
draft version for dreamview backend handling of pointcloud
上级
443923b9
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
218 addition
and
0 deletion
+218
-0
modules/dreamview/backend/BUILD
modules/dreamview/backend/BUILD
+1
-0
modules/dreamview/backend/dreamview.cc
modules/dreamview/backend/dreamview.cc
+5
-0
modules/dreamview/backend/dreamview.h
modules/dreamview/backend/dreamview.h
+3
-0
modules/dreamview/backend/point_cloud/BUILD
modules/dreamview/backend/point_cloud/BUILD
+27
-0
modules/dreamview/backend/point_cloud/point_cloud_updater.cc
modules/dreamview/backend/point_cloud/point_cloud_updater.cc
+99
-0
modules/dreamview/backend/point_cloud/point_cloud_updater.h
modules/dreamview/backend/point_cloud/point_cloud_updater.h
+78
-0
modules/dreamview/conf/adapter.conf
modules/dreamview/conf/adapter.conf
+5
-0
未找到文件。
modules/dreamview/backend/BUILD
浏览文件 @
b432bb79
...
...
@@ -16,6 +16,7 @@ cc_library(
"//modules/common/adapters:adapter_manager"
,
"//modules/dreamview/backend/handlers:websocket"
,
"//modules/dreamview/backend/hmi"
,
"//modules/dreamview/backend/point_cloud:point_cloud_updater"
,
"//modules/dreamview/backend/sim_control"
,
"//modules/dreamview/backend/simulation_world:simulation_world_updater"
,
"//modules/map/hdmap:hdmap_util"
,
...
...
modules/dreamview/backend/dreamview.cc
浏览文件 @
b432bb79
...
...
@@ -101,17 +101,21 @@ Status Dreamview::Init() {
image_
.
reset
(
new
ImageHandler
());
websocket_
.
reset
(
new
WebSocketHandler
());
<<<<<<<
HEAD
map_ws_
.
reset
(
new
WebSocketHandler
());
point_cloud_ws_
.
reset
(
new
WebSocketHandler
());
map_service_
.
reset
(
new
MapService
());
sim_control_
.
reset
(
new
SimControl
(
map_service_
.
get
()));
sim_world_updater_
.
reset
(
new
SimulationWorldUpdater
(
websocket_
.
get
(),
map_ws_
.
get
(),
sim_control_
.
get
(),
map_service_
.
get
(),
FLAGS_routing_from_file
));
point_cloud_updater_
.
reset
(
new
PointCloudUpdater
(
point_cloud_ws_
.
get
()));
hmi_
.
reset
(
new
HMI
(
websocket_
.
get
(),
map_service_
.
get
()));
server_
->
addWebSocketHandler
(
"/websocket"
,
*
websocket_
);
server_
->
addWebSocketHandler
(
"/map"
,
*
map_ws_
);
server_
->
addWebSocketHandler
(
"/pointcloud"
,
*
point_cloud_ws_
);
server_
->
addHandler
(
"/image"
,
*
image_
);
ApolloApp
::
SetCallbackThreadNumber
(
FLAGS_dreamview_worker_num
);
...
...
@@ -121,6 +125,7 @@ Status Dreamview::Init() {
Status
Dreamview
::
Start
()
{
sim_world_updater_
->
Start
();
point_cloud_updater_
->
Start
();
return
Status
::
OK
();
}
...
...
modules/dreamview/backend/dreamview.h
浏览文件 @
b432bb79
...
...
@@ -28,6 +28,7 @@
#include "modules/dreamview/backend/handlers/websocket.h"
#include "modules/dreamview/backend/hmi/hmi.h"
#include "modules/dreamview/backend/map/map_service.h"
#include "modules/dreamview/backend/point_cloud/point_cloud_updater.h"
#include "modules/dreamview/backend/sim_control/sim_control.h"
#include "modules/dreamview/backend/simulation_world/simulation_world_updater.h"
...
...
@@ -51,10 +52,12 @@ class Dreamview : public apollo::common::ApolloApp {
ros
::
Timer
exit_timer_
;
std
::
unique_ptr
<
SimulationWorldUpdater
>
sim_world_updater_
;
std
::
unique_ptr
<
PointCloudUpdater
>
point_cloud_updater_
;
std
::
unique_ptr
<
CivetServer
>
server_
;
std
::
unique_ptr
<
SimControl
>
sim_control_
;
std
::
unique_ptr
<
WebSocketHandler
>
websocket_
;
std
::
unique_ptr
<
WebSocketHandler
>
map_ws_
;
std
::
unique_ptr
<
WebSocketHandler
>
point_cloud_ws_
;
std
::
unique_ptr
<
ImageHandler
>
image_
;
std
::
unique_ptr
<
MapService
>
map_service_
;
std
::
unique_ptr
<
HMI
>
hmi_
;
...
...
modules/dreamview/backend/point_cloud/BUILD
0 → 100644
浏览文件 @
b432bb79
load
(
"//tools:cpplint.bzl"
,
"cpplint"
)
package
(
default_visibility
=
[
"//visibility:public"
])
cc_library
(
name
=
"point_cloud_updater"
,
srcs
=
[
"point_cloud_updater.cc"
,
],
hdrs
=
[
"point_cloud_updater.h"
,
],
linkopts
=
[
"-lboost_thread"
,
],
deps
=
[
"//modules/common:log"
,
"//modules/common/adapters:adapter_manager"
,
"//modules/dreamview/backend/common:dreamview_gflags"
,
"//modules/dreamview/backend/handlers:websocket"
,
"//third_party/json"
,
"@com_google_protobuf//:protobuf"
,
"@pcl//:pcl"
,
],
)
cpplint
()
modules/dreamview/backend/point_cloud/point_cloud_updater.cc
0 → 100644
浏览文件 @
b432bb79
/******************************************************************************
* Copyright 2018 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 "modules/dreamview/backend/point_cloud/point_cloud_updater.h"
#include "modules/common/adapters/adapter_manager.h"
#include "modules/common/log.h"
#include "modules/dreamview/backend/common/dreamview_gflags.h"
#include "pcl_conversions/pcl_conversions.h"
#include "pcl/point_cloud.h"
#include "pcl/point_types.h"
#include "third_party/json/json.hpp"
namespace
apollo
{
namespace
dreamview
{
using
apollo
::
common
::
adapter
::
AdapterManager
;
using
sensor_msgs
::
PointCloud2
;
using
Json
=
nlohmann
::
json
;
PointCloudUpdater
::
PointCloudUpdater
(
WebSocketHandler
*
websocket
)
:
websocket_
(
websocket
)
{
RegisterMessageHandlers
();
}
void
PointCloudUpdater
::
RegisterMessageHandlers
()
{
websocket_
->
RegisterMessageHandler
(
"RequestPointCloud"
,
[
this
](
const
Json
&
json
,
WebSocketHandler
::
Connection
*
conn
)
{
std
::
string
to_send
;
{
// Pay the price to copy the data instead of sending data over the
// wire while holding the lock.
boost
::
shared_lock
<
boost
::
shared_mutex
>
lock
(
mutex_
);
to_send
=
point_cloud_str_
;
}
websocket_
->
SendData
(
conn
,
to_send
,
true
);
});
}
void
PointCloudUpdater
::
Start
()
{
AdapterManager
::
AddPointCloudCallback
(
&
PointCloudUpdater
::
UpdatePointCloud
,
this
);
}
void
PointCloudUpdater
::
UpdatePointCloud
(
const
PointCloud2
&
point_cloud
)
{
// transform from ros to pcl
pcl
::
PointCloud
<
pcl
::
PointXYZ
>
pcl_data
;
pcl
::
fromROSMsg
(
point_cloud
,
pcl_data
);
if
(
pcl_data
.
size
()
==
0
)
{
point_cloud_str_
=
"[]"
;
return
;
}
std
::
stringstream
stream
;
std
::
string
data
(
"["
);
for
(
size_t
idx
=
0
;
idx
<
pcl_data
.
size
();
idx
+=
2
)
{
pcl
::
PointXYZ
&
pt
=
pcl_data
.
points
[
idx
];
if
(
!
isnan
(
pt
.
x
)
&&
!
isnan
(
pt
.
y
)
&&
!
isnan
(
pt
.
z
))
{
data
.
append
(
"["
);
stream
.
str
(
std
::
string
());
stream
<<
std
::
fixed
<<
std
::
setprecision
(
4
)
<<
pt
.
x
;
data
.
append
(
stream
.
str
());
data
.
append
(
","
);
stream
.
str
(
std
::
string
());
stream
<<
std
::
fixed
<<
std
::
setprecision
(
4
)
<<
pt
.
y
;
data
.
append
(
stream
.
str
());
data
.
append
(
","
);
stream
.
str
(
std
::
string
());
stream
<<
std
::
fixed
<<
std
::
setprecision
(
4
)
<<
pt
.
z
;
data
.
append
(
stream
.
str
());
data
.
append
(
"]"
);
if
((
idx
+
1
)
==
pcl_data
.
size
())
{
data
.
append
(
"]"
);
}
else
{
data
.
append
(
","
);
}
}
}
boost
::
shared_lock
<
boost
::
shared_mutex
>
lock
(
mutex_
);
point_cloud_str_
=
data
;
}
}
// namespace dreamview
}
// namespace apollo
modules/dreamview/backend/point_cloud/point_cloud_updater.h
0 → 100644
浏览文件 @
b432bb79
/******************************************************************************
* Copyright 2018 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.
*****************************************************************************/
/**
* @file
*/
#ifndef MODULES_DREAMVIEW_BACKEND_POINT_CLOUD_POINT_CLOUD_UPDATER_H_
#define MODULES_DREAMVIEW_BACKEND_POINT_CLOUD_POINT_CLOUD_UPDATER_H_
#include <string>
#include "boost/thread/locks.hpp"
#include "boost/thread/shared_mutex.hpp"
#include "modules/common/log.h"
#include "modules/common/util/string_util.h"
#include "modules/dreamview/backend/handlers/websocket.h"
#include "sensor_msgs/PointCloud2.h"
/**
* @namespace apollo::dreamview
* @brief apollo::dreamview
*/
namespace
apollo
{
namespace
dreamview
{
/**
* @class PointCloudUpdater
* @brief A wrapper around WebSocketHandler to keep pushing PointCloud to frontend
* via websocket while handling the response from frontend.
*/
class
PointCloudUpdater
{
public:
/**
* @brief Constructor with the websocket handler.
* @param websocket Pointer of the websocket handler that has been attached to
* the server.
*/
explicit
PointCloudUpdater
(
WebSocketHandler
*
websocket
);
/**
* @brief Starts to push PointCloud to frontend.
*/
void
Start
();
private:
void
RegisterMessageHandlers
();
void
UpdatePointCloud
(
const
sensor_msgs
::
PointCloud2
&
point_cloud
);
WebSocketHandler
*
websocket_
;
// The PointCloud to be pushed to frontend.
std
::
string
point_cloud_str_
;
// Mutex to protect concurrent access to point_cloud_str_.
// NOTE: Use boost until we have std version of rwlock support.
boost
::
shared_mutex
mutex_
;
};
}
// namespace dreamview
}
// namespace apollo
#endif // MODULES_DREAMVIEW_BACKEND_POINT_CLOUD_POINT_CLOUD_UPDATER_H_
modules/dreamview/conf/adapter.conf
浏览文件 @
b432bb79
...
...
@@ -48,6 +48,11 @@ config {
mode
:
RECEIVE_ONLY
message_history_limit
:
1
}
config
: {
type
:
POINT_CLOUD
mode
:
RECEIVE_ONLY
message_history_limit
:
1
}
config
{
type
:
ROUTING_RESPONSE
mode
:
DUPLEX
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录