Skip to content

Commit

Permalink
canbus: neolix_edu add battery signals (ApolloAuto#13044)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkuwangjia authored Nov 24, 2020
1 parent dd57c42 commit 6069b0b
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 4 deletions.
10 changes: 8 additions & 2 deletions modules/canbus/proto/neolix_edu.proto
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,16 @@ message Vcu_powerstatus_214 {
optional int32 vcu_powermodevalid = 2;
// 0x0:NotActivate;0x1:Activate [bit] [0|1]
optional bool replacebatterystateindication = 3;
// 0x0:Normal AEB;0x1:Forbidden [bit] [0|1]
optional bool forbidden_aeb_signal = 4;
// [A] [-400|910.68]
optional double bcu_chargedischargecurrent = 5;
// [V] [0|655.35]
optional double bcu_batt_internalvoltage = 6;
// [bit] [0|15]
optional int32 vcu_driverinfo_alivecounter = 4;
optional int32 vcu_driverinfo_alivecounter = 7;
// [bit] [0|255]
optional int32 vcu_driverinfo_checksum = 5;
optional int32 vcu_driverinfo_checksum = 8;
}

message Ads_light_horn_command_310 {
Expand Down
14 changes: 12 additions & 2 deletions modules/canbus/vehicle/neolix_edu/neolix_edu_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Chassis Neolix_eduController::chassis() {
// 3
chassis_.set_engine_started(true);

// 4 speed_mps
// 3 speed_mps
if (chassis_detail.neolix_edu().has_aeb_frontwheelspeed_353() &&
chassis_detail.neolix_edu().has_aeb_rearwheelspeed_354()) {
auto wheelspeed = chassis_.mutable_wheel_speed();
Expand All @@ -185,7 +185,17 @@ Chassis Neolix_eduController::chassis() {
} else {
chassis_.set_speed_mps(0);
}

// 4 SOC
if (chassis_detail.neolix_edu().has_vcu_vehicle_status_report_101() &&
chassis_detail.neolix_edu()
.vcu_vehicle_status_report_101()
.has_vcu_display_soc()) {
chassis_.set_battery_soc_percentage(chassis_detail.neolix_edu()
.vcu_vehicle_status_report_101()
.vcu_display_soc());
} else {
chassis_.set_battery_soc_percentage(0);
}
// 5 steering
if (chassis_detail.neolix_edu().has_vcu_eps_report_57() &&
chassis_detail.neolix_edu().vcu_eps_report_57().has_vcu_real_angle()) {
Expand Down
41 changes: 41 additions & 0 deletions modules/canbus/vehicle/neolix_edu/protocol/vcu_powerstatus_214.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ void Vcupowerstatus214::Parse(const std::uint8_t* bytes, int32_t length,
->mutable_vcu_powerstatus_214()
->set_replacebatterystateindication(
replacebatterystateindication(bytes, length));
chassis->mutable_neolix_edu()
->mutable_vcu_powerstatus_214()
->set_forbidden_aeb_signal(forbidden_aeb_signal(bytes, length));
chassis->mutable_neolix_edu()
->mutable_vcu_powerstatus_214()
->set_bcu_chargedischargecurrent(
bcu_chargedischargecurrent(bytes, length));
chassis->mutable_neolix_edu()
->mutable_vcu_powerstatus_214()
->set_bcu_batt_internalvoltage(bcu_batt_internalvoltage(bytes, length));
chassis->mutable_neolix_edu()
->mutable_vcu_powerstatus_214()
->set_vcu_driverinfo_alivecounter(
Expand Down Expand Up @@ -92,6 +102,37 @@ bool Vcupowerstatus214::replacebatterystateindication(const std::uint8_t* bytes,
return ret;
}

bool Vcupowerstatus214::forbidden_aeb_signal(const std::uint8_t* bytes,
const int32_t length) const {
Byte t0(bytes + 1);
int32_t x = t0.get_byte(7, 1);

bool ret = x;
return ret;
}

float Vcupowerstatus214::bcu_chargedischargecurrent(
const std::uint8_t* bytes, const int32_t length) const {
Byte t0(bytes + 2);
Byte t1(bytes + 3);
int32_t x1 = t0.get_byte(0, 8);
int32_t x2 = t1.get_byte(0, 8);

int ret = (x1 << 8 | x2) * 0.02 - 400;
return ret;
}

float Vcupowerstatus214::bcu_batt_internalvoltage(const std::uint8_t* bytes,
const int32_t length) const {
Byte t0(bytes + 4);
Byte t1(bytes + 5);
int32_t x1 = t0.get_byte(0, 8);
int32_t x2 = t1.get_byte(0, 8);

int ret = (x1 << 8 | x2) * 0.01;
return ret;
}

// config detail: {'name': 'vcu_driverinfo_alivecounter', 'offset': 0.0,
// 'precision': 1.0, 'len': 4, 'is_signed_var': False, 'physical_range':
// '[0|15]', 'bit': 55, 'type': 'int', 'order': 'motorola', 'physical_unit':
Expand Down
21 changes: 21 additions & 0 deletions modules/canbus/vehicle/neolix_edu/protocol/vcu_powerstatus_214.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,27 @@ class Vcupowerstatus214 : public ::apollo::drivers::canbus::ProtocolData<
bool replacebatterystateindication(const std::uint8_t* bytes,
const int32_t length) const;

// config detail: {'description': '0x0:Normal AEB;0x1:Forbidden', 'offset':
// 0.0, 'precision': 1.0, 'len': 1, 'name': 'forbidden_aeb_signal',
// 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 15, 'type':
// 'bool', 'order': 'motorola', 'physical_unit': 'bit'}
bool forbidden_aeb_signal(const std::uint8_t* bytes,
const int32_t length) const;

// config detail: {'description': ';', 'offset': -400, 'precision': 0.02,
// 'len': 16, 'name': 'chargedischargecurrent', 'is_signed_var': False,
// 'physical_range': '[-400|910.68]', 'bit': 40, 'type': 'double', 'order':
// 'motorola', 'physical_unit': ''}
float bcu_chargedischargecurrent(const std::uint8_t* bytes,
const int32_t length) const;

// config detail: {'description': ';', 'offset': 0, 'precision': 0.01,
// 'len': 16, 'name': 'batt_internalvoltage', 'is_signed_var': False,
// 'physical_range': '[0|655.35]', 'bit': 54, 'type': 'double', 'order':
// 'motorola', 'physical_unit': ''}
float bcu_batt_internalvoltage(const std::uint8_t* bytes,
const int32_t length) const;

// config detail: {'name': 'VCU_DriverInfo_AliveCounter', 'offset': 0.0,
// 'precision': 1.0, 'len': 4, 'is_signed_var': False, 'physical_range':
// '[0|15]', 'bit': 55, 'type': 'int', 'order': 'motorola', 'physical_unit':
Expand Down

0 comments on commit 6069b0b

Please sign in to comment.