Apollo 10.0
自动驾驶开放平台
audio_component.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2020 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
18#include "modules/audio/proto/audio_conf.pb.h"
19#include "modules/common_msgs/basic_msgs/geometry.pb.h"
21
22namespace apollo {
23namespace audio {
24
26using apollo::common::util::FillHeader;
28
30
31std::string AudioComponent::Name() const {
32 // TODO(all) implement
33 return "";
34}
35
37 AudioConf audio_conf;
38 if (!ComponentBase::GetProtoConfig(&audio_conf)) {
39 AERROR << "Unable to load audio conf file: "
40 << ComponentBase::ConfigFilePath();
41 return false;
42 }
43 localization_reader_ =
45 audio_conf.topic_conf().localization_topic_name(), nullptr);
46 audio_writer_ = node_->CreateWriter<AudioDetection>(
48 respeaker_extrinsics_file_ = audio_conf.respeaker_extrinsics_path();
49 return true;
50}
51
52bool AudioComponent::Proc(const std::shared_ptr<AudioData>& audio_data) {
53 // TODO(all) remove GetSignals() multiple calls
54 AudioDetection audio_detection;
55 MessageProcess::OnMicrophone(*audio_data, respeaker_extrinsics_file_,
56 &audio_info_, &direction_detection_, &moving_detection_,
57 &siren_detection_, &audio_detection);
58
59 FillHeader(node_->Name(), &audio_detection);
60 audio_writer_->Write(audio_detection);
61 return true;
62}
63
64} // namespace audio
65} // namespace apollo
bool Proc(const std::shared_ptr< apollo::drivers::microphone::config::AudioData > &) override
static void OnMicrophone(const apollo::drivers::microphone::config::AudioData &audio_data, const std::string &respeaker_extrinsics_file, AudioInfo *audio_info, DirectionDetection *direction_detection, MovingDetection *moving_detection, SirenDetection *siren_detection, AudioDetection *audio_detection)
std::shared_ptr< Node > node_
#define AERROR
Definition log.h:44
Some string util functions.
class register implement
Definition arena_queue.h:37
optional TopicConf topic_conf
optional string respeaker_extrinsics_path
optional string localization_topic_name
optional string audio_detection_topic_name