10 #include <boost/thread/thread.hpp> 11 #include <boost/assign/list_of.hpp> 12 #include <boost/bind.hpp> 25 #define STABLE_BAND_JNT 0.05 26 #define DSR_CTL_PUB_RATE 100 //[hz] 10ms <----- 퍼블리싱 주기, but OnMonitoringDataCB() 은 100ms 마다 불려짐을 유의! 34 case STATE_INITIALIZING:
return "(0) INITIALIZING";
35 case STATE_STANDBY:
return "(1) STANDBY";
36 case STATE_MOVING:
return "(2) MOVING";
37 case STATE_SAFE_OFF:
return "(3) SAFE_OFF";
38 case STATE_TEACHING:
return "(4) TEACHING";
39 case STATE_SAFE_STOP:
return "(5) SAFE_STOP";
40 case STATE_EMERGENCY_STOP:
return "(6) EMERGENCY_STOP";
41 case STATE_HOMMING:
return "(7) HOMMING";
42 case STATE_RECOVERY:
return "(8) RECOVERY";
43 case STATE_SAFE_STOP2:
return "(9) SAFE_STOP2";
44 case STATE_SAFE_OFF2:
return "(10) SAFE_OFF2";
45 case STATE_RESERVED1:
return "(11) RESERVED1";
46 case STATE_RESERVED2:
return "(12) RESERVED2";
47 case STATE_RESERVED3:
return "(13) RESERVED3";
48 case STATE_RESERVED4:
return "(14) RESERVED4";
49 case STATE_NOT_READY:
return "(15) NOT_READY";
51 default:
return "UNKNOWN";
59 double dError[NUM_JOINT] ={0.0, };
61 for(
int i=0;i<NUM_JOINT;i++)
63 dError[i] = dCurPosDeg[i] - dCmdPosDeg[i];
64 ROS_INFO(
"<inpos> %f = %f -%f",dError[i], dCurPosDeg[i], dCmdPosDeg[i]);
78 cout <<
"[callback OnTpInitializingCompletedCB] tp initializing completed" << endl;
81 Drfl.ManageAccessControl(MANAGE_ACCESS_CONTROL_FORCE_REQUEST);
90 cout <<
"[callback OnHommingCompletedCB] homming completed" << endl;
97 cout <<
"[callback OnProgramStoppedCB] Program Stop: " << (int)iStopCause << endl;
103 for (
int i = 0; i < NUM_DIGITAL; i++){
113 g_stDrState.
nRegCount = pModbus->_iRegCount;
114 for (
int i = 0; i < pModbus->_iRegCount; i++){
115 cout <<
"[callback OnMonitoringModbusCB] " << pModbus->_tRegister[i]._szSymbol <<
": " << pModbus->_tRegister[i]._iValue<< endl;
117 g_stDrState.
nModbusValue[i] = pModbus->_tRegister[i]._iValue;
160 g_stDrState.
nActualMode = pData->_tCtrl._tState._iActualMode;
161 g_stDrState.
nActualSpace = pData->_tCtrl._tState._iActualSpace;
163 for (
int i = 0; i < NUM_JOINT; i++){
165 g_stDrState.
fCurrentPosj[i] = pData->_tCtrl._tJoint._fActualPos[i];
166 g_stDrState.
fCurrentPosx[i] = pData->_tCtrl._tTool._fActualPos[0][i];
167 g_stDrState.
fCurrentVelj[i] = pData->_tCtrl._tJoint._fActualVel[i];
168 g_stDrState.
fCurrentVelx[i] = pData->_tCtrl._tTool._fActualVel[i];
169 g_stDrState.
fJointAbs[i] = pData->_tCtrl._tJoint._fActualAbs[i];
170 g_stDrState.
fJointErr[i] = pData->_tCtrl._tJoint._fActualErr[i];
171 g_stDrState.
fTargetPosj[i] = pData->_tCtrl._tJoint._fTargetPos[i];
172 g_stDrState.
fTargetVelj[i] = pData->_tCtrl._tJoint._fTargetVel[i];
174 g_stDrState.
fTaskErr[i] = pData->_tCtrl._tTool._fActualErr[i];
175 g_stDrState.
fTargetPosx[i] = pData->_tCtrl._tTool._fTargetPos[i];
176 g_stDrState.
fTargetVelx[i] = pData->_tCtrl._tTool._fTargetVel[i];
178 g_stDrState.
fDynamicTor[i] = pData->_tCtrl._tTorque._fDynamicTor[i];
179 g_stDrState.
fActualJTS[i] = pData->_tCtrl._tTorque._fActualJTS[i];
180 g_stDrState.
fActualEJT[i] = pData->_tCtrl._tTorque._fActualEJT[i];
181 g_stDrState.
fActualETT[i] = pData->_tCtrl._tTorque._fActualETT[i];
183 g_stDrState.
nActualBK[i] = pData->_tMisc._iActualBK[i];
184 g_stDrState.
fActualMC[i] = pData->_tMisc._fActualMC[i];
185 g_stDrState.
fActualMT[i] = pData->_tMisc._fActualMT[i];
188 for (
int i = 5; i < NUM_BUTTON; i++){
190 g_stDrState.
nActualBT[i] = pData->_tMisc._iActualBT[i];
194 g_stDrState.
nSolutionSpace = pData->_tCtrl._tTool._iSolutionSpace;
195 g_stDrState.
dSyncTime = pData->_tMisc._dSyncTime;
197 for(
int i = 0; i < 3; i++){
198 for(
int j = 0; j < 3; j++){
200 g_stDrState.
fRotationMatrix[j][i] = pData->_tCtrl._tTool._fRotationMatrix[j][i];
205 for (
int i = 0; i < NUM_FLANGE_IO; i++){
219 switch((
unsigned char)eState)
221 #if 0 // TP initializing logic, Don't use in API level. (If you want to operate without TP, use this logic) 222 case eSTATE_NOT_READY:
225 case eSTATE_INITIALIZING:
230 case STATE_EMERGENCY_STOP:
237 case STATE_SAFE_STOP:
239 Drfl.SetSafeStopResetType(SAFE_STOP_RESET_TYPE_DEFAULT);
240 Drfl.SetRobotControl(CONTROL_RESET_SAFET_STOP);
245 Drfl.SetRobotControl(CONTROL_SERVO_ON);
248 case STATE_SAFE_STOP2:
251 case STATE_SAFE_OFF2:
253 Drfl.SetRobotControl(CONTROL_RECOVERY_SAFE_OFF);
257 Drfl.SetRobotControl(CONTROL_RESET_RECOVERY);
263 cout <<
"[callback OnMonitoringStateCB] current state: " <<
GetRobotStateString((
int)eState) << endl;
272 cout <<
"[callback OnMonitoringAccessControlCB] eAccCtrl: " << eAccCtrl << endl;
275 case MONITORING_ACCESS_CONTROL_REQUEST:
276 Drfl.ManageAccessControl(MANAGE_ACCESS_CONTROL_RESPONSE_NO);
279 case MONITORING_ACCESS_CONTROL_GRANT:
280 cout <<
"access control granted" << endl;
284 case MONITORING_ACCESS_CONTROL_DENY:
285 ROS_INFO(
"Access control deny !!!!!!!!!!!!!!!");
287 case MONITORING_ACCESS_CONTROL_LOSS:
290 Drfl.ManageAccessControl(MANAGE_ACCESS_CONTROL_REQUEST);
304 ros::Publisher PubRobotError = node->advertise<dsr_msgs::RobotError>(
"error",100);
305 dsr_msgs::RobotError msg;
308 ROS_ERROR(
" level : %d",(
unsigned int)pLogAlarm->_iLevel );
309 ROS_ERROR(
" group : %d",(
unsigned int)pLogAlarm->_iGroup );
310 ROS_ERROR(
" index : %d", pLogAlarm->_iIndex );
311 ROS_ERROR(
" param : %s", pLogAlarm->_szParam[0] );
312 ROS_ERROR(
" param : %s", pLogAlarm->_szParam[1] );
313 ROS_ERROR(
" param : %s", pLogAlarm->_szParam[2] );
315 g_stDrError.
nLevel = (
unsigned int)pLogAlarm->_iLevel;
316 g_stDrError.
nGroup = (
unsigned int)pLogAlarm->_iGroup;
317 g_stDrError.
nCode = pLogAlarm->_iIndex;
318 strncpy(g_stDrError.
strMsg1, pLogAlarm->_szParam[0], MAX_STRING_SIZE);
319 strncpy(g_stDrError.
strMsg2, pLogAlarm->_szParam[1], MAX_STRING_SIZE);
320 strncpy(g_stDrError.
strMsg3, pLogAlarm->_szParam[2], MAX_STRING_SIZE);
322 msg.level = g_stDrError.
nLevel;
323 msg.group = g_stDrError.
nGroup;
324 msg.code = g_stDrError.
nCode;
325 msg.msg1 = g_stDrError.
strMsg1;
326 msg.msg2 = g_stDrError.
strMsg2;
327 msg.msg3 = g_stDrError.
strMsg3;
329 PubRobotError.publish(msg);
340 ROS_INFO(
"receive msg.stop_mode = %d", msg->stop_mode);
342 Drfl.MoveStop((STOP_TYPE)msg->stop_mode);
347 dsr_msgs::RobotState msg;
348 dsr_msgs::ModbusState modbus_state;
357 for (
int i = 0; i < NUM_JOINT; i++)
384 std_msgs::Float64MultiArray arr;
386 for (
int i = 0; i < 3; i++){
388 for (
int j = 0; j < 3; j++){
391 msg.rotation_matrix.push_back(arr);
394 for (
int i = 0; i < NUM_BUTTON; i++){
397 for (
int i = 0; i < NUM_DIGITAL; i++){
401 for (
int i = 0; i < NUM_FLANGE_IO; i++){
409 msg.modbus_state.push_back(modbus_state);
454 dsr_msgs::RobotState msg;
480 ROS_INFO(
"[dsr_hw_interface] constructed");
484 boost::assign::list_of(
"joint1")(
"joint2")(
"joint3")(
"joint4")(
"joint5")(
"joint6")(
"robotiq_85_left_knuckle_joint").convert_to_container<
ros::V_string>();
489 boost::assign::list_of(
"joint1")(
"joint2")(
"joint3")(
"joint4")(
"joint5")(
"joint6").convert_to_container<ros::V_string>();
491 for(
unsigned int i = 0; i < arm_joint_names.size(); i++){
590 memset(&g_stDrState, 0x00,
sizeof(
DR_STATE));
591 memset(&g_stDrError, 0x00,
sizeof(
DR_ERROR));
603 Drfl.CloseConnection();
610 ROS_INFO(
"DRHWInterface::~DRHWInterface()");
615 ROS_INFO(
"[dsr_hw_interface] init() ==> setup callback fucntion");
616 int nServerPort = 12345;
617 ROS_INFO(
"INIT@@@@@@@@@@@@@@@@@@@@@@@@@2");
628 ROS_INFO(
"[dsr_hw_interface] init() ==> arm is standby");
639 ROS_INFO(
"host %s, port=%d bCommand: %d, mode: %s\n", host.c_str(), nServerPort,
bCommand_, mode.c_str());
641 if(
Drfl.OpenConnection(host, nServerPort))
644 SYSTEM_VERSION tSysVerion = {
'\0', };
645 assert(
Drfl.GetSystemVersion(&tSysVerion));
646 ROS_INFO(
"DRCF version = %s",tSysVerion._szController);
647 ROS_INFO(
"DRFL version = %s",
Drfl.GetLibraryVersion());
651 ros::param::param<int>(
"~standby", delay, 5000);
652 while ((
Drfl.GetRobotState() != STATE_STANDBY)){
657 assert(
Drfl.SetRobotMode(ROBOT_MODE_MANUAL));
660 ROBOT_SYSTEM eTargetSystem = ROBOT_SYSTEM_VIRTUAL;
661 if(mode ==
"real") eTargetSystem = ROBOT_SYSTEM_REAL;
662 assert(
Drfl.SetRobotSystem(eTargetSystem));
665 for(
int i = 0; i < NUM_JOINT; i++){
666 ROS_INFO(
"[init]::read %d-pos: %7.3f", i,
joints[i].
cmd);
676 std_msgs::Float64MultiArray msg;
679 LPROBOT_POSE pose =
Drfl.GetCurrentPose();
680 for(
int i = 0; i < NUM_JOINT; i++){
681 ROS_DEBUG(
"[DRHWInterface::read] %d-pos: %7.3f", i, pose->_fPosition[i]);
683 msg.data.push_back(
joints[i].pos);
686 msg.data.push_back(
joints[6].pos);
693 static int count = 0;
695 std::array<float, NUM_JOINT> tmp;
696 for(
int i = 0; i < NUM_JOINT; i++){
697 ROS_DEBUG(
"[write]::write %d-pos: %7.3f %d-vel: %7.3f %d-cmd: %7.3f",
723 ROS_INFO(
"[sigint_hangler] CloseConnection");
724 ROS_INFO(
"[sigint_hangler] CloseConnection");
725 ROS_INFO(
"[sigint_hangler] CloseConnection");
728 ROS_INFO(
"callback: Position received");
729 std::array<float, NUM_JOINT> target_pos;
730 std::copy(msg->data.cbegin(), msg->data.cend(), target_pos.begin());
731 Drfl.MoveJAsync(target_pos.data(), 50, 50);
736 ROS_INFO(
"callback: Trajectory received");
737 ROS_INFO(
" msg->goal.trajectory.points.size() =%d",(
int)msg->goal.trajectory.points.size());
738 ROS_INFO(
" msg->goal.trajectory.joint_names.size() =%d",(
int)msg->goal.trajectory.joint_names.size());
740 float preTargetTime = 0.0;
741 float targetTime = 0.0;
743 float fTargetPos[MAX_SPLINE_POINT][NUM_JOINT] = {0.0, };
744 int nCntTargetPos =0;
746 nCntTargetPos = msg->goal.trajectory.points.size();
747 if(nCntTargetPos > MAX_SPLINE_POINT)
749 ROS_INFO(
"DRHWInterface::trajectoryCallback over max Trajectory (%d > %d)",nCntTargetPos ,MAX_SPLINE_POINT);
753 for(
int i = 0; i < msg->goal.trajectory.points.size(); i++)
755 std::array<float, NUM_JOINT> degrees;
760 targetTime = d.
toSec();
766 ROS_INFO(
"[trajectory] [%02d : %.3f] %7.3f %7.3f %7.3f %7.3f %7.3f %7.3f",i ,targetTime
767 ,
rad2deg(msg->goal.trajectory.points[i].positions[0]) ,
rad2deg(msg->goal.trajectory.points[i].positions[1]),
rad2deg(msg->goal.trajectory.points[i].positions[2])
768 ,
rad2deg(msg->goal.trajectory.points[i].positions[3]) ,
rad2deg(msg->goal.trajectory.points[i].positions[4]),
rad2deg(msg->goal.trajectory.points[i].positions[5]) );
770 for(
int j = 0; j < msg->goal.trajectory.joint_names.size(); j++)
778 degrees[j] =
rad2deg( msg->goal.trajectory.points[i].positions[j] );
780 fTargetPos[i][j] = degrees[j];
784 Drfl.MoveSJ(fTargetPos, nCntTargetPos, 0.0, 0.0, targetTime, (MOVE_MODE)MOVE_MODE_ABSOLUTE);
798 res.success =
Drfl.SetRobotMode((ROBOT_MODE)req.robot_mode);
802 res.robot_mode =
Drfl.GetRobotMode();
807 std::array<float, NUM_JOINT> target_pos;
808 std::copy(req.pos.cbegin(), req.pos.cend(), target_pos.begin());
809 if(req.syncType == 0){
811 res.success =
Drfl.MoveJ(target_pos.data(), req.vel, req.acc, req.time, (MOVE_MODE)req.mode, req.radius, (BLENDING_SPEED_TYPE)req.blendType);
815 res.success =
Drfl.MoveJAsync(target_pos.data(), req.vel, req.acc, req.time, (MOVE_MODE)req.mode, (BLENDING_SPEED_TYPE)req.blendType);
820 std::array<float, NUM_TASK> target_pos;
821 std::array<float, 2> target_vel;
822 std::array<float, 2> target_acc;
823 std::copy(req.pos.cbegin(), req.pos.cend(), target_pos.begin());
824 std::copy(req.vel.cbegin(), req.vel.cend(), target_vel.begin());
825 std::copy(req.acc.cbegin(), req.acc.cend(), target_acc.begin());
827 if(req.syncType == 0){
829 res.success =
Drfl.MoveL(target_pos.data(), target_vel.data(), target_acc.data(), req.time, (MOVE_MODE)req.mode, (MOVE_REFERENCE)req.ref, req.radius, (BLENDING_SPEED_TYPE)req.blendType);
833 res.success =
Drfl.MoveLAsync(target_pos.data(), target_vel.data(), target_acc.data(), req.time, (MOVE_MODE)req.mode, (MOVE_REFERENCE)req.ref, (BLENDING_SPEED_TYPE)req.blendType);
838 std::array<float, NUM_TASK> target_pos;
839 std::copy(req.pos.cbegin(), req.pos.cend(), target_pos.begin());
840 if(req.syncType == 0){
842 res.success =
Drfl.MoveJX(target_pos.data(), req.sol, req.vel, req.acc, req.time, (MOVE_MODE)req.mode, (MOVE_REFERENCE)req.ref, req.radius, (BLENDING_SPEED_TYPE)req.blendType);
846 res.success =
Drfl.MoveJXAsync(target_pos.data(), req.sol, req.vel, req.acc, req.time, (MOVE_MODE)req.mode, (MOVE_REFERENCE)req.ref, (BLENDING_SPEED_TYPE)req.blendType);
851 float fTargetPos[2][NUM_TASK];
854 for(
int i = 0; i < 2; i++){
855 for(
int j = 0; j < NUM_TASK; j++){
856 std_msgs::Float64MultiArray pos = req.pos.at(i);
857 fTargetPos[i][j] = pos.data[j];
859 fTargetVel[i] = req.vel[i];
860 fTargetAcc[i] = req.acc[i];
864 if(req.syncType == 0){
866 res.success =
Drfl.MoveC(fTargetPos, fTargetVel, fTargetAcc, req.time, (MOVE_MODE)req.mode, (MOVE_REFERENCE)req.ref, req.radius, (BLENDING_SPEED_TYPE)req.blendType);
870 res.success =
Drfl.MoveCAsync(fTargetPos, fTargetVel, fTargetAcc, req.time, (MOVE_MODE)req.mode, (MOVE_REFERENCE)req.ref, (BLENDING_SPEED_TYPE)req.blendType);
875 float fTargetPos[MAX_SPLINE_POINT][NUM_JOINT];
877 for(
int i=0; i<req.posCnt; i++){
878 for(
int j=0; j<NUM_JOINT; j++){
879 std_msgs::Float64MultiArray pos = req.pos.at(i);
880 fTargetPos[i][j] = pos.data[j];
883 if(req.syncType == 0){
885 res.success =
Drfl.MoveSJ(fTargetPos, req.posCnt, req.vel, req.acc, req.time, (MOVE_MODE)req.mode);
889 res.success =
Drfl.MoveSJAsync(fTargetPos, req.posCnt, req.vel, req.acc, req.time, (MOVE_MODE)req.mode);
894 float fTargetPos[MAX_SPLINE_POINT][NUM_TASK];
898 for(
int i=0; i<req.posCnt; i++){
899 for(
int j=0; j<NUM_TASK; j++){
900 std_msgs::Float64MultiArray pos = req.pos.at(i);
901 fTargetPos[i][j] = pos.data[j];
906 for(
int i=0; i<2; i++){
907 fTargetVel[i] = req.vel[i];
908 fTargetAcc[i] = req.acc[i];
910 if(req.syncType == 0){
912 res.success =
Drfl.MoveSX(fTargetPos, req.posCnt, fTargetVel, fTargetAcc, req.time, (MOVE_MODE)req.mode, (MOVE_REFERENCE)req.ref, (SPLINE_VELOCITY_OPTION)req.opt);
916 res.success =
Drfl.MoveSXAsync(fTargetPos, req.posCnt, fTargetVel, fTargetAcc, req.time, (MOVE_MODE)req.mode, (MOVE_REFERENCE)req.ref, (SPLINE_VELOCITY_OPTION)req.opt);
922 MOVE_POSB posb[req.posCnt];
923 for(
int i=0; i<req.posCnt; i++){
924 std_msgs::Float64MultiArray segment = req.segment.at(i);
925 for(
int j=0; j<NUM_TASK; j++){
926 posb[i]._fTargetPos[0][j] = segment.data[j];
927 posb[i]._fTargetPos[1][j] = segment.data[j + NUM_TASK];
929 posb[i]._iBlendType = segment.data[NUM_TASK + NUM_TASK];
930 posb[i]._fBlendRad = segment.data[NUM_TASK + NUM_TASK +1];
947 std::array<float, 2> target_vel;
948 std::array<float, 2> target_acc;
949 std::copy(req.vel.cbegin(), req.vel.cend(), target_vel.begin());
950 std::copy(req.acc.cbegin(), req.acc.cend(), target_acc.begin());
952 if(req.syncType == 0){
954 res.success =
Drfl.MoveB(posb, req.posCnt, target_vel.data(), target_acc.data(), req.time, (MOVE_MODE)req.mode, (MOVE_REFERENCE)req.ref);
958 res.success =
Drfl.MoveBAsync(posb, req.posCnt, target_vel.data(), target_acc.data(), req.time, (MOVE_MODE)req.mode, (MOVE_REFERENCE)req.ref);
963 std::array<float, 2> target_vel;
964 std::array<float, 2> target_acc;
965 std::copy(req.vel.cbegin(), req.vel.cend(), target_vel.begin());
966 std::copy(req.acc.cbegin(), req.acc.cend(), target_acc.begin());
968 if(req.syncType == 0){
970 res.success =
Drfl.MoveSpiral((TASK_AXIS)req.taskAxis, req.revolution, req.maxRadius, req.maxLength, target_vel.data(), target_acc.data(), req.time, (MOVE_REFERENCE)req.ref);
974 res.success =
Drfl.MoveSpiralAsync((TASK_AXIS)req.taskAxis, req.revolution, req.maxRadius, req.maxLength, target_vel.data(), target_acc.data(), req.time, (MOVE_REFERENCE)req.ref);
979 std::array<float, NUM_TASK> target_amp;
980 std::array<float, NUM_TASK> target_periodic;
981 std::copy(req.amp.cbegin(), req.amp.cend(), target_amp.begin());
982 std::copy(req.periodic.cbegin(), req.periodic.cend(), target_periodic.begin());
983 if(req.syncType == 0){
985 res.success =
Drfl.MovePeriodic(target_amp.data(), target_periodic.data(), req.acc, req.repeat, (MOVE_REFERENCE)req.ref);
989 res.success =
Drfl.MovePeriodicAsync(target_amp.data(), target_periodic.data(), req.acc, req.repeat, (MOVE_REFERENCE)req.ref);
996 res.success =
Drfl.MoveWait();
1002 res.success =
Drfl.SetCtrlBoxDigitalOutput((GPIO_CTRLBOX_DIGITAL_INDEX)req.index, req.value);
1007 res.value =
Drfl.GetCtrlBoxDigitalInput((GPIO_CTRLBOX_DIGITAL_INDEX)req.index);
1012 res.success =
Drfl.SetToolDigitalOutput((GPIO_TOOL_DIGITAL_INDEX)req.index, req.value);
1017 res.value =
Drfl.GetToolDigitalInput((GPIO_TOOL_DIGITAL_INDEX)req.index);
1022 res.success =
Drfl.SetCtrlBoxAnalogOutput((GPIO_CTRLBOX_ANALOG_INDEX)req.channel, req.value);
1027 res.value =
Drfl.GetCtrlBoxAnalogInput((GPIO_CTRLBOX_ANALOG_INDEX)req.channel);
1032 res.success =
Drfl.SetCtrlBoxAnalogOutputType((GPIO_CTRLBOX_ANALOG_INDEX)req.channel, (GPIO_ANALOG_TYPE)req.mode);
1037 res.success =
Drfl.SetCtrlBoxAnalogInputType((GPIO_CTRLBOX_ANALOG_INDEX)req.channel, (GPIO_ANALOG_TYPE)req.mode);
1042 res.success =
Drfl.SetModbusValue(req.name, (
unsigned short)req.value);
1047 res.value =
Drfl.GetModbusValue(req.name);
1052 res.success =
Drfl.ConfigCreateModbus(req.name, req.ip, (
unsigned short)req.port, (MODBUS_REGISTER_TYPE)req.reg_type, (
unsigned short)req.index, (
unsigned short)req.value);
1057 res.success =
Drfl.ConfigDeleteModbus(req.name);
1062 res.success =
Drfl.PlayDrlPause();
1067 res.success =
Drfl.PlayDrlStart((ROBOT_SYSTEM)req.robotSystem, req.code);
1072 res.success =
Drfl.PlayDrlStop((STOP_TYPE)req.stop_mode);
1077 res.success =
Drfl.PlayDrlResume();
1081 res.drl_state =
Drfl.GetProgramState();
1086 res.success =
Drfl.SetCurrentTCP(req.name);
1091 res.info =
Drfl.GetCurrentTCP();
1096 std::array<float, 6> target_pos;
1097 std::copy(req.pos.cbegin(), req.pos.cend(), target_pos.begin());
1098 res.success =
Drfl.ConfigCreateTCP(req.name, target_pos.data());
1103 res.success =
Drfl.ConfigDeleteTCP(req.name);
1108 res.success =
Drfl.SetCurrentTool(req.name);
1113 res.info =
Drfl.GetCurrentTool();
1118 std::array<float, 3> target_cog;
1119 std::array<float, 6> target_inertia;
1120 std::copy(req.cog.cbegin(), req.cog.cend(), target_cog.begin());
1121 std::copy(req.inertia.cbegin(), req.inertia.cend(), target_inertia.begin());
1122 res.success =
Drfl.ConfigCreateTool(req.name, req.weight, target_cog.data(), target_inertia.data());
1127 res.success =
Drfl.ConfigDeleteTool(req.name);
1145 float goal_pos = req.width;
1147 while(abs(goal_pos -
joints[6].pos) > 0.01){
1148 if(goal_pos >
joints[6].pos){
1151 else if(
joints[6].pos > goal_pos){
1159 float goal_pos = 0.8;
1160 while(abs(goal_pos -
joints[6].pos) > 0.01){
1161 if(goal_pos >
joints[6].pos){
1164 else if(
joints[6].pos > goal_pos){
1173 float goal_pos = 0.0;
1175 while(abs(goal_pos -
joints[6].pos) > 0.01){
1176 if(goal_pos >
joints[6].pos){
1179 else if(
joints[6].pos > goal_pos){
1188 std_msgs::String send_data;
1189 send_data.data = req.data;
char strMsg2[MAX_STRING_SIZE]
void registerInterface(T *iface)
bool set_analog_input_type_cb(dsr_msgs::SetCtrlBoxAnalogInputType::Request &req, dsr_msgs::SetCtrlBoxAnalogInputType::Response &res)
ros::ServiceServer m_nh_io_service[8]
hardware_interface::JointStateInterface jnt_state_interface
float fCurrentVelj[NUM_JOINT]
ros::ServiceServer m_nh_gripper_service[10]
bool movespiral_cb(dsr_msgs::MoveSpiral::Request &req, dsr_msgs::MoveSpiral::Response &res)
ros::ServiceServer m_nh_tcp_service[4]
bool drl_start_cb(dsr_msgs::DrlStart::Request &req, dsr_msgs::DrlStart::Response &res)
float fCurrentPosj[NUM_JOINT]
std::string m_strRobotModel
bool g_bHasControlAuthority
ros::ServiceServer m_nh_move_service[10]
bool robotiq_2f_close_cb(dsr_msgs::Robotiq2FClose::Request &req, dsr_msgs::Robotiq2FClose::Response &res)
void publish(const boost::shared_ptr< M > &message) const
void trajectoryCallback(const control_msgs::FollowJointTrajectoryActionGoal::ConstPtr &msg)
bool bFlangeDigitalOutput[6]
bool robotiq_2f_move_cb(dsr_msgs::Robotiq2FMove::Request &req, dsr_msgs::Robotiq2FMove::Response &res)
ros::Publisher m_PubRobotError
bool movesx_cb(dsr_msgs::MoveSplineTask::Request &req, dsr_msgs::MoveSplineTask::Response &res)
float fCurrentVelx[NUM_TASK]
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
virtual void read(ros::Duration &elapsed_time)
bool set_current_tcp_cb(dsr_msgs::SetCurrentTcp::Request &req, dsr_msgs::SetCurrentTcp::Response &res)
bool drl_pause_cb(dsr_msgs::DrlPause::Request &req, dsr_msgs::DrlPause::Response &res)
static void OnMonitoringStateCB(const ROBOT_STATE eState)
bool set_robot_mode_cb(dsr_msgs::SetRobotMode::Request &req, dsr_msgs::SetRobotMode::Response &res)
bool g_bTpInitailizingComplted
int nActualBT[NUM_BUTTON]
ros::ServiceServer m_nh_system[4]
ros::ServiceServer m_nh_serial_service[4]
bool get_current_tcp_cb(dsr_msgs::GetCurrentTcp::Request &req, dsr_msgs::GetCurrentTcp::Response &res)
bool config_delete_modbus_cb(dsr_msgs::ConfigDeleteModbus::Request &req, dsr_msgs::ConfigDeleteModbus::Response &res)
void sigint_handler(int signo)
bool set_analog_output_cb(dsr_msgs::SetCtrlBoxAnalogOutput::Request &req, dsr_msgs::SetCtrlBoxAnalogOutput::Response &res)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
bool config_delete_tcp_cb(dsr_msgs::ConfigDeleteTcp::Request &req, dsr_msgs::ConfigDeleteTcp::Response &res)
float fJointErr[NUM_JOINT]
boost::thread m_th_subscribe
static void thread_publisher(DRHWInterface *pDRHWInterface, ros::NodeHandle nh, int nPubRate)
std::string m_strRobotName
static void OnTpInitializingCompletedCB()
float fActualETT[NUM_JOINT]
bool config_delete_tool_cb(dsr_msgs::ConfigDeleteTool::Request &req, dsr_msgs::ConfigDeleteTool::Response &res)
char strMsg1[MAX_STRING_SIZE]
float fRotationMatrix[3][3]
int MsgPublisher_RobotState()
bool movesj_cb(dsr_msgs::MoveSplineJoint::Request &req, dsr_msgs::MoveSplineJoint::Response &res)
bool bFlangeDigitalInput[6]
std::vector< std::string > V_string
bool drl_resume_cb(dsr_msgs::DrlResume::Request &req, dsr_msgs::DrlResume::Response &res)
bool movewait_cb(dsr_msgs::MoveWait::Request &req, dsr_msgs::MoveWait::Response &res)
bool set_current_tool_cb(dsr_msgs::SetCurrentTool::Request &req, dsr_msgs::SetCurrentTool::Response &res)
ros::NodeHandle private_nh_
bool movejx_cb(dsr_msgs::MoveJointx::Request &req, dsr_msgs::MoveJointx::Response &res)
bool set_analog_output_type_cb(dsr_msgs::SetCtrlBoxAnalogOutputType::Request &req, dsr_msgs::SetCtrlBoxAnalogOutputType::Response &res)
ros::Publisher m_PubRobotState
ros::ServiceServer m_nh_modbus_service[4]
bool get_tool_digital_input_cb(dsr_msgs::GetToolDigitalInput::Request &req, dsr_msgs::GetToolDigitalInput::Response &res)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
bool moveperiodic_cb(dsr_msgs::MovePeriodic::Request &req, dsr_msgs::MovePeriodic::Response &res)
bool config_create_modbus_cb(dsr_msgs::ConfigCreateModbus::Request &req, dsr_msgs::ConfigCreateModbus::Response &res)
bool moveb_cb(dsr_msgs::MoveBlending::Request &req, dsr_msgs::MoveBlending::Response &res)
bool get_digital_input_cb(dsr_msgs::GetCtrlBoxDigitalInput::Request &req, dsr_msgs::GetCtrlBoxDigitalInput::Response &res)
bool bCtrlBoxDigitalOutput[16]
bool get_drl_state_cb(dsr_msgs::GetDrlState::Request &req, dsr_msgs::GetDrlState::Response &res)
static void OnMonitoringModbusCB(const LPMONITORING_MODBUS pModbus)
hardware_interface::PositionJointInterface jnt_pos_interface
bool config_create_tcp_cb(dsr_msgs::ConfigCreateTcp::Request &req, dsr_msgs::ConfigCreateTcp::Response &res)
float fActualMT[NUM_JOINT]
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ros::Subscriber m_sub_joint_trajectory
bool set_tool_digital_output_cb(dsr_msgs::SetToolDigitalOutput::Request &req, dsr_msgs::SetToolDigitalOutput::Response &res)
bool bCtrlBoxDigitalInput[16]
virtual void spin(CallbackQueue *queue=0)
static void OnMonitoringAccessControlCB(const MONITORING_ACCESS_CONTROL eAccCtrl)
static void OnProgramStoppedCB(const PROGRAM_STOP_CAUSE iStopCause)
std::string m_strRobotGripper
void MsgScriber(const dsr_msgs::RobotStop::ConstPtr &msg)
int IsInposition(double dCurPosDeg[], double dCmdPosDeg[])
void registerHandle(const JointStateHandle &handle)
static void OnMonitoringDataCB(const LPMONITORING_DATA pData)
float fTargetVelj[NUM_JOINT]
float fDynamicTor[NUM_JOINT]
bool set_modbus_output_cb(dsr_msgs::SetModbusOutput::Request &req, dsr_msgs::SetModbusOutput::Response &res)
char strRobotState[MAX_SYMBOL_SIZE]
static void thread_subscribe(ros::NodeHandle nh)
float fTargetPosx[NUM_TASK]
const char * GetRobotStateString(int nState)
bool drl_stop_cb(dsr_msgs::DrlStop::Request &req, dsr_msgs::DrlStop::Response &res)
static void OnLogAlarm(LPLOG_ALARM pLogAlarm)
bool set_digital_output_cb(dsr_msgs::SetCtrlBoxDigitalOutput::Request &req, dsr_msgs::SetCtrlBoxDigitalOutput::Response &res)
bool get_analog_input_cb(dsr_msgs::GetCtrlBoxAnalogInput::Request &req, dsr_msgs::GetCtrlBoxAnalogInput::Response &res)
float fActualJTS[NUM_JOINT]
virtual void write(ros::Duration &elapsed_time)
bool getParam(const std::string &key, std::string &s) const
bool get_modbus_input_cb(dsr_msgs::GetModbusInput::Request &req, dsr_msgs::GetModbusInput::Response &res)
struct dsr_control::DRHWInterface::Joint joints[NUM_JOINT]
bool serial_send_data_cb(dsr_msgs::SerialSendData::Request &req, dsr_msgs::SerialSendData::Response &res)
float fTargetVelx[NUM_TASK]
ros::Publisher m_PubtoGazebo
bool get_robot_mode_cb(dsr_msgs::GetRobotMode::Request &req, dsr_msgs::GetRobotMode::Response &res)
string strModbusSymbol[100]
float fCurrentPosx[NUM_TASK]
float fTargetPosj[NUM_JOINT]
bool movec_cb(dsr_msgs::MoveCircle::Request &req, dsr_msgs::MoveCircle::Response &res)
ros::Publisher m_PubSerialWrite
ros::Subscriber m_sub_joint_position
bool movel_cb(dsr_msgs::MoveLine::Request &req, dsr_msgs::MoveLine::Response &res)
bool get_current_tool_cb(dsr_msgs::GetCurrentTool::Request &req, dsr_msgs::GetCurrentTool::Response &res)
static void OnHommingCompletedCB()
int MsgPublisher_RobotError(); 현재 미사용 : DRHWInterface::OnLogAlarm 에서 바로 퍼블리싱 함...
float fActualEJT[NUM_JOINT]
ros::ServiceServer m_nh_drl_service[10]
ros::ServiceServer m_nh_tool_service[4]
float fActualMC[NUM_JOINT]
bool robotiq_2f_open_cb(dsr_msgs::Robotiq2FOpen::Request &req, dsr_msgs::Robotiq2FOpen::Response &res)
std::array< float, NUM_JOINT > cmd_
ros::Subscriber m_SubSerialRead
void positionCallback(const std_msgs::Float64MultiArray::ConstPtr &msg)
bool movej_cb(dsr_msgs::MoveJoint::Request &req, dsr_msgs::MoveJoint::Response &res)
bool config_create_tool_cb(dsr_msgs::ConfigCreateTool::Request &req, dsr_msgs::ConfigCreateTool::Response &res)
boost::thread m_th_publisher
char strMsg3[MAX_STRING_SIZE]
DRHWInterface(ros::NodeHandle &nh)
static void OnMonitoringCtrlIOCB(const LPMONITORING_CTRLIO pCtrlIO)
float fJointAbs[NUM_JOINT]