控制器二次开发-使用配置好的码垛工艺包创建作业程序

2022-01-20

  • NexDroid-Controller 函数库提供了码垛工艺包,当配置好码垛工艺包的参数后,可通过创建作业文件来使用码垛工艺包。
  • 本例中我们就使用工艺号 1 来举例,实现从固定点取料进行码垛放料的功能。
  1. 首先使用NRC_CreateJobfile("PALLET");新建一个作业文件

    • 本例中我们就使用PALLET为作业文件名称来举例
    • int NRC_CreateJobfile(std::string jobname);
      • jobname 为要新建的作业文件名称
  2. 使用NRC_OpenJobfile("PALLET");打开作业文件

    • int NRC_OpenJobfile(std::string jobname);
      • jobname 为要打开的作业文件名称
  3. 插入运动指令,用来将机器人移动到固定取料点

    • NRC_Position pickPos; NRC_JobfileInsertMOVJ(1, 100, 100, 100, pickPos, 5);
    • 若取料途中为了避障,可根据需要再插入几条运动指令,本例中只使用一条来举例
    • int NRC_JobfileInsertMOVJ(int line, int vel, int acc, int dec, const NRC_Position& target, int pl=0,int tm = 0);
      • line 将指令插入到第 line 行
      • vel 机器人的运行速度,为机器人最大速度的百分比,参数范围:0 < vel <= 100
      • acc 机器人运行加速度,为机器人各关节最大加速度的百分比,参数范围:0 < acc <= 100
      • dec 机器人运行减速度,为机器人各关节最大减速度的百分比,参数范围:0 < dec <= 100
      • target 机器人运动目标位置
      • pl 平滑度,将和后面一条移动指令进行平滑过渡,数值越大,越平滑,轨迹偏差也越大,参数范围:0 <= pl <= 5
  4. 插入数字端口输出指令,用来通过 io 端口输出高电平,让抓手或吸盘来抓取工件

    • NRC_JobfileInsertDOUT(2, 1, 1);,本例中使用 io 端口 1 来控制抓手或吸盘
    • int NRC_JobfileInsertDOUT(int line, int port, int value);
      • line 将指令插入到第 line 行
      • port 要输出的数字输出端口号,参数范围:port > 0
      • value 端口输出的状态,0:输出低电平,1:输出高电平
  5. 插入延时指令,等待抓手或吸盘来抓取到工件

    • NRC_JobfileInsertTIMER(3, 0.5);,本例中使用延时 0.5 秒来举例
    • int NRC_JobfileInsertTIMER(int line, double timeSec);
      • line 将指令插入到第 line 行
      • timeSec 要延时的时间,单位为秒,参数范围:timeSec > 0
  6. 插入码垛开始指令,NRC_JobfileInsertPALON(4, 1, 0);,本例中使用工艺号 1 来进行码垛

    • int NRC_JobfileInsertPALON(int line, int id, int type, int var1=0, int var2=0, int var3=0);
      • line 将指令插入到第 line 行
      • id 使用的码垛工艺的工艺号
      • type 码垛类型,0:码垛,1:卸跺 1
  7. 插入运动到入口点指令,NRC_JobfileInsertPALENTER(5, 1, 1, 100, 100, 100, 5);

    • int NRC_JobfileInsertPALENTER(int line, int id, int moveType, int vel, int acc, int dec, int pl);
      • line 将指令插入到第 line 行
      • id 使用的码垛工艺的工艺号
      • moveType 该条指令所使用的插补方式,1:关节插补,2:直线插补,3:圆弧插补
      • vel 机器人的运行速度
        • 插补方式为关节时,为机器人最大速度的百分比,参数范围:0 < vel <= 100
        • 插补方式为直线或圆弧时,为机器人末端位置点绝对运行速度,单位为 毫米每秒(mm/s),参数范围:vel > 1
      • acc 机器人运行加速度,参数范围:0 < vel <= 100
        • 插补方式为关节时,为机器人各关节最大加速度的百分比
        • 插补方式为直线或圆弧时,为机器人笛卡尔最大加速度的百分比
      • dec 机器人运行减速度,同 acc
      • pl 平滑度,将和后面一条移动指令进行平滑过渡,数值越大,越平滑,轨迹偏差也越大,参数范围:0 <= pl <= 5
  8. 插入运动到辅助点指令,NRC_JobfileInsertPALSHIFT(6, 1, 1, 100, 100, 100, 5);

    • NRC_JobfileInsertPALSHIFT(int line, int id, int moveType, int acc, int dec, int vel, int pl=0);
      • 各参数同“插入运动到入口点指令”
  9. 插入运动到工件点指令,NRC_JobfileInsertPALREAL(7, 1, 2, 100, 100, 100, 5);

    • NRC_JobfileInsertPALREAL(int line, int id, int moveType, int acc, int dec, int vel, int pl=0);
      • 各参数同“插入运动到入口点指令”
  10. 插入数字端口输出指令,用来通过 io 端口输出低电平,让抓手或吸盘来放下工件

    • NRC_JobfileInsertDOUT(8, 1, 0);
  11. 插入延时指令,等待抓手或吸盘来已放下工件

    • NRC_JobfileInsertTIMER(9, 0.5);
  12. 插入运动到辅助点指令

    • NRC_JobfileInsertPALSHIFT(10, 1, 1, 100, 100, 100, 5);
  13. 插入运动到入口点指令

    • NRC_JobfileInsertPALENTER(11, 1, 1, 100, 100, 100, 5);
  14. 插入码垛结束指令,NRC_JobfileInsertPALOFF(12, 1);

    • int NRC_JobfileInsertPALOFF(int line, int id, int var=0);
      • line 将指令插入到第 line 行
      • id 使用的码垛工艺的工艺号

至此,使用码垛工艺包的作业文件已创建完成。

附录:

NRC_CreateJobfile("PALLET");
NRC_OpenJobfile("PALLET");
NRC_Position pickPos;
NRC_JobfileInsertMOVJ(1, 100, 100, 100, pickPos, 5);
NRC_JobfileInsertDOUT(2, 1, 1);
NRC_JobfileInsertTIMER(3, 0.5);
NRC_JobfileInsertPALON(4, 1, 0);
NRC_JobfileInsertPALENTER(5, 1, 1, 100, 100, 100, 5);
NRC_JobfileInsertPALSHIFT(6, 1, 1, 100, 100, 100, 5);
NRC_JobfileInsertPALREAL(7, 1, 2, 100, 100, 100, 5);
NRC_JobfileInsertDOUT(8, 1, 0);
NRC_JobfileInsertTIMER(9, 0.5);
NRC_JobfileInsertPALSHIFT(10, 1, 1, 100, 100, 100, 5);
NRC_JobfileInsertPALENTER(11, 1, 1, 100, 100, 100, 5);
NRC_JobfileInsertPALOFF(12, 1);
如果本文有错误请向我们反馈,我们很珍惜您的意见或建议。