161 if (!msg->is_rtr && !msg->is_error) {
167 if (msg->dlc >= message->
GetDlc()) {
172 bool brakeSystemFault = message->
GetSignal(
"DBW_BrakeFault")->
GetResult() ?
true :
false;
173 bool dbwSystemFault = brakeSystemFault;
179 dbw_pacifica_msgs::BrakeReport brakeReport;
180 brakeReport.header.stamp = msg->header.stamp;
181 brakeReport.pedal_position = message->
GetSignal(
"DBW_BrakePdlDriverInput")->
GetResult();
184 brakeReport.enabled = message->
GetSignal(
"DBW_BrakeEnabled")->
GetResult() ?
true :
false;
185 brakeReport.driver_activity = message->
GetSignal(
"DBW_BrakeDriverActivity")->
GetResult() ?
true :
false;
187 brakeReport.fault_brake_system = brakeSystemFault;
189 brakeReport.fault_ch2 = faultCh2;
191 brakeReport.rolling_counter = message->
GetSignal(
"DBW_BrakeRollingCntr")->
GetResult();
193 brakeReport.brake_torque_actual = message->
GetSignal(
"DBW_BrakePcntTorqueActual")->
GetResult();
195 brakeReport.intervention_active = message->
GetSignal(
"DBW_BrakeInterventionActv")->
GetResult() ?
true :
false;
196 brakeReport.intervention_ready = message->
GetSignal(
"DBW_BrakeInterventionReady")->
GetResult() ?
true :
false;
198 brakeReport.parking_brake.status = message->
GetSignal(
"DBW_BrakeParkingBrkStatus")->
GetResult();
200 brakeReport.control_type.value = message->
GetSignal(
"DBW_BrakeCtrlType")->
GetResult();
203 if (faultCh1 || faultCh2) {
205 faultCh1 ?
"true, " :
"false,",
206 faultCh2 ?
"true, " :
"false,");
215 if (msg->dlc >= message->
GetDlc()) {
219 bool faultCh1 = message->
GetSignal(
"DBW_AccelPdlFault_Ch1")->
GetResult() ?
true :
false;
220 bool faultCh2 = message->
GetSignal(
"DBW_AccelPdlFault_Ch2")->
GetResult() ?
true :
false;
221 bool accelPdlSystemFault = message->
GetSignal(
"DBW_AccelPdlFault")->
GetResult() ?
true :
false;
222 bool dbwSystemFault = accelPdlSystemFault;
231 dbw_pacifica_msgs::AcceleratorPedalReport accelPedalReprt;
232 accelPedalReprt.header.stamp = msg->header.stamp;
233 accelPedalReprt.pedal_input = message->
GetSignal(
"DBW_AccelPdlDriverInput")->
GetResult();
234 accelPedalReprt.pedal_output = message->
GetSignal(
"DBW_AccelPdlPosnFdbck")->
GetResult();
235 accelPedalReprt.enabled = message->
GetSignal(
"DBW_AccelPdlEnabled")->
GetResult() ?
true :
false;
236 accelPedalReprt.ignore_driver = message->
GetSignal(
"DBW_AccelPdlIgnoreDriver")->
GetResult() ?
true :
false;
237 accelPedalReprt.driver_activity = message->
GetSignal(
"DBW_AccelPdlDriverActivity")->
GetResult() ?
true :
false;
238 accelPedalReprt.torque_actual = message->
GetSignal(
"DBW_AccelPcntTorqueActual")->
GetResult();
240 accelPedalReprt.control_type.value = message->
GetSignal(
"DBW_AccelCtrlType")->
GetResult();
242 accelPedalReprt.rolling_counter = message->
GetSignal(
"DBW_AccelPdlRollingCntr")->
GetResult();
244 accelPedalReprt.fault_accel_pedal_system = accelPdlSystemFault;
246 accelPedalReprt.fault_ch1 = faultCh1;
247 accelPedalReprt.fault_ch2 = faultCh2;
251 if (faultCh1 || faultCh2) {
253 faultCh1 ?
"true, " :
"false,",
254 faultCh2 ?
"true, " :
"false,");
263 if (msg->dlc >= message->
GetDlc()) {
267 bool steeringSystemFault = message->
GetSignal(
"DBW_SteeringFault")->
GetResult() ?
true :
false;
268 bool dbwSystemFault = steeringSystemFault;
275 dbw_pacifica_msgs::SteeringReport steeringReport;
276 steeringReport.header.stamp = msg->header.stamp;
277 steeringReport.steering_wheel_angle = message->
GetSignal(
"DBW_SteeringWhlAngleAct")->
GetResult() * (M_PI / 180);
278 steeringReport.steering_wheel_angle_cmd = message->
GetSignal(
"DBW_SteeringWhlAngleDes")->
GetResult() * (M_PI / 180);
279 steeringReport.steering_wheel_torque = message->
GetSignal(
"DBW_SteeringWhlPcntTrqCmd")->
GetResult() * 0.0625;
281 steeringReport.enabled = message->
GetSignal(
"DBW_SteeringEnabled")->
GetResult() ?
true :
false;
282 steeringReport.driver_activity = message->
GetSignal(
"DBW_SteeringDriverActivity")->
GetResult() ?
true :
false;
284 steeringReport.rolling_counter = message->
GetSignal(
"DBW_SteeringRollingCntr")->
GetResult();
286 steeringReport.control_type.value = message->
GetSignal(
"DBW_SteeringCtrlType")->
GetResult();
288 steeringReport.overheat_prevention_mode = message->
GetSignal(
"DBW_OverheatPreventMode")->
GetResult() ?
true :
false;
290 steeringReport.steering_overheat_warning = message->
GetSignal(
"DBW_SteeringOverheatWarning")->
GetResult() ?
true :
false;
292 steeringReport.fault_steering_system = steeringSystemFault;
298 if (steeringSystemFault) {
300 steeringSystemFault ?
"true, " :
"false,");
314 bool driverActivity = message->
GetSignal(
"DBW_PrndDriverActivity")->
GetResult() ?
true :
false;
317 dbw_pacifica_msgs::GearReport out;
318 out.header.stamp = msg->header.stamp;
322 out.driver_activity = driverActivity;
323 out.gear_select_system_fault = message->
GetSignal(
"DBW_PrndFault")->
GetResult() ?
true :
false;
336 if (msg->dlc >= message->
GetDlc()) {
339 dbw_pacifica_msgs::WheelSpeedReport out;
340 out.header.stamp = msg->header.stamp;
356 if (msg->dlc >= message->
GetDlc()) {
360 dbw_pacifica_msgs::WheelPositionReport out;
361 out.header.stamp = msg->header.stamp;
377 if (msg->dlc >= message->
GetDlc()) {
381 dbw_pacifica_msgs::TirePressureReport out;
382 out.header.stamp = msg->header.stamp;
396 if (msg->dlc >= message->
GetDlc()) {
400 dbw_pacifica_msgs::SurroundReport out;
401 out.header.stamp = msg->header.stamp;
404 out.rear_radar_object_distance = message->
GetSignal(
"DBW_SonarRearDist")->
GetResult();
406 out.front_radar_distance_valid = message->
GetSignal(
"DBW_Reserved3")->
GetResult() ?
true :
false;
407 out.parking_sonar_data_valid = message->
GetSignal(
"DBW_SonarVld")->
GetResult() ?
true :
false;
426 if (msg->dlc >= message->
GetDlc()) {
450 std_msgs::String msg; msg.data =
vin_;
462 if (msg->dlc >= message->
GetDlc()) {
466 sensor_msgs::Imu out;
467 out.header.stamp = msg->header.stamp;
470 out.angular_velocity.z = (double)message->
GetSignal(
"DBW_ImuYawRate")->
GetResult() * (M_PI / 180.0);
484 if (msg->dlc >= message->
GetDlc()) {
488 dbw_pacifica_msgs::DriverInputReport out;
489 out.header.stamp = msg->header.stamp;
492 out.high_beam_headlights.status = message->
GetSignal(
"DBW_DrvInptHiBeam")->
GetResult();
495 out.cruise_resume_button = message->
GetSignal(
"DBW_DrvInptCruiseResumeBtn")->
GetResult() ?
true :
false;
496 out.cruise_cancel_button = message->
GetSignal(
"DBW_DrvInptCruiseCancelBtn")->
GetResult() ?
true :
false;
497 out.cruise_accel_button = message->
GetSignal(
"DBW_DrvInptCruiseAccelBtn")->
GetResult() ?
true :
false;
498 out.cruise_decel_button = message->
GetSignal(
"DBW_DrvInptCruiseDecelBtn")->
GetResult() ?
true :
false;
499 out.cruise_on_off_button = message->
GetSignal(
"DBW_DrvInptCruiseOnOffBtn")->
GetResult() ?
true :
false;
501 out.adaptive_cruise_on_off_button = message->
GetSignal(
"DBW_DrvInptAccOnOffBtn")->
GetResult() ?
true :
false;
502 out.adaptive_cruise_increase_distance_button = message->
GetSignal(
"DBW_DrvInptAccIncDistBtn")->
GetResult() ?
true :
false;
503 out.adaptive_cruise_decrease_distance_button = message->
GetSignal(
"DBW_DrvInptAccDecDistBtn")->
GetResult() ?
true :
false;
505 out.door_or_hood_ajar = message->
GetSignal(
"DBW_OccupAnyDoorOrHoodAjar")->
GetResult() ?
true :
false;
507 out.airbag_deployed = message->
GetSignal(
"DBW_OccupAnyAirbagDeployed")->
GetResult() ?
true :
false;
508 out.any_seatbelt_unbuckled = message->
GetSignal(
"DBW_OccupAnySeatbeltUnbuckled")->
GetResult() ?
true :
false;
519 if (msg->dlc >= message->
GetDlc()) {
523 dbw_pacifica_msgs::MiscReport out;
524 out.header.stamp = msg->header.stamp;
528 out.drive_by_wire_enabled = (bool)message->
GetSignal(
"DBW_MiscByWireEnabled")->
GetResult();
531 out.software_build_number = message->
GetSignal(
"DBW_SoftwareBuildNumber")->
GetResult();
532 out.general_actuator_fault = message->
GetSignal(
"DBW_MiscFault")->
GetResult() ?
true :
false;
533 out.by_wire_ready = message->
GetSignal(
"DBW_MiscByWireReady")->
GetResult() ?
true :
false;
534 out.general_driver_activity = message->
GetSignal(
"DBW_MiscDriverActivity")->
GetResult() ?
true :
false;
535 out.comms_fault = message->
GetSignal(
"DBW_MiscAKitCommFault")->
GetResult() ?
true :
false;
548 if (msg->dlc >= message->
GetDlc()) {
552 dbw_pacifica_msgs::LowVoltageSystemReport lvSystemReport;
553 lvSystemReport.header.stamp = msg->header.stamp;
555 lvSystemReport.vehicle_battery_volts = (double)message->
GetSignal(
"DBW_LvVehBattVlt")->
GetResult();
556 lvSystemReport.vehicle_battery_current = (double)message->
GetSignal(
"DBW_LvBattCurr")->
GetResult();
557 lvSystemReport.vehicle_alternator_current = (double)message->
GetSignal(
"DBW_LvAlternatorCurr")->
GetResult();
559 lvSystemReport.dbw_battery_volts = (double)message->
GetSignal(
"DBW_LvDbwBattVlt")->
GetResult();
560 lvSystemReport.dcdc_current = (double)message->
GetSignal(
"DBW_LvDcdcCurr")->
GetResult();
562 lvSystemReport.aux_inverter_contactor = message->
GetSignal(
"DBW_LvInvtrContactorCmd")->
GetResult() ?
true :
false;
573 if (msg->dlc >= message->
GetDlc()) {
576 dbw_pacifica_msgs::Brake2Report brake2Report;
577 brake2Report.header.stamp = msg->header.stamp;
581 brake2Report.estimated_road_slope = message->
GetSignal(
"DBW_RoadSlopeEstimate")->
GetResult();
594 if (msg->dlc >= message->
GetDlc()) {
597 dbw_pacifica_msgs::Steering2Report steering2Report;
598 steering2Report.header.stamp = msg->header.stamp;
600 steering2Report.vehicle_curvature_actual = message->
GetSignal(
"DBW_SteeringVehCurvatureAct")->
GetResult();
602 steering2Report.max_torque_driver = message->
GetSignal(
"DBW_SteerTrq_Driver")->
GetResult();
604 steering2Report.max_torque_motor = message->
GetSignal(
"DBW_SteerTrq_Motor")->
GetResult();
615 if (msg->dlc >= message->
GetDlc()) {
618 dbw_pacifica_msgs::FaultActionsReport faultActionsReport;
619 faultActionsReport.header.stamp = msg->header.stamp;
621 faultActionsReport.autonomous_disabled_no_brakes = message->
GetSignal(
"DBW_FltAct_AutonDsblNoBrakes")->
GetResult();
623 faultActionsReport.autonomous_disabled_apply_brakes = message->
GetSignal(
"DBW_FltAct_AutonDsblApplyBrakes")->
GetResult();
624 faultActionsReport.can_gateway_disabled = message->
GetSignal(
"DBW_FltAct_CANGatewayDsbl")->
GetResult();
625 faultActionsReport.inverter_contactor_disabled = message->
GetSignal(
"DBW_FltAct_InvtrCntctrDsbl")->
GetResult();
626 faultActionsReport.prevent_enter_autonomous_mode = message->
GetSignal(
"DBW_FltAct_PreventEnterAutonMode")->
GetResult();
627 faultActionsReport.warn_driver_only = message->
GetSignal(
"DBW_FltAct_WarnDriverOnly")->
GetResult();
638 if (msg->dlc >= message->
GetDlc()) {
641 dbw_pacifica_msgs::HmiGlobalEnableReport hmiGlobalEnableReport;
642 hmiGlobalEnableReport.header.stamp = msg->header.stamp;
644 hmiGlobalEnableReport.enable_request = message->
GetSignal(
"HMI_GlobalByWireEnblReq")->
GetResult();
646 hmiGlobalEnableReport.disable_request = message->
GetSignal(
"HMI_GlobalByWireDisblReq")->
GetResult();
647 hmiGlobalEnableReport.checksum = message->
GetSignal(
"HMI_GlobalEnblChecksum")->
GetResult();
648 hmiGlobalEnableReport.ecu_build_number = message->
GetSignal(
"HMI_SoftwareBuildNumber")->
GetResult();
649 hmiGlobalEnableReport.rolling_counter = message->
GetSignal(
"HMI_GlobalEnblRollingCntr")->
GetResult();
671 ROS_INFO(
"ena: %s, clr: %s, brake: %s, Accelerator Pedal: %s, steering: %s, gear: %s",
673 clear() ?
"true " :
"false",
694 if (msg->control_type.value == dbw_pacifica_msgs::ActuatorControlMode::open_loop) {
697 }
else if (msg->control_type.value == dbw_pacifica_msgs::ActuatorControlMode::closed_loop_actuator) {
700 }
else if (msg->control_type.value == dbw_pacifica_msgs::ActuatorControlMode::closed_loop_vehicle) {
703 message->
GetSignal(
"AKit_SpeedModeNegJerkLim")->
SetResult(msg->decel_negative_jerk_limit);
717 can_msgs::Frame frame = message->
GetFrame();
740 if (msg->control_type.value == dbw_pacifica_msgs::ActuatorControlMode::open_loop) {
743 }
else if (msg->control_type.value == dbw_pacifica_msgs::ActuatorControlMode::closed_loop_actuator) {
746 }
else if (msg->control_type.value == dbw_pacifica_msgs::ActuatorControlMode::closed_loop_vehicle) {
752 message->
GetSignal(
"AKit_SpeedModePosJerkLim")->
SetResult(msg->accel_positive_jerk_limit);
769 can_msgs::Frame frame = message->
GetFrame();
788 if (msg->control_type.value == dbw_pacifica_msgs::ActuatorControlMode::open_loop) {
791 }
else if (msg->control_type.value == dbw_pacifica_msgs::ActuatorControlMode::closed_loop_actuator) {
793 double scmd = std::max((
float)-470.0, std::min((
float)470.0, (
float)(msg->angle_cmd * (180 / M_PI * 1.0))));
795 }
else if (msg->control_type.value == dbw_pacifica_msgs::ActuatorControlMode::closed_loop_vehicle) {
797 message->
GetSignal(
"AKit_SteeringVehCurvatureReq")->
SetResult(msg->vehicle_curvature_cmd);
802 if (fabsf(msg->angle_velocity) > 0)
804 uint16_t vcmd = std::max((
float)1, std::min((
float)254, (
float)roundf(fabsf(msg->angle_velocity) * 180 / M_PI / 2)));
819 can_msgs::Frame frame = message->
GetFrame();
843 can_msgs::Frame frame = message->
GetFrame();
859 if(msg->global_enable) {
863 if(msg->enable_joystick_limits) {
872 can_msgs::Frame frame = message->
GetFrame();
900 message->
GetSignal(
"AKit_RightRearDoorReq")->
SetResult(msg->door_request_right_rear.value);
908 message->
GetSignal(
"AKit_LeftRearDoorReq")->
SetResult(msg->door_request_left_rear.value);
909 message->
GetSignal(
"AKit_LiftgateDoorReq")->
SetResult(msg->door_request_lift_gate.value);
911 message->
GetSignal(
"AKit_BlockBasicCruiseCtrlBtns")->
SetResult(msg->block_standard_cruise_buttons);
912 message->
GetSignal(
"AKit_BlockAdapCruiseCtrlBtns")->
SetResult(msg->block_adaptive_cruise_buttons);
913 message->
GetSignal(
"AKit_BlockTurnSigStalkInpts")->
SetResult(msg->block_turn_signal_stalk);
921 can_msgs::Frame frame = message->
GetFrame();
944 out.is_extended =
false;
993 ROS_WARN(
"DBW system not enabled. Steering calibration fault.");
996 ROS_WARN(
"DBW system not enabled. Braking fault.");
999 ROS_WARN(
"DBW system not enabled. Accelerator Pedal fault.");
1002 ROS_WARN(
"DBW system not enabled. Steering fault.");
1005 ROS_WARN(
"DBW system not enabled. Watchdog fault.");
1012 ROS_INFO(
"DBW system enable requested. Waiting for ready.");
1032 ROS_WARN(
"DBW system disabled. Cancel button pressed.");
1039 if (
override && en) {
1045 ROS_WARN(
"DBW system disabled. Driver override on brake/Accelerator Pedal pedal.");
1055 if (
override && en) {
1061 ROS_WARN(
"DBW system disabled. Driver override on brake/Accelerator Pedal pedal.");
1071 if (
override && en) {
1077 ROS_WARN(
"DBW system disabled. Driver override on steering wheel.");
1087 if (
override && en) {
1093 ROS_WARN(
"DBW system disabled. Driver override on shifter.");
1103 ROS_WARN(
"Brake subsystem disabled after 100ms command timeout");
1112 ROS_WARN(
"Accelerator Pedal subsystem disabled after 100ms command timeout");
1121 ROS_WARN(
"Steering subsystem disabled after 100ms command timeout");
1136 ROS_ERROR(
"DBW system disabled. Braking fault.");
1152 ROS_ERROR(
"DBW system disabled. Accelerator Pedal fault.");
1168 ROS_ERROR(
"DBW system disabled. Steering fault.");
1184 ROS_ERROR(
"DBW system disabled. Steering calibration fault.");
1200 ROS_ERROR(
"DBW system disabled. Watchdog fault.");
1206 ROS_WARN(
"Watchdog event: Alerting driver and applying brakes.");
1208 ROS_INFO(
"Watchdog event: Driver has successfully taken control.");
1211 ROS_WARN(
"Watchdog event: Unknown Fault!");
1260 }
else if (!fault) {
1265 ROS_WARN_THROTTLE(2.0,
"Watchdog event: Press left OK button on the steering wheel or cycle power to clear event.");
1275 double dt = (stamp -
joint_state_.header.stamp).toSec();
1285 const double r = L / tan(steering->steering_wheel_angle /
steering_ratio_);
void recvGearCmd(const dbw_pacifica_msgs::GearCmd::ConstPtr &msg)
bool fault_watchdog_warned_
NewEagle::DbcSignal * GetSignal(std::string signalName)
void publishJointStates(const ros::Time &stamp, const dbw_pacifica_msgs::WheelSpeedReport *wheels, const dbw_pacifica_msgs::SteeringReport *steering)
void recvMiscCmd(const dbw_pacifica_msgs::MiscCmd::ConstPtr &msg)
ros::Publisher pub_brake_2_report_
void faultWatchdog(bool fault, uint8_t src, bool braking)
#define ROS_WARN_THROTTLE(rate,...)
ros::Publisher pub_sys_enable_
void publish(const boost::shared_ptr< M > &message) const
ros::Subscriber sub_global_enable_
void SetFrame(const can_msgs::Frame::ConstPtr &msg)
void recvCAN(const can_msgs::Frame::ConstPtr &msg)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ros::Publisher pub_driver_input_
sensor_msgs::JointState joint_state_
ros::Publisher pub_fault_actions_report_
void recvAcceleratorPedalCmd(const dbw_pacifica_msgs::AcceleratorPedalCmd::ConstPtr &msg)
NewEagle::Dbc NewDbc(const std::string &dbcFile)
void recvDisable(const std_msgs::Empty::ConstPtr &msg)
ros::Publisher pub_wheel_speeds_
bool enabled_accelerator_pedal_
ros::Subscriber sub_gear_
void timeoutAcceleratorPedal(bool timeout, bool enabled)
ros::Publisher pub_steering_2_report_
void faultSteeringCal(bool fault)
ros::Publisher pub_brake_
void overrideSteering(bool override)
can_msgs::Frame GetFrame()
ros::Publisher pdu1_relay_pub_
ros::Publisher pub_low_voltage_system_
NewEagle::DbcMessage * GetMessage(std::string messageName)
ros::Subscriber sub_accelerator_pedal_
void timeoutSteering(bool timeout, bool enabled)
void timerCallback(const ros::TimerEvent &event)
ros::Subscriber sub_brake_
bool fault_watchdog_using_brakes_
void timeoutBrake(bool timeout, bool enabled)
ros::Subscriber sub_misc_
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
void recvGlobalEnableCmd(const dbw_pacifica_msgs::GlobalEnableCmd::ConstPtr &msg)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void recvEnable(const std_msgs::Empty::ConstPtr &msg)
ros::Subscriber sub_disable_
void SetResult(double result)
void overrideAcceleratorPedal(bool override)
ros::Subscriber sub_steering_
ros::Publisher pub_wheel_positions_
bool override_accelerator_pedal_
bool timeout_accelerator_pedal_
ros::Publisher pub_joint_states_
void faultBrakes(bool fault)
DbwNode(ros::NodeHandle &node, ros::NodeHandle &priv_nh)
void overrideGear(bool override)
ros::Publisher pub_hmi_global_enable_report_
NewEagle::DbcMessage * GetMessageById(uint32_t id)
bool getParam(const std::string &key, std::string &s) const
ros::Publisher pub_tire_pressure_
ros::Subscriber sub_enable_
void recvSteeringCmd(const dbw_pacifica_msgs::SteeringCmd::ConstPtr &msg)
bool fault_accelerator_pedal_
void faultAcceleratorPedal(bool fault)
ros::Publisher pub_surround_
void faultSteering(bool fault)
void overrideBrake(bool override)
ros::Publisher pub_steering_
void recvBrakeCmd(const dbw_pacifica_msgs::BrakeCmd::ConstPtr &msg)
ros::Publisher pub_twist_
ros::Publisher pub_accel_pedal_