2 from robodk_postprocessors.Fanuc_R30iA 
import RobotPost 
as FanucR30iAPost
     3 from robodk_postprocessors.Motoman 
import Pose
     4 from robodk_postprocessors.Motoman 
import RobotPost 
as MotomanPost
     5 from robodk_postprocessors.robodk 
import *
     8 import geometry_msgs.msg
    15     quat = [p.orientation.w, p.orientation.x, p.orientation.y, p.orientation.z]
    17     mat.setPos([p.position.x * 1000, p.position.y * 1000, p.position.z * 1000])
    22     if p.orientation.x == 0 
and p.orientation.y == 0 
and p.orientation.z == 0 
and p.orientation.w == 0:
    28         return [config.pp_not_init]
    30     if len(req.joints_1) != config.pp.nAxes:
    31         return [
"Joints tuple does not match the number of axes"]
    32     if len(req.joints_2) != config.pp.nAxes:
    33         return [
"Joints tuple does not match the number of axes"]
    34     if len(req.conf_RLF_1) != 3:
    35         return [
"conf_RLF_1 size must be 3"]
    36     if len(req.conf_RLF_2) != 3:
    37         return [
"conf_RLF_2 size must be 3"]
    40         return [
"Pose 1 quaternions are not initialized"]
    42         return [
"Pose 2 quaternions are not initialized"]
    45     config.pp.MoveC(p1, req.joints_1, p2, req.joints_2, list(req.conf_RLF_1), list(req.conf_RLF_2))
    50         return [config.pp_not_init]
    52     if len(req.joints) != config.pp.nAxes:
    53         return [
"Joints tuple does not match the number of axes"]
    54     if len(req.conf_RLF) != 3:
    55         return [
"conf_RLF size must be 3"]
    58         return [
"Pose quaternions are not initialized"]
    60     config.pp.MoveJ(p, req.joints, list(req.conf_RLF))
    65         return [config.pp_not_init]
    67     if len(req.joints) != config.pp.nAxes:
    68         return [
"Joints tuple does not match the number of axes"]
    69     if len(req.conf_RLF) != 3:
    70         return [
"conf_RLF size must be 3"]
    73         return [
"Pose quaternions are not initialized"]
    76     config.pp.MoveL(p, req.joints, list(req.conf_RLF))
    81         return [config.pp_not_init]
    83     if req.seconds <= 0.0:
    84         return [
"Pause cannot be zero or negative"];
    86     config.pp.Pause(req.seconds * 1000)
    91         return [config.pp_not_init]
    93     config.pp.ProgFinish(req.program_name)
    94     if len(config.pp.LOG) > 0:
    95         return [config.pp.LOG, 
""]
    98     for line 
in config.pp.PROG_LIST[-1]:
   103     if config.pp 
is None:
   104         return [config.pp_not_init, 
""]
   106     if len(config.pp.PROG_LIST) 
is 0:
   107         return [
"Program list is empty", 
""]
   110     for line 
in config.pp.PROG_LIST[-1]:
   113     if not req.program_name:
   114         return [
"program_name cannot be empty", 
""]
   115     if not req.file_saving_dir:
   116         return [
"file_saving_dir cannot be empty", 
""]
   117     config.pp.ProgSave(req.file_saving_dir, req.program_name)
   121     if config.pp 
is None:
   122         return [config.pp_not_init, 
""]
   125         return [
"robot_ip cannot be empty"]
   127     config.pp.ProgSendRobot(req.robot_ip, req.remote_path, req.ftp_user, req.ftp_pass)
   131     if len(req.post_processor) 
is 0:
   132         return [
"Post processor name is empty"]
   133     elif req.post_processor == 
"Motoman":
   134         config.pp = MotomanPost()
   135         config.pp.LAST_CONFDATA = [
None, 
None, 
None, 
None] 
   136     elif req.post_processor == 
"Fanuc_R30iA":
   137         config.pp = FanucR30iAPost()
   140         return [
"'%s' post processor is not supported" % req.post_processor]
   142     config.pp.PROG_TARGETS = []
   144     if len(req.program_name) 
