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
17
#include "
modules/canbus_vehicle/gem/protocol/vehicle_speed_rpt_6f.h
"
18
19
#include "glog/logging.h"
20
21
#include "
modules/drivers/canbus/common/byte.h
"
22
#include "
modules/drivers/canbus/common/canbus_consts.h
"
23
24
namespace
apollo
{
25
namespace
canbus {
26
namespace
gem {
27
28
using ::apollo::drivers::canbus::Byte;
29
30
Vehiclespeedrpt6f::Vehiclespeedrpt6f
() {}
31
const
int32_t
Vehiclespeedrpt6f::ID
= 0x6F;
32
33
void
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'}
44
double
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': ''}
66
Vehicle_speed_rpt_6f::Vehicle_speed_validType
67
Vehiclespeedrpt6f::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
72
Vehicle_speed_rpt_6f::Vehicle_speed_validType
ret =
73
static_cast<
Vehicle_speed_rpt_6f::Vehicle_speed_validType
>
(x);
74
return
ret;
75
}
76
}
// namespace gem
77
}
// namespace canbus
78
}
// namespace apollo
byte.h
Defines the Byte class.
canbus_consts.h
apollo::canbus::gem::Vehiclespeedrpt6f::Vehiclespeedrpt6f
Vehiclespeedrpt6f()
Definition
vehicle_speed_rpt_6f.cc:30
apollo::canbus::gem::Vehiclespeedrpt6f::ID
static const int32_t ID
Definition
vehicle_speed_rpt_6f.h:29
apollo::canbus::gem::Vehiclespeedrpt6f::Parse
void Parse(const std::uint8_t *bytes, int32_t length, Gem *chassis) const override
Definition
vehicle_speed_rpt_6f.cc:33
apollo
class register implement
Definition
arena_queue.h:37
apollo::canbus::Gem
Definition
gem.proto:470
apollo::canbus::Vehicle_speed_rpt_6f::Vehicle_speed_validType
Vehicle_speed_validType
Definition
gem.proto:378
vehicle_speed_rpt_6f.h
modules
canbus_vehicle
gem
protocol
vehicle_speed_rpt_6f.cc