Apollo 10.0
自动驾驶开放平台
parser_common.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 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
17#pragma once
18
19#include <cmath>
20#include <limits>
21
22#include "modules/common_msgs/basic_msgs/geometry.pb.h"
23
24#include "cyber/cyber.h"
25
26namespace apollo {
27namespace drivers {
28namespace gnss {
29
30constexpr int SECONDS_PER_WEEK = 60 * 60 * 24 * 7;
31
32constexpr double DEG_TO_RAD = M_PI / 180.0;
33
34constexpr double EPS = 1e-8;
35
36constexpr float FLOAT_NAN = std::numeric_limits<float>::quiet_NaN();
37
38constexpr double azimuth_deg_to_yaw_rad(double azimuth) {
39 return (90.0 - azimuth) * DEG_TO_RAD;
40}
41
42// A helper that fills an Point3D object (which uses the FLU frame) using RFU
43// measurements.
44inline void rfu_to_flu(double r, double f, double u,
46 flu->set_x(f);
47 flu->set_y(-r);
48 flu->set_z(u);
49}
50
51constexpr uint64_t PERIOD_NS_1HZ = 900 * 1e6;
53 public:
54 explicit RateControl(uint64_t period_ns) : period_ns_(period_ns) {}
55 bool check() {
56 auto now = cyber::Time::Now().ToNanosecond();
57 if (now - latest_ns_ > period_ns_) {
58 latest_ns_ = now;
59 return true;
60 }
61 return false;
62 }
63
64 private:
65 uint64_t period_ns_;
66 uint64_t latest_ns_ = 0;
67};
68
69} // namespace gnss
70} // namespace drivers
71} // namespace apollo
double f
uint64_t ToNanosecond() const
convert time to nanosecond.
Definition time.cc:83
static Time Now()
get the current time.
Definition time.cc:57
constexpr double DEG_TO_RAD
constexpr double EPS
void rfu_to_flu(double r, double f, double u, ::apollo::common::Point3D *flu)
constexpr int SECONDS_PER_WEEK
constexpr uint64_t PERIOD_NS_1HZ
constexpr double azimuth_deg_to_yaw_rad(double azimuth)
constexpr float FLOAT_NAN
class register implement
Definition arena_queue.h:37