is 0:
   145         return [
"Program name is empty"]
   146     config.pp.ProgStart(req.program_name)
   149     config.pp.PROG_COMMENT = req.program_comment
   154     if config.pp 
is None:
   155         return [config.pp_not_init]
   158         return [
"message cannot be empty"]
   160     config.pp.RunMessage(req.msg)
   164     if config.pp 
is None:
   165         return [config.pp_not_init]
   168         return [
"code cannot be empty"]
   170     config.pp.RunCode(req.code, req.is_function_call)
   174     if config.pp 
is None:
   175         return [config.pp_not_init]
   178         var = int(req.io_var)
   179         config.pp.setDO(var, req.io_value)
   181         config.pp.setDO(req.io_var, req.io_value)
   186     if config.pp 
is None:
   187         return [config.pp_not_init]
   190         return [
"Pose quaternions are not initialized"]
   192     config.pp.setFrame(p, req.frame_id, req.frame_name)
   196     if config.pp 
is None:
   197         return [config.pp_not_init]
   199     config.pp.setSpeed(req.mm_sec)
   203     if config.pp 
is None:
   204         return [config.pp_not_init]
   206     config.pp.setSpeedJoints(req.deg_sec)
   210     if config.pp 
is None:
   211         return [config.pp_not_init]
   214         return [
"Pose quaternions are not initialized"]
   216     config.pp.setTool(p, req.tool_id, req.tool_name)
   220     if config.pp 
is None:
   221         return [config.pp_not_init]
   223     config.pp.setZoneData(req.zone_mm)
   227     if config.pp 
is None:
   228         return [config.pp_not_init]
   231         var = int(req.io_var)
   232         config.pp.waitDI(var, req.io_value, req.timeout_ms)
   234         config.pp.waitDI(req.io_var, req.io_value, req.timeout_ms)
   240     rospy.init_node(
'ros_robodk_post_processors')
   241     service_prefix = 
'robodk_post_processors/'   245     services.append(rospy.Service(service_prefix + 
'move_c', MoveC, move_c))
   246     services.append(rospy.Service(service_prefix + 
'move_j', MoveJ, move_j))
   247     services.append(rospy.Service(service_prefix + 
'move_l', MoveL, move_l))
   248     services.append(rospy.Service(service_prefix + 
'pause', Pause, pause))
   249     services.append(rospy.Service(service_prefix + 
'prog_finish', ProgFinish, prog_finish))
   250     services.append(rospy.Service(service_prefix + 
'prog_save', ProgSave, prog_save))
   251     services.append(rospy.Service(service_prefix + 
'prog_send_robot', ProgSendRobot, prog_send_robot))
   252     services.append(rospy.Service(service_prefix + 
'prog_start', ProgStart, prog_start))
   253     services.append(rospy.Service(service_prefix + 
'run_code', RunCode, run_code))
   254     services.append(rospy.Service(service_prefix + 
'run_message', RunMessage, run_message))
   255     services.append(rospy.Service(service_prefix + 
'set_do', SetDO, set_do))
   256     services.append(rospy.Service(service_prefix + 
'set_frame', SetFrame, set_frame))
   257     services.append(rospy.Service(service_prefix + 
'set_speed', SetSpeed, set_speed))
   258     services.append(rospy.Service(service_prefix + 
'set_speed_joints', SetSpeedJoints, set_speed_joints))
   259     services.append(rospy.Service(service_prefix + 
'set_tool', SetTool, set_tool))
   260     services.append(rospy.Service(service_prefix + 
'set_zone_data', SetZoneData, set_zone_data))
   261     services.append(rospy.Service(service_prefix + 
'wait_di', WaitDI, wait_di))
   271     motoman.services(service_prefix, services)
   275         rospy.loginfo(
"Service %s ready", s.resolved_name)
   278 if __name__ == 
'__main__':
 
def quaternion_2_pose(qin)
def set_speed_joints(req)