40 #define ROS_LOG_ONCE_ID(id, level, name, ...) \
43 ROSCONSOLE_DEFINE_LOCATION(true, level, name); \
44 static std::map<int, bool> map; \
45 bool &hit = map[id]; \
46 if (ROS_UNLIKELY(__rosconsole_define_location__enabled) && ROS_UNLIKELY(!hit)) \
49 ROSCONSOLE_PRINT_AT_LOCATION(__VA_ARGS__); \
52 #define ROS_DEBUG_ONCE_ID(id, ...) ROS_LOG_ONCE_ID(id, ::ros::console::levels::Debug, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__)
53 #define ROS_INFO_ONCE_ID(id, ...) ROS_LOG_ONCE_ID(id, ::ros::console::levels::Info, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__)
54 #define ROS_WARN_ONCE_ID(id, ...) ROS_LOG_ONCE_ID(id, ::ros::console::levels::Warn, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__)
55 #define ROS_ERROR_ONCE_ID(id, ...) ROS_LOG_ONCE_ID(id, ::ros::console::levels::Error, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__)
56 #define ROS_FATAL_ONCE_ID(id, ...) ROS_LOG_ONCE_ID(id, ::ros::console::levels::Fatal, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__)
147 pub_can_ =
node.advertise<can_msgs::Frame>(
"can_tx", 10);
148 pub_brake_ =
node.advertise<dbw_fca_msgs::BrakeReport>(
"brake_report", 2);
149 pub_throttle_ =
node.advertise<dbw_fca_msgs::ThrottleReport>(
"throttle_report", 2);
150 pub_steering_ =
node.advertise<dbw_fca_msgs::SteeringReport>(
"steering_report", 2);
151 pub_gear_ =
node.advertise<dbw_fca_msgs::GearReport>(
"gear_report", 2);
152 pub_misc_1_ =
node.advertise<dbw_fca_msgs::Misc1Report>(
"misc_1_report", 2);
153 pub_misc_2_ =
node.advertise<dbw_fca_msgs::Misc2Report>(
"misc_2_report", 2);
160 pub_imu_ =
node.advertise<sensor_msgs::Imu>(
"imu/data_raw", 10);
164 pub_twist_ =
node.advertise<geometry_msgs::TwistStamped>(
"twist", 10);
165 pub_vin_ =
node.advertise<std_msgs::String>(
"vin", 1,
true);
209 if (!msg->is_rtr && !msg->is_error && !msg->is_extended) {
218 dbw_fca_msgs::BrakeReport out;
219 out.header.stamp = msg->header.stamp;
220 if (ptr->
BTYPE == 0) {
222 out.pedal_input = (float)ptr->
PI / UINT16_MAX;
223 out.pedal_cmd = (
float)ptr->
PC / UINT16_MAX;
224 out.pedal_output = (float)ptr->
PO / UINT16_MAX;
228 }
else if (ptr->
BTYPE == 1) {
230 out.torque_input = ptr->
PI;
231 out.decel_cmd = ptr->
PC * 1e-3
f;
232 out.decel_output = ptr->
PO * 1e-3
f;
236 out.enabled = ptr->
ENABLED ? true :
false;
237 out.override = ptr->
OVERRIDE ? true :
false;
238 out.driver = ptr->
DRIVER ? true :
false;
239 out.watchdog_counter.source = ptr->
WDCSRC;
240 out.watchdog_braking = ptr->
WDCBRK ? true :
false;
241 out.fault_wdc = ptr->
FLTWDC ? true :
false;
242 out.fault_ch1 = ptr->
FLT1 ? true :
false;
243 out.fault_ch2 = ptr->
FLT2 ? true :
false;
244 out.fault_power = ptr->
FLTPWR ? true :
false;
245 out.timeout = ptr->
TMOUT ? true :
false;
249 ptr->
FLT1 ?
"true, " :
"false,",
250 ptr->
FLT2 ?
"true, " :
"false,",
251 ptr->
FLTPWR ?
"true" :
"false");
263 dbw_fca_msgs::ThrottleReport out;
264 out.header.stamp = msg->header.stamp;
265 out.pedal_input = (float)ptr->
PI / UINT16_MAX;
266 out.pedal_cmd = (
float)ptr->
PC / UINT16_MAX;
267 out.pedal_output = (float)ptr->
PO / UINT16_MAX;
268 out.enabled = ptr->
ENABLED ?
true :
false;
269 out.override = ptr->
OVERRIDE ?
true :
false;
270 out.driver = ptr->
DRIVER ?
true :
false;
271 out.watchdog_counter.source = ptr->
WDCSRC;
272 out.fault_wdc = ptr->
FLTWDC ?
true :
false;
273 out.fault_ch1 = ptr->
FLT1 ?
true :
false;
274 out.fault_ch2 = ptr->
FLT2 ?
true :
false;
275 out.fault_power = ptr->
FLTPWR ?
true :
false;
276 out.timeout = ptr->
TMOUT ?
true :
false;
280 ptr->
FLT1 ?
"true, " :
"false,",
281 ptr->
FLT2 ?
"true, " :
"false,",
282 ptr->
FLTPWR ?
"true" :
"false");
295 dbw_fca_msgs::SteeringReport out;
296 out.header.stamp = msg->header.stamp;
297 if ((uint16_t)ptr->
ANGLE == 0x8000) {
298 out.steering_wheel_angle = NAN;
300 out.steering_wheel_angle = (float)ptr->
ANGLE * (
float)(0.1 * M_PI / 180);
302 out.steering_wheel_cmd_type = ptr->
TMODE ? dbw_fca_msgs::SteeringReport::CMD_TORQUE : dbw_fca_msgs::SteeringReport::CMD_ANGLE;
303 if ((uint16_t)ptr->
CMD == 0xC000) {
304 out.steering_wheel_cmd = NAN;
305 }
else if (out.steering_wheel_cmd_type == dbw_fca_msgs::SteeringReport::CMD_ANGLE) {
306 out.steering_wheel_cmd = (float)ptr->
CMD * (
float)(0.1 * M_PI / 180);
308 out.steering_wheel_cmd = (float)ptr->
CMD / 128.0f;
310 if ((uint8_t)ptr->
TORQUE == 0x80) {
311 out.steering_wheel_torque = NAN;
313 out.steering_wheel_torque = (float)ptr->
TORQUE * (
float)0.0625;
315 if ((uint16_t)ptr->
VEH_VEL == 0x8000) {
318 out.speed = (float)ptr->
VEH_VEL * (
float)(0.01 / 3.6);
320 out.enabled = ptr->
ENABLED ? true :
false;
321 out.override = ptr->
OVERRIDE ? true :
false;
322 out.fault_wdc = ptr->
FLTWDC ? true :
false;
323 out.fault_bus1 = ptr->
FLTBUS1 ? true :
false;
324 out.fault_bus2 = ptr->
FLTBUS2 ? true :
false;
325 out.fault_calibration = ptr->
FLTCAL ? true :
false;
326 out.fault_power = ptr->
FLTPWR ? true :
false;
327 out.timeout = ptr->
TMOUT ? true :
false;
329 geometry_msgs::TwistStamped twist;
330 twist.header.stamp = out.header.stamp;
332 twist.twist.linear.x = out.speed;
340 ptr->
FLTBUS1 ?
"true, " :
"false,",
341 ptr->
FLTBUS2 ?
"true, " :
"false,",
342 ptr->
FLTPWR ?
"true" :
"false");
344 ROS_WARN_THROTTLE(5.0,
"Steering calibration fault. Drive at least 25 mph for at least 10 seconds in a straight line.");
353 dbw_fca_msgs::GearReport out;
354 out.header.stamp = msg->header.stamp;
355 out.state.gear = ptr->
STATE;
356 out.cmd.gear = ptr->
CMD;
357 out.ready = ptr->
READY ? true :
false;
358 out.override = ptr->
OVERRIDE ? true :
false;
359 out.fault_bus = ptr->
FLTBUS ? true :
false;
361 out.reject.value = ptr->
REJECT;
362 if (out.reject.value == dbw_fca_msgs::GearReject::NONE) {
366 switch (out.reject.value) {
367 case dbw_fca_msgs::GearReject::SHIFT_IN_PROGRESS:
368 ROS_WARN(
"Gear shift rejected: Shift in progress");
370 case dbw_fca_msgs::GearReject::OVERRIDE:
371 ROS_WARN(
"Gear shift rejected: Override on brake, throttle, or steering");
373 case dbw_fca_msgs::GearReject::VEHICLE:
374 ROS_WARN(
"Gear shift rejected: Rejected by vehicle, try pressing the brakes");
376 case dbw_fca_msgs::GearReject::UNSUPPORTED:
377 ROS_WARN(
"Gear shift rejected: Unsupported gear command");
379 case dbw_fca_msgs::GearReject::FAULT:
380 ROS_WARN(
"Gear shift rejected: System in fault state");
399 dbw_fca_msgs::Misc1Report out;
400 out.header.stamp = msg->header.stamp;
405 out.btn_cc_res = ptr->
btn_cc_res ? true :
false;
412 out.btn_ld_ok = ptr->
btn_ld_ok ? true :
false;
413 out.btn_ld_up = ptr->
btn_ld_up ? true :
false;
417 out.fault_bus = ptr->
FLTBUS ? true :
false;
420 out.door_trunk = ptr->
door_trunk ? true :
false;
428 dbw_fca_msgs::Misc2Report out;
429 out.header.stamp = msg->header.stamp;
433 out.max_ac = ptr->
max_ac ?
true :
false;
434 out.ac = ptr->
ac ?
true :
false;
435 out.ft_hvac = ptr->
ft_hvac ?
true :
false;
436 out.auto_md = ptr->
auto_md ?
true :
false;
437 out.recirc = ptr->
recirc ?
true :
false;
438 out.sync = ptr->
sync ?
true :
false;
439 out.r_defr = ptr->
r_defr ?
true :
false;
440 out.f_defr = ptr->
f_defr ?
true :
false;
442 out.heated_steering_wheel = ptr->
hsw_stat ?
true :
false;
454 dbw_fca_msgs::WheelSpeedReport out;
455 out.header.stamp = msg->header.stamp;
459 out.front_left = (float)ptr->
front_left * 0.01f;
462 out.front_right = NAN;
466 if ((uint16_t)ptr->
rear_left == 0x8000) {
469 out.rear_left = (float)ptr->
rear_left * 0.01f;
472 out.rear_right = NAN;
474 out.rear_right = (float)ptr->
rear_right * 0.01f;
483 dbw_fca_msgs::WheelPositionReport out;
484 out.header.stamp = msg->header.stamp;
496 dbw_fca_msgs::TirePressureReport out;
497 out.header.stamp = msg->header.stamp;
504 out.front_right = NAN;
514 out.rear_right = NAN;
526 dbw_fca_msgs::FuelLevelReport out;
527 out.header.stamp = msg->header.stamp;
530 out.battery_12v = (float)ptr->
battery_12v * 0.0625f;
531 out.odometer = (
float)ptr->
odometer * 0.1f;
540 dbw_fca_msgs::BrakeInfoReport out;
541 out.header.stamp = msg->header.stamp;
545 out.brake_pc = (float)ptr->
brake_pc * 0.4f;
548 out.brake_torque_request = NAN;
553 out.brake_torque_actual = NAN;
558 out.brake_pressure = NAN;
570 dbw_fca_msgs::ThrottleInfoReport out;
571 out.header.stamp = msg->header.stamp;
578 out.axle_torque = NAN;
580 out.axle_torque = (float)ptr->
axle_torque * 1.5625f;
597 ROS_WARN_ONCE_ID(module,
"Licensing: %s one or more features licensed as a counted trial. Visit https://www.dataspeedinc.com/products/maintenance-subscription/ to request a full license.", str_m);
600 ROS_WARN_ONCE_ID(module,
"Licensing: %s one or more feature licenses expired due to the firmware build date", str_m);
602 }
else if (module ==
M_STEER) {
622 ROS_INFO(
"Licensing: %s license string date: %s", str_m,
ldate_.c_str());
625 ROS_INFO_ONCE(
"Licensing: %s MAC: %02X:%02X:%02X:%02X:%02X:%02X", str_m,
626 ptr->
mac.addr0, ptr->
mac.addr1,
627 ptr->
mac.addr2, ptr->
mac.addr3,
628 ptr->
mac.addr4, ptr->
mac.addr5);
630 std::string &bdate =
bdate_[module];
631 if (bdate.size() == 0) {
632 bdate.push_back(ptr->
bdate0.date0);
633 bdate.push_back(ptr->
bdate0.date1);
634 bdate.push_back(ptr->
bdate0.date2);
635 bdate.push_back(ptr->
bdate0.date3);
636 bdate.push_back(ptr->
bdate0.date4);
637 bdate.push_back(ptr->
bdate0.date5);
640 std::string &bdate =
bdate_[module];
641 if (bdate.size() == 6) {
642 bdate.push_back(ptr->
bdate1.date6);
643 bdate.push_back(ptr->
bdate1.date7);
644 bdate.push_back(ptr->
bdate1.date8);
645 bdate.push_back(ptr->
bdate1.date9);
646 ROS_INFO(
"Licensing: %s firmware build date: %s", str_m, bdate.c_str());
649 if (
vin_.size() == 0) {
658 if (
vin_.size() == 6) {
667 if (
vin_.size() == 12) {
673 std_msgs::String msg; msg.data =
vin_;
677 }
else if ((LIC_MUX_F0 <= ptr->mux) && (ptr->
mux <=
LIC_MUX_F7)) {
678 constexpr std::array<const char*, 8>
NAME = {
"BASE",
"CONTROL",
"SENSORS",
"",
"",
"",
"",
""};
679 constexpr std::array<bool, 8> WARN = {
true,
true,
true,
false,
true,
true,
true,
true};
681 const int id = module *
NAME.size() + i;
682 const std::string name = strcmp(
NAME[i],
"") ?
NAME[i] : std::string(1,
'0' + i);
684 ROS_INFO_ONCE_ID(
id,
"Licensing: %s feature '%s' enabled%s", str_m, name.c_str(), ptr->
license.trial ?
" as a counted trial" :
"");
685 }
else if (ptr->
ready && !WARN[i]) {
686 ROS_INFO_ONCE_ID(
id,
"Licensing: %s feature '%s' not licensed.", str_m, name.c_str());
687 }
else if (ptr->
ready) {
688 ROS_WARN_ONCE_ID(
id,
"Licensing: %s feature '%s' not licensed. Visit https://www.dataspeedinc.com/products/maintenance-subscription/ to request a license.", str_m, name.c_str());
691 ROS_INFO_ONCE(
"Licensing: Feature '%s' trials used: %u, remaining: %u", name.c_str(),
707 if (latest.
valid()) {
710 ROS_WARN(
"Detected %s %s firmware version %u.%u.%u, which is unsupported. Platform: 0x%02X, Module: %u", str_p, str_m,
713 if (version < latest) {
714 ROS_WARN(
"Firmware %s %s has old version %u.%u.%u, updating to %u.%u.%u is suggested.", str_p, str_m,
715 version.v.major(), version.v.minor(), version.v.build(),
724 "DBW system: Another node on the CAN bus is commanding the vehicle!!! Subsystem: Brake. Id: 0x%03X",
ID_BRAKE_CMD);
728 "DBW system: Another node on the CAN bus is commanding the vehicle!!! Subsystem: Throttle. Id: 0x%03X",
ID_THROTTLE_CMD);
732 "DBW system: Another node on the CAN bus is commanding the vehicle!!! Subsystem: Steering. Id: 0x%03X",
ID_STEERING_CMD);
736 "DBW system: Another node on the CAN bus is commanding the vehicle!!! Subsystem: Shifting. Id: 0x%03X",
ID_GEAR_CMD);
742 case 0x100 ... 0x103:
743 case 0x6C0 ... 0x6C5:
744 ROS_WARN_ONCE_ID(msg->id,
"Received unsupported CAN ID %03X from next-generation drive-by-wire system (DBW2)"
745 "\nUse the ROS2 ds_dbw_can package instead", msg->id);
750 ROS_INFO(
"ena: %s, clr: %s, brake: %s, throttle: %s, steering: %s, gear: %s",
752 clear() ?
"true " :
"false",
768 sensor_msgs::Imu out;
769 out.header.stamp = msgs[0]->header.stamp;
771 out.orientation_covariance[0] = -1;
772 if ((uint16_t)ptr_accel->
accel_long == 0x8000) {
773 out.linear_acceleration.x = NAN;
775 out.linear_acceleration.x = (double)ptr_accel->
accel_long * 0.01;
777 if ((uint16_t)ptr_accel->
accel_lat == 0x8000) {
778 out.linear_acceleration.y = NAN;
780 out.linear_acceleration.y = (double)ptr_accel->
accel_lat * -0.01;
782 if ((uint16_t)ptr_gyro->gyro_yaw == 0x8000) {
783 out.angular_velocity.z = NAN;
785 out.angular_velocity.z = (double)ptr_gyro->gyro_yaw * 0.0002;
790 ROS_INFO(
"Time: %u.%u, %u.%u, delta: %fms",
791 msgs[0]->
header.stamp.sec, msgs[0]->header.stamp.nsec,
792 msgs[1]->header.stamp.sec, msgs[1]->header.stamp.nsec,
793 labs((msgs[1]->
header.stamp - msgs[0]->header.stamp).toNSec()) / 1000000.0);
807 sensor_msgs::NavSatFix msg_fix;
808 msg_fix.header.stamp = msgs[0]->header.stamp;
809 msg_fix.latitude = (
double)ptr1->
latitude / 3e6;
810 msg_fix.longitude = (double)ptr1->
longitude / 3e6;
811 msg_fix.altitude = 0.0;
812 msg_fix.position_covariance_type = sensor_msgs::NavSatFix::COVARIANCE_TYPE_UNKNOWN;
813 msg_fix.status.service = sensor_msgs::NavSatStatus::SERVICE_GPS;
814 msg_fix.status.status = sensor_msgs::NavSatStatus::STATUS_NO_FIX;
817 sensor_msgs::TimeReference msg_time;
819 unix_time.tm_year = ptr2->utc_year + 100;
820 unix_time.tm_mon = ptr2->utc_month - 1;
821 unix_time.tm_mday = ptr2->utc_day;
822 unix_time.tm_hour = ptr2->utc_hours;
823 unix_time.tm_min = ptr2->utc_minutes;
824 unix_time.tm_sec = ptr2->utc_seconds;
825 msg_time.header.stamp = msgs[0]->header.stamp;
826 msg_time.time_ref.sec = timegm(&unix_time);
827 msg_time.time_ref.nsec = 0;
830 sensor_msgs::NavSatFix msg_fix_dr;
831 msg_fix_dr.header.stamp = msgs[2]->header.stamp;
832 msg_fix_dr.latitude = (double)ptr3->
dr_latitude / 3e6;
833 msg_fix_dr.longitude = (
double)ptr3->
dr_longitude / 3e6;
834 msg_fix_dr.altitude = 0.0;
835 msg_fix_dr.position_covariance_type = sensor_msgs::NavSatFix::COVARIANCE_TYPE_UNKNOWN;
836 msg_fix_dr.status.service = sensor_msgs::NavSatStatus::SERVICE_GPS;
840 ROS_INFO(
"UTC Time: %04d-%02d-%02d %02d:%02d:%02d",
841 2000 + ptr2->utc_year, ptr2->utc_month, ptr2->utc_day,
842 ptr2->utc_hours, ptr2->utc_minutes, ptr2->utc_seconds);
846 ROS_INFO(
"Time: %u.%u, %u.%u, %u.%u, delta: %fms",
847 msgs[0]->
header.stamp.sec, msgs[0]->header.stamp.nsec,
848 msgs[1]->header.stamp.sec, msgs[1]->header.stamp.nsec,
849 msgs[2]->header.stamp.sec, msgs[2]->header.stamp.nsec,
851 labs((msgs[1]->
header.stamp - msgs[0]->header.stamp).toNSec()),
852 labs((msgs[2]->
header.stamp - msgs[1]->header.stamp).toNSec())),
853 labs((msgs[0]->
header.stamp - msgs[2]->header.stamp).toNSec())) / 1000000.0);
860 out.is_extended =
false;
863 memset(ptr, 0x00,
sizeof(*ptr));
867 switch (msg->pedal_cmd_type) {
868 case dbw_fca_msgs::BrakeCmd::CMD_NONE:
870 case dbw_fca_msgs::BrakeCmd::CMD_PEDAL:
871 ptr->
CMD_TYPE = dbw_fca_msgs::BrakeCmd::CMD_PEDAL;
872 ptr->
PCMD = std::clamp<float>(msg->pedal_cmd * UINT16_MAX, 0, UINT16_MAX);
877 case dbw_fca_msgs::BrakeCmd::CMD_PERCENT:
879 ptr->
CMD_TYPE = dbw_fca_msgs::BrakeCmd::CMD_PERCENT;
880 ptr->
PCMD = std::clamp<float>(msg->pedal_cmd * UINT16_MAX, 0, UINT16_MAX);
882 ptr->
CMD_TYPE = dbw_fca_msgs::BrakeCmd::CMD_PEDAL;
886 case dbw_fca_msgs::BrakeCmd::CMD_TORQUE:
888 ptr->
CMD_TYPE = dbw_fca_msgs::BrakeCmd::CMD_TORQUE;
889 ptr->
PCMD = std::clamp<float>(msg->pedal_cmd, 0, UINT16_MAX);
891 ptr->
CMD_TYPE = dbw_fca_msgs::BrakeCmd::CMD_PEDAL;
898 case dbw_fca_msgs::BrakeCmd::CMD_TORQUE_RQ:
900 ptr->
CMD_TYPE = dbw_fca_msgs::BrakeCmd::CMD_TORQUE_RQ;
901 ptr->
PCMD = std::clamp<float>(msg->pedal_cmd, 0, UINT16_MAX);
903 ROS_WARN_THROTTLE(1.0,
"Module ABS does not support brake command type TORQUE_RQ");
906 case dbw_fca_msgs::BrakeCmd::CMD_DECEL:
908 ptr->
CMD_TYPE = dbw_fca_msgs::BrakeCmd::CMD_DECEL;
909 ptr->
PCMD = std::clamp<float>(msg->pedal_cmd * 1e3f, 0, 10e3);
915 ROS_WARN(
"Unknown brake command type: %u", msg->pedal_cmd_type);
918 if (
enabled() && msg->enable) {
921 if (
clear() || msg->clear) {
927 ptr->
COUNT = msg->count;
935 out.is_extended =
false;
938 memset(ptr, 0x00,
sizeof(*ptr));
941 switch (msg->pedal_cmd_type) {
942 case dbw_fca_msgs::ThrottleCmd::CMD_NONE:
944 case dbw_fca_msgs::ThrottleCmd::CMD_PEDAL:
945 ptr->
CMD_TYPE = dbw_fca_msgs::ThrottleCmd::CMD_PEDAL;
946 cmd = msg->pedal_cmd;
948 case dbw_fca_msgs::ThrottleCmd::CMD_PERCENT:
950 ptr->
CMD_TYPE = dbw_fca_msgs::ThrottleCmd::CMD_PERCENT;
951 cmd = msg->pedal_cmd;
953 ptr->
CMD_TYPE = dbw_fca_msgs::ThrottleCmd::CMD_PEDAL;
958 ROS_WARN(
"Unknown throttle command type: %u", msg->pedal_cmd_type);
961 ptr->
PCMD = std::clamp<float>(
cmd * UINT16_MAX, 0, UINT16_MAX);
962 if (
enabled() && msg->enable) {
965 if (
clear() || msg->clear) {
971 ptr->
COUNT = msg->count;
979 out.is_extended =
false;
982 memset(ptr, 0x00,
sizeof(*ptr));
983 switch (msg->cmd_type) {
984 case dbw_fca_msgs::SteeringCmd::CMD_ANGLE:
985 ptr->
SCMD = std::clamp<float>(msg->steering_wheel_angle_cmd * (
float)(180 / M_PI * 10), -INT16_MAX, INT16_MAX);
986 if (fabsf(msg->steering_wheel_angle_velocity) > 0) {
988 ptr->
SVEL = std::clamp<float>(roundf(fabsf(msg->steering_wheel_angle_velocity) * (
float)(180 / M_PI / 4)), 1, 254);
990 ptr->
SVEL = std::clamp<float>(roundf(fabsf(msg->steering_wheel_angle_velocity) * (
float)(180 / M_PI / 2)), 1, 254);
993 ptr->
CMD_TYPE = dbw_fca_msgs::SteeringCmd::CMD_ANGLE;
995 case dbw_fca_msgs::SteeringCmd::CMD_TORQUE:
996 ptr->
SCMD = std::clamp<float>(msg->steering_wheel_torque_cmd * 128, -INT16_MAX, INT16_MAX);
997 ptr->
CMD_TYPE = dbw_fca_msgs::SteeringCmd::CMD_TORQUE;
1000 ROS_WARN(
"Unknown steering command type: %u", msg->cmd_type);
1003 if (
enabled() && msg->enable) {
1006 if (
clear() || msg->clear) {
1018 ptr->
COUNT = msg->count;
1024 can_msgs::Frame out;
1026 out.is_extended =
false;
1029 memset(ptr, 0x00,
sizeof(*ptr));
1031 ptr->
GCMD = msg->cmd.gear;
1033 if (
clear() || msg->clear) {
1041 can_msgs::Frame out;
1043 out.is_extended =
false;
1046 memset(ptr, 0x00,
sizeof(*ptr));
1048 ptr->
TRNCMD = msg->cmd.value;
1049 ptr->
DOORSEL = msg->door.select;
1050 ptr->
DOORCMD = msg->door.action;
1055 ptr->
sync = msg->sync.cmd;
1056 ptr->
max_ac = msg->max_ac.cmd;
1057 ptr->
ac = msg->ac.cmd;
1058 ptr->
ft_hvac = msg->ft_hvac.cmd;
1059 ptr->
auto_md = msg->auto_md.cmd;
1060 ptr->
recirc = msg->recirc.cmd;
1061 ptr->
sync = msg->sync.cmd;
1062 ptr->
r_defr = msg->r_defr.cmd;
1063 ptr->
f_defr = msg->f_defr.cmd;
1064 ptr->
hsw_cmd = msg->heated_steering_wheel.cmd;
1065 ptr->
fl_hs_cmd = msg->fl_heated_seat.value;
1066 ptr->
fl_vs_cmd = msg->fl_vented_seat.value;
1067 ptr->
fr_hs_cmd = msg->fr_heated_seat.value;
1068 ptr->
fr_vs_cmd = msg->fr_vented_seat.value;
1077 if (change || force) {
1090 ROS_WARN(
"DBW system enable status changed unexpectedly");
1095 can_msgs::Frame out;
1096 out.is_extended =
false;
1101 memset(out.data.elems, 0x00, 8);
1109 memset(out.data.elems, 0x00, 8);
1117 memset(out.data.elems, 0x00, 8);
1125 memset(out.data.elems, 0x00, 8);
1137 ROS_WARN(
"DBW system not enabled. Steering calibration fault.");
1140 ROS_WARN(
"DBW system not enabled. Braking fault.");
1143 ROS_WARN(
"DBW system not enabled. Throttle fault.");
1146 ROS_WARN(
"DBW system not enabled. Steering fault.");
1149 ROS_WARN(
"DBW system not enabled. Watchdog fault.");
1156 ROS_INFO(
"DBW system enable requested. Waiting for ready.");
1176 ROS_WARN(
"DBW system disabled. Cancel button pressed.");
1183 if (en && timeout) {
1186 if (en &&
override) {
1192 ROS_WARN(
"DBW system disabled. Driver override on brake/throttle pedal.");
1202 if (en && timeout) {
1205 if (en &&
override) {
1211 ROS_WARN(
"DBW system disabled. Driver override on brake/throttle pedal.");
1221 if (en && timeout) {
1224 if (en &&
override) {
1230 ROS_WARN(
"DBW system disabled. Driver override on steering wheel.");
1240 if (en &&
override) {
1246 ROS_WARN(
"DBW system disabled. Driver override on shifter.");
1256 ROS_WARN(
"Brake subsystem disabled after 100ms command timeout");
1265 ROS_WARN(
"Throttle subsystem disabled after 100ms command timeout");
1274 ROS_WARN(
"Steering subsystem disabled after 100ms command timeout");
1289 ROS_ERROR(
"DBW system disabled. Braking fault.");
1305 ROS_ERROR(
"DBW system disabled. Throttle fault.");
1321 ROS_ERROR(
"DBW system disabled. Steering fault.");
1337 ROS_ERROR(
"DBW system disabled. Steering calibration fault.");
1353 ROS_ERROR(
"DBW system disabled. Watchdog fault.");
1359 ROS_WARN(
"Watchdog event: Alerting driver and applying brakes.");
1361 ROS_INFO(
"Watchdog event: Driver has successfully taken control.");
1365 case dbw_fca_msgs::WatchdogCounter::OTHER_BRAKE:
1366 ROS_WARN(
"Watchdog event: Fault determined by brake controller");
1368 case dbw_fca_msgs::WatchdogCounter::OTHER_THROTTLE:
1369 ROS_WARN(
"Watchdog event: Fault determined by throttle controller");
1371 case dbw_fca_msgs::WatchdogCounter::OTHER_STEERING:
1372 ROS_WARN(
"Watchdog event: Fault determined by steering controller");
1374 case dbw_fca_msgs::WatchdogCounter::BRAKE_COUNTER:
1375 ROS_WARN(
"Watchdog event: Brake command counter failed to increment");
1377 case dbw_fca_msgs::WatchdogCounter::BRAKE_DISABLED:
1378 ROS_WARN(
"Watchdog event: Brake transition to disabled while in gear or moving");
1380 case dbw_fca_msgs::WatchdogCounter::BRAKE_COMMAND:
1381 ROS_WARN(
"Watchdog event: Brake command timeout after 100ms");
1383 case dbw_fca_msgs::WatchdogCounter::BRAKE_REPORT:
1384 ROS_WARN(
"Watchdog event: Brake report timeout after 100ms");
1386 case dbw_fca_msgs::WatchdogCounter::THROTTLE_COUNTER:
1387 ROS_WARN(
"Watchdog event: Throttle command counter failed to increment");
1389 case dbw_fca_msgs::WatchdogCounter::THROTTLE_DISABLED:
1390 ROS_WARN(
"Watchdog event: Throttle transition to disabled while in gear or moving");
1392 case dbw_fca_msgs::WatchdogCounter::THROTTLE_COMMAND:
1393 ROS_WARN(
"Watchdog event: Throttle command timeout after 100ms");
1395 case dbw_fca_msgs::WatchdogCounter::THROTTLE_REPORT:
1396 ROS_WARN(
"Watchdog event: Throttle report timeout after 100ms");
1398 case dbw_fca_msgs::WatchdogCounter::STEERING_COUNTER:
1399 ROS_WARN(
"Watchdog event: Steering command counter failed to increment");
1401 case dbw_fca_msgs::WatchdogCounter::STEERING_DISABLED:
1402 ROS_WARN(
"Watchdog event: Steering transition to disabled while in gear or moving");
1404 case dbw_fca_msgs::WatchdogCounter::STEERING_COMMAND:
1405 ROS_WARN(
"Watchdog event: Steering command timeout after 100ms");
1407 case dbw_fca_msgs::WatchdogCounter::STEERING_REPORT:
1408 ROS_WARN(
"Watchdog event: Steering report timeout after 100ms");
1412 }
else if (!
fault) {
1417 ROS_WARN_THROTTLE(2.0,
"Watchdog event: Press left OK button on the steering wheel or cycle power to clear event.");
1427 double dt = (stamp -
joint_state_.header.stamp).toSec();
1429 if (std::isfinite(steering->steering_wheel_angle)) {
1432 const double r = L / tan(steering->steering_wheel_angle /
steering_ratio_);
1436 if (std::isfinite(steering->speed)) {