Apollo 10.0
自动驾驶开放平台
ads_eps_113.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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 wey {
24
25using ::apollo::drivers::canbus::Byte;
26
27const int32_t Adseps113::ID = 0x113;
28
29// public
31
32uint32_t Adseps113::GetPeriod() const {
33 // TODO(ChaoMa) :modify every protocol's period manually
34 static const uint32_t PERIOD = 20 * 1000;
35 return PERIOD;
36}
37
38void Adseps113::UpdateData(uint8_t* data) {
39 set_p_ads_epsmode(data, ads_epsmode_);
40 set_p_ads_reqepstargetangle(data, ads_reqepstargetangle_);
41}
42
44 // TODO(ChaoMa) :you should check this manually
46 ads_reqepstargetangle_ = 0.0;
47}
48
50 Ads_eps_113::Ads_epsmodeType ads_epsmode) {
51 ads_epsmode_ = ads_epsmode;
52 return this;
53}
54
55// config detail: {'description': 'EPS Mode', 'enum': {0: 'ADS_EPSMODE_DISABLE'
56// 2: 'ADS_EPSMODE_ACTIVE'}, 'precision': 1.0, 'len': 2, 'name': 'ADS_EPSMode',
57// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|3]', 'bit': 7,
58// 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
59void Adseps113::set_p_ads_epsmode(uint8_t* data,
60 Ads_eps_113::Ads_epsmodeType ads_epsmode) {
61 int x = ads_epsmode;
62
63 Byte to_set(data + 0);
64 to_set.set_value(static_cast<uint8_t>(x), 6, 2);
65}
66
67Adseps113* Adseps113::set_ads_reqepstargetangle(double ads_reqepstargetangle) {
68 ads_reqepstargetangle_ = ads_reqepstargetangle;
69 return this;
70}
71
72// config detail: {'description': 'Steering Wheel Target Angle', 'offset':
73// -800.0, 'precision': 0.1, 'len': 14, 'name': 'ADS_ReqEPSTargetAngle',
74// 'is_signed_var': False, 'physical_range': '[-800|838.3]', 'bit': 15,
75// 'type': 'double', 'order': 'motorola', 'physical_unit': 'deg'}
76void Adseps113::set_p_ads_reqepstargetangle(uint8_t* data,
77 double ads_reqepstargetangle) {
78 ads_reqepstargetangle =
79 ProtocolData::BoundedValue(-800.0, 838.3, ads_reqepstargetangle);
80 int x = static_cast<int>((ads_reqepstargetangle - -800.000000) / 0.100000);
81 uint8_t t = 0;
82
83 t = static_cast<uint8_t>(x & 0x3F);
84 Byte to_set0(data + 2);
85 to_set0.set_value(t, 2, 6);
86 x >>= 6;
87
88 t = static_cast<uint8_t>(x & 0xFF);
89 Byte to_set1(data + 1);
90 to_set1.set_value(t, 0, 8);
91}
92
93} // namespace wey
94} // namespace canbus
95} // namespace apollo
Defines the Byte class.
Adseps113 * set_ads_epsmode(Ads_eps_113::Ads_epsmodeType ads_epsmode)
static const int32_t ID
Definition ads_eps_113.h:29
void UpdateData(uint8_t *data) override
Adseps113 * set_ads_reqepstargetangle(double ads_reqepstargetangle)
uint32_t GetPeriod() const override
class register implement
Definition arena_queue.h:37