Apollo 10.0
自动驾驶开放平台
apollo::canbus::lincoln::Gear67类 参考

one of the protocol data of lincoln vehicle 更多...

#include <gear_67.h>

类 apollo::canbus::lincoln::Gear67 继承关系图:
apollo::canbus::lincoln::Gear67 的协作图:

Public 成员函数

virtual void Parse (const std::uint8_t *bytes, int32_t length, Lincoln *chassis_detail) const
 
int32_t gear_state (const std::uint8_t *bytes, int32_t length) const
 get the gear state from byte array config detail: {'name': 'state', 'offset': 0.0, 'precision': 1.0, 'len': 3, 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit': 0, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
 
bool is_canbus_fault (const std::uint8_t *bytes, int32_t length) const
 check canbus fault from byte array config detail: {'name': 'fltbus', 'offset': 0.0, 'precision': 1.0, 'len': 1, 'f_type': 'valid', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit': 7, 'type': 'bool', 'order': 'intel', 'physical_unit': '""'}
 
bool is_driver_override (const std::uint8_t *bytes, int32_t length) const
 check driver override from byte array config detail: {'name': 'driver', 'offset': 0.0, 'precision': 1.0, 'len': 1, 'f_type': 'valid', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit': 3, 'type': 'bool', 'order': 'intel', 'physical_unit': '""'}
 
int32_t reported_gear_cmd (const std::uint8_t *bytes, int32_t length) const
 get reported gear command from byte array config detail: {'name': 'cmd', 'offset': 0.0, 'precision': 1.0, 'len': 3, 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit': 4, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
 
- Public 成员函数 继承自 apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Lincoln >
 ProtocolData ()=default
 construct protocol data.
 
virtual ~ProtocolData ()=default
 destruct protocol data.
 
virtual uint32_t GetPeriod () const
 
virtual int32_t GetLength () const
 
virtual void Parse (const uint8_t *bytes, int32_t length, ::apollo::canbus::Lincoln *sensor_data) const
 
virtual void UpdateData (uint8_t *data)
 
virtual void UpdateData_Heartbeat (uint8_t *data)
 
virtual void Reset ()
 

静态 Public 属性

static const int32_t ID = 0x67
 

额外继承的成员函数

- 静态 Public 成员函数 继承自 apollo::drivers::canbus::ProtocolData< ::apollo::canbus::Lincoln >
static std::uint8_t CalculateCheckSum (const uint8_t *input, const uint32_t length)
 static function, used to calculate the checksum of input array.
 
static T BoundedValue (T lower, T upper, T val)
 

详细描述

one of the protocol data of lincoln vehicle

在文件 gear_67.h40 行定义.

成员函数说明

◆ gear_state()

int32_t apollo::canbus::lincoln::Gear67::gear_state ( const std::uint8_t *  bytes,
int32_t  length 
) const

get the gear state from byte array config detail: {'name': 'state', 'offset': 0.0, 'precision': 1.0, 'len': 3, 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit': 0, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}

参数
bytesa pointer to the byte array
lengththe length of the byte array
返回
the value of the gear state

在文件 gear_67.cc95 行定义.

95 {
96 Byte frame(bytes + 0);
97 int32_t x = frame.get_byte(0, 3);
98 return x;
99}

◆ is_canbus_fault()

bool apollo::canbus::lincoln::Gear67::is_canbus_fault ( const std::uint8_t *  bytes,
int32_t  length 
) const

check canbus fault from byte array config detail: {'name': 'fltbus', 'offset': 0.0, 'precision': 1.0, 'len': 1, 'f_type': 'valid', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit': 7, 'type': 'bool', 'order': 'intel', 'physical_unit': '""'}

参数
bytesa pointer to the byte array
lengththe length of the byte array
返回
the boolean value of canbus fault

在文件 gear_67.cc114 行定义.

114 {
115 Byte frame(bytes + 0);
116 return frame.is_bit_1(7);
117}

◆ is_driver_override()

bool apollo::canbus::lincoln::Gear67::is_driver_override ( const std::uint8_t *  bytes,
int32_t  length 
) const

check driver override from byte array config detail: {'name': 'driver', 'offset': 0.0, 'precision': 1.0, 'len': 1, 'f_type': 'valid', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit': 3, 'type': 'bool', 'order': 'intel', 'physical_unit': '""'}

参数
bytesa pointer to the byte array
lengththe length of the byte array
返回
the boolean value of driver override

在文件 gear_67.cc101 行定义.

102 {
103 Byte frame(bytes + 0);
104 return frame.is_bit_1(3);
105}

◆ Parse()

void apollo::canbus::lincoln::Gear67::Parse ( const std::uint8_t *  bytes,
int32_t  length,
Lincoln chassis_detail 
) const
virtual

在文件 gear_67.cc29 行定义.

30 {
31 int32_t gear = gear_state(bytes, length);
32 switch (gear) {
33 case 0x01:
34 chassis_detail->mutable_gear()->set_gear_state(Chassis::GEAR_PARKING);
35 break;
36 case 0x02:
37 chassis_detail->mutable_gear()->set_gear_state(Chassis::GEAR_REVERSE);
38 break;
39 case 0x03:
40 chassis_detail->mutable_gear()->set_gear_state(Chassis::GEAR_NEUTRAL);
41 break;
42 case 0x04:
43 chassis_detail->mutable_gear()->set_gear_state(Chassis::GEAR_DRIVE);
44 break;
45 case 0x05:
46 chassis_detail->mutable_gear()->set_gear_state(Chassis::GEAR_LOW);
47 break;
48 case 0x00:
49 chassis_detail->mutable_gear()->set_gear_state(Chassis::GEAR_NONE);
50 break;
51 default:
52 chassis_detail->mutable_gear()->set_gear_state(Chassis::GEAR_INVALID);
53 break;
54 }
55
56 if (is_driver_override(bytes, length)) {
57 // last shift requested by driver
58 chassis_detail->mutable_gear()->set_is_shift_position_valid(false);
59 } else {
60 // last shift requested by-wire
61 chassis_detail->mutable_gear()->set_is_shift_position_valid(true);
62 }
63 chassis_detail->mutable_gear()->set_driver_override(
64 is_driver_override(bytes, length));
65
66 int32_t gear_cmd = reported_gear_cmd(bytes, length);
67 switch (gear_cmd) {
68 case 0x01:
69 chassis_detail->mutable_gear()->set_gear_cmd(Chassis::GEAR_PARKING);
70 break;
71 case 0x02:
72 chassis_detail->mutable_gear()->set_gear_cmd(Chassis::GEAR_REVERSE);
73 break;
74 case 0x03:
75 chassis_detail->mutable_gear()->set_gear_cmd(Chassis::GEAR_NEUTRAL);
76 break;
77 case 0x04:
78 chassis_detail->mutable_gear()->set_gear_cmd(Chassis::GEAR_DRIVE);
79 break;
80 case 0x05:
81 chassis_detail->mutable_gear()->set_gear_cmd(Chassis::GEAR_LOW);
82 break;
83 case 0x00:
84 chassis_detail->mutable_gear()->set_gear_cmd(Chassis::GEAR_NONE);
85 break;
86 default:
87 chassis_detail->mutable_gear()->set_gear_cmd(Chassis::GEAR_INVALID);
88 break;
89 }
90
91 chassis_detail->mutable_gear()->set_canbus_fault(
92 is_canbus_fault(bytes, length));
93}
bool is_driver_override(const std::uint8_t *bytes, int32_t length) const
check driver override from byte array config detail: {'name': 'driver', 'offset': 0....
Definition gear_67.cc:101
int32_t gear_state(const std::uint8_t *bytes, int32_t length) const
get the gear state from byte array config detail: {'name': 'state', 'offset': 0.0,...
Definition gear_67.cc:95
int32_t reported_gear_cmd(const std::uint8_t *bytes, int32_t length) const
get reported gear command from byte array config detail: {'name': 'cmd', 'offset': 0....
Definition gear_67.cc:107
bool is_canbus_fault(const std::uint8_t *bytes, int32_t length) const
check canbus fault from byte array config detail: {'name': 'fltbus', 'offset': 0.0,...
Definition gear_67.cc:114

◆ reported_gear_cmd()

int32_t apollo::canbus::lincoln::Gear67::reported_gear_cmd ( const std::uint8_t *  bytes,
int32_t  length 
) const

get reported gear command from byte array config detail: {'name': 'cmd', 'offset': 0.0, 'precision': 1.0, 'len': 3, 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit': 4, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}

参数
bytesa pointer to the byte array
lengththe length of the byte array
返回
the value of reported gear command

在文件 gear_67.cc107 行定义.

108 {
109 Byte frame(bytes + 0);
110 int32_t x = frame.get_byte(4, 3);
111 return x;
112}

类成员变量说明

◆ ID

const int32_t apollo::canbus::lincoln::Gear67::ID = 0x67
static

在文件 gear_67.h43 行定义.


该类的文档由以下文件生成: