11 #include <boost/thread/thread.hpp> 19 #include <dsr_msgs/RobotState.h> 20 #include <dsr_msgs/RobotStop.h> 22 #include <dsr_msgs/MoveJoint.h> 23 #include <dsr_msgs/MoveLine.h> 24 #include <dsr_msgs/MoveJointx.h> 25 #include <dsr_msgs/MoveCircle.h> 26 #include <dsr_msgs/MoveSplineJoint.h> 27 #include <dsr_msgs/MoveSplineTask.h> 28 #include <dsr_msgs/MoveBlending.h> 29 #include <dsr_msgs/MoveSpiral.h> 30 #include <dsr_msgs/MovePeriodic.h> 31 #include <dsr_msgs/MoveWait.h> 33 #include <dsr_msgs/ConfigCreateTcp.h> 34 #include <dsr_msgs/ConfigDeleteTcp.h> 35 #include <dsr_msgs/GetCurrentTcp.h> 36 #include <dsr_msgs/SetCurrentTcp.h> 38 #include <dsr_msgs/SetCurrentTool.h> 39 #include <dsr_msgs/GetCurrentTool.h> 40 #include <dsr_msgs/ConfigCreateTool.h> 41 #include <dsr_msgs/ConfigDeleteTool.h> 43 #include <dsr_msgs/SetCtrlBoxDigitalOutput.h> 44 #include <dsr_msgs/GetCtrlBoxDigitalInput.h> 45 #include <dsr_msgs/SetToolDigitalOutput.h> 46 #include <dsr_msgs/GetToolDigitalInput.h> 47 #include <dsr_msgs/SetCtrlBoxAnalogOutput.h> 48 #include <dsr_msgs/GetCtrlBoxAnalogInput.h> 49 #include <dsr_msgs/SetCtrlBoxAnalogOutputType.h> 50 #include <dsr_msgs/SetCtrlBoxAnalogInputType.h> 52 #include <dsr_msgs/SetModbusOutput.h> 53 #include <dsr_msgs/GetModbusInput.h> 54 #include <dsr_msgs/ConfigCreateModbus.h> 55 #include <dsr_msgs/ConfigDeleteModbus.h> 57 #include <dsr_msgs/DrlPause.h> 58 #include <dsr_msgs/DrlStart.h> 59 #include <dsr_msgs/DrlStop.h> 60 #include <dsr_msgs/DrlResume.h> 74 int movej(
float fTargetPos[NUM_JOINT],
77 float fTargetTime = 0.f,
78 int nMoveMode = MOVE_MODE_ABSOLUTE,
79 float fBlendingRadius = 0.f,
80 int nBlendingType = BLENDING_SPEED_TYPE_DUPLICATE,
88 dsr_msgs::MoveJoint srv;
90 for(
int i=0; i<NUM_JOINT; i++)
91 srv.request.pos[i] = fTargetPos[i];
92 srv.request.vel = fTargetVel;
93 srv.request.acc = fTargetAcc;
94 srv.request.time = fTargetTime;
95 srv.request.mode = nMoveMode;
96 srv.request.radius = fBlendingRadius;
97 srv.request.blendType = nBlendingType;
98 srv.request.syncType = nSyncType;
100 if(srvMoveJoint.call(srv))
103 return (srv.response.success);
107 ROS_ERROR(
"Failed to call service dr_control_service : move_joint\n");
120 dsr_msgs::SetCtrlBoxDigitalOutput srv;
122 srv.request.index = nGpioIndex;
123 srv.request.value = bGpioValue;
125 if(srvSetCtrlBoxDigitalOutput.call(srv))
128 return (srv.response.success);
132 ROS_ERROR(
"Failed to call service dr_control_service : set_digital_output\n");
143 dsr_msgs::GetCtrlBoxDigitalInput srv;
145 srv.request.index = nGpioIndex;
147 if(srvGetCtrlBoxDigitalInput.call(srv))
150 return (srv.response.value);
154 ROS_ERROR(
"Failed to call service dr_control_service : get_digital_input\n");
166 dsr_msgs::SetToolDigitalOutput srv;
168 srv.request.index = nGpioIndex;
169 srv.request.value = bGpioValue;
171 if(srvSetToolDigitalOutput.call(srv))
174 return (srv.response.success);
178 ROS_ERROR(
"Failed to call service dr_control_service : set_tool_digital_output\n");
189 dsr_msgs::GetToolDigitalInput srv;
191 srv.request.index = nGpioIndex;
193 if(srvGetToolDigitalInput.call(srv))
196 return (srv.response.value);
200 ROS_ERROR(
"Failed to call service dr_control_service : get_tool_digital_input\n");
212 dsr_msgs::SetCtrlBoxAnalogOutput srv;
214 srv.request.channel = nGpioChannel;
215 srv.request.value = fGpioValue;
217 if(srvSetCtrlBoxAnalogOutput.call(srv))
220 return (srv.response.success);
224 ROS_ERROR(
"Failed to call service dr_control_service : set_analog_output\n");
235 dsr_msgs::GetCtrlBoxAnalogInput srv;
237 srv.request.channel = nGpioChannel;
239 if(srvGetCtrlBoxAnalogInput.call(srv))
242 return (srv.response.value);
246 ROS_ERROR(
"Failed to call service dr_control_service : get_analog_input\n");
258 dsr_msgs::SetCtrlBoxAnalogOutputType srv;
260 srv.request.channel = nGpioChannel;
261 srv.request.mode = nGpioMode;
263 if(srvSetCtrlBoxAnalogOutputType.call(srv))
266 return (srv.response.success);
270 ROS_ERROR(
"Failed to call service dr_control_service : set_analog_output_type\n");
282 dsr_msgs::SetCtrlBoxAnalogInputType srv;
284 srv.request.channel = nGpioChannel;
285 srv.request.mode = nGpioMode;
287 if(srvSetCtrlBoxAnalogInputType.call(srv))
290 return (srv.response.success);
294 ROS_ERROR(
"Failed to call service dr_control_service : set_analog_input_type\n");
314 ROS_INFO(
"shutdown time! sig=%d",sig);
315 ROS_INFO(
"shutdown time! sig=%d",sig);
316 ROS_INFO(
"shutdown time! sig=%d",sig);
322 dsr_msgs::RobotStop msg;
324 msg.stop_mode = STOP_TYPE_QUICK;
325 pubRobotStop.publish(msg);
330 int main(
int argc,
char** argv)
333 string my_robot_id =
"dsr01";
334 string my_robot_model =
"m1013";
336 ROS_INFO(
"default arguments: dsr01 m1013");
340 ROS_ERROR(
"invalid arguments: <ns> <model> (ex) dsr01 m1013");
343 for (
int i = 1; i < argc; i++){
344 printf(
"argv[%d] = %s\n", i, argv[i]);
346 my_robot_id = argv[1];
347 my_robot_model = argv[2];
388 ROS_INFO(
"dsr_service_test finished !!!!!!!!!!!!!!!!!!!!!");
int set_analog_output(int nGpioChannel, float fGpioValue)
int get_digital_input(int nGpioIndex)
int set_digital_output(int nGpioIndex, bool bGpioValue)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int main(int argc, char **argv)
void SET_ROBOT(string id, string model)
int set_analog_input_type(int nGpioChannel, int nGpioMode)
int get_tool_digital_input(int nGpioIndex)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
int get_analog_input(int nGpioChannel)
int set_analog_output_type(int nGpioChannel, int nGpioMode)
int set_tool_digital_output(int nGpioIndex, bool bGpioValue)
ROSCPP_DECL void shutdown()
int movej(float fTargetPos[NUM_JOINT], float fTargetVel, float fTargetAcc, float fTargetTime=0.f, int nMoveMode=MOVE_MODE_ABSOLUTE, float fBlendingRadius=0.f, int nBlendingType=BLENDING_SPEED_TYPE_DUPLICATE, int nSyncType=0)