Apollo 10.0
自动驾驶开放平台
gyro_6c.cc
浏览该文件的文档.
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
18
20
21namespace apollo {
22namespace canbus {
23namespace lincoln {
24
25using ::apollo::drivers::canbus::Byte;
26
27const int32_t Gyro6c::ID = 0x6C;
28
29void Gyro6c::Parse(const std::uint8_t *bytes, int32_t length,
30 Lincoln *chassis_detail) const {
31 chassis_detail->mutable_vehicle_spd()->set_roll_rate(
32 roll_rate(bytes, length));
33 chassis_detail->mutable_vehicle_spd()->set_yaw_rate(yaw_rate(bytes, length));
34 // why
35 chassis_detail->mutable_vehicle_spd()->set_is_yaw_rate_valid(true);
36}
37
38double Gyro6c::roll_rate(const std::uint8_t *bytes, int32_t length) const {
39 Byte high_frame(bytes + 1);
40 int32_t high = high_frame.get_byte(0, 8);
41 Byte low_frame(bytes + 0);
42 int32_t low = low_frame.get_byte(0, 8);
43 int32_t value = (high << 8) | low;
44 if (value > 0x7FFF) {
45 value -= 0x10000;
46 }
47 return value * 0.000200;
48}
49
50double Gyro6c::yaw_rate(const std::uint8_t *bytes, int32_t length) const {
51 Byte high_frame(bytes + 3);
52 int32_t high = high_frame.get_byte(0, 8);
53 Byte low_frame(bytes + 2);
54 int32_t low = low_frame.get_byte(0, 8);
55 int32_t value = (high << 8) | low;
56 if (value > 0x7FFF) {
57 value -= 0x10000;
58 }
59 return value * 0.000200;
60}
61
62} // namespace lincoln
63} // namespace canbus
64} // namespace apollo
Defines the Byte class.
double roll_rate(const std::uint8_t *bytes, int32_t length) const
calculate the roll rate based on byte array.
Definition gyro_6c.cc:38
virtual void Parse(const std::uint8_t *bytes, int32_t length, Lincoln *chassis_detail) const
Definition gyro_6c.cc:29
double yaw_rate(const std::uint8_t *bytes, int32_t length) const
calculate longitudinal_acceleration based on byte array.
Definition gyro_6c.cc:50
static const int32_t ID
Definition gyro_6c.h:43
the class of Gyro6c (for lincoln vehicle)
class register implement
Definition arena_queue.h:37