Apollo 10.0
自动驾驶开放平台
motion_input_yawrate_301.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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
21namespace apollo {
22namespace drivers {
23namespace conti_radar {
24
27
28const uint32_t MotionInputYawRate301::ID = 0x301;
29
32
34 static const uint32_t PERIOD = 20 * 1000;
35 return PERIOD;
36}
37
43 if (std::isnan(yaw_rate_)) {
44 AWARN << "yaw_rate is nan";
45 return;
46 }
47 // Due to radar 408 manual: max 327.68, res 0.01, unit:deg/s
48 uint32_t yaw_rate_value = static_cast<uint32_t>((yaw_rate_ + 327.68) * 100);
49 Byte yaw_rate_low(data);
50 yaw_rate_low.set_value(
51 static_cast<unsigned char>((yaw_rate_value & 0xFF00) >> 8), 0, 8);
52 Byte yaw_rate_high(data + 1);
53 yaw_rate_high.set_value(static_cast<unsigned char>(yaw_rate_value & 0x00FF),
54 0, 8);
55}
56
60void MotionInputYawRate301::Reset() { yaw_rate_ = NAN; }
61
62void MotionInputYawRate301::SetYawRate(const float& yaw_rate) {
63 yaw_rate_ = yaw_rate;
64}
65
66} // namespace conti_radar
67} // namespace drivers
68} // namespace apollo
Defines the Byte class.
The class of one byte, which is 8 bits.
Definition byte.h:39
void set_value(const uint8_t value)
Reset this Byte by a specified one-byte unsigned integer.
Definition byte.cc:90
uint32_t GetPeriod() const override
get the data period
void UpdateData(uint8_t *data) override
update the data
void Reset() override
reset the private variables
#define AWARN
Definition log.h:43
class register implement
Definition arena_queue.h:37