Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef _DBW_NODE_H_
00037 #define _DBW_NODE_H_
00038
00039 #include <ros/ros.h>
00040
00041
00042 #include <can_msgs/Frame.h>
00043 #include <dbw_pacifica_msgs/BrakeCmd.h>
00044 #include <dbw_pacifica_msgs/BrakeReport.h>
00045 #include <dbw_pacifica_msgs/AcceleratorPedalCmd.h>
00046 #include <dbw_pacifica_msgs/AcceleratorPedalReport.h>
00047 #include <dbw_pacifica_msgs/SteeringCmd.h>
00048 #include <dbw_pacifica_msgs/SteeringReport.h>
00049 #include <dbw_pacifica_msgs/GearCmd.h>
00050 #include <dbw_pacifica_msgs/GearReport.h>
00051 #include <dbw_pacifica_msgs/MiscCmd.h>
00052 #include <dbw_pacifica_msgs/MiscReport.h>
00053 #include <dbw_pacifica_msgs/WheelPositionReport.h>
00054 #include <dbw_pacifica_msgs/WheelSpeedReport.h>
00055 #include <dbw_pacifica_msgs/TirePressureReport.h>
00056 #include <dbw_pacifica_msgs/SurroundReport.h>
00057 #include <dbw_pacifica_msgs/DriverInputReport.h>
00058 #include <dbw_pacifica_msgs/LowVoltageSystemReport.h>
00059 #include <dbw_pacifica_msgs/ActuatorControlMode.h>
00060 #include <dbw_pacifica_msgs/Brake2Report.h>
00061 #include <dbw_pacifica_msgs/Steering2Report.h>
00062 #include <dbw_pacifica_msgs/GlobalEnableCmd.h>
00063 #include <dbw_pacifica_msgs/FaultActionsReport.h>
00064 #include <dbw_pacifica_msgs/HmiGlobalEnableReport.h>
00065
00066 #include <sensor_msgs/Imu.h>
00067 #include <sensor_msgs/JointState.h>
00068 #include <geometry_msgs/TwistStamped.h>
00069 #include <std_msgs/Empty.h>
00070 #include <std_msgs/Bool.h>
00071 #include <std_msgs/String.h>
00072
00073
00074 #include <dbc/DbcMessage.h>
00075 #include <dbc/DbcSignal.h>
00076 #include <dbc/Dbc.h>
00077 #include <dbc/DbcBuilder.h>
00078
00079 #include <pdu_msgs/RelayCommand.h>
00080 #include <pdu_msgs/RelayState.h>
00081
00082 namespace dbw_pacifica_can
00083 {
00084
00085 class DbwNode
00086 {
00087 public:
00088 DbwNode(ros::NodeHandle &node, ros::NodeHandle &priv_nh);
00089 ~DbwNode();
00090
00091 private:
00092 void timerCallback(const ros::TimerEvent& event);
00093 void recvEnable(const std_msgs::Empty::ConstPtr& msg);
00094 void recvDisable(const std_msgs::Empty::ConstPtr& msg);
00095 void recvCAN(const can_msgs::Frame::ConstPtr& msg);
00096 void recvCanImu(const std::vector<can_msgs::Frame::ConstPtr> &msgs);
00097 void recvCanGps(const std::vector<can_msgs::Frame::ConstPtr> &msgs);
00098 void recvBrakeCmd(const dbw_pacifica_msgs::BrakeCmd::ConstPtr& msg);
00099 void recvAcceleratorPedalCmd(const dbw_pacifica_msgs::AcceleratorPedalCmd::ConstPtr& msg);
00100 void recvSteeringCmd(const dbw_pacifica_msgs::SteeringCmd::ConstPtr& msg);
00101 void recvGearCmd(const dbw_pacifica_msgs::GearCmd::ConstPtr& msg);
00102 void recvMiscCmd(const dbw_pacifica_msgs::MiscCmd::ConstPtr& msg);
00103 void recvGlobalEnableCmd(const dbw_pacifica_msgs::GlobalEnableCmd::ConstPtr& msg);
00104
00105 ros::Timer timer_;
00106 bool prev_enable_;
00107 bool enable_;
00108 bool override_brake_;
00109 bool override_accelerator_pedal_;
00110 bool override_steering_;
00111 bool override_gear_;
00112 bool fault_brakes_;
00113 bool fault_accelerator_pedal_;
00114 bool fault_steering_;
00115 bool fault_steering_cal_;
00116 bool fault_watchdog_;
00117 bool fault_watchdog_using_brakes_;
00118 bool fault_watchdog_warned_;
00119 bool timeout_brakes_;
00120 bool timeout_accelerator_pedal_;
00121 bool timeout_steering_;
00122 bool enabled_brakes_;
00123 bool enabled_accelerator_pedal_;
00124 bool enabled_steering_;
00125 bool gear_warned_;
00126 inline bool fault() { return fault_brakes_ || fault_accelerator_pedal_ || fault_steering_ || fault_steering_cal_ || fault_watchdog_; }
00127 inline bool override() { return override_brake_ || override_accelerator_pedal_ || override_steering_ || override_gear_; }
00128 inline bool clear() { return enable_ && override(); }
00129 inline bool enabled() { return enable_ && !fault() && !override(); }
00130 bool publishDbwEnabled();
00131 void enableSystem();
00132 void disableSystem();
00133 void buttonCancel();
00134 void overrideBrake(bool override);
00135 void overrideAcceleratorPedal(bool override);
00136 void overrideSteering(bool override);
00137 void overrideGear(bool override);
00138 void timeoutBrake(bool timeout, bool enabled);
00139 void timeoutAcceleratorPedal(bool timeout, bool enabled);
00140 void timeoutSteering(bool timeout, bool enabled);
00141 void faultBrakes(bool fault);
00142 void faultAcceleratorPedal(bool fault);
00143 void faultSteering(bool fault);
00144 void faultSteeringCal(bool fault);
00145 void faultWatchdog(bool fault, uint8_t src, bool braking);
00146 void faultWatchdog(bool fault, uint8_t src = 0);
00147
00148 enum {
00149 JOINT_FL = 0,
00150 JOINT_FR,
00151 JOINT_RL,
00152 JOINT_RR,
00153 JOINT_SL,
00154 JOINT_SR,
00155 JOINT_COUNT,
00156 };
00157 sensor_msgs::JointState joint_state_;
00158 void publishJointStates(const ros::Time &stamp, const dbw_pacifica_msgs::WheelSpeedReport *wheels, const dbw_pacifica_msgs::SteeringReport *steering);
00159
00160 std::string vin_;
00161
00162
00163 std::string frame_id_;
00164
00165
00166 bool buttons_;
00167
00168
00169 double acker_wheelbase_;
00170 double acker_track_;
00171 double steering_ratio_;
00172
00173
00174 ros::Subscriber sub_enable_;
00175 ros::Subscriber sub_disable_;
00176 ros::Subscriber sub_can_;
00177 ros::Subscriber sub_brake_;
00178 ros::Subscriber sub_accelerator_pedal_;
00179 ros::Subscriber sub_steering_;
00180 ros::Subscriber sub_gear_;
00181 ros::Subscriber sub_misc_;
00182 ros::Subscriber sub_global_enable_;
00183
00184
00185 ros::Publisher pub_can_;
00186 ros::Publisher pub_brake_;
00187 ros::Publisher pub_accel_pedal_;
00188 ros::Publisher pub_steering_;
00189 ros::Publisher pub_gear_;
00190 ros::Publisher pub_misc_;
00191 ros::Publisher pub_wheel_speeds_;
00192 ros::Publisher pub_wheel_positions_;
00193 ros::Publisher pub_tire_pressure_;
00194 ros::Publisher pub_surround_;
00195 ros::Publisher pub_imu_;
00196 ros::Publisher pub_joint_states_;
00197 ros::Publisher pub_twist_;
00198 ros::Publisher pub_vin_;
00199 ros::Publisher pub_sys_enable_;
00200 ros::Publisher pub_driver_input_;
00201 ros::Publisher pub_low_voltage_system_;
00202
00203 ros::Publisher pub_brake_2_report_;
00204 ros::Publisher pub_steering_2_report_;
00205 ros::Publisher pub_fault_actions_report_;
00206 ros::Publisher pub_hmi_global_enable_report_;
00207
00208 NewEagle::Dbc dbwDbc_;
00209 std::string dbcFile_;
00210
00211
00212 ros::Publisher pdu1_relay_pub_;
00213 uint32_t count_;
00214 };
00215
00216 }
00217
00218 #endif // _DBW_NODE_H_
00219