Apollo 10.0
自动驾驶开放平台
vehicle_speed_rpt_6f.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
19#include "glog/logging.h"
20
23
24namespace apollo {
25namespace canbus {
26namespace gem {
27
28using ::apollo::drivers::canbus::Byte;
29
31const int32_t Vehiclespeedrpt6f::ID = 0x6F;
32
33void Vehiclespeedrpt6f::Parse(const std::uint8_t* bytes, int32_t length,
34 Gem* chassis) const {
35 chassis->mutable_vehicle_speed_rpt_6f()->set_vehicle_speed(
36 vehicle_speed(bytes, length));
37 chassis->mutable_vehicle_speed_rpt_6f()->set_vehicle_speed_valid(
38 vehicle_speed_valid(bytes, length));
39}
40
41// config detail: {'name': 'vehicle_speed', 'offset': 0.0, 'precision': 0.01,
42// 'len': 16, 'is_signed_var': True, 'physical_range': '[-327.68|327.67]',
43// 'bit': 7, 'type': 'double', 'order': 'motorola', 'physical_unit': 'm/s'}
44double Vehiclespeedrpt6f::vehicle_speed(const std::uint8_t* bytes,
45 int32_t length) const {
46 Byte t0(bytes + 0);
47 int32_t x = t0.get_byte(0, 8);
48
49 Byte t1(bytes + 1);
50 int32_t t = t1.get_byte(0, 8);
51 x <<= 8;
52 x |= t;
53
54 x <<= 16;
55 x >>= 16;
56
57 double ret = x * 0.010000;
58 return ret;
59}
60
61// config detail: {'name': 'vehicle_speed_valid', 'enum': {0:
62// 'VEHICLE_SPEED_VALID_INVALID', 1: 'VEHICLE_SPEED_VALID_VALID'},
63// 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'offset': 0.0,
64// 'physical_range': '[0|1]', 'bit': 16, 'type': 'enum', 'order': 'motorola',
65// 'physical_unit': ''}
67Vehiclespeedrpt6f::vehicle_speed_valid(const std::uint8_t* bytes,
68 int32_t length) const {
69 Byte t0(bytes + 2);
70 int32_t x = t0.get_byte(0, 1);
71
74 return ret;
75}
76} // namespace gem
77} // namespace canbus
78} // namespace apollo
Defines the Byte class.
void Parse(const std::uint8_t *bytes, int32_t length, Gem *chassis) const override
class register implement
Definition arena_queue.h:37