Apollo 10.0
自动驾驶开放平台
oculii_radar_component.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 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
20
21#include "cyber/cyber.h"
22
23namespace apollo {
24namespace drivers {
25namespace radar {
26
28 config_ = std::make_shared<OculiiRadarConf>();
30 config_.get())) {
31 return false;
32 }
33 AINFO << "OculiiRadarComponent config: " << config_->DebugString();
34 parser_.reset(new OculiiRadarUdpParser);
35 if (!parser_->Init(config_->port())) {
36 AERROR << "Init parser of oculii radar failed";
37 return false;
38 }
39 writer_ = node_->CreateWriter<OculiiPointCloud>(config_->channel_name());
40 frame_drop_interval_ = static_cast<float>(0.9 / config_->frame_rate());
41 last_process_time_ = 0;
42 async_result_ = cyber::Async(&OculiiRadarComponent::run, this);
43 return true;
44}
45
46void OculiiRadarComponent::run() {
47 running_.exchange(true);
48 while (!cyber::IsShutdown()) {
49 OculiiPointCloud pb_output;
50
51 cyber::Time process_time = cyber::Time::Now();
52 auto output_time = process_time.ToSecond();
53
54 pb_output.mutable_header()->set_frame_id(config_->frame_id());
55 common::util::FillHeader(node_->Name(), &pb_output);
56 pb_output.set_frame_id(config_->frame_id());
57 pb_output.set_is_dense(true);
58 pb_output.set_measurement_time(output_time);
59
60 if (parser_->Parse(pb_output) != 0) {
61 AERROR << "parse oculii udp packet failed";
62 continue;
63 }
64 writer_->Write(pb_output);
65 }
66}
67
69 if (running_.load()) {
70 running_.exchange(false);
71 }
72}
73
74} // namespace radar
75} // namespace drivers
76} // namespace apollo
std::shared_ptr< Node > node_
Cyber has builtin time type Time.
Definition time.h:31
static Time Now()
get the current time.
Definition time.cc:57
double ToSecond() const
convert time to second.
Definition time.cc:77
bool Init() override
initialize OculiiRadarComponent
#define AERROR
Definition log.h:44
#define AINFO
Definition log.h:42
Some string util functions.
bool GetProtoFromFile(const std::string &file_name, google::protobuf::Message *message)
Parses the content of the file specified by the file_name as a representation of protobufs,...
Definition file.cc:132
bool IsShutdown()
Definition state.h:46
class register implement
Definition arena_queue.h:37