DbwNode does not forward correct Brake Command in specific firmware versions
Issue #32
new
Reviewing the CAN TX traffic from the DataSpeed ROS Node to the DataSpeed Brake Module, it was found for old firmware revisions, the commanded “percent” does not go from 0 - 100%. Instead, it goes from 0.15 to 50%.
It seems the issue is related to the fwd flag:
bool fwd_abs = firmware_.findModule(M_ABS).valid(); // Does the ABS braking module exist? bool fwd_bpe = firmware_.findPlatform(M_BPEC) >= FIRMWARE_CMDTYPE; // Minimum required BPEC firmware version bool fwd = !pedal_luts_; // Forward command type, or apply pedal LUTs locally fwd |= fwd_abs; // The local pedal LUTs are for the BPEC module, the ABS module requires forwarding fwd &= fwd_bpe; // Only modern BPEC firmware supports forwarding the command type
I.e. Firmware 2.0.0 will set:
fwd_abs = 0
fwd_bpe = 0
fwd = !pedal_luts_ → 1
fwd |= fw_abs → 1
fwd &= fwd_bpe → 0
case dbw_mkz_msgs::BrakeCmd::CMD_PERCENT: if (fwd) { ptr->CMD_TYPE = dbw_mkz_msgs::BrakeCmd::CMD_PERCENT; ptr->PCMD = std::clamp<float>(msg->pedal_cmd * UINT16_MAX, 0, UINT16_MAX); } else { ptr->CMD_TYPE = dbw_mkz_msgs::BrakeCmd::CMD_PEDAL; ptr->PCMD = std::clamp<float>(brakePedalFromPercent(msg->pedal_cmd) * UINT16_MAX, 0, UINT16_MAX); }
When commanding CMD_PERCENT, it uses the BrakeLUT Table due to fwd is set to 0