DbwNode.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2018-2019 New Eagle
5  * Copyright (c) 2015-2018, Dataspeed Inc.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of Dataspeed Inc. nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *********************************************************************/
35 
36 #ifndef _DBW_NODE_H_
37 #define _DBW_NODE_H_
38 
39 #include <ros/ros.h>
40 
41 // ROS messages
42 #include <can_msgs/Frame.h>
43 #include <raptor_dbw_msgs/BrakeCmd.h>
44 #include <raptor_dbw_msgs/BrakeReport.h>
45 #include <raptor_dbw_msgs/AcceleratorPedalCmd.h>
46 #include <raptor_dbw_msgs/AcceleratorPedalReport.h>
47 #include <raptor_dbw_msgs/SteeringCmd.h>
48 #include <raptor_dbw_msgs/SteeringReport.h>
49 #include <raptor_dbw_msgs/GearCmd.h>
50 #include <raptor_dbw_msgs/GearReport.h>
51 #include <raptor_dbw_msgs/MiscCmd.h>
52 #include <raptor_dbw_msgs/MiscReport.h>
53 #include <raptor_dbw_msgs/WheelPositionReport.h>
54 #include <raptor_dbw_msgs/WheelSpeedReport.h>
55 #include <raptor_dbw_msgs/TirePressureReport.h>
56 #include <raptor_dbw_msgs/SurroundReport.h>
57 #include <raptor_dbw_msgs/DriverInputReport.h>
58 #include <raptor_dbw_msgs/LowVoltageSystemReport.h>
59 #include <raptor_dbw_msgs/ActuatorControlMode.h>
60 #include <raptor_dbw_msgs/Brake2Report.h>
61 #include <raptor_dbw_msgs/Steering2Report.h>
62 #include <raptor_dbw_msgs/GlobalEnableCmd.h>
63 #include <raptor_dbw_msgs/FaultActionsReport.h>
64 #include <raptor_dbw_msgs/HmiGlobalEnableReport.h>
65 
66 #include <sensor_msgs/Imu.h>
67 #include <sensor_msgs/JointState.h>
68 #include <geometry_msgs/TwistStamped.h>
69 #include <std_msgs/Empty.h>
70 #include <std_msgs/Bool.h>
71 #include <std_msgs/String.h>
72 
73 //#include <can_dbc_parser/DbcUtilities.h>
76 #include <can_dbc_parser/Dbc.h>
78 
79 #include <pdu_msgs/RelayCommand.h>
80 #include <pdu_msgs/RelayState.h>
81 
82 namespace raptor_dbw_can
83 {
84 
85 class DbwNode
86 {
87 public:
88  DbwNode(ros::NodeHandle &node, ros::NodeHandle &priv_nh);
89  ~DbwNode();
90 
91 private:
92  void timerCallback(const ros::TimerEvent& event);
93  void recvEnable(const std_msgs::Empty::ConstPtr& msg);
94  void recvDisable(const std_msgs::Empty::ConstPtr& msg);
95  void recvCAN(const can_msgs::Frame::ConstPtr& msg);
96  void recvCanImu(const std::vector<can_msgs::Frame::ConstPtr> &msgs);
97  void recvCanGps(const std::vector<can_msgs::Frame::ConstPtr> &msgs);
98  void recvBrakeCmd(const raptor_dbw_msgs::BrakeCmd::ConstPtr& msg);
99  void recvAcceleratorPedalCmd(const raptor_dbw_msgs::AcceleratorPedalCmd::ConstPtr& msg);
100  void recvSteeringCmd(const raptor_dbw_msgs::SteeringCmd::ConstPtr& msg);
101  void recvGearCmd(const raptor_dbw_msgs::GearCmd::ConstPtr& msg);
102  void recvMiscCmd(const raptor_dbw_msgs::MiscCmd::ConstPtr& msg);
103  void recvGlobalEnableCmd(const raptor_dbw_msgs::GlobalEnableCmd::ConstPtr& msg);
104 
106  bool prev_enable_;
107  bool enable_;
108  bool override_brake_;
110  bool override_steering_;
111  bool override_gear_;
112  bool fault_brakes_;
114  bool fault_steering_;
115  bool fault_steering_cal_;
116  bool fault_watchdog_;
119  bool timeout_brakes_;
121  bool timeout_steering_;
122  bool enabled_brakes_;
124  bool enabled_steering_;
125  bool gear_warned_;
127  inline bool override() { return override_brake_ || override_accelerator_pedal_ || override_steering_ || override_gear_; }
128  inline bool clear() { return enable_ && override(); }
129  inline bool enabled() { return enable_ && !fault() && !override(); }
130  bool publishDbwEnabled();
131  void enableSystem();
132  void disableSystem();
133  void buttonCancel();
134  void overrideBrake(bool override);
135  void overrideAcceleratorPedal(bool override);
136  void overrideSteering(bool override);
137  void overrideGear(bool override);
138  void timeoutBrake(bool timeout, bool enabled);
139  void timeoutAcceleratorPedal(bool timeout, bool enabled);
140  void timeoutSteering(bool timeout, bool enabled);
141  void faultBrakes(bool fault);
142  void faultAcceleratorPedal(bool fault);
143  void faultSteering(bool fault);
144  void faultSteeringCal(bool fault);
145  void faultWatchdog(bool fault, uint8_t src, bool braking);
146  void faultWatchdog(bool fault, uint8_t src = 0);
147 
148  enum {
149  JOINT_FL = 0, // Front left wheel
150  JOINT_FR, // Front right wheel
151  JOINT_RL, // Rear left wheel
152  JOINT_RR, // Rear right wheel
153  JOINT_SL, // Steering left
154  JOINT_SR, // Steering right
155  JOINT_COUNT, // Number of joints
156  };
157  sensor_msgs::JointState joint_state_;
158  void publishJointStates(const ros::Time &stamp, const raptor_dbw_msgs::WheelSpeedReport *wheels, const raptor_dbw_msgs::SteeringReport *steering);
159  // Licensing
160  std::string vin_;
161 
162  // Frame ID
163  std::string frame_id_;
164 
165  // Buttons (enable/disable)
166  bool buttons_;
167 
168  // Ackermann steering
169  double acker_wheelbase_;
170  double acker_track_;
172 
173  // Subscribed topics
183 
184  // Published topics
202 
207 
209  std::string dbcFile_;
210 
211  // Test stuff
213  uint32_t count_;
214 };
215 
216 } // raptor_dbw_can
217 
218 #endif // _DBW_NODE_H_
219 
raptor_dbw_can::DbwNode::fault
bool fault()
Definition: DbwNode.h:192
raptor_dbw_can::DbwNode::JOINT_RL
@ JOINT_RL
Definition: DbwNode.h:217
raptor_dbw_can::DbwNode::dbwDbc_
NewEagle::Dbc dbwDbc_
Definition: DbwNode.h:274
raptor_dbw_can::DbwNode::override_steering_
bool override_steering_
Definition: DbwNode.h:176
ros::Publisher
raptor_dbw_can::DbwNode::recvAcceleratorPedalCmd
void recvAcceleratorPedalCmd(const raptor_dbw_msgs::AcceleratorPedalCmd::ConstPtr &msg)
Definition: DbwNode.cpp:733
raptor_dbw_can::DbwNode::sub_can_
ros::Subscriber sub_can_
Definition: DbwNode.h:242
raptor_dbw_can::DbwNode::override_accelerator_pedal_
bool override_accelerator_pedal_
Definition: DbwNode.h:175
raptor_dbw_can::DbwNode::sub_disable_
ros::Subscriber sub_disable_
Definition: DbwNode.h:241
raptor_dbw_can::DbwNode::fault_accelerator_pedal_
bool fault_accelerator_pedal_
Definition: DbwNode.h:179
raptor_dbw_can::DbwNode::enable_
bool enable_
Definition: DbwNode.h:173
raptor_dbw_can::DbwNode::overrideBrake
void overrideBrake(bool override)
Definition: DbwNode.cpp:1047
raptor_dbw_can::DbwNode::pub_steering_
ros::Publisher pub_steering_
Definition: DbwNode.h:254
raptor_dbw_can::DbwNode::recvMiscCmd
void recvMiscCmd(const raptor_dbw_msgs::MiscCmd::ConstPtr &msg)
Definition: DbwNode.cpp:888
raptor_dbw_can::DbwNode::override_gear_
bool override_gear_
Definition: DbwNode.h:177
raptor_dbw_can::DbwNode::enabled
bool enabled()
Definition: DbwNode.h:195
raptor_dbw_can::DbwNode::dbcFile_
std::string dbcFile_
Definition: DbwNode.h:275
ros.h
NewEagle::Dbc
raptor_dbw_can::DbwNode::gear_warned_
bool gear_warned_
Definition: DbwNode.h:191
raptor_dbw_can::DbwNode::overrideAcceleratorPedal
void overrideAcceleratorPedal(bool override)
Definition: DbwNode.cpp:1063
raptor_dbw_can::DbwNode::~DbwNode
~DbwNode()
Definition: DbwNode.cpp:177
raptor_dbw_can::DbwNode::override_brake_
bool override_brake_
Definition: DbwNode.h:174
DbcMessage.h
raptor_dbw_can::DbwNode::recvGlobalEnableCmd
void recvGlobalEnableCmd(const raptor_dbw_msgs::GlobalEnableCmd::ConstPtr &msg)
Definition: DbwNode.cpp:859
raptor_dbw_can::DbwNode::JOINT_COUNT
@ JOINT_COUNT
Definition: DbwNode.h:221
raptor_dbw_can::DbwNode::sub_global_enable_
ros::Subscriber sub_global_enable_
Definition: DbwNode.h:248
raptor_dbw_can::DbwNode::recvGearCmd
void recvGearCmd(const raptor_dbw_msgs::GearCmd::ConstPtr &msg)
Definition: DbwNode.cpp:835
raptor_dbw_can::DbwNode::fault_watchdog_warned_
bool fault_watchdog_warned_
Definition: DbwNode.h:184
raptor_dbw_can
Definition: dispatch.h:40
raptor_dbw_can::DbwNode::recvSteeringCmd
void recvSteeringCmd(const raptor_dbw_msgs::SteeringCmd::ConstPtr &msg)
Definition: DbwNode.cpp:785
raptor_dbw_can::DbwNode::enabled_accelerator_pedal_
bool enabled_accelerator_pedal_
Definition: DbwNode.h:189
raptor_dbw_can::DbwNode::pub_brake_
ros::Publisher pub_brake_
Definition: DbwNode.h:252
raptor_dbw_can::DbwNode::timer_
ros::Timer timer_
Definition: DbwNode.h:171
raptor_dbw_can::DbwNode::enableSystem
void enableSystem()
Definition: DbwNode.cpp:999
raptor_dbw_can::DbwNode::faultSteering
void faultSteering(bool fault)
Definition: DbwNode.cpp:1170
raptor_dbw_can::DbwNode::timeoutSteering
void timeoutSteering(bool timeout, bool enabled)
Definition: DbwNode.cpp:1129
raptor_dbw_can::DbwNode::recvCanGps
void recvCanGps(const std::vector< can_msgs::Frame::ConstPtr > &msgs)
raptor_dbw_can::DbwNode::DbwNode
DbwNode(ros::NodeHandle &node, ros::NodeHandle &priv_nh)
Definition: DbwNode.cpp:75
DbcBuilder.h
raptor_dbw_can::DbwNode::publishJointStates
void publishJointStates(const ros::Time &stamp, const raptor_dbw_msgs::WheelSpeedReport *wheels, const raptor_dbw_msgs::SteeringReport *steering)
Definition: DbwNode.cpp:1284
raptor_dbw_can::DbwNode::pub_twist_
ros::Publisher pub_twist_
Definition: DbwNode.h:263
raptor_dbw_can::DbwNode::pub_vin_
ros::Publisher pub_vin_
Definition: DbwNode.h:264
raptor_dbw_can::DbwNode::sub_brake_
ros::Subscriber sub_brake_
Definition: DbwNode.h:243
raptor_dbw_can::DbwNode::fault_brakes_
bool fault_brakes_
Definition: DbwNode.h:178
raptor_dbw_can::DbwNode::JOINT_FR
@ JOINT_FR
Definition: DbwNode.h:216
raptor_dbw_can::DbwNode::steering_ratio_
double steering_ratio_
Definition: DbwNode.h:237
raptor_dbw_can::DbwNode::fault_steering_cal_
bool fault_steering_cal_
Definition: DbwNode.h:181
raptor_dbw_can::DbwNode::enabled_brakes_
bool enabled_brakes_
Definition: DbwNode.h:188
raptor_dbw_can::DbwNode::recvBrakeCmd
void recvBrakeCmd(const raptor_dbw_msgs::BrakeCmd::ConstPtr &msg)
Definition: DbwNode.cpp:693
raptor_dbw_can::DbwNode::sub_misc_
ros::Subscriber sub_misc_
Definition: DbwNode.h:247
raptor_dbw_can::DbwNode::buttons_
bool buttons_
Definition: DbwNode.h:232
raptor_dbw_can::DbwNode::pub_steering_2_report_
ros::Publisher pub_steering_2_report_
Definition: DbwNode.h:270
raptor_dbw_can::DbwNode::timeout_brakes_
bool timeout_brakes_
Definition: DbwNode.h:185
raptor_dbw_can::DbwNode::fault_watchdog_
bool fault_watchdog_
Definition: DbwNode.h:182
raptor_dbw_can::DbwNode::buttonCancel
void buttonCancel()
Definition: DbwNode.cpp:1038
raptor_dbw_can::DbwNode::disableSystem
void disableSystem()
Definition: DbwNode.cpp:1029
raptor_dbw_can::DbwNode::vin_
std::string vin_
Definition: DbwNode.h:226
raptor_dbw_can::DbwNode::sub_enable_
ros::Subscriber sub_enable_
Definition: DbwNode.h:240
raptor_dbw_can::DbwNode::sub_steering_
ros::Subscriber sub_steering_
Definition: DbwNode.h:245
raptor_dbw_can::DbwNode::sub_accelerator_pedal_
ros::Subscriber sub_accelerator_pedal_
Definition: DbwNode.h:244
raptor_dbw_can::DbwNode::faultWatchdog
void faultWatchdog(bool fault, uint8_t src, bool braking)
Definition: DbwNode.cpp:1202
ros::TimerEvent
raptor_dbw_can::DbwNode::enabled_steering_
bool enabled_steering_
Definition: DbwNode.h:190
raptor_dbw_can::DbwNode::pub_fault_actions_report_
ros::Publisher pub_fault_actions_report_
Definition: DbwNode.h:271
raptor_dbw_can::DbwNode::pub_sys_enable_
ros::Publisher pub_sys_enable_
Definition: DbwNode.h:265
raptor_dbw_can::DbwNode::count_
uint32_t count_
Definition: DbwNode.h:279
raptor_dbw_can::DbwNode::clear
bool clear()
Definition: DbwNode.h:194
raptor_dbw_can::DbwNode::fault_steering_
bool fault_steering_
Definition: DbwNode.h:180
Dbc.h
raptor_dbw_can::DbwNode::pub_surround_
ros::Publisher pub_surround_
Definition: DbwNode.h:260
raptor_dbw_can::DbwNode::pub_hmi_global_enable_report_
ros::Publisher pub_hmi_global_enable_report_
Definition: DbwNode.h:272
raptor_dbw_can::DbwNode::acker_track_
double acker_track_
Definition: DbwNode.h:236
raptor_dbw_can::DbwNode::acker_wheelbase_
double acker_wheelbase_
Definition: DbwNode.h:235
raptor_dbw_can::DbwNode::timeout_steering_
bool timeout_steering_
Definition: DbwNode.h:187
ros::Time
raptor_dbw_can::DbwNode::recvEnable
void recvEnable(const std_msgs::Empty::ConstPtr &msg)
Definition: DbwNode.cpp:181
raptor_dbw_can::DbwNode::pub_wheel_speeds_
ros::Publisher pub_wheel_speeds_
Definition: DbwNode.h:257
raptor_dbw_can::DbwNode::timeoutAcceleratorPedal
void timeoutAcceleratorPedal(bool timeout, bool enabled)
Definition: DbwNode.cpp:1120
raptor_dbw_can::DbwNode::publishDbwEnabled
bool publishDbwEnabled()
Definition: DbwNode.cpp:937
raptor_dbw_can::DbwNode::pub_joint_states_
ros::Publisher pub_joint_states_
Definition: DbwNode.h:262
raptor_dbw_can::DbwNode::recvCAN
void recvCAN(const can_msgs::Frame::ConstPtr &msg)
Definition: DbwNode.cpp:191
DbcSignal.h
raptor_dbw_can::DbwNode::sub_gear_
ros::Subscriber sub_gear_
Definition: DbwNode.h:246
raptor_dbw_can::DbwNode::prev_enable_
bool prev_enable_
Definition: DbwNode.h:172
raptor_dbw_can::DbwNode::JOINT_FL
@ JOINT_FL
Definition: DbwNode.h:215
raptor_dbw_can::DbwNode::JOINT_SL
@ JOINT_SL
Definition: DbwNode.h:219
raptor_dbw_can::DbwNode::pub_wheel_positions_
ros::Publisher pub_wheel_positions_
Definition: DbwNode.h:258
raptor_dbw_can::DbwNode::pub_tire_pressure_
ros::Publisher pub_tire_pressure_
Definition: DbwNode.h:259
raptor_dbw_can::DbwNode::pub_imu_
ros::Publisher pub_imu_
Definition: DbwNode.h:261
raptor_dbw_can::DbwNode::faultSteeringCal
void faultSteeringCal(bool fault)
Definition: DbwNode.cpp:1186
raptor_dbw_can::DbwNode::pub_gear_
ros::Publisher pub_gear_
Definition: DbwNode.h:255
raptor_dbw_can::DbwNode::timerCallback
void timerCallback(const ros::TimerEvent &event)
Definition: DbwNode.cpp:951
raptor_dbw_can::DbwNode::faultAcceleratorPedal
void faultAcceleratorPedal(bool fault)
Definition: DbwNode.cpp:1154
raptor_dbw_can::DbwNode::overrideSteering
void overrideSteering(bool override)
Definition: DbwNode.cpp:1079
raptor_dbw_can::DbwNode::pub_driver_input_
ros::Publisher pub_driver_input_
Definition: DbwNode.h:266
raptor_dbw_can::DbwNode::faultBrakes
void faultBrakes(bool fault)
Definition: DbwNode.cpp:1138
raptor_dbw_can::DbwNode::pub_brake_2_report_
ros::Publisher pub_brake_2_report_
Definition: DbwNode.h:269
raptor_dbw_can::DbwNode::pub_misc_
ros::Publisher pub_misc_
Definition: DbwNode.h:256
raptor_dbw_can::DbwNode::frame_id_
std::string frame_id_
Definition: DbwNode.h:229
raptor_dbw_can::DbwNode::pub_low_voltage_system_
ros::Publisher pub_low_voltage_system_
Definition: DbwNode.h:267
raptor_dbw_can::DbwNode::pub_accel_pedal_
ros::Publisher pub_accel_pedal_
Definition: DbwNode.h:253
raptor_dbw_can::DbwNode::pdu1_relay_pub_
ros::Publisher pdu1_relay_pub_
Definition: DbwNode.h:278
ros::Timer
raptor_dbw_can::DbwNode::fault_watchdog_using_brakes_
bool fault_watchdog_using_brakes_
Definition: DbwNode.h:183
raptor_dbw_can::DbwNode::JOINT_SR
@ JOINT_SR
Definition: DbwNode.h:220
raptor_dbw_can::DbwNode::timeout_accelerator_pedal_
bool timeout_accelerator_pedal_
Definition: DbwNode.h:186
raptor_dbw_can::DbwNode::recvDisable
void recvDisable(const std_msgs::Empty::ConstPtr &msg)
Definition: DbwNode.cpp:186
raptor_dbw_can::DbwNode::joint_state_
sensor_msgs::JointState joint_state_
Definition: DbwNode.h:223
raptor_dbw_can::DbwNode::pub_can_
ros::Publisher pub_can_
Definition: DbwNode.h:251
raptor_dbw_can::DbwNode::timeoutBrake
void timeoutBrake(bool timeout, bool enabled)
Definition: DbwNode.cpp:1111
raptor_dbw_can::DbwNode::JOINT_RR
@ JOINT_RR
Definition: DbwNode.h:218
raptor_dbw_can::DbwNode::recvCanImu
void recvCanImu(const std::vector< can_msgs::Frame::ConstPtr > &msgs)
ros::NodeHandle
ros::Subscriber
raptor_dbw_can::DbwNode::overrideGear
void overrideGear(bool override)
Definition: DbwNode.cpp:1095


raptor_dbw_can
Author(s): Ryan Borchert
autogenerated on Sat Apr 9 2022 02:34:35