DbwNode.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2020, Dataspeed Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Dataspeed Inc. nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 #include "DbwNode.h"
38 
39 // Log once per unique identifier, similar to ROS_LOG_ONCE()
40 #define ROS_LOG_ONCE_ID(id, level, name, ...) \
41  do \
42  { \
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)) \
47  { \
48  hit = true; \
49  ROSCONSOLE_PRINT_AT_LOCATION(__VA_ARGS__); \
50  } \
51  } while(false)
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__)
57 
58 namespace dbw_polaris_can
59 {
60 
61 // Latest firmware versions
62 PlatformMap FIRMWARE_LATEST({
63  {PlatformVersion(P_POLARIS_GEM, M_TPEC, ModuleVersion(1,2,2))},
64  {PlatformVersion(P_POLARIS_GEM, M_STEER, ModuleVersion(1,2,2))},
65  {PlatformVersion(P_POLARIS_GEM, M_BOO, ModuleVersion(1,2,2))},
66  {PlatformVersion(P_POLARIS_RZR, M_TPEC, ModuleVersion(0,4,2))},
67  {PlatformVersion(P_POLARIS_RZR, M_STEER, ModuleVersion(0,4,2))},
68  {PlatformVersion(P_POLARIS_RZR, M_BOO, ModuleVersion(0,4,2))},
69 });
70 
72 : sync_imu_(10, boost::bind(&DbwNode::recvCanImu, this, _1), ID_REPORT_ACCEL, ID_REPORT_GYRO)
73 {
74  // Reduce synchronization delay
75  sync_imu_.setInterMessageLowerBound(ros::Duration(0.003)); // 10ms period
76 
77  // Initialize enable state machine
78  prev_enable_ = true;
79  enable_ = false;
80  override_brake_ = false;
81  override_throttle_ = false;
82  override_steering_ = false;
83  override_gear_ = false;
84  fault_brakes_ = false;
85  fault_throttle_ = false;
86  fault_steering_ = false;
87  fault_steering_cal_ = false;
88  fault_watchdog_ = false;
90  fault_watchdog_warned_ = false;
91  timeout_brakes_ = false;
92  timeout_throttle_ = false;
93  timeout_steering_ = false;
94  enabled_brakes_ = false;
95  enabled_throttle_ = false;
96  enabled_steering_ = false;
97  gear_warned_ = false;
98 
99  // Frame ID
100  frame_id_ = "base_footprint";
101  priv_nh.getParam("frame_id", frame_id_);
102 
103  // Warn on received commands
104  warn_cmds_ = true;
105  priv_nh.getParam("warn_cmds", warn_cmds_);
106 
107  // Pedal LUTs (local/embedded)
108  pedal_luts_ = false;
109  priv_nh.getParam("pedal_luts", pedal_luts_);
110 
111  // Ackermann steering parameters @TODO
112  acker_wheelbase_ = 3.08864; // 121.6 inches
113  acker_track_ = 1.73228; // 68.2 inches
114  steering_ratio_ = 16.2;
115  wheel_radius_ = 0.365;
116  priv_nh.getParam("ackermann_wheelbase", acker_wheelbase_);
117  priv_nh.getParam("ackermann_track", acker_track_);
118  priv_nh.getParam("steering_ratio", steering_ratio_);
119 
120  // Initialize joint states
121  joint_state_.position.resize(JOINT_COUNT);
122  joint_state_.velocity.resize(JOINT_COUNT);
123  joint_state_.effort.resize(JOINT_COUNT);
124  joint_state_.name.resize(JOINT_COUNT);
125  joint_state_.name[JOINT_FL] = "wheel_fl"; // Front Left
126  joint_state_.name[JOINT_FR] = "wheel_fr"; // Front Right
127  joint_state_.name[JOINT_RL] = "wheel_rl"; // Rear Left
128  joint_state_.name[JOINT_RR] = "wheel_rr"; // Rear Right
129  joint_state_.name[JOINT_SL] = "steer_fl";
130  joint_state_.name[JOINT_SR] = "steer_fr";
131 
132  // Setup Publishers
133  pub_can_ = node.advertise<can_msgs::Frame>("can_tx", 10);
134  pub_brake_ = node.advertise<dbw_polaris_msgs::BrakeReport>("brake_report", 2);
135  pub_throttle_ = node.advertise<dbw_polaris_msgs::ThrottleReport>("throttle_report", 2);
136  pub_steering_ = node.advertise<dbw_polaris_msgs::SteeringReport>("steering_report", 2);
137  pub_gear_ = node.advertise<dbw_polaris_msgs::GearReport>("gear_report", 2);
138  pub_imu_ = node.advertise<sensor_msgs::Imu>("imu/data_raw", 10);
139  pub_joint_states_ = node.advertise<sensor_msgs::JointState>("joint_states", 10);
140  pub_twist_ = node.advertise<geometry_msgs::TwistStamped>("twist", 10);
141  pub_vin_ = node.advertise<std_msgs::String>("vin", 1, true);
142  pub_sys_enable_ = node.advertise<std_msgs::Bool>("dbw_enabled", 1, true);
144 
145  // Setup Subscribers
147  sub_enable_ = node.subscribe("enable", 10, &DbwNode::recvEnable, this, NODELAY);
148  sub_disable_ = node.subscribe("disable", 10, &DbwNode::recvDisable, this, NODELAY);
149  sub_can_ = node.subscribe("can_rx", 100, &DbwNode::recvCAN, this, NODELAY);
150  sub_brake_ = node.subscribe("brake_cmd", 1, &DbwNode::recvBrakeCmd, this, NODELAY);
151  sub_throttle_ = node.subscribe("throttle_cmd", 1, &DbwNode::recvThrottleCmd, this, NODELAY);
152  sub_steering_ = node.subscribe("steering_cmd", 1, &DbwNode::recvSteeringCmd, this, NODELAY);
153  sub_gear_ = node.subscribe("gear_cmd", 1, &DbwNode::recvGearCmd, this, NODELAY);
154  sub_calibrate_steering_ = node.subscribe("calibrate_steering", 1, &DbwNode::recvCalibrateSteering, this, NODELAY);
155 
156  // Setup Timer
157  timer_ = node.createTimer(ros::Duration(1 / 20.0), &DbwNode::timerCallback, this);
158 }
159 
161 {
162 }
163 
164 void DbwNode::recvEnable(const std_msgs::Empty::ConstPtr& msg)
165 {
166  enableSystem();
167 }
168 
169 void DbwNode::recvDisable(const std_msgs::Empty::ConstPtr& msg)
170 {
171  disableSystem();
172 }
173 
174 void DbwNode::recvCAN(const can_msgs::Frame::ConstPtr& msg)
175 {
176  sync_imu_.processMsg(msg);
177  if (!msg->is_rtr && !msg->is_error && !msg->is_extended) {
178  switch (msg->id) {
179  case ID_BRAKE_REPORT:
180  if (msg->dlc >= sizeof(MsgBrakeReport)) {
181  const MsgBrakeReport *ptr = (const MsgBrakeReport*)msg->data.elems;
182  faultBrakes(ptr->FLT1 || ptr->FLT2);
183  faultWatchdog(ptr->FLTWDC, ptr->WDCSRC, ptr->WDCBRK);
184  overrideBrake(ptr->OVERRIDE, ptr->TMOUT);
185  timeoutBrake(ptr->TMOUT, ptr->ENABLED);
186  dbw_polaris_msgs::BrakeReport out;
187  out.header.stamp = msg->header.stamp;
188  if (ptr->BTYPE == 2 || ptr->BTYPE == 1) {
189  // Type 1 is for backwards compatibility only
190  out.torque_input = ptr->PI;
191  out.torque_cmd = ptr->PC;
192  out.torque_output = ptr->PO;
193  } else {
194  ROS_WARN_THROTTLE(5.0, "Unsupported brake report type: %u", ptr->BTYPE);
195  }
196  out.enabled = ptr->ENABLED ? true : false;
197  out.override = ptr->OVERRIDE ? true : false;
198  out.driver = ptr->DRIVER ? true : false;
199  out.watchdog_counter.source = ptr->WDCSRC;
200  out.watchdog_braking = ptr->WDCBRK ? true : false;
201  out.fault_wdc = ptr->FLTWDC ? true : false;
202  out.fault_ch1 = ptr->FLT1 ? true : false;
203  out.fault_ch2 = ptr->FLT2 ? true : false;
204  out.fault_power = ptr->FLTPWR ? true : false;
205  out.timeout = ptr->TMOUT ? true : false;
206  pub_brake_.publish(out);
207  if (ptr->FLT1 || ptr->FLT2 || ptr->FLTPWR) {
208  ROS_WARN_THROTTLE(5.0, "Brake fault. FLT1: %s FLT2: %s FLTPWR: %s",
209  ptr->FLT1 ? "true, " : "false,",
210  ptr->FLT2 ? "true, " : "false,",
211  ptr->FLTPWR ? "true" : "false");
212  }
213  }
214  break;
215 
216  case ID_THROTTLE_REPORT:
217  if (msg->dlc >= sizeof(MsgThrottleReport)) {
218  const MsgThrottleReport *ptr = (const MsgThrottleReport*)msg->data.elems;
219  faultThrottle(ptr->FLT1 || ptr->FLT2);
220  faultWatchdog(ptr->FLTWDC, ptr->WDCSRC);
221  overrideThrottle(ptr->OVERRIDE, ptr->TMOUT);
222  timeoutThrottle(ptr->TMOUT, ptr->ENABLED);
223  dbw_polaris_msgs::ThrottleReport out;
224  out.header.stamp = msg->header.stamp;
225  out.pedal_input = (float)ptr->PI / UINT16_MAX;
226  out.pedal_cmd = (float)ptr->PC / UINT16_MAX;
227  out.pedal_output = (float)ptr->PO / UINT16_MAX;
228  out.enabled = ptr->ENABLED ? true : false;
229  out.override = ptr->OVERRIDE ? true : false;
230  out.driver = ptr->DRIVER ? true : false;
231  out.watchdog_counter.source = ptr->WDCSRC;
232  out.fault_wdc = ptr->FLTWDC ? true : false;
233  out.fault_ch1 = ptr->FLT1 ? true : false;
234  out.fault_ch2 = ptr->FLT2 ? true : false;
235  out.fault_power = ptr->FLTPWR ? true : false;
236  out.timeout = ptr->TMOUT ? true : false;
237  pub_throttle_.publish(out);
238  if (ptr->FLT1 || ptr->FLT2 || ptr->FLTPWR) {
239  ROS_WARN_THROTTLE(5.0, "Throttle fault. FLT1: %s FLT2: %s FLTPWR: %s",
240  ptr->FLT1 ? "true, " : "false,",
241  ptr->FLT2 ? "true, " : "false,",
242  ptr->FLTPWR ? "true" : "false");
243  }
244  }
245  break;
246 
247  case ID_STEERING_REPORT:
248  if (msg->dlc >= sizeof(MsgSteeringReport)) {
249  const MsgSteeringReport *ptr = (const MsgSteeringReport*)msg->data.elems;
250  faultSteering(ptr->FLTBUS1 || ptr->FLTBUS2);
251  faultSteeringCal(ptr->FLTCAL);
252  faultWatchdog(ptr->FLTWDC);
253  overrideSteering(ptr->OVERRIDE, ptr->TMOUT);
254  timeoutSteering(ptr->TMOUT, ptr->ENABLED);
255  dbw_polaris_msgs::SteeringReport out;
256  out.header.stamp = msg->header.stamp;
257  if ((uint16_t)ptr->ANGLE == 0x8000) {
258  out.steering_wheel_angle = NAN;
259  } else {
260  out.steering_wheel_angle = (float)ptr->ANGLE * (float)(0.1 * M_PI / 180);
261  }
262  out.steering_wheel_cmd_type = ptr->TMODE ? dbw_polaris_msgs::SteeringReport::CMD_TORQUE : dbw_polaris_msgs::SteeringReport::CMD_ANGLE;
263  if ((uint16_t)ptr->CMD == 0xC000) {
264  out.steering_wheel_cmd = NAN;
265  } else if (out.steering_wheel_cmd_type == dbw_polaris_msgs::SteeringReport::CMD_ANGLE) {
266  out.steering_wheel_cmd = (float)ptr->CMD * (float)(0.1 * M_PI / 180);
267  } else {
268  out.steering_wheel_cmd = (float)ptr->CMD / 128.0f;
269  }
270  if ((uint8_t)ptr->TORQUE == 0x80) {
271  out.steering_wheel_torque = NAN;
272  } else {
273  out.steering_wheel_torque = (float)ptr->TORQUE * (float)0.0625;
274  }
275  if ((uint16_t)ptr->VEH_VEL == 0x8000) {
276  out.speed = NAN;
277  } else {
278  out.speed = (float)ptr->VEH_VEL * (float)(0.01 / 3.6);
279  }
280  out.enabled = ptr->ENABLED ? true : false;
281  out.override = ptr->OVERRIDE ? true : false;
282  out.fault_wdc = ptr->FLTWDC ? true : false;
283  out.fault_bus1 = ptr->FLTBUS1 ? true : false;
284  out.fault_bus2 = ptr->FLTBUS2 ? true : false;
285  out.fault_calibration = ptr->FLTCAL ? true : false;
286  out.fault_power = ptr->FLTPWR ? true : false;
287  out.timeout = ptr->TMOUT ? true : false;
288  pub_steering_.publish(out);
289  geometry_msgs::TwistStamped twist;
290  twist.header.stamp = out.header.stamp;
291  twist.header.frame_id = frame_id_;
292  twist.twist.linear.x = out.speed;
293  twist.twist.angular.z = out.speed * tan(out.steering_wheel_angle / steering_ratio_) / acker_wheelbase_;
294  pub_twist_.publish(twist);
295  publishJointStates(msg->header.stamp, &out);
296  if (ptr->FLTBUS1 || ptr->FLTBUS2 || ptr->FLTPWR) {
297  ROS_WARN_THROTTLE(5.0, "Steering fault. FLT1: %s FLT2: %s FLTPWR: %s",
298  ptr->FLTBUS1 ? "true, " : "false,",
299  ptr->FLTBUS2 ? "true, " : "false,",
300  ptr->FLTPWR ? "true" : "false");
301  if (ptr->FLTBUS2) {
302  ROS_WARN_THROTTLE(5.0, "Steering fault. Too many calibrations stored. Reset need to continue");
303  }
304  } else if (ptr->FLTCAL) {
305  ROS_WARN_THROTTLE(5.0, "Steering calibration fault. Press the two steering multiplier buttons at the same "
306  "time to set the center offset when the wheel is straight. For a more exact "
307  "calibration set the SteeringCal and SteeringCal offset parameters using DbwConfig.");
308  }
309  }
310  break;
311 
312  case ID_GEAR_REPORT:
313  if (msg->dlc >= sizeof(MsgGearReport)) {
314  const MsgGearReport *ptr = (const MsgGearReport*)msg->data.elems;
315  overrideGear(ptr->OVERRIDE);
316  dbw_polaris_msgs::GearReport out;
317  out.header.stamp = msg->header.stamp;
318  out.state.gear = ptr->STATE;
319  out.cmd.gear = ptr->CMD;
320  out.override = ptr->OVERRIDE ? true : false;
321  out.fault_bus = ptr->FLTBUS ? true : false;
322  out.reject.value = ptr->REJECT;
323  if (out.reject.value == dbw_polaris_msgs::GearReject::NONE) {
324  gear_warned_ = false;
325  } else if (!gear_warned_) {
326  gear_warned_ = true;
327  switch (out.reject.value) {
328  case dbw_polaris_msgs::GearReject::SHIFT_IN_PROGRESS:
329  ROS_WARN("Gear shift rejected: Shift in progress");
330  break;
331  case dbw_polaris_msgs::GearReject::OVERRIDE:
332  ROS_WARN("Gear shift rejected: Override on brake, throttle, or steering");
333  break;
334  case dbw_polaris_msgs::GearReject::NEUTRAL:
335  ROS_WARN("Gear shift rejected: Manually shift to neutral before auto-shift");
336  break;
337  case dbw_polaris_msgs::GearReject::VEHICLE:
338  ROS_WARN("Gear shift rejected: Rejected by vehicle, try pressing the brakes");
339  break;
340  case dbw_polaris_msgs::GearReject::UNSUPPORTED:
341  ROS_WARN("Gear shift rejected: Unsupported gear command");
342  break;
343  case dbw_polaris_msgs::GearReject::FAULT:
344  ROS_WARN("Gear shift rejected: System in fault state");
345  break;
346  }
347  }
348  pub_gear_.publish(out);
349  }
350  break;
351 
352  case ID_LICENSE:
353  if (msg->dlc >= sizeof(MsgLicense)) {
354  const MsgLicense *ptr = (const MsgLicense*)msg->data.elems;
355  const Module module = ptr->module ? (Module)ptr->module : M_STEER; // Legacy steering firmware reports zero for module
356  const char * str_m = moduleToString(module);
357  ROS_DEBUG("LICENSE(%x,%02X,%s)", ptr->module, ptr->mux, str_m);
358  if (ptr->ready) {
359  ROS_INFO_ONCE_ID(module, "Licensing: %s ready", str_m);
360  if (ptr->trial) {
361  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);
362  }
363  if (ptr->expired) {
364  ROS_WARN_ONCE_ID(module, "Licensing: %s one or more feature licenses expired due to the firmware build date", str_m);
365  }
366  } else if (module == M_STEER) {
367  ROS_INFO_THROTTLE(10.0, "Licensing: Waiting for VIN...");
368  } else {
369  ROS_INFO_THROTTLE(10.0, "Licensing: Waiting for required info...");
370  }
371  if (ptr->mux == LIC_MUX_LDATE0) {
372  if (ldate_.size() == 0) {
373  ldate_.push_back(ptr->ldate0.ldate0);
374  ldate_.push_back(ptr->ldate0.ldate1);
375  ldate_.push_back(ptr->ldate0.ldate2);
376  ldate_.push_back(ptr->ldate0.ldate3);
377  ldate_.push_back(ptr->ldate0.ldate4);
378  ldate_.push_back(ptr->ldate0.ldate5);
379  }
380  } else if (ptr->mux == LIC_MUX_LDATE1) {
381  if (ldate_.size() == 6) {
382  ldate_.push_back(ptr->ldate1.ldate6);
383  ldate_.push_back(ptr->ldate1.ldate7);
384  ldate_.push_back(ptr->ldate1.ldate8);
385  ldate_.push_back(ptr->ldate1.ldate9);
386  ROS_INFO("Licensing: %s license string date: %s", str_m, ldate_.c_str());
387  }
388  } else if (ptr->mux == LIC_MUX_MAC) {
389  ROS_INFO_ONCE("Licensing: %s MAC: %02X:%02X:%02X:%02X:%02X:%02X", str_m,
390  ptr->mac.addr0, ptr->mac.addr1,
391  ptr->mac.addr2, ptr->mac.addr3,
392  ptr->mac.addr4, ptr->mac.addr5);
393  } else if (ptr->mux == LIC_MUX_BDATE0) {
394  std::string &bdate = bdate_[module];
395  if (bdate.size() == 0) {
396  bdate.push_back(ptr->bdate0.date0);
397  bdate.push_back(ptr->bdate0.date1);
398  bdate.push_back(ptr->bdate0.date2);
399  bdate.push_back(ptr->bdate0.date3);
400  bdate.push_back(ptr->bdate0.date4);
401  bdate.push_back(ptr->bdate0.date5);
402  }
403  } else if (ptr->mux == LIC_MUX_BDATE1) {
404  std::string &bdate = bdate_[module];
405  if (bdate.size() == 6) {
406  bdate.push_back(ptr->bdate1.date6);
407  bdate.push_back(ptr->bdate1.date7);
408  bdate.push_back(ptr->bdate1.date8);
409  bdate.push_back(ptr->bdate1.date9);
410  ROS_INFO("Licensing: %s firmware build date: %s", str_m, bdate.c_str());
411  }
412  } else if (ptr->mux == LIC_MUX_VIN0) {
413  if (vin_.size() == 0) {
414  vin_.push_back(ptr->vin0.vin00);
415  vin_.push_back(ptr->vin0.vin01);
416  vin_.push_back(ptr->vin0.vin02);
417  vin_.push_back(ptr->vin0.vin03);
418  vin_.push_back(ptr->vin0.vin04);
419  vin_.push_back(ptr->vin0.vin05);
420  }
421  } else if (ptr->mux == LIC_MUX_VIN1) {
422  if (vin_.size() == 6) {
423  vin_.push_back(ptr->vin1.vin06);
424  vin_.push_back(ptr->vin1.vin07);
425  vin_.push_back(ptr->vin1.vin08);
426  vin_.push_back(ptr->vin1.vin09);
427  vin_.push_back(ptr->vin1.vin10);
428  vin_.push_back(ptr->vin1.vin11);
429  }
430  } else if (ptr->mux == LIC_MUX_VIN2) {
431  if (vin_.size() == 12) {
432  vin_.push_back(ptr->vin2.vin12);
433  vin_.push_back(ptr->vin2.vin13);
434  vin_.push_back(ptr->vin2.vin14);
435  vin_.push_back(ptr->vin2.vin15);
436  vin_.push_back(ptr->vin2.vin16);
437  std_msgs::String msg; msg.data = vin_;
438  pub_vin_.publish(msg);
439  ROS_INFO("Licensing: VIN: %s", vin_.c_str());
440  }
441  } else if ((LIC_MUX_F0 <= ptr->mux) && (ptr->mux <= LIC_MUX_F7)) {
442  constexpr std::array<const char*, 8> NAME = {"BASE","CONTROL","SENSORS","","","","",""};
443  constexpr std::array<bool, 8> WARN = {true, true, true, false, true, true, true, true};
444  const size_t i = ptr->mux - LIC_MUX_F0;
445  const int id = module * NAME.size() + i;
446  const std::string name = strcmp(NAME[i], "") ? NAME[i] : std::string(1, '0' + i);
447  if (ptr->license.enabled) {
448  ROS_INFO_ONCE_ID(id, "Licensing: %s feature '%s' enabled%s", str_m, name.c_str(), ptr->license.trial ? " as a counted trial" : "");
449  } else if (ptr->ready && !WARN[i]) {
450  ROS_INFO_ONCE_ID(id, "Licensing: %s feature '%s' not licensed.", str_m, name.c_str());
451  } else if (ptr->ready) {
452  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());
453  }
454  if (ptr->ready && (module == M_STEER) && (ptr->license.trial || (!ptr->license.enabled && WARN[i]))) {
455  ROS_INFO_ONCE("Licensing: Feature '%s' trials used: %u, remaining: %u", name.c_str(),
456  ptr->license.trials_used, ptr->license.trials_left);
457  }
458  }
459  }
460  break;
461 
462  case ID_VERSION:
463  if (msg->dlc >= sizeof(MsgVersion)) {
464  const MsgVersion *ptr = (const MsgVersion*)msg->data.elems;
465  const PlatformVersion version((Platform)ptr->platform, (Module)ptr->module, ptr->major, ptr->minor, ptr->build);
466  const ModuleVersion latest = FIRMWARE_LATEST.findModule(version);
467  const char * str_p = platformToString(version.p);
468  const char * str_m = moduleToString(version.m);
469  if (firmware_.findModule(version) != version.v) {
470  firmware_.insert(version);
471  if (latest.valid()) {
472  ROS_INFO("Detected %s %s firmware version %u.%u.%u", str_p, str_m, ptr->major, ptr->minor, ptr->build);
473  } else {
474  ROS_WARN("Detected %s %s firmware version %u.%u.%u, which is unsupported. Platform: 0x%02X, Module: %u", str_p, str_m,
475  ptr->major, ptr->minor, ptr->build, ptr->platform, ptr->module);
476  }
477  if (version < latest) {
478  ROS_WARN("Firmware %s %s has old version %u.%u.%u, updating to %u.%u.%u is suggested.", str_p, str_m,
479  version.v.major(), version.v.minor(), version.v.build(),
480  latest.major(), latest.minor(), latest.build());
481  }
482  }
483  }
484  break;
485 
486  case ID_BRAKE_CMD:
487  ROS_WARN_COND(warn_cmds_ && !((const MsgBrakeCmd*)msg->data.elems)->RES1 && !((const MsgBrakeCmd*)msg->data.elems)->RES2,
488  "DBW system: Another node on the CAN bus is commanding the vehicle!!! Subsystem: Brake. Id: 0x%03X", ID_BRAKE_CMD);
489  break;
490  case ID_THROTTLE_CMD:
491  ROS_WARN_COND(warn_cmds_ && !((const MsgThrottleCmd*)msg->data.elems)->RES1 && !((const MsgThrottleCmd*)msg->data.elems)->RES2,
492  "DBW system: Another node on the CAN bus is commanding the vehicle!!! Subsystem: Throttle. Id: 0x%03X", ID_THROTTLE_CMD);
493  break;
494  case ID_STEERING_CMD:
495  ROS_WARN_COND(warn_cmds_ && !((const MsgSteeringCmd*)msg->data.elems)->RES1 && !((const MsgSteeringCmd*)msg->data.elems)->RES2,
496  "DBW system: Another node on the CAN bus is commanding the vehicle!!! Subsystem: Steering. Id: 0x%03X", ID_STEERING_CMD);
497  break;
498  case ID_GEAR_CMD:
499  ROS_WARN_COND(warn_cmds_ && !((const MsgGearCmd*)msg->data.elems)->RES1 && !((const MsgGearCmd*)msg->data.elems)->RES2,
500  "DBW system: Another node on the CAN bus is commanding the vehicle!!! Subsystem: Shifting. Id: 0x%03X", ID_GEAR_CMD);
501  break;
502 
503  case 0x100 ... 0x103: // DBW2 steer/brake/throttle/gear report
504  case 0x6C0 ... 0x6C5: // DBW2 ECU info for each module
505  ROS_WARN_ONCE_ID(msg->id, "Received unsupported CAN ID %03X from next-generation drive-by-wire system (DBW2)"
506  "\nUse the ROS2 ds_dbw_can package instead", msg->id);
507  break;
508  }
509  }
510 #if 0
511  ROS_INFO("ena: %s, clr: %s, brake: %s, throttle: %s, steering: %s, gear: %s",
512  enabled() ? "true " : "false",
513  clear() ? "true " : "false",
514  override_brake_ ? "true " : "false",
515  override_throttle_ ? "true " : "false",
516  override_steering_ ? "true " : "false",
517  override_gear_ ? "true " : "false"
518  );
519 #endif
520 }
521 
522 void DbwNode::recvCanImu(const std::vector<can_msgs::Frame::ConstPtr> &msgs) {
523  ROS_ASSERT(msgs.size() == 2);
524  ROS_ASSERT(msgs[0]->id == ID_REPORT_ACCEL);
525  ROS_ASSERT(msgs[1]->id == ID_REPORT_GYRO);
526  if ((msgs[0]->dlc >= sizeof(MsgReportAccel)) && (msgs[1]->dlc >= sizeof(MsgReportGyro))) {
527  const MsgReportAccel *ptr_accel = (const MsgReportAccel*)msgs[0]->data.elems;
528  const MsgReportGyro *ptr_gyro = (const MsgReportGyro*)msgs[1]->data.elems;
529  sensor_msgs::Imu out;
530  out.header.stamp = msgs[0]->header.stamp;
531  out.header.frame_id = frame_id_;
532  out.orientation_covariance[0] = -1; // Orientation not present
533  if ((uint16_t)ptr_accel->accel_long == 0x8000) {
534  out.linear_acceleration.x = NAN;
535  } else {
536  out.linear_acceleration.x = (double)ptr_accel->accel_long * 0.01;
537  }
538  if ((uint16_t)ptr_accel->accel_lat == 0x8000) {
539  out.linear_acceleration.y = NAN;
540  } else {
541  out.linear_acceleration.y = (double)ptr_accel->accel_lat * -0.01;
542  }
543  if ((uint16_t)ptr_accel->accel_vert == 0x8000) {
544  out.linear_acceleration.z = NAN;
545  } else {
546  out.linear_acceleration.z = (double)ptr_accel->accel_vert * -0.01;
547  }
548  if ((uint16_t)ptr_gyro->gyro_roll == 0x8000) {
549  out.angular_velocity.x = NAN;
550  } else {
551  out.angular_velocity.x = (double)ptr_gyro->gyro_roll * 0.0002;
552  }
553  if ((uint16_t)ptr_gyro->gyro_pitch == 0x8000) {
554  out.angular_velocity.y = NAN;
555  } else {
556  out.angular_velocity.y = (double)ptr_gyro->gyro_pitch * 0.0002;
557  }
558  if ((uint16_t)ptr_gyro->gyro_yaw == 0x8000) {
559  out.angular_velocity.z = NAN;
560  } else {
561  out.angular_velocity.z = (double)ptr_gyro->gyro_yaw * 0.0002;
562  }
563  pub_imu_.publish(out);
564  }
565 #if 0
566  ROS_INFO("Time: %u.%u, %u.%u, delta: %fms",
567  msgs[0]->header.stamp.sec, msgs[0]->header.stamp.nsec,
568  msgs[1]->header.stamp.sec, msgs[1]->header.stamp.nsec,
569  labs((msgs[1]->header.stamp - msgs[0]->header.stamp).toNSec()) / 1000000.0);
570 #endif
571 }
572 
573 void DbwNode::recvBrakeCmd(const dbw_polaris_msgs::BrakeCmd::ConstPtr& msg)
574 {
575  can_msgs::Frame out;
576  out.id = ID_BRAKE_CMD;
577  out.is_extended = false;
578  out.dlc = sizeof(MsgBrakeCmd);
579  MsgBrakeCmd *ptr = (MsgBrakeCmd*)out.data.elems;
580  memset(ptr, 0x00, sizeof(*ptr));
581  switch (msg->pedal_cmd_type) {
582  case dbw_polaris_msgs::BrakeCmd::CMD_NONE:
583  break;
584  case dbw_polaris_msgs::BrakeCmd::CMD_PERCENT:
585  ptr->CMD_TYPE = dbw_polaris_msgs::BrakeCmd::CMD_PERCENT;
586  ptr->PCMD = std::clamp<float>(msg->pedal_cmd * UINT16_MAX, 0, UINT16_MAX);
587  break;
588  case dbw_polaris_msgs::BrakeCmd::CMD_TORQUE:
589  ptr->CMD_TYPE = dbw_polaris_msgs::BrakeCmd::CMD_TORQUE;
590  ptr->PCMD = std::clamp<float>(msg->pedal_cmd, 0, UINT16_MAX);
591  break;
592  case dbw_polaris_msgs::BrakeCmd::CMD_TORQUE_RQ:
593  ptr->CMD_TYPE = dbw_polaris_msgs::BrakeCmd::CMD_TORQUE_RQ;
594  ptr->PCMD = std::clamp<float>(msg->pedal_cmd, 0, UINT16_MAX);
595  break;
596  default:
597  ROS_WARN("Unknown brake command type: %u", msg->pedal_cmd_type);
598  break;
599  }
600  if (enabled() && msg->enable) {
601  ptr->EN = 1;
602  }
603  if (clear() || msg->clear) {
604  ptr->CLEAR = 1;
605  }
606  if (msg->ignore) {
607  ptr->IGNORE = 1;
608  }
609  ptr->COUNT = msg->count;
610  pub_can_.publish(out);
611 }
612 
613 void DbwNode::recvThrottleCmd(const dbw_polaris_msgs::ThrottleCmd::ConstPtr& msg)
614 {
615  can_msgs::Frame out;
616  out.id = ID_THROTTLE_CMD;
617  out.is_extended = false;
618  out.dlc = sizeof(MsgThrottleCmd);
619  MsgThrottleCmd *ptr = (MsgThrottleCmd*)out.data.elems;
620  memset(ptr, 0x00, sizeof(*ptr));
621  bool fwd = !pedal_luts_; // Forward command type, or apply pedal LUTs locally
622  float cmd = 0.0;
623  switch (msg->pedal_cmd_type) {
624  case dbw_polaris_msgs::ThrottleCmd::CMD_NONE:
625  break;
626  case dbw_polaris_msgs::ThrottleCmd::CMD_PEDAL:
627  ptr->CMD_TYPE = dbw_polaris_msgs::ThrottleCmd::CMD_PEDAL;
628  cmd = msg->pedal_cmd;
629  break;
630  case dbw_polaris_msgs::ThrottleCmd::CMD_PERCENT:
631  if (fwd) {
632  ptr->CMD_TYPE = dbw_polaris_msgs::ThrottleCmd::CMD_PERCENT;
633  cmd = msg->pedal_cmd;
634  } else {
635  ptr->CMD_TYPE = dbw_polaris_msgs::ThrottleCmd::CMD_PEDAL;
636  cmd = throttlePedalFromPercent(msg->pedal_cmd);
637  }
638  break;
639  default:
640  ROS_WARN("Unknown throttle command type: %u", msg->pedal_cmd_type);
641  break;
642  }
643  ptr->PCMD = std::clamp<float>(cmd * UINT16_MAX, 0, UINT16_MAX);
644  if (enabled() && msg->enable) {
645  ptr->EN = 1;
646  }
647  if (clear() || msg->clear) {
648  ptr->CLEAR = 1;
649  }
650  if (msg->ignore) {
651  ptr->IGNORE = 1;
652  }
653  ptr->COUNT = msg->count;
654  pub_can_.publish(out);
655 }
656 
657 void DbwNode::recvSteeringCmd(const dbw_polaris_msgs::SteeringCmd::ConstPtr& msg)
658 {
659  can_msgs::Frame out;
660  out.id = ID_STEERING_CMD;
661  out.is_extended = false;
662  out.dlc = sizeof(MsgSteeringCmd);
663  MsgSteeringCmd *ptr = (MsgSteeringCmd*)out.data.elems;
664  memset(ptr, 0x00, sizeof(*ptr));
665  switch (msg->cmd_type) {
666  case dbw_polaris_msgs::SteeringCmd::CMD_ANGLE:
667  ptr->SCMD = std::clamp<float>(msg->steering_wheel_angle_cmd * (float)(180 / M_PI * 10), -INT16_MAX, INT16_MAX);
668  if (fabsf(msg->steering_wheel_angle_velocity) > 0) {
669  ptr->SVEL = std::clamp<float>(roundf(fabsf(msg->steering_wheel_angle_velocity) * (float)(180 / M_PI / 4)), 1, 254);
670  }
671  ptr->CMD_TYPE = dbw_polaris_msgs::SteeringCmd::CMD_ANGLE;
672  break;
673  case dbw_polaris_msgs::SteeringCmd::CMD_TORQUE:
674  ptr->SCMD = std::clamp<float>(msg->steering_wheel_torque_cmd * 128, -INT16_MAX, INT16_MAX);
675  ptr->CMD_TYPE = dbw_polaris_msgs::SteeringCmd::CMD_TORQUE;
676  break;
677  default:
678  ROS_WARN("Unknown steering command type: %u", msg->cmd_type);
679  break;
680  }
681  if (enabled() && msg->enable) {
682  ptr->EN = 1;
683  }
684  if (clear() || msg->clear) {
685  ptr->CLEAR = 1;
686  }
687  if (msg->ignore) {
688  ptr->IGNORE = 1;
689  }
690  if (msg->calibrate) {
691  ptr->CAL = 1;
692  }
693  if (msg->quiet) {
694  ptr->QUIET = 1;
695  }
696  if (msg->alert) {
697  ptr->ALERT = 1;
698  }
699  ptr->COUNT = msg->count;
700  pub_can_.publish(out);
701 }
702 
703 void DbwNode::recvGearCmd(const dbw_polaris_msgs::GearCmd::ConstPtr& msg)
704 {
705  can_msgs::Frame out;
706  out.id = ID_GEAR_CMD;
707  out.is_extended = false;
708  out.dlc = sizeof(MsgGearCmd);
709  MsgGearCmd *ptr = (MsgGearCmd*)out.data.elems;
710  memset(ptr, 0x00, sizeof(*ptr));
711  if (enabled()) {
712  ptr->GCMD = msg->cmd.gear;
713  }
714  if (clear() || msg->clear) {
715  ptr->CLEAR = 1;
716  }
717  pub_can_.publish(out);
718 }
719 
720 void DbwNode::recvCalibrateSteering(const std_msgs::Empty::ConstPtr& msg)
721 {
722  /* Send steering command to save current angle as zero.
723  * The preferred method is to set the 'calibrate' field in a ROS steering
724  * command so that recvSteeringCmd() saves the current angle as the
725  * specified command.
726  */
727  can_msgs::Frame out;
728  out.id = ID_STEERING_CMD;
729  out.is_extended = false;
730  out.dlc = 4; // Sending the full eight bytes will fault the watchdog counter (if enabled)
731  MsgSteeringCmd *ptr = (MsgSteeringCmd*)out.data.elems;
732  ptr->CAL = 1;
733  pub_can_.publish(out);
734 }
735 
737 {
738  bool en = enabled();
739  bool change = prev_enable_ != en;
740  if (change || force) {
741  std_msgs::Bool msg;
742  msg.data = en;
744  }
745  prev_enable_ = en;
746  return change;
747 }
748 
750 {
751  // Publish status periodically, in addition to latched and on change
752  if (publishDbwEnabled(true)) {
753  ROS_WARN("DBW system enable status changed unexpectedly");
754  }
755 
756  // Clear override statuses if necessary
757  if (clear()) {
758  can_msgs::Frame out;
759  out.is_extended = false;
760 
761  if (override_brake_) {
762  out.id = ID_BRAKE_CMD;
763  out.dlc = 4; // Sending the full eight bytes will fault the watchdog counter (if enabled)
764  memset(out.data.elems, 0x00, 8);
765  ((MsgBrakeCmd*)out.data.elems)->CLEAR = 1;
766  pub_can_.publish(out);
767  }
768 
769  if (override_throttle_) {
770  out.id = ID_THROTTLE_CMD;
771  out.dlc = 4; // Sending the full eight bytes will fault the watchdog counter (if enabled)
772  memset(out.data.elems, 0x00, 8);
773  ((MsgThrottleCmd*)out.data.elems)->CLEAR = 1;
774  pub_can_.publish(out);
775  }
776 
777  if (override_steering_) {
778  out.id = ID_STEERING_CMD;
779  out.dlc = 4; // Sending the full eight bytes will fault the watchdog counter (if enabled)
780  memset(out.data.elems, 0x00, 8);
781  ((MsgSteeringCmd*)out.data.elems)->CLEAR = 1;
782  pub_can_.publish(out);
783  }
784 
785  if (override_gear_) {
786  out.id = ID_GEAR_CMD;
787  out.dlc = sizeof(MsgGearCmd);
788  memset(out.data.elems, 0x00, 8);
789  ((MsgGearCmd*)out.data.elems)->CLEAR = 1;
790  pub_can_.publish(out);
791  }
792  }
793 }
794 
796 {
797  if (!enable_) {
798  if (fault()) {
799  if (fault_steering_cal_) {
800  ROS_WARN("DBW system not enabled. Steering calibration fault.");
801  }
802  if (fault_brakes_) {
803  ROS_WARN("DBW system not enabled. Braking fault.");
804  }
805  if (fault_throttle_) {
806  ROS_WARN("DBW system not enabled. Throttle fault.");
807  }
808  if (fault_steering_) {
809  ROS_WARN("DBW system not enabled. Steering fault.");
810  }
811  if (fault_watchdog_) {
812  ROS_WARN("DBW system not enabled. Watchdog fault.");
813  }
814  } else {
815  enable_ = true;
816  if (publishDbwEnabled()) {
817  ROS_INFO("DBW system enabled.");
818  } else {
819  ROS_INFO("DBW system enable requested. Waiting for ready.");
820  }
821  }
822  }
823 }
824 
826 {
827  if (enable_) {
828  enable_ = false;
830  ROS_WARN("DBW system disabled.");
831  }
832 }
833 
835 {
836  if (enable_) {
837  enable_ = false;
839  ROS_WARN("DBW system disabled. Cancel button pressed.");
840  }
841 }
842 
843 void DbwNode::overrideBrake(bool override, bool timeout)
844 {
845  bool en = enabled();
846  if (en && timeout) {
847  override = false;
848  }
849  if (en && override) {
850  enable_ = false;
851  }
852  override_brake_ = override;
853  if (publishDbwEnabled()) {
854  if (en) {
855  ROS_WARN("DBW system disabled. Driver override on brake/throttle pedal.");
856  } else {
857  ROS_INFO("DBW system enabled.");
858  }
859  }
860 }
861 
862 void DbwNode::overrideThrottle(bool override, bool timeout)
863 {
864  bool en = enabled();
865  if (en && timeout) {
866  override = false;
867  }
868  if (en && override) {
869  enable_ = false;
870  }
871  override_throttle_ = override;
872  if (publishDbwEnabled()) {
873  if (en) {
874  ROS_WARN("DBW system disabled. Driver override on brake/throttle pedal.");
875  } else {
876  ROS_INFO("DBW system enabled.");
877  }
878  }
879 }
880 
881 void DbwNode::overrideSteering(bool override, bool timeout)
882 {
883  bool en = enabled();
884  if (en && timeout) {
885  override = false;
886  }
887  if (en && override) {
888  enable_ = false;
889  }
890  override_steering_ = override;
891  if (publishDbwEnabled()) {
892  if (en) {
893  ROS_WARN("DBW system disabled. Driver override on steering wheel.");
894  } else {
895  ROS_INFO("DBW system enabled.");
896  }
897  }
898 }
899 
900 void DbwNode::overrideGear(bool override)
901 {
902  bool en = enabled();
903  if (en && override) {
904  enable_ = false;
905  }
906  override_gear_ = override;
907  if (publishDbwEnabled()) {
908  if (en) {
909  ROS_WARN("DBW system disabled. Driver override on shifter.");
910  } else {
911  ROS_INFO("DBW system enabled.");
912  }
913  }
914 }
915 
916 void DbwNode::timeoutBrake(bool timeout, bool enabled)
917 {
918  if (!timeout_brakes_ && enabled_brakes_ && timeout && !enabled) {
919  ROS_WARN("Brake subsystem disabled after 100ms command timeout");
920  }
921  timeout_brakes_ = timeout;
923 }
924 
925 void DbwNode::timeoutThrottle(bool timeout, bool enabled)
926 {
927  if (!timeout_throttle_ && enabled_throttle_ && timeout && !enabled) {
928  ROS_WARN("Throttle subsystem disabled after 100ms command timeout");
929  }
930  timeout_throttle_ = timeout;
932 }
933 
934 void DbwNode::timeoutSteering(bool timeout, bool enabled)
935 {
936  if (!timeout_steering_ && enabled_steering_ && timeout && !enabled) {
937  ROS_WARN("Steering subsystem disabled after 100ms command timeout");
938  }
939  timeout_steering_ = timeout;
941 }
942 
943 void DbwNode::faultBrakes(bool fault)
944 {
945  bool en = enabled();
946  if (fault && en) {
947  enable_ = false;
948  }
950  if (publishDbwEnabled()) {
951  if (en) {
952  ROS_ERROR("DBW system disabled. Braking fault.");
953  } else {
954  ROS_INFO("DBW system enabled.");
955  }
956  }
957 }
958 
959 void DbwNode::faultThrottle(bool fault)
960 {
961  bool en = enabled();
962  if (fault && en) {
963  enable_ = false;
964  }
966  if (publishDbwEnabled()) {
967  if (en) {
968  ROS_ERROR("DBW system disabled. Throttle fault.");
969  } else {
970  ROS_INFO("DBW system enabled.");
971  }
972  }
973 }
974 
975 void DbwNode::faultSteering(bool fault)
976 {
977  bool en = enabled();
978  if (fault && en) {
979  enable_ = false;
980  }
982  if (publishDbwEnabled()) {
983  if (en) {
984  ROS_ERROR("DBW system disabled. Steering fault.");
985  } else {
986  ROS_INFO("DBW system enabled.");
987  }
988  }
989 }
990 
992 {
993  bool en = enabled();
994  if (fault && en) {
995  enable_ = false;
996  }
998  if (publishDbwEnabled()) {
999  if (en) {
1000  ROS_ERROR("DBW system disabled. Steering calibration fault.");
1001  } else {
1002  ROS_INFO("DBW system enabled.");
1003  }
1004  }
1005 }
1006 
1007 void DbwNode::faultWatchdog(bool fault, uint8_t src, bool braking)
1008 {
1009  bool en = enabled();
1010  if (fault && en) {
1011  enable_ = false;
1012  }
1014  if (publishDbwEnabled()) {
1015  if (en) {
1016  ROS_ERROR("DBW system disabled. Watchdog fault.");
1017  } else {
1018  ROS_INFO("DBW system enabled.");
1019  }
1020  }
1021  if (braking && !fault_watchdog_using_brakes_) {
1022  ROS_WARN("Watchdog event: Alerting driver and applying brakes.");
1023  } else if (!braking && fault_watchdog_using_brakes_) {
1024  ROS_INFO("Watchdog event: Driver has successfully taken control.");
1025  }
1026  if (fault && src && !fault_watchdog_warned_) {
1027  switch (src) {
1028  case dbw_polaris_msgs::WatchdogCounter::OTHER_BRAKE:
1029  ROS_WARN("Watchdog event: Fault determined by brake controller");
1030  break;
1031  case dbw_polaris_msgs::WatchdogCounter::OTHER_THROTTLE:
1032  ROS_WARN("Watchdog event: Fault determined by throttle controller");
1033  break;
1034  case dbw_polaris_msgs::WatchdogCounter::OTHER_STEERING:
1035  ROS_WARN("Watchdog event: Fault determined by steering controller");
1036  break;
1037  case dbw_polaris_msgs::WatchdogCounter::BRAKE_COUNTER:
1038  ROS_WARN("Watchdog event: Brake command counter failed to increment");
1039  break;
1040  case dbw_polaris_msgs::WatchdogCounter::BRAKE_DISABLED:
1041  ROS_WARN("Watchdog event: Brake transition to disabled while in gear or moving");
1042  break;
1043  case dbw_polaris_msgs::WatchdogCounter::BRAKE_COMMAND:
1044  ROS_WARN("Watchdog event: Brake command timeout after 100ms");
1045  break;
1046  case dbw_polaris_msgs::WatchdogCounter::BRAKE_REPORT:
1047  ROS_WARN("Watchdog event: Brake report timeout after 100ms");
1048  break;
1049  case dbw_polaris_msgs::WatchdogCounter::THROTTLE_COUNTER:
1050  ROS_WARN("Watchdog event: Throttle command counter failed to increment");
1051  break;
1052  case dbw_polaris_msgs::WatchdogCounter::THROTTLE_DISABLED:
1053  ROS_WARN("Watchdog event: Throttle transition to disabled while in gear or moving");
1054  break;
1055  case dbw_polaris_msgs::WatchdogCounter::THROTTLE_COMMAND:
1056  ROS_WARN("Watchdog event: Throttle command timeout after 100ms");
1057  break;
1058  case dbw_polaris_msgs::WatchdogCounter::THROTTLE_REPORT:
1059  ROS_WARN("Watchdog event: Throttle report timeout after 100ms");
1060  break;
1061  case dbw_polaris_msgs::WatchdogCounter::STEERING_COUNTER:
1062  ROS_WARN("Watchdog event: Steering command counter failed to increment");
1063  break;
1064  case dbw_polaris_msgs::WatchdogCounter::STEERING_DISABLED:
1065  ROS_WARN("Watchdog event: Steering transition to disabled while in gear or moving");
1066  break;
1067  case dbw_polaris_msgs::WatchdogCounter::STEERING_COMMAND:
1068  ROS_WARN("Watchdog event: Steering command timeout after 100ms");
1069  break;
1070  case dbw_polaris_msgs::WatchdogCounter::STEERING_REPORT:
1071  ROS_WARN("Watchdog event: Steering report timeout after 100ms");
1072  break;
1073  }
1074  fault_watchdog_warned_ = true;
1075  } else if (!fault) {
1076  fault_watchdog_warned_ = false;
1077  }
1078  fault_watchdog_using_brakes_ = braking;
1080  ROS_WARN_THROTTLE(2.0, "Watchdog event: Press left OK button on the steering wheel or cycle power to clear event.");
1081  }
1082 }
1083 
1084 void DbwNode::faultWatchdog(bool fault, uint8_t src) {
1085  faultWatchdog(fault, src, fault_watchdog_using_brakes_); // No change to 'using brakes' status
1086 }
1087 
1088 void DbwNode::publishJointStates(const ros::Time &stamp, const dbw_polaris_msgs::SteeringReport *steering)
1089 {
1090  double dt = (stamp - joint_state_.header.stamp).toSec();
1091  if (steering) {
1092  if (std::isfinite(steering->steering_wheel_angle)) {
1093  const double L = acker_wheelbase_;
1094  const double W = acker_track_;
1095  const double r = L / tan(steering->steering_wheel_angle / steering_ratio_);
1096  joint_state_.position[JOINT_SL] = atan(L / (r - W/2));
1097  joint_state_.position[JOINT_SR] = atan(L / (r + W/2));
1098  }
1099  if (std::isfinite(steering->speed)) {
1100  joint_state_.velocity[JOINT_FL] = steering->speed / wheel_radius_;
1101  joint_state_.velocity[JOINT_FR] = steering->speed / wheel_radius_;
1102  joint_state_.velocity[JOINT_RL] = steering->speed / wheel_radius_;
1103  joint_state_.velocity[JOINT_RR] = steering->speed / wheel_radius_;
1104  }
1105  }
1106  if (dt < 0.5) {
1107  for (size_t i = JOINT_FL; i <= JOINT_RR; i++) {
1108  joint_state_.position[i] = fmod(joint_state_.position[i] + dt * joint_state_.velocity[i], 2*M_PI);
1109  }
1110  }
1111  joint_state_.header.stamp = stamp;
1113 }
1114 
1115 } // namespace dbw_polaris_can
1116 
dbw_polaris_can::MsgSteeringCmd::CMD_TYPE
uint8_t CMD_TYPE
Definition: dispatch.h:149
dbw_polaris_can::DbwNode::faultBrakes
void faultBrakes(bool fault)
Definition: DbwNode.cpp:943
NAME
string NAME
dbw_polaris_can::DbwNode::prev_enable_
bool prev_enable_
Definition: DbwNode.h:147
dbw_polaris_can::MsgThrottleReport::WDCSRC
uint8_t WDCSRC
Definition: dispatch.h:129
dbw_polaris_can::MsgThrottleReport::ENABLED
uint8_t ENABLED
Definition: dispatch.h:130
dbw_polaris_can::MsgThrottleReport::OVERRIDE
uint8_t OVERRIDE
Definition: dispatch.h:131
dbw_polaris_can::MsgThrottleReport::DRIVER
uint8_t DRIVER
Definition: dispatch.h:132
dbw_polaris_can::DbwNode::JOINT_RL
@ JOINT_RL
Definition: DbwNode.h:192
dbw_polaris_can::DbwNode::override_throttle_
bool override_throttle_
Definition: DbwNode.h:150
dbw_polaris_can::DbwNode
Definition: DbwNode.h:96
dbw_polaris_can::DbwNode::faultSteeringCal
void faultSteeringCal(bool fault)
Definition: DbwNode.cpp:991
dbw_polaris_can::MsgSteeringReport::CMD
int16_t CMD
Definition: dispatch.h:160
dbw_polaris_can::MsgSteeringCmd::SCMD
int16_t SCMD
Definition: dispatch.h:141
dbw_polaris_can::throttlePedalFromPercent
static float throttlePedalFromPercent(float percent)
Definition: pedal_lut.h:80
dbw_polaris_can::MsgSteeringCmd::ALERT
uint8_t ALERT
Definition: dispatch.h:148
dbw_polaris_can::LIC_MUX_MAC
@ LIC_MUX_MAC
Definition: dispatch.h:214
dbw_polaris_can::DbwNode::override_brake_
bool override_brake_
Definition: DbwNode.h:149
dbw_polaris_can::DbwNode::pub_joint_states_
ros::Publisher pub_joint_states_
Definition: DbwNode.h:246
dbw_polaris_can::MsgThrottleCmd::EN
uint8_t EN
Definition: dispatch.h:112
dbw_polaris_can::MsgVersion::module
uint8_t module
Definition: dispatch.h:305
dbw_polaris_can::MsgReportAccel::accel_lat
int16_t accel_lat
Definition: dispatch.h:192
dbw_polaris_can::DbwNode::sync_imu_
dataspeed_can_msg_filters::ApproximateTime sync_imu_
Definition: DbwNode.h:252
dbw_polaris_can::MsgSteeringReport::FLTBUS1
uint8_t FLTBUS1
Definition: dispatch.h:168
dbw_polaris_can::DbwNode::recvGearCmd
void recvGearCmd(const dbw_polaris_msgs::GearCmd::ConstPtr &msg)
Definition: DbwNode.cpp:703
dbw_polaris_can::MsgReportAccel
Definition: dispatch.h:191
dbw_polaris_can::DbwNode::fault_steering_
bool fault_steering_
Definition: DbwNode.h:155
dbw_polaris_can::DbwNode::pub_vin_
ros::Publisher pub_vin_
Definition: DbwNode.h:248
dbw_polaris_can::MsgLicense::trial
uint8_t trial
Definition: dispatch.h:224
ROS_INFO_ONCE_ID
#define ROS_INFO_ONCE_ID(id,...)
Definition: DbwNode.cpp:53
dbw_polaris_can::ID_LICENSE
@ ID_LICENSE
Definition: dispatch.h:340
dbw_polaris_can::MsgBrakeReport::BTYPE
uint8_t BTYPE
Definition: dispatch.h:94
dbw_polaris_can::DbwNode::sub_gear_
ros::Subscriber sub_gear_
Definition: DbwNode.h:236
dbw_polaris_can::DbwNode::fault_steering_cal_
bool fault_steering_cal_
Definition: DbwNode.h:156
dbw_polaris_can::MsgLicense::mux
uint8_t mux
Definition: dispatch.h:222
dbw_polaris_can::MsgThrottleReport::FLT1
uint8_t FLT1
Definition: dispatch.h:134
dbw_polaris_can::ID_STEERING_REPORT
@ ID_STEERING_REPORT
Definition: dispatch.h:335
dbw_polaris_can::platformToString
static const char * platformToString(Platform x)
Definition: PlatformVersion.h:103
dbw_polaris_can::MsgBrakeReport::FLTWDC
uint8_t FLTWDC
Definition: dispatch.h:101
dbw_polaris_can::MsgLicense::vin2
struct dbw_polaris_can::MsgLicense::@1::@11 vin2
dbw_polaris_can::MsgGearReport::OVERRIDE
uint8_t OVERRIDE
Definition: dispatch.h:184
dbw_polaris_can::DbwNode::recvSteeringCmd
void recvSteeringCmd(const dbw_polaris_msgs::SteeringCmd::ConstPtr &msg)
Definition: DbwNode.cpp:657
dbw_polaris_can::DbwNode::sub_brake_
ros::Subscriber sub_brake_
Definition: DbwNode.h:233
dbw_polaris_can::MsgSteeringCmd::QUIET
uint8_t QUIET
Definition: dispatch.h:146
dbw_polaris_can::ModuleVersion::build
uint16_t build() const
Definition: ModuleVersion.h:128
dbw_polaris_can::DbwNode::timerCallback
void timerCallback(const ros::TimerEvent &event)
Definition: DbwNode.cpp:749
dbw_polaris_can::MsgBrakeReport::PI
uint16_t PI
Definition: dispatch.h:91
ROS_WARN_ONCE_ID
#define ROS_WARN_ONCE_ID(id,...)
Definition: DbwNode.cpp:54
dbw_polaris_can::DbwNode::JOINT_FL
@ JOINT_FL
Definition: DbwNode.h:190
dbw_polaris_can::DbwNode::pub_throttle_
ros::Publisher pub_throttle_
Definition: DbwNode.h:242
dbw_polaris_can::DbwNode::sub_enable_
ros::Subscriber sub_enable_
Definition: DbwNode.h:230
dbw_polaris_can::MsgThrottleReport
Definition: dispatch.h:124
dbw_polaris_can::DbwNode::fault_throttle_
bool fault_throttle_
Definition: DbwNode.h:154
dbw_polaris_can::DbwNode::pedal_luts_
bool pedal_luts_
Definition: DbwNode.h:221
ros::NodeHandle::getParam
bool getParam(const std::string &key, bool &b) const
dbw_polaris_can::MsgLicense::ldate0
uint8_t ldate0
Definition: dispatch.h:238
ROS_WARN_THROTTLE
#define ROS_WARN_THROTTLE(period,...)
dbw_polaris_can::DbwNode::buttonCancel
void buttonCancel()
Definition: DbwNode.cpp:834
dbw_polaris_can::DbwNode::disableSystem
void disableSystem()
Definition: DbwNode.cpp:825
dbw_polaris_can::DbwNode::fault_watchdog_using_brakes_
bool fault_watchdog_using_brakes_
Definition: DbwNode.h:158
dbw_polaris_can::LIC_MUX_BDATE1
@ LIC_MUX_BDATE1
Definition: dispatch.h:216
dbw_polaris_can::MsgLicense::bdate0
struct dbw_polaris_can::MsgLicense::@1::@7 bdate0
dbw_polaris_can::LIC_MUX_VIN1
@ LIC_MUX_VIN1
Definition: dispatch.h:218
dbw_polaris_can::MsgThrottleCmd::CLEAR
uint8_t CLEAR
Definition: dispatch.h:113
dbw_polaris_can::DbwNode::joint_state_
sensor_msgs::JointState joint_state_
Definition: DbwNode.h:198
dbw_polaris_can::MsgBrakeCmd::COUNT
uint8_t COUNT
Definition: dispatch.h:119
dbw_polaris_can::MsgVersion::minor
uint16_t minor
Definition: dispatch.h:308
dbw_polaris_can::DbwNode::recvThrottleCmd
void recvThrottleCmd(const dbw_polaris_msgs::ThrottleCmd::ConstPtr &msg)
Definition: DbwNode.cpp:613
ROS_DEBUG
#define ROS_DEBUG(...)
dbw_polaris_can::P_POLARIS_GEM
@ P_POLARIS_GEM
Definition: PlatformVersion.h:120
ros::TransportHints
dbw_polaris_can::DbwNode::acker_track_
double acker_track_
Definition: DbwNode.h:225
dbw_polaris_can::DbwNode::sub_steering_
ros::Subscriber sub_steering_
Definition: DbwNode.h:235
dbw_polaris_can::MsgGearReport::FLTBUS
uint8_t FLTBUS
Definition: dispatch.h:186
dbw_polaris_can::MsgThrottleCmd::PCMD
uint16_t PCMD
Definition: dispatch.h:109
dbw_polaris_can::DbwNode::sub_throttle_
ros::Subscriber sub_throttle_
Definition: DbwNode.h:234
dbw_polaris_can::MsgSteeringCmd::COUNT
uint8_t COUNT
Definition: dispatch.h:155
dbw_polaris_can::MsgLicense::ready
uint8_t ready
Definition: dispatch.h:223
boost
dbw_polaris_can::MsgThrottleReport::PC
uint16_t PC
Definition: dispatch.h:126
dbw_polaris_can::LIC_MUX_VIN0
@ LIC_MUX_VIN0
Definition: dispatch.h:217
dbw_polaris_can::MsgVersion::major
uint16_t major
Definition: dispatch.h:307
dbw_polaris_can::DbwNode::override_steering_
bool override_steering_
Definition: DbwNode.h:151
dbw_polaris_can::DbwNode::sub_calibrate_steering_
ros::Subscriber sub_calibrate_steering_
Definition: DbwNode.h:237
dbw_polaris_can::ID_THROTTLE_REPORT
@ ID_THROTTLE_REPORT
Definition: dispatch.h:333
dbw_polaris_can::M_TPEC
@ M_TPEC
Definition: PlatformVersion.h:95
dbw_polaris_can::DbwNode::pub_can_
ros::Publisher pub_can_
Definition: DbwNode.h:240
dbw_polaris_can::M_BOO
@ M_BOO
Definition: PlatformVersion.h:99
dbw_polaris_can::LIC_MUX_BDATE0
@ LIC_MUX_BDATE0
Definition: dispatch.h:215
dbw_polaris_can::DbwNode::fault_brakes_
bool fault_brakes_
Definition: DbwNode.h:153
dbw_polaris_can::MsgLicense::ldate1
uint8_t ldate1
Definition: dispatch.h:239
dbw_polaris_can::MsgThrottleCmd::CMD_TYPE
uint8_t CMD_TYPE
Definition: dispatch.h:111
dbw_polaris_can::DbwNode::pub_sys_enable_
ros::Publisher pub_sys_enable_
Definition: DbwNode.h:249
dbw_polaris_can::MsgThrottleReport::FLTWDC
uint8_t FLTWDC
Definition: dispatch.h:133
ros::Publisher::publish
void publish(const boost::shared_ptr< M > &message) const
ros::NodeHandle::advertise
Publisher advertise(AdvertiseOptions &ops)
ros::TransportHints::tcpNoDelay
TransportHints & tcpNoDelay(bool nodelay=true)
dbw_polaris_can::DbwNode::timeout_steering_
bool timeout_steering_
Definition: DbwNode.h:162
dbw_polaris_can::M_STEER
@ M_STEER
Definition: PlatformVersion.h:96
dbw_polaris_can::DbwNode::fault_watchdog_warned_
bool fault_watchdog_warned_
Definition: DbwNode.h:159
ROS_WARN_COND
#define ROS_WARN_COND(cond,...)
dbw_polaris_can::LIC_MUX_F7
@ LIC_MUX_F7
Definition: dispatch.h:211
dbw_polaris_can::DbwNode::gear_warned_
bool gear_warned_
Definition: DbwNode.h:166
dbw_polaris_can::DbwNode::recvBrakeCmd
void recvBrakeCmd(const dbw_polaris_msgs::BrakeCmd::ConstPtr &msg)
Definition: DbwNode.cpp:573
dbw_polaris_can::DbwNode::firmware_
PlatformMap firmware_
Definition: DbwNode.h:212
dbw_polaris_can::DbwNode::pub_twist_
ros::Publisher pub_twist_
Definition: DbwNode.h:247
dbw_polaris_can::MsgGearCmd::GCMD
uint8_t GCMD
Definition: dispatch.h:175
dbw_polaris_can::MsgLicense::vin1
struct dbw_polaris_can::MsgLicense::@1::@10 vin1
dispatch.h
dbw_polaris_can::MsgThrottleReport::TMOUT
uint8_t TMOUT
Definition: dispatch.h:137
dbw_polaris_can::DbwNode::recvCAN
void recvCAN(const can_msgs::Frame::ConstPtr &msg)
Definition: DbwNode.cpp:174
dbw_polaris_can::DbwNode::~DbwNode
~DbwNode()
Definition: DbwNode.cpp:160
dbw_polaris_can::MsgSteeringReport
Definition: dispatch.h:158
dbw_polaris_can::DbwNode::recvCalibrateSteering
void recvCalibrateSteering(const std_msgs::Empty::ConstPtr &msg)
Definition: DbwNode.cpp:720
dbw_polaris_can::MsgBrakeReport::WDCSRC
uint8_t WDCSRC
Definition: dispatch.h:97
dbw_polaris_can::DbwNode::faultWatchdog
void faultWatchdog(bool fault, uint8_t src, bool braking)
Definition: DbwNode.cpp:1007
dbw_polaris_can::MsgSteeringCmd::CLEAR
uint8_t CLEAR
Definition: dispatch.h:143
dbw_polaris_can::DbwNode::enabled_throttle_
bool enabled_throttle_
Definition: DbwNode.h:164
dbw_polaris_can::DbwNode::faultSteering
void faultSteering(bool fault)
Definition: DbwNode.cpp:975
dbw_polaris_can::MsgThrottleReport::FLTPWR
uint8_t FLTPWR
Definition: dispatch.h:136
dbw_polaris_can::DbwNode::recvCanImu
void recvCanImu(const std::vector< can_msgs::Frame::ConstPtr > &msgs)
Definition: DbwNode.cpp:522
dbw_polaris_can::DbwNode::enable_
bool enable_
Definition: DbwNode.h:148
dbw_polaris_can::DbwNode::steering_ratio_
double steering_ratio_
Definition: DbwNode.h:226
dbw_polaris_can::MsgLicense::mac
struct dbw_polaris_can::MsgLicense::@1::@6 mac
dbw_polaris_can::MsgSteeringReport::VEH_VEL
int16_t VEH_VEL
Definition: dispatch.h:162
dbw_polaris_can::DbwNode::enabled_steering_
bool enabled_steering_
Definition: DbwNode.h:165
dbw_polaris_can::MsgLicense::license
struct dbw_polaris_can::MsgLicense::@1::@3 license
dbw_polaris_can::ID_BRAKE_CMD
@ ID_BRAKE_CMD
Definition: dispatch.h:330
dbw_polaris_can::DbwNode::fault_watchdog_
bool fault_watchdog_
Definition: DbwNode.h:157
dbw_polaris_can::Module
Module
Definition: PlatformVersion.h:93
dbw_polaris_can::DbwNode::faultThrottle
void faultThrottle(bool fault)
Definition: DbwNode.cpp:959
dataspeed_can_msg_filters::ApproximateTime::setInterMessageLowerBound
void setInterMessageLowerBound(ros::Duration lower_bound)
dbw_polaris_can::DbwNode::enabled
bool enabled()
Definition: DbwNode.h:170
dbw_polaris_can::MsgBrakeReport::FLTPWR
uint8_t FLTPWR
Definition: dispatch.h:104
dbw_polaris_can::ModuleVersion
Definition: ModuleVersion.h:83
dbw_polaris_can::ModuleVersion::valid
bool valid() const
Definition: ModuleVersion.h:125
dbw_polaris_can::MsgBrakeReport::OVERRIDE
uint8_t OVERRIDE
Definition: dispatch.h:99
dbw_polaris_can::DbwNode::recvEnable
void recvEnable(const std_msgs::Empty::ConstPtr &msg)
Definition: DbwNode.cpp:164
dbw_polaris_can::MsgBrakeReport::ENABLED
uint8_t ENABLED
Definition: dispatch.h:98
ROS_INFO_ONCE
#define ROS_INFO_ONCE(...)
dbw_polaris_can::MsgThrottleReport::FLT2
uint8_t FLT2
Definition: dispatch.h:135
dbw_polaris_can::ModuleVersion::minor
uint16_t minor() const
Definition: ModuleVersion.h:127
ROS_ERROR
#define ROS_ERROR(...)
dbw_polaris_can::MsgSteeringCmd::EN
uint8_t EN
Definition: dispatch.h:142
dbw_polaris_can::MsgVersion::build
uint16_t build
Definition: dispatch.h:309
dbw_polaris_can::MsgBrakeReport::FLT2
uint8_t FLT2
Definition: dispatch.h:103
dbw_polaris_can::LIC_MUX_LDATE0
@ LIC_MUX_LDATE0
Definition: dispatch.h:212
pedal_lut.h
dbw_polaris_can::MsgSteeringReport::FLTWDC
uint8_t FLTWDC
Definition: dispatch.h:167
ROS_WARN
#define ROS_WARN(...)
dbw_polaris_can::DbwNode::ldate_
std::string ldate_
Definition: DbwNode.h:208
dbw_polaris_can::DbwNode::recvDisable
void recvDisable(const std_msgs::Empty::ConstPtr &msg)
Definition: DbwNode.cpp:169
dbw_polaris_can::MsgGearReport::REJECT
uint8_t REJECT
Definition: dispatch.h:187
dbw_polaris_can::DbwNode::pub_brake_
ros::Publisher pub_brake_
Definition: DbwNode.h:241
dbw_polaris_can::DbwNode::override_gear_
bool override_gear_
Definition: DbwNode.h:152
dbw_polaris_can::DbwNode::timeout_brakes_
bool timeout_brakes_
Definition: DbwNode.h:160
dbw_polaris_can::DbwNode::wheel_radius_
double wheel_radius_
Definition: DbwNode.h:227
dbw_polaris_can::MsgThrottleCmd::IGNORE
uint8_t IGNORE
Definition: dispatch.h:114
dbw_polaris_can::MsgLicense
Definition: dispatch.h:221
ros::NodeHandle::subscribe
Subscriber subscribe(const std::string &topic, uint32_t queue_size, const boost::function< void(C)> &callback, const VoidConstPtr &tracked_object=VoidConstPtr(), const TransportHints &transport_hints=TransportHints())
dbw_polaris_can::LIC_MUX_F0
@ LIC_MUX_F0
Definition: dispatch.h:204
dataspeed_can_msg_filters::ApproximateTime::processMsg
void processMsg(const Type &msg)
ros::TimerEvent
dbw_polaris_can::PlatformMap::findModule
ModuleVersion findModule(Module m) const
Definition: PlatformMap.h:129
dbw_polaris_can::MsgBrakeReport::FLT1
uint8_t FLT1
Definition: dispatch.h:102
dbw_polaris_can::DbwNode::JOINT_SR
@ JOINT_SR
Definition: DbwNode.h:195
dbw_polaris_can::MsgSteeringReport::ENABLED
uint8_t ENABLED
Definition: dispatch.h:164
dbw_polaris_can::MsgBrakeCmd::IGNORE
uint8_t IGNORE
Definition: dispatch.h:112
dbw_polaris_can::MsgThrottleReport::PO
uint16_t PO
Definition: dispatch.h:127
dbw_polaris_can::Platform
Platform
Definition: PlatformVersion.h:77
dbw_polaris_can::MsgThrottleReport::PI
uint16_t PI
Definition: dispatch.h:125
dbw_polaris_can::DbwNode::bdate_
std::map< uint8_t, std::string > bdate_
Definition: DbwNode.h:209
dbw_polaris_can::moduleToString
static const char * moduleToString(Module x)
Definition: PlatformVersion.h:121
dbw_polaris_can::ID_REPORT_ACCEL
@ ID_REPORT_ACCEL
Definition: dispatch.h:338
dbw_polaris_can::LIC_MUX_VIN2
@ LIC_MUX_VIN2
Definition: dispatch.h:219
dbw_polaris_can::MsgVersion::platform
uint8_t platform
Definition: dispatch.h:306
dbw_polaris_can::MsgSteeringReport::FLTBUS2
uint8_t FLTBUS2
Definition: dispatch.h:169
dbw_polaris_can::DbwNode::sub_disable_
ros::Subscriber sub_disable_
Definition: DbwNode.h:231
dbw_polaris_can::DbwNode::enabled_brakes_
bool enabled_brakes_
Definition: DbwNode.h:163
dbw_polaris_can::DbwNode::frame_id_
std::string frame_id_
Definition: DbwNode.h:215
dbw_polaris_can::DbwNode::timeoutThrottle
void timeoutThrottle(bool timeout, bool enabled)
Definition: DbwNode.cpp:925
dbw_polaris_can::MsgThrottleCmd
Definition: dispatch.h:108
dbw_polaris_can::DbwNode::pub_steering_
ros::Publisher pub_steering_
Definition: DbwNode.h:243
dbw_polaris_can::MsgSteeringReport::ANGLE
int16_t ANGLE
Definition: dispatch.h:159
dbw_polaris_can::ID_BRAKE_REPORT
@ ID_BRAKE_REPORT
Definition: dispatch.h:331
dbw_polaris_can::MsgGearReport::CMD
uint8_t CMD
Definition: dispatch.h:185
dbw_polaris_can::DbwNode::overrideSteering
void overrideSteering(bool override, bool timeout)
Definition: DbwNode.cpp:881
dbw_polaris_can::DbwNode::clear
bool clear()
Definition: DbwNode.h:169
dbw_polaris_can::ModuleVersion::major
uint16_t major() const
Definition: ModuleVersion.h:126
dbw_polaris_can::DbwNode::JOINT_COUNT
@ JOINT_COUNT
Definition: DbwNode.h:196
dbw_polaris_can::DbwNode::acker_wheelbase_
double acker_wheelbase_
Definition: DbwNode.h:224
dbw_polaris_can::MsgBrakeCmd
Definition: dispatch.h:74
dbw_polaris_can::DbwNode::enableSystem
void enableSystem()
Definition: DbwNode.cpp:795
ros::Time
dbw_polaris_can::DbwNode::JOINT_RR
@ JOINT_RR
Definition: DbwNode.h:193
dbw_polaris_can::DbwNode::warn_cmds_
bool warn_cmds_
Definition: DbwNode.h:218
dbw_polaris_can::MsgSteeringReport::FLTPWR
uint8_t FLTPWR
Definition: dispatch.h:166
dbw_polaris_can::MsgGearReport::STATE
uint8_t STATE
Definition: dispatch.h:183
dbw_polaris_can::DbwNode::JOINT_FR
@ JOINT_FR
Definition: DbwNode.h:191
dbw_polaris_can::ID_VERSION
@ ID_VERSION
Definition: dispatch.h:341
dbw_polaris_can::MsgSteeringCmd::IGNORE
uint8_t IGNORE
Definition: dispatch.h:144
dbw_polaris_can::MsgBrakeReport::PO
uint16_t PO
Definition: dispatch.h:93
DbwNode.h
dbw_polaris_can::DbwNode::timeoutSteering
void timeoutSteering(bool timeout, bool enabled)
Definition: DbwNode.cpp:934
dbw_polaris_can::DbwNode::DbwNode
DbwNode(ros::NodeHandle &node, ros::NodeHandle &priv_nh)
Definition: DbwNode.cpp:71
dbw_polaris_can::DbwNode::fault
bool fault()
Definition: DbwNode.h:167
dbw_polaris_can::MsgLicense::vin0
struct dbw_polaris_can::MsgLicense::@1::@9 vin0
dbw_polaris_can::MsgBrakeReport::PC
uint16_t PC
Definition: dispatch.h:92
dbw_polaris_can::MsgBrakeCmd::CMD_TYPE
uint8_t CMD_TYPE
Definition: dispatch.h:109
dbw_polaris_can::MsgReportAccel::accel_long
int16_t accel_long
Definition: dispatch.h:193
dbw_polaris_can::ID_GEAR_CMD
@ ID_GEAR_CMD
Definition: dispatch.h:336
dbw_polaris_can::DbwNode::publishDbwEnabled
bool publishDbwEnabled(bool force=false)
Definition: DbwNode.cpp:736
dbw_polaris_can::MsgThrottleCmd::COUNT
uint8_t COUNT
Definition: dispatch.h:121
dbw_polaris_can::MsgReportGyro
Definition: dispatch.h:197
dbw_polaris_can::DbwNode::pub_gear_
ros::Publisher pub_gear_
Definition: DbwNode.h:244
dbw_polaris_can::LIC_MUX_LDATE1
@ LIC_MUX_LDATE1
Definition: dispatch.h:213
dbw_polaris_can::MsgSteeringCmd
Definition: dispatch.h:140
dbw_polaris_can::DbwNode::JOINT_SL
@ JOINT_SL
Definition: DbwNode.h:194
dbw_polaris_can::MsgBrakeCmd::EN
uint8_t EN
Definition: dispatch.h:110
dbw_polaris_can
Definition: dispatch.h:39
dbw_polaris_can::MsgBrakeReport
Definition: dispatch.h:90
dbw_polaris_can::MsgReportAccel::accel_vert
int16_t accel_vert
Definition: dispatch.h:194
dbw_polaris_can::MsgSteeringCmd::CAL
uint8_t CAL
Definition: dispatch.h:145
dbw_polaris_can::ID_THROTTLE_CMD
@ ID_THROTTLE_CMD
Definition: dispatch.h:332
dbw_polaris_can::MsgLicense::expired
uint8_t expired
Definition: dispatch.h:225
cmd
string cmd
dbw_polaris_can::MsgSteeringReport::FLTCAL
uint8_t FLTCAL
Definition: dispatch.h:170
header
const std::string header
dbw_polaris_can::MsgSteeringReport::TMOUT
uint8_t TMOUT
Definition: dispatch.h:171
dbw_polaris_can::DbwNode::overrideThrottle
void overrideThrottle(bool override, bool timeout)
Definition: DbwNode.cpp:862
dbw_polaris_can::MsgVersion
Definition: dispatch.h:304
ROS_INFO
#define ROS_INFO(...)
dbw_polaris_can::MsgGearCmd::CLEAR
uint8_t CLEAR
Definition: dispatch.h:179
dbw_polaris_can::MsgSteeringReport::TMODE
uint8_t TMODE
Definition: dispatch.h:161
ROS_ASSERT
#define ROS_ASSERT(cond)
dbw_polaris_can::MsgBrakeReport::TMOUT
uint8_t TMOUT
Definition: dispatch.h:105
dbw_polaris_can::MsgSteeringReport::TORQUE
int8_t TORQUE
Definition: dispatch.h:163
dbw_polaris_can::MsgSteeringReport::OVERRIDE
uint8_t OVERRIDE
Definition: dispatch.h:165
dbw_polaris_can::DbwNode::sub_can_
ros::Subscriber sub_can_
Definition: DbwNode.h:232
dbw_polaris_can::MsgLicense::bdate1
struct dbw_polaris_can::MsgLicense::@1::@8 bdate1
dbw_polaris_can::ID_GEAR_REPORT
@ ID_GEAR_REPORT
Definition: dispatch.h:337
ros::NodeHandle::createTimer
Timer createTimer(Duration period, const TimerCallback &callback, bool oneshot=false, bool autostart=true) const
dbw_polaris_can::MsgGearReport
Definition: dispatch.h:182
dbw_polaris_can::MsgBrakeCmd::PCMD
uint16_t PCMD
Definition: dispatch.h:107
dbw_polaris_can::MsgSteeringCmd::SVEL
uint8_t SVEL
Definition: dispatch.h:150
dbw_polaris_can::MsgBrakeReport::DRIVER
uint8_t DRIVER
Definition: dispatch.h:100
ros::Duration
dbw_polaris_can::MsgGearCmd
Definition: dispatch.h:174
dbw_polaris_can::ID_STEERING_CMD
@ ID_STEERING_CMD
Definition: dispatch.h:334
dbw_polaris_can::MsgBrakeReport::WDCBRK
uint8_t WDCBRK
Definition: dispatch.h:96
dbw_polaris_can::MsgLicense::module
uint8_t module
Definition: dispatch.h:227
dbw_polaris_can::DbwNode::publishJointStates
void publishJointStates(const ros::Time &stamp, const dbw_polaris_msgs::SteeringReport *steering)
Definition: DbwNode.cpp:1088
dbw_polaris_can::PlatformMap::insert
void insert(Platform p, Module m, ModuleVersion v)
Definition: PlatformMap.h:123
dbw_polaris_can::DbwNode::timeoutBrake
void timeoutBrake(bool timeout, bool enabled)
Definition: DbwNode.cpp:916
dbw_polaris_can::PlatformVersion
Definition: PlatformVersion.h:134
dbw_polaris_can::DbwNode::overrideBrake
void overrideBrake(bool override, bool timeout)
Definition: DbwNode.cpp:843
dbw_polaris_can::DbwNode::pub_imu_
ros::Publisher pub_imu_
Definition: DbwNode.h:245
dbw_polaris_can::ID_REPORT_GYRO
@ ID_REPORT_GYRO
Definition: dispatch.h:339
dbw_polaris_can::DbwNode::overrideGear
void overrideGear(bool override)
Definition: DbwNode.cpp:900
ros::NodeHandle
dbw_polaris_can::DbwNode::timeout_throttle_
bool timeout_throttle_
Definition: DbwNode.h:161
dbw_polaris_can::MsgBrakeCmd::CLEAR
uint8_t CLEAR
Definition: dispatch.h:111
dbw_polaris_can::DbwNode::timer_
ros::Timer timer_
Definition: DbwNode.h:146
dbw_polaris_can::DbwNode::vin_
std::string vin_
Definition: DbwNode.h:207
ROS_INFO_THROTTLE
#define ROS_INFO_THROTTLE(period,...)
dbw_polaris_can::FIRMWARE_LATEST
PlatformMap FIRMWARE_LATEST({ {PlatformVersion(P_POLARIS_GEM, M_TPEC, ModuleVersion(1, 2, 2))}, {PlatformVersion(P_POLARIS_GEM, M_STEER, ModuleVersion(1, 2, 2))}, {PlatformVersion(P_POLARIS_GEM, M_BOO, ModuleVersion(1, 2, 2))}, {PlatformVersion(P_POLARIS_RZR, M_TPEC, ModuleVersion(0, 4, 2))}, {PlatformVersion(P_POLARIS_RZR, M_STEER, ModuleVersion(0, 4, 2))}, {PlatformVersion(P_POLARIS_RZR, M_BOO, ModuleVersion(0, 4, 2))}, })
dbw_polaris_can::P_POLARIS_RZR
@ P_POLARIS_RZR
Definition: PlatformVersion.h:121


dbw_polaris_can
Author(s): Kevin Hallenbeck
autogenerated on Thu Jan 4 2024 03:36:18