Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
2d621a09
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,发现更多精彩内容 >>
提交
2d621a09
编写于
9月 17, 2018
作者:
Z
zhuangli1987
提交者:
Liangliang Zhang
9月 17, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
migration ultrasonic
上级
72b29e27
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
160 addition
and
81 deletion
+160
-81
apollo.sh
apollo.sh
+1
-0
modules/common/monitor_log/proto/monitor_log.proto
modules/common/monitor_log/proto/monitor_log.proto
+2
-0
modules/drivers/radar/conti_radar/conti_radar_canbus_component.cc
...drivers/radar/conti_radar/conti_radar_canbus_component.cc
+0
-1
modules/drivers/radar/ultrasonic_radar/BUILD
modules/drivers/radar/ultrasonic_radar/BUILD
+22
-12
modules/drivers/radar/ultrasonic_radar/dag/ultrasonic_radar.dag
...s/drivers/radar/ultrasonic_radar/dag/ultrasonic_radar.dag
+11
-0
modules/drivers/radar/ultrasonic_radar/launch/ultrasonic_radar.launch
...ers/radar/ultrasonic_radar/launch/ultrasonic_radar.launch
+7
-0
modules/drivers/radar/ultrasonic_radar/ultrasonic_radar_canbus.cc
...drivers/radar/ultrasonic_radar/ultrasonic_radar_canbus.cc
+25
-27
modules/drivers/radar/ultrasonic_radar/ultrasonic_radar_canbus.h
.../drivers/radar/ultrasonic_radar/ultrasonic_radar_canbus.h
+11
-24
modules/drivers/radar/ultrasonic_radar/ultrasonic_radar_canbus_component.cc
...dar/ultrasonic_radar/ultrasonic_radar_canbus_component.cc
+19
-4
modules/drivers/radar/ultrasonic_radar/ultrasonic_radar_canbus_component.h
...adar/ultrasonic_radar/ultrasonic_radar_canbus_component.h
+47
-0
modules/drivers/radar/ultrasonic_radar/ultrasonic_radar_message_manager.cc
...adar/ultrasonic_radar/ultrasonic_radar_message_manager.cc
+7
-8
modules/drivers/radar/ultrasonic_radar/ultrasonic_radar_message_manager.h
...radar/ultrasonic_radar/ultrasonic_radar_message_manager.h
+8
-5
未找到文件。
apollo.sh
浏览文件 @
2d621a09
...
...
@@ -108,6 +108,7 @@ function generate_build_targets() {
//modules/drivers/gnss/...
//modules/drivers/velodyne/...
//modules/drivers/usb_cam/...
//modules/drivers/radar/ultrasonic_radar/...
//modules/guardian/...
//modules/integration_test/...
//modules/localization/proto/...
...
...
modules/common/monitor_log/proto/monitor_log.proto
浏览文件 @
2d621a09
...
...
@@ -21,6 +21,8 @@ message MonitorMessageItem {
RELATIVE_MAP
=
13
;
GNSS
=
14
;
CONTI_RADAR
=
15
;
RACOBIT_RADAR
=
16
;
ULTRASONIC_RADAR
=
17
;
}
optional
MessageSource
source
=
1
[
default
=
UNKNOWN
];
...
...
modules/drivers/radar/conti_radar/conti_radar_canbus_component.cc
浏览文件 @
2d621a09
...
...
@@ -73,7 +73,6 @@ bool ContiRadarCanbusComponent::Init() {
start_success_
=
Start
();
return
start_success_
;
return
true
;
}
apollo
::
common
::
ErrorCode
ContiRadarCanbusComponent
::
ConfigureRadar
()
{
...
...
modules/drivers/radar/ultrasonic_radar/BUILD
浏览文件 @
2d621a09
...
...
@@ -15,12 +15,14 @@ cc_library(
"//modules/drivers/canbus/can_client:can_client_factory"
,
"//modules/drivers/canbus/can_comm:can_sender"
,
"//modules/drivers/canbus/can_comm:message_manager_base"
,
"//modules/drivers/proto:sensor_proto"
,
"//modules/common/util:message_util"
,
],
)
# cc_test(
#
name = "ultrasonic_radar_message_manager_test",
#
size = "small",
#
cc_test(
# name = "ultrasonic_radar_message_manager_test",
# size = "small",
# srcs = [
# "ultrasonic_radar_message_manager_test.cc",
# ],
...
...
@@ -41,12 +43,12 @@ cc_library(
deps
=
[
":ultrasonic_radar_message_manager"
,
"//modules/common"
,
"//modules/common:apollo_app"
,
"//modules/common/monitor_log"
,
"//modules/drivers/canbus:sensor_gflags"
,
"//modules/drivers/canbus/can_client:can_client_factory"
,
"//modules/drivers/canbus/can_comm:can_receiver"
,
"//modules/drivers/canbus/can_comm:message_manager_base"
,
"//modules/drivers/proto:sensor_proto"
,
],
)
...
...
@@ -62,17 +64,25 @@ cc_library(
# ],
# )
cc_binary
(
name
=
"ultrasonic_radar"
,
srcs
=
[
"main.cc"
],
cc_library
(
name
=
"ultrasonic_radar_canbus_component_lib"
,
srcs
=
[
"ultrasonic_radar_canbus_component.cc"
,
],
hdrs
=
[
"ultrasonic_radar_canbus_component.h"
,
],
deps
=
[
":ultrasonic_radar_canbus_lib"
,
"//external:gflags"
,
"//framework:cybertron"
,
"//modules/common/monitor_log"
,
"//modules/drivers/canbus/common:canbus_common"
,
"@ros//:ros_common"
,
"//modules/common/adapters:adapter_gflags"
,
],
copts
=
[
'-DMODULE_NAME=
\\
"ultrasonic_radar_canbus
\\
"'
]
)
cc_binary
(
name
=
"libultrasonic_radar_canbus_component.so"
,
deps
=
[
":ultrasonic_radar_canbus_component_lib"
],
linkopts
=
[
"-shared"
],
)
cpplint
()
modules/drivers/radar/ultrasonic_radar/dag/ultrasonic_radar.dag
0 → 100644
浏览文件 @
2d621a09
module_config {
module_library :
"/apollo/bazel-bin/modules/drivers/radar/ultrasonic_radar/libultrasonic_radar_canbus_component.so"
components {
class_name : "UltrasonicRadarCanbusComponent"
config {
name: "ultrasonic_radar"
config_file_path: "/apollo/modules/drivers/radar/ultrasonic_radar/conf/ultrasonic_radar_conf.pb.txt"
}
}
}
modules/drivers/radar/ultrasonic_radar/launch/ultrasonic_radar.launch
0 → 100644
浏览文件 @
2d621a09
<cybertron>
<module>
<name>ultrasonic_radar</name>
<dag_conf>/apollo/modules/drivers/radar/ultrasonic_radar/dag/ultrasonic_radar.dag</dag_conf>
<process_name></process_name>
</module>
</cybertron>
modules/drivers/radar/ultrasonic_radar/ultrasonic_radar_canbus.cc
浏览文件 @
2d621a09
...
...
@@ -14,13 +14,10 @@
* limitations under the License.
*****************************************************************************/
/**
* @file
*/
#include "modules/drivers/radar/ultrasonic_radar/ultrasonic_radar_canbus.h"
#include "modules/drivers/radar/ultrasonic_radar/ultrasonic_radar_message_manager.h"
#include "modules/drivers/proto/ultrasonic_radar.pb.h"
#include "modules/common/util/util.h"
/**
* @namespace apollo::drivers::ultrasonic_radar
...
...
@@ -30,24 +27,33 @@ namespace apollo {
namespace
drivers
{
namespace
ultrasonic_radar
{
UltrasonicRadarCanbus
::
UltrasonicRadarCanbus
()
:
monitor_logger_buffer_
(
common
::
monitor
::
MonitorMessageItem
::
ULTRASONIC_RADAR
)
{
}
UltrasonicRadarCanbus
::~
UltrasonicRadarCanbus
()
{
can_receiver_
.
Stop
();
can_client_
->
Stop
();
}
std
::
string
UltrasonicRadarCanbus
::
Name
()
const
{
return
FLAGS_canbus_driver_name
;
return
"ultrasonic_radar"
;
}
apollo
::
common
::
Status
UltrasonicRadarCanbus
::
Init
()
{
AdapterManager
::
Init
(
FLAGS_adapter_config_filename
);
AINFO
<<
"The adapter manager is successfully initialized."
;
if
(
!::
apollo
::
common
::
util
::
GetProtoFromFile
(
FLAGS_sensor_conf_file
,
&
ultrasonic_radar_conf_
))
{
return
OnError
(
"Unable to load canbus conf file: "
+
FLAGS_sensor_conf_file
);
apollo
::
common
::
Status
UltrasonicRadarCanbus
::
Init
(
const
std
::
string
&
config_path
,
const
std
::
shared_ptr
<::
apollo
::
cybertron
::
Writer
<
Ultrasonic
>>&
writer
)
{
if
(
!
apollo
::
common
::
util
::
GetProtoFromFile
(
config_path
,
&
ultrasonic_radar_conf_
))
{
return
OnError
(
"Unable to load canbus conf file: "
+
config_path
);
}
AINFO
<<
"The canbus conf file is loaded: "
<<
FLAGS_sensor_conf_file
;
AINFO
<<
"The canbus conf file is loaded: "
<<
config_path
;
ADEBUG
<<
"Canbus_conf:"
<<
ultrasonic_radar_conf_
.
ShortDebugString
();
// Init can client
auto
*
can_factory
=
CanClientFactory
::
Instance
();
auto
can_factory
=
CanClientFactory
::
Instance
();
can_factory
->
RegisterCanClients
();
can_client_
=
can_factory
->
CreateCANClient
(
ultrasonic_radar_conf_
.
can_conf
().
can_card_parameter
());
...
...
@@ -59,7 +65,8 @@ apollo::common::Status UltrasonicRadarCanbus::Init() {
sensor_message_manager_
=
std
::
unique_ptr
<
UltrasonicRadarMessageManager
>
(
new
UltrasonicRadarMessageManager
(
ultrasonic_radar_conf_
.
entrance_num
()));
ultrasonic_radar_conf_
.
entrance_num
(),
writer
));
if
(
sensor_message_manager_
==
nullptr
)
{
return
OnError
(
"Failed to create message manager."
);
}
...
...
@@ -93,27 +100,18 @@ apollo::common::Status UltrasonicRadarCanbus::Start() {
AINFO
<<
"Can receiver is started."
;
// last step: publish monitor messages
apollo
::
common
::
monitor
::
MonitorLogBuffer
buffer
(
&
monitor_logger_
);
buffer
.
INFO
(
"Canbus is started."
);
monitor_logger_buffer_
.
INFO
(
"Canbus is started."
);
return
Status
::
OK
();
}
void
UltrasonicRadarCanbus
::
Stop
()
{
can_receiver_
.
Stop
();
can_client_
->
Stop
();
}
void
UltrasonicRadarCanbus
::
PublishSensorData
()
{
}
// Send the error to monitor and return it
Status
UltrasonicRadarCanbus
::
OnError
(
const
std
::
string
&
error_msg
)
{
apollo
::
common
::
monitor
::
MonitorLogBuffer
buffer
(
&
monitor_logger_
);
buffer
.
ERROR
(
error_msg
);
monitor_logger_buffer_
.
ERROR
(
error_msg
);
return
Status
(
ErrorCode
::
CANBUS_ERROR
,
error_msg
);
}
}
// namespace ultrasonic_radar
}
// namespace drivers
}
// namespace apollo
modules/drivers/radar/ultrasonic_radar/ultrasonic_radar_canbus.h
浏览文件 @
2d621a09
...
...
@@ -26,16 +26,11 @@
#include <utility>
#include <vector>
#include "
ros/include/ros/
ros.h"
#include "
cybertron/common/mac
ros.h"
#include "modules/common/adapters/adapter_manager.h"
#include "modules/common/adapters/proto/adapter_config.pb.h"
#include "modules/common/apollo_app.h"
#include "modules/common/macro.h"
#include "modules/common/monitor_log/monitor_log_buffer.h"
#include "modules/common/time/time.h"
#include "modules/common/util/util.h"
#include "modules/control/proto/control_cmd.pb.h"
#include "modules/common/status/status.h"
#include "modules/drivers/canbus/can_client/can_client.h"
#include "modules/drivers/canbus/can_client/can_client_factory.h"
#include "modules/drivers/canbus/can_comm/can_receiver.h"
...
...
@@ -62,8 +57,6 @@ namespace ultrasonic_radar {
* @brief template of canbus-based sensor module main class (e.g., ultrasonic_radar).
*/
using
apollo
::
common
::
adapter
::
AdapterConfig
;
using
apollo
::
common
::
adapter
::
AdapterManager
;
using
apollo
::
common
::
monitor
::
MonitorMessageItem
;
using
apollo
::
common
::
Status
;
using
apollo
::
common
::
ErrorCode
;
...
...
@@ -74,38 +67,32 @@ using apollo::drivers::canbus::CanReceiver;
using
apollo
::
drivers
::
canbus
::
SenderMessage
;
using
apollo
::
drivers
::
canbus
::
SensorCanbusConf
;
class
UltrasonicRadarCanbus
:
public
apollo
::
common
::
ApolloApp
{
class
UltrasonicRadarCanbus
{
public:
// TODO(lizh): check whether we need a new msg item, say
// MonitorMessageItem::SENSORCANBUS
UltrasonicRadarCanbus
()
:
monitor_logger_
(
apollo
::
common
::
monitor
::
MonitorMessageItem
::
CANBUS
)
{}
UltrasonicRadarCanbus
();
~
UltrasonicRadarCanbus
();
/**
* @brief obtain module name
* @return module name
*/
std
::
string
Name
()
const
override
;
std
::
string
Name
()
const
;
/**
* @brief module initialization function
* @return initialization status
*/
apollo
::
common
::
Status
Init
()
override
;
apollo
::
common
::
Status
Init
(
const
std
::
string
&
config_path
,
const
std
::
shared_ptr
<::
apollo
::
cybertron
::
Writer
<
Ultrasonic
>>&
writer
);
/**
* @brief module start function
* @return start status
*/
apollo
::
common
::
Status
Start
()
override
;
/**
* @brief module stop function
*/
void
Stop
()
override
;
apollo
::
common
::
Status
Start
();
private:
void
PublishSensorData
();
Status
OnError
(
const
std
::
string
&
error_msg
);
void
RegisterCanClients
();
...
...
@@ -115,7 +102,7 @@ class UltrasonicRadarCanbus : public apollo::common::ApolloApp {
std
::
unique_ptr
<
UltrasonicRadarMessageManager
>
sensor_message_manager_
;
int64_t
last_timestamp_
=
0
;
apollo
::
common
::
monitor
::
MonitorLog
ger
monitor_logg
er_
;
apollo
::
common
::
monitor
::
MonitorLog
Buffer
monitor_logger_buff
er_
;
};
}
// namespace ultrasonic_radar
...
...
modules/drivers/radar/ultrasonic_radar/
main
.cc
→
modules/drivers/radar/ultrasonic_radar/
ultrasonic_radar_canbus_component
.cc
浏览文件 @
2d621a09
...
...
@@ -14,8 +14,23 @@
* limitations under the License.
*****************************************************************************/
#include "modules/common/apollo_app.h"
#include "modules/drivers/radar/ultrasonic_radar/ultrasonic_radar_canbus.h"
#include "modules/drivers/radar/ultrasonic_radar/ultrasonic_radar_canbus_component.h"
#include "modules/common/adapters/adapter_gflags.h"
namespace
apollo
{
namespace
drivers
{
namespace
ultrasonic_radar
{
UltrasonicRadarCanbusComponent
::
UltrasonicRadarCanbusComponent
()
{
writer_
=
node_
->
CreateWriter
<
Ultrasonic
>
(
FLAGS_ultrasonic_radar_topic
);
}
bool
UltrasonicRadarCanbusComponent
::
Init
()
{
return
utralsonic_radar_canbus_
.
Init
(
ConfigFilePath
(),
writer_
).
ok
()
&&
utralsonic_radar_canbus_
.
Start
().
ok
();
}
}
// namespace ultrasonic_radar
}
// namespace drivers
}
// namespace apollo
using
::
apollo
::
drivers
::
ultrasonic_radar
::
UltrasonicRadarCanbus
;
APOLLO_MAIN
(
UltrasonicRadarCanbus
);
modules/drivers/radar/ultrasonic_radar/ultrasonic_radar_canbus_component.h
0 → 100644
浏览文件 @
2d621a09
/******************************************************************************
* 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.
*****************************************************************************/
#ifndef MODULES_DRIVERS_RADAR_ULTRASONIC_RADAR_ULTRASONIC_RADAR_CANBUS_COMPONENT_H_
#define MODULES_DRIVERS_RADAR_ULTRASONIC_RADAR_ULTRASONIC_RADAR_CANBUS_COMPONENT_H_
#include "modules/drivers/radar/ultrasonic_radar/ultrasonic_radar_canbus.h"
/**
* @namespace apollo::drivers
* @brief apollo::drivers
*/
namespace
apollo
{
namespace
drivers
{
namespace
ultrasonic_radar
{
class
UltrasonicRadarCanbusComponent
:
public
apollo
::
cybertron
::
Component
<>
{
public:
UltrasonicRadarCanbusComponent
();
~
UltrasonicRadarCanbusComponent
()
=
default
;
bool
Init
()
override
;
private:
UltrasonicRadarCanbus
utralsonic_radar_canbus_
;
std
::
shared_ptr
<::
apollo
::
cybertron
::
Writer
<
Ultrasonic
>>
writer_
;
};
CYBERTRON_REGISTER_COMPONENT
(
UltrasonicRadarCanbusComponent
)
}
// namespace ultrasonic_radar
}
// namespace drivers
}
// namespace apollo
#endif // MODULES_DRIVERS_RADAR_ULTRASONIC_RADAR_ULTRASONIC_RADAR_CANBUS_COMPONENT_H_
modules/drivers/radar/ultrasonic_radar/ultrasonic_radar_message_manager.cc
浏览文件 @
2d621a09
...
...
@@ -20,17 +20,16 @@
*/
#include "modules/drivers/radar/ultrasonic_radar/ultrasonic_radar_message_manager.h"
#include "modules/common/util/message_util.h"
namespace
apollo
{
namespace
drivers
{
namespace
ultrasonic_radar
{
using
::
apollo
::
common
::
adapter
::
AdapterManager
;
UltrasonicRadarMessageManager
::
UltrasonicRadarMessageManager
(
int
entrance_num
)
:
MessageManager
<
Ultrasonic
>
(),
entrance_num_
(
entrance_num
)
{
UltrasonicRadarMessageManager
::
UltrasonicRadarMessageManager
(
const
int
entrance_num
,
const
std
::
shared_ptr
<::
apollo
::
cybertron
::
Writer
<
Ultrasonic
>>
&
writer
)
:
entrance_num_
(
entrance_num
),
ultrasonic_radar_writer_
(
writer
)
{
sensor_data_
.
mutable_ranges
()
->
Resize
(
entrance_num_
,
0.0
);
}
...
...
@@ -57,8 +56,8 @@ void UltrasonicRadarMessageManager::Parse(const uint32_t message_id,
}
else
if
(
message_id
==
0x304
)
{
sensor_data_
.
set_ranges
(
10
,
data
[
1
]);
sensor_data_
.
set_ranges
(
11
,
data
[
2
]);
AdapterManager
::
FillUltrasonicHeader
(
FLAGS_sensor_node_name
,
&
sensor_data_
);
AdapterManager
::
PublishUltrasonic
(
sensor_data_
);
common
::
util
::
FillHeader
(
"ultrasonic_radar"
,
&
sensor_data_
);
ultrasonic_radar_writer_
->
Write
(
std
::
make_shared
<
Ultrasonic
>
(
sensor_data_
)
);
}
received_ids_
.
insert
(
message_id
);
...
...
modules/drivers/radar/ultrasonic_radar/ultrasonic_radar_message_manager.h
浏览文件 @
2d621a09
...
...
@@ -22,12 +22,14 @@
#define MODULES_DRIVERS_RADAR_ULTRASONIC_RADAR_MESSAGE_MANAGER_H_
#include <memory>
#include "cybertron/cybertron.h"
#include "modules/drivers/canbus/can_client/can_client_factory.h"
#include "modules/drivers/canbus/can_comm/can_sender.h"
#include "modules/drivers/canbus/can_comm/message_manager.h"
#include "modules/drivers/proto/ultrasonic_radar.pb.h"
#include "modules/common/adapters/adapter_manager.h"
#include "modules/drivers/canbus/sensor_gflags.h"
namespace
apollo
{
...
...
@@ -35,7 +37,6 @@ namespace drivers {
namespace
ultrasonic_radar
{
using
::
apollo
::
drivers
::
canbus
::
ProtocolData
;
using
::
apollo
::
common
::
adapter
::
AdapterManager
;
using
::
apollo
::
drivers
::
canbus
::
MessageManager
;
using
Clock
=
::
apollo
::
common
::
time
::
Clock
;
using
micros
=
std
::
chrono
::
microseconds
;
...
...
@@ -45,14 +46,16 @@ using apollo::drivers::canbus::SenderMessage;
class
UltrasonicRadarMessageManager
:
public
MessageManager
<
Ultrasonic
>
{
public:
explicit
UltrasonicRadarMessageManager
(
int
entrance_num
);
virtual
~
UltrasonicRadarMessageManager
()
{}
explicit
UltrasonicRadarMessageManager
(
const
int
entrance_num
,
const
std
::
shared_ptr
<::
apollo
::
cybertron
::
Writer
<
Ultrasonic
>>
&
writer
);
virtual
~
UltrasonicRadarMessageManager
()
=
default
;
void
Parse
(
const
uint32_t
message_id
,
const
uint8_t
*
data
,
int32_t
length
);
void
set_can_client
(
std
::
shared_ptr
<
CanClient
>
can_client
);
private:
int
entrance_num_
=
0
;
std
::
shared_ptr
<::
apollo
::
cybertron
::
Writer
<
Ultrasonic
>>
ultrasonic_radar_writer_
;
std
::
shared_ptr
<
CanClient
>
can_client_
;
int
entrance_num_
;
};
}
// namespace ultrasonic_radar
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录