39 #ifndef DR_HW_INTERFACE_H 40 #define DR_HW_INTERFACE_H 43 #include <boost/thread/thread.hpp> 50 #include <std_msgs/Float64MultiArray.h> 51 #include <std_msgs/String.h> 52 #include <std_srvs/Empty.h> 55 #include <dsr_msgs/RobotError.h> 56 #include <dsr_msgs/RobotState.h> 57 #include <dsr_msgs/RobotStop.h> 61 #include <dsr_msgs/SetRobotMode.h> 62 #include <dsr_msgs/GetRobotMode.h> 64 #include <dsr_msgs/MoveJoint.h> 65 #include <dsr_msgs/MoveLine.h> 66 #include <dsr_msgs/MoveJointx.h> 67 #include <dsr_msgs/MoveCircle.h> 68 #include <dsr_msgs/MoveSplineJoint.h> 69 #include <dsr_msgs/MoveSplineTask.h> 70 #include <dsr_msgs/MoveBlending.h> 71 #include <dsr_msgs/MoveSpiral.h> 72 #include <dsr_msgs/MovePeriodic.h> 73 #include <dsr_msgs/MoveWait.h> 75 #include <dsr_msgs/SetCtrlBoxDigitalOutput.h> 76 #include <dsr_msgs/GetCtrlBoxDigitalInput.h> 77 #include <dsr_msgs/SetToolDigitalOutput.h> 78 #include <dsr_msgs/GetToolDigitalInput.h> 79 #include <dsr_msgs/SetCtrlBoxAnalogOutput.h> 80 #include <dsr_msgs/GetCtrlBoxAnalogInput.h> 81 #include <dsr_msgs/SetCtrlBoxAnalogOutputType.h> 82 #include <dsr_msgs/SetCtrlBoxAnalogInputType.h> 85 #include <dsr_msgs/SetModbusOutput.h> 86 #include <dsr_msgs/GetModbusInput.h> 87 #include <dsr_msgs/ConfigCreateModbus.h> 88 #include <dsr_msgs/ConfigDeleteModbus.h> 91 #include <dsr_msgs/DrlPause.h> 92 #include <dsr_msgs/DrlStart.h> 93 #include <dsr_msgs/DrlStop.h> 94 #include <dsr_msgs/DrlResume.h> 95 #include <dsr_msgs/GetDrlState.h> 99 #include <dsr_msgs/ConfigCreateTcp.h> 100 #include <dsr_msgs/ConfigDeleteTcp.h> 101 #include <dsr_msgs/GetCurrentTcp.h> 102 #include <dsr_msgs/SetCurrentTcp.h> 105 #include <dsr_msgs/ConfigCreateTool.h> 106 #include <dsr_msgs/ConfigDeleteTool.h> 107 #include <dsr_msgs/GetCurrentTool.h> 108 #include <dsr_msgs/SetCurrentTool.h> 111 #include <dsr_msgs/Robotiq2FOpen.h> 112 #include <dsr_msgs/Robotiq2FClose.h> 113 #include <dsr_msgs/Robotiq2FMove.h> 116 #include <dsr_msgs/SerialSendData.h> 119 #include <moveit_msgs/DisplayTrajectory.h> 120 #include <moveit_msgs/RobotTrajectory.h> 121 #include <trajectory_msgs/JointTrajectory.h> 122 #include <trajectory_msgs/JointTrajectoryPoint.h> 123 #include <control_msgs/FollowJointTrajectoryActionGoal.h> 126 #include "../../../common/include/DRFL.h" 127 #include "../../../common/include/dsr_serial.h" 130 #define PI 3.14159265359 132 #define deg2rad(deg) ((deg) * PI / 180.0) 133 #define rad2deg(rad) ((rad) * 180.0 / PI) 139 char strMsg1[MAX_STRING_SIZE];
140 char strMsg2[MAX_STRING_SIZE];
141 char strMsg3[MAX_STRING_SIZE];
146 char strRobotState[MAX_SYMBOL_SIZE];
147 float fCurrentPosj[NUM_JOINT];
148 float fCurrentPosx[NUM_TASK];
153 float fJointAbs[NUM_JOINT];
154 float fJointErr[NUM_JOINT];
155 float fTargetPosj[NUM_JOINT];
156 float fTargetVelj[NUM_JOINT];
157 float fCurrentVelj[NUM_JOINT];
159 float fTaskErr[NUM_TASK];
160 float fTargetPosx[NUM_TASK];
161 float fTargetVelx[NUM_TASK];
162 float fCurrentVelx[NUM_TASK];
164 float fRotationMatrix[3][3];
166 float fDynamicTor[NUM_JOINT];
167 float fActualJTS[NUM_JOINT];
168 float fActualEJT[NUM_JOINT];
169 float fActualETT[NUM_JOINT];
172 int nActualBK[NUM_JOINT];
173 int nActualBT[NUM_BUTTON];
174 float fActualMC[NUM_JOINT];
175 float fActualMT[NUM_JOINT];
176 bool bCtrlBoxDigitalOutput[16];
177 bool bCtrlBoxDigitalInput[16];
178 bool bFlangeDigitalOutput[6];
179 bool bFlangeDigitalInput[6];
183 string strModbusSymbol[100];
184 int nModbusValue[100];
207 int MsgPublisher_RobotState();
209 static void OnHommingCompletedCB();
210 static void OnProgramStoppedCB(
const PROGRAM_STOP_CAUSE iStopCause);
211 static void OnMonitoringDataCB(
const LPMONITORING_DATA pData);
212 static void OnTpInitializingCompletedCB();
214 static void OnMonitoringCtrlIOCB (
const LPMONITORING_CTRLIO pCtrlIO);
215 static void OnMonitoringModbusCB (
const LPMONITORING_MODBUS pModbus);
216 static void OnMonitoringStateCB(
const ROBOT_STATE eState);
217 static void OnMonitoringAccessControlCB(
const MONITORING_ACCESS_CONTROL eAccCtrl);
218 static void OnLogAlarm(LPLOG_ALARM pLogAlarm);
255 std::array<float, NUM_JOINT>
cmd_;
262 Joint(): cmd(0), pos(0), vel(0), eff(0) {}
266 void sigint_handler(
int signo);
267 void trajectoryCallback(
const control_msgs::FollowJointTrajectoryActionGoal::ConstPtr& msg);
268 void positionCallback(
const std_msgs::Float64MultiArray::ConstPtr& msg);
281 bool set_robot_mode_cb(dsr_msgs::SetRobotMode::Request& req, dsr_msgs::SetRobotMode::Response& res);
282 bool get_robot_mode_cb(dsr_msgs::GetRobotMode::Request& req, dsr_msgs::GetRobotMode::Response& res);
284 bool movej_cb(dsr_msgs::MoveJoint::Request& req, dsr_msgs::MoveJoint::Response& res);
285 bool movel_cb(dsr_msgs::MoveLine::Request& req, dsr_msgs::MoveLine::Response& res);
286 bool movejx_cb(dsr_msgs::MoveJointx::Request& req, dsr_msgs::MoveJointx::Response& res);
287 bool movec_cb(dsr_msgs::MoveCircle::Request& req, dsr_msgs::MoveCircle::Response& res);
288 bool movesj_cb(dsr_msgs::MoveSplineJoint::Request& req, dsr_msgs::MoveSplineJoint::Response& res);
289 bool movesx_cb(dsr_msgs::MoveSplineTask::Request& req, dsr_msgs::MoveSplineTask::Response& res);
290 bool moveb_cb(dsr_msgs::MoveBlending::Request& req, dsr_msgs::MoveBlending::Response& res);
291 bool movespiral_cb(dsr_msgs::MoveSpiral::Request& req, dsr_msgs::MoveSpiral::Response& res);
292 bool moveperiodic_cb(dsr_msgs::MovePeriodic::Request& req, dsr_msgs::MovePeriodic::Response& res);
293 bool movewait_cb(dsr_msgs::MoveWait::Request& req, dsr_msgs::MoveWait::Response& res);
297 bool set_current_tcp_cb(dsr_msgs::SetCurrentTcp::Request& req, dsr_msgs::SetCurrentTcp::Response& res);
298 bool get_current_tcp_cb(dsr_msgs::GetCurrentTcp::Request& req, dsr_msgs::GetCurrentTcp::Response& res);
299 bool config_create_tcp_cb(dsr_msgs::ConfigCreateTcp::Request& req, dsr_msgs::ConfigCreateTcp::Response& res);
300 bool config_delete_tcp_cb(dsr_msgs::ConfigDeleteTcp::Request& req, dsr_msgs::ConfigDeleteTcp::Response& res);
303 bool set_current_tool_cb(dsr_msgs::SetCurrentTool::Request& req, dsr_msgs::SetCurrentTool::Response& res);
304 bool get_current_tool_cb(dsr_msgs::GetCurrentTool::Request& req, dsr_msgs::GetCurrentTool::Response& res);
305 bool config_create_tool_cb(dsr_msgs::ConfigCreateTool::Request& req, dsr_msgs::ConfigCreateTool::Response& res);
306 bool config_delete_tool_cb(dsr_msgs::ConfigDeleteTool::Request& req, dsr_msgs::ConfigDeleteTool::Response& res);
309 bool set_digital_output_cb(dsr_msgs::SetCtrlBoxDigitalOutput::Request& req, dsr_msgs::SetCtrlBoxDigitalOutput::Response& res);
310 bool get_digital_input_cb(dsr_msgs::GetCtrlBoxDigitalInput::Request& req, dsr_msgs::GetCtrlBoxDigitalInput::Response& res);
311 bool set_tool_digital_output_cb(dsr_msgs::SetToolDigitalOutput::Request& req, dsr_msgs::SetToolDigitalOutput::Response& res);
312 bool get_tool_digital_input_cb(dsr_msgs::GetToolDigitalInput::Request& req, dsr_msgs::GetToolDigitalInput::Response& res);
314 bool set_analog_output_cb(dsr_msgs::SetCtrlBoxAnalogOutput::Request& req, dsr_msgs::SetCtrlBoxAnalogOutput::Response& res);
315 bool get_analog_input_cb(dsr_msgs::GetCtrlBoxAnalogInput::Request& req, dsr_msgs::GetCtrlBoxAnalogInput::Response& res);
316 bool set_analog_output_type_cb(dsr_msgs::SetCtrlBoxAnalogOutputType::Request& req, dsr_msgs::SetCtrlBoxAnalogOutputType::Response& res);
317 bool set_analog_input_type_cb(dsr_msgs::SetCtrlBoxAnalogInputType::Request& req, dsr_msgs::SetCtrlBoxAnalogInputType::Response& res);
320 bool set_modbus_output_cb(dsr_msgs::SetModbusOutput::Request& req, dsr_msgs::SetModbusOutput::Response& res);
321 bool get_modbus_input_cb(dsr_msgs::GetModbusInput::Request& req, dsr_msgs::GetModbusInput::Response& res);
322 bool config_create_modbus_cb(dsr_msgs::ConfigCreateModbus::Request& req, dsr_msgs::ConfigCreateModbus::Response& res);
323 bool config_delete_modbus_cb(dsr_msgs::ConfigDeleteModbus::Request& req, dsr_msgs::ConfigDeleteModbus::Response& res);
326 bool drl_pause_cb(dsr_msgs::DrlPause::Request& req, dsr_msgs::DrlPause::Response& res);
327 bool drl_start_cb(dsr_msgs::DrlStart::Request& req, dsr_msgs::DrlStart::Response& res);
328 bool drl_stop_cb(dsr_msgs::DrlStop::Request& req, dsr_msgs::DrlStop::Response& res);
329 bool drl_resume_cb(dsr_msgs::DrlResume::Request& req, dsr_msgs::DrlResume::Response& res);
330 bool get_drl_state_cb(dsr_msgs::GetDrlState::Request& req, dsr_msgs::GetDrlState::Response& res);
333 bool robotiq_2f_open_cb(dsr_msgs::Robotiq2FOpen::Request& req, dsr_msgs::Robotiq2FOpen::Response& res);
334 bool robotiq_2f_close_cb(dsr_msgs::Robotiq2FClose::Request& req, dsr_msgs::Robotiq2FClose::Response& res);
335 bool robotiq_2f_move_cb(dsr_msgs::Robotiq2FMove::Request& req, dsr_msgs::Robotiq2FMove::Response& res);
338 bool serial_send_data_cb(dsr_msgs::SerialSendData::Request& req, dsr_msgs::SerialSendData::Response& res);
hardware_interface::JointStateInterface jnt_state_interface
std::string m_strRobotModel
ros::Publisher m_PubRobotError
struct DR_ERROR * LPDR_ERROR
void init(const M_string &remappings)
boost::thread m_th_subscribe
std::string m_strRobotName
struct DR_STATE * LPDR_STATE
ros::NodeHandle private_nh_
ros::Publisher m_PubRobotState
hardware_interface::PositionJointInterface jnt_pos_interface
ros::Subscriber m_sub_joint_trajectory
std::string m_strRobotGripper
hardware_interface::VelocityJointInterface velocity_joint_interface_
ros::Publisher m_PubtoGazebo
ros::Publisher m_PubSerialWrite
ros::Subscriber m_sub_joint_position
std::array< float, NUM_JOINT > cmd_
ros::Subscriber m_SubSerialRead
boost::thread m_th_publisher