Apollo 10.0
自动驾驶开放平台
direction_detection.h
浏览该文件的文档.
1
2/******************************************************************************
3 * Copyright 2020 The Apollo Authors. All Rights Reserved.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *****************************************************************************/
17
18#pragma once
19
20#include <algorithm>
21#include <cmath>
22#include <memory>
23#include <string>
24#include <utility>
25#include <vector>
26
27#include "Eigen/Eigen"
28// Eigen 3.3.7: #define ALIVE (0)
29// fastrtps: enum ChangeKind_t { ALIVE, ... };
30#if defined(ALIVE)
31#undef ALIVE
32#endif
33
34#include "ATen/ATen.h"
35#include "torch/torch.h"
36
37#include "modules/common_msgs/basic_msgs/geometry.pb.h"
38
39namespace apollo {
40namespace audio {
41
43
45 public:
48 // Estimates the position of the source of the sound
49 std::pair<Point3D, double> EstimateSoundSource(
50 std::vector<std::vector<double>>&& channels_vec,
51 const std::string& respeaker_extrinsic_file,
52 const int sample_rate, const double mic_distance);
53
54 private:
55 const double kSoundSpeed = 343.2;
56 const int kDistance = 50;
57 std::unique_ptr<Eigen::Matrix4d> respeaker2imu_ptr_;
58
59 // Estimates the direction of the source of the sound
60 double EstimateDirection(std::vector<std::vector<double>>&& channels_vec,
61 const int sample_rate, const double mic_distance);
62
63 bool LoadExtrinsics(const std::string& yaml_file,
64 Eigen::Matrix4d* respeaker_extrinsic);
65
66 // Computes the offset between the signal sig and the reference signal refsig
67 // using the Generalized Cross Correlation - Phase Transform (GCC-PHAT)method.
68 double GccPhat(const torch::Tensor& sig, const torch::Tensor& refsig, int fs,
69 double max_tau, int interp);
70
71 // Libtorch does not support Complex type currently.
72 void ConjugateTensor(torch::Tensor* tensor);
73 torch::Tensor ComplexMultiply(const torch::Tensor& a, const torch::Tensor& b);
74 torch::Tensor ComplexAbsolute(const torch::Tensor& tensor);
75};
76
77} // namespace audio
78} // namespace apollo
std::pair< Point3D, double > EstimateSoundSource(std::vector< std::vector< double > > &&channels_vec, const std::string &respeaker_extrinsic_file, const int sample_rate, const double mic_distance)
class register implement
Definition arena_queue.h:37