我创建了一个由内置GUI程序指令和c++ api执行的相同程序的并排视频。视频同步开始时,两个机器人开始移动。正如您在视频中看到的,GUI程序模拟在c++ api模拟完成之前就已经完成了。此外,c++程序看起来非常慢,以至于它跳过了程序的步骤,比如速度变化和移动指令。
代码:
# include < iostream >
# include <字符串>
# include < cstdlib >
# include < cmath >
# include“UR10Simulate.h”
UR10Simulate: UR10Simulate () {
this->RDK = NULL;
}
//方法名:UR10Simulate构造函数
//目标:传递RDK的当前实例,并为所有站项配置变量
//与此模拟一起使用
//Input: RoboDK* rdk_api::RoboDK* RDK_instance . //
/ /输出:没有
初始化所有成员为默认值188bet体育官网体
UR10Simulate: UR10Simulate (RoboDK_API:: RoboDK * RDK_instance) {
//指向RoboDK的指针
this->RDK = RDK_instance;
//指向活动机器人的指针
this->active_robot = RDK->getItem("UR10e");
//选择/放置对象的指针
this->i_2084m61_blade = RDK->getItem("2084M61");
this->i_2084m61_cup = RDK->getItem(“2084M61 VPA TOOL B 10-22-19”);
//指向参考系的指针
this->r_input_tray = RDK->getItem("M61输入托盘");
this->r_input_tray_active = RDK->getItem(“Active Input Bin”);
this->r_output_tray = RDK->getItem("M61输出托盘");
this->r_output_tray_active = RDK->getItem(“Active Output Bin”);
this->r_stationary_gripper = RDK->getItem(“Stationary Gripper”);
//备用位置的指针
this->p_home = RDK->getItem("Home");
this->p_input_cup_standby = RDK->getItem("Input Cup Standby");
this->p_input_blade_standby = RDK->getItem("Input Standby");
this->p_output_blade_standby = RDK->getItem("Output Standby");
this->p_stationary_cup_standby = RDK->getItem(“Stationary Cup Standby”);
this->p_stationary_blade_standby = RDK->getItem(“固定刀片待机”);
//指向托盘杯目标的指针
this->p_tray_cup_0 = RDK->getItem("Cup Pick 0");
this->p_tray_cup_1 = RDK->getItem("Cup Pick 1");
this->p_tray_cup_2 = RDK->getItem("Cup Pick 2");
//指向托盘刀片目标的指针
this->p_tray_blade_0 = RDK->getItem("Blade Pick 0");
this->p_tray_blade_1 = RDK->getItem("Blade Pick 1");
this->p_tray_blade_2 = RDK->getItem("Blade Pick 2");
//指向静止夹具杯目标的指针
this->p_stationary_cup_0 = RDK->getItem(“Stationary Cup 0”);
this->p_stationary_cup_1 = RDK->getItem(“Stationary Cup 1”);
this->p_stationary_cup_2 = RDK->getItem("Statopmaru Cup 2");
//指向静止夹持刃目标的指针
this->p_stationary_blade_0 = RDK->getItem(“Stationary Blade 0”);
this->p_stationary_blade_1 = RDK->getItem(“Stationary Blade 1”);
this->p_stationary_blade_2 = RDK->getItem(“Stationary Blade 2”);
//指向爆炸联合目标的指针
this->p_blast_position = RDK->getItem(“Blast Position”);
this->p_blast_position_finish = RDK->getItem(“Blast Position Finish”);
//显示工具的指针
这->t_cup_closed_airfoil_closed = RDK->getItem("DGATC杯关闭翼型关闭");
这->t_cup_closed_airfoil_open = RDK->getItem("DGATC杯关闭翼型打开");
这->t_cup_open_airfoil_closed = RDK->getItem("DGATC杯打开翼型关闭");
这->t_cup_open_airfoil_open = RDK->getItem("DGATC杯开放翼型开放");
this->t_stationary_gripper_closed = RDK->getItem(“Stationary Gripper Closed”);
this->t_stationary_gripper_open = RDK->getItem(“Stationary Gripper Open”);
//指向活动工具的指针
这->t_airfoil_tool = RDK->getItem(“翼型工具”);
this->t_cup_tool = RDK->getItem("Cup Tool");
/ /程序变量
This ->current_part = 0;
This ->part_count = 0;
This ->part_count_x = 1;
This ->part_count_y = 1;
}
UR10Simulate:: ~ UR10Simulate () {
}
//方法名称:SetTraySize
//目标:确定托盘的大小
//输入:int x_size, int y_size, int count
/ /输出:没有
//步骤:将part_count_x, part_count_y, part_count设置为input
SetTraySize(int x_size, int y_size, int count){
这->part_count_x = x_size;
This ->part_count_y = y_size;
This ->part_count = count;
}
/ /方法名称:
/ /目标:
/ /输入:
/ /输出:
/ /步骤:
空白UR10Simulate: GenerateObjects () {
}
/ /方法名称:
/ /目标:
/ /输入:
/ /输出:
/ /步骤:
空白UR10Simulate: ClearObjects () {
}
/ /方法名称:
/ /目标:
/ /输入:
/ /输出:
/ /步骤:
空白UR10Simulate: MoveActiveReferenceFrames () {
}
/ /方法名称:
/ /目标:
/ /输入:
/ /输出:
/ /步骤:
空白UR10Simulate:调用(){
如果(RDK - >连接()){
RDK - > setSimulationSpeed (1.0);
//重置对象显示和激活工具
t_cup_open_airfoil_open.setVisible(真正的);
t_cup_closed_airfoil_open.setVisible(假);
t_cup_open_airfoil_closed.setVisible(假);
t_cup_closed_airfoil_closed.setVisible(假);
t_stationary_gripper_open.setVisible(真正的);
t_stationary_gripper_closed.setVisible(假);
active_robot.setPoseTool (t_cup_tool);
/ /移动的家
/ / active_robot。setSpeed(100,1200,30,80);
active_robot.setRounding (20);
/ / active_robot.MoveJ (p_home);
//对于每个部分,执行如下操作
//while(current_part < part_count){
//移动到输入区取杯刀片组件
active_robot.setPoseTool (t_cup_tool);
active_robot.setPoseFrame (r_input_tray_active);
active_robot。setSpeed(600, 1200, 120, 80);
active_robot.MoveJ (p_input_blade_standby);
active_robot.MoveJ (p_input_cup_standby);
active_robot.MoveJ (p_tray_cup_2);
active_robot。setSpeed(100, 1200, 120, 80);
active_robot.MoveL (p_tray_cup_1);
/ / active_robot。setSpeed(100,600,60,80);
active_robot.MoveL (p_tray_cup_0);
//从输入托盘中取出杯片组件
active_robot.Pause (0.25);
t_cup_open_airfoil_open.setVisible(假);
t_cup_closed_airfoil_open.setVisible(真正的);
active_robot.Pause (0.25);
//移回输入杯待机区
active_robot.MoveL (p_tray_cup_1);
/ / active_robot。setSpeed(300, 600, 60, 80);
active_robot.MoveL (p_tray_cup_2);
active_robot。setSpeed(600, 1200, 120, 80);
active_robot.MoveJ (p_input_cup_standby);
//移动到固定夹具转移杯形叶片组件
active_robot.setPoseFrame (r_stationary_gripper);
active_robot.MoveJ (p_stationary_cup_standby);
active_robot.MoveJ (p_stationary_cup_2);
active_robot。setSpeed(100, 1200, 120, 80);
active_robot.MoveL (p_stationary_cup_1);
active_robot.MoveL (p_stationary_cup_0);
//将杯刃组件转移到固定夹具上
active_robot.Pause (0.25);
t_cup_open_airfoil_open.setVisible(真正的);
t_cup_closed_airfoil_open.setVisible(假);
t_stationary_gripper_open.setVisible(假);
t_stationary_gripper_closed.setVisible(真正的);
active_robot.Pause (0.25);
//移动到固定刀片待机位置
active_robot.MoveL (p_stationary_cup_1);
/ / active_robot。setSpeed(300, 600, 60, 80);
active_robot.MoveL (p_stationary_cup_2);
active_robot。setSpeed(600, 1200, 120, 80);
active_robot.MoveJ (p_stationary_cup_standby);
//移到固定拣刀位置
active_robot.setPoseTool (t_airfoil_tool);
active_robot.MoveJ (p_stationary_blade_standby);
active_robot.MoveJ (p_stationary_blade_2);
active_robot。setSpeed(100, 1200, 120, 80);
active_robot.MoveL (p_stationary_blade_1);
active_robot.MoveL (p_stationary_blade_0);
//从杯口-杯口组合中拔出刀片
active_robot.Pause (0.25);
t_cup_open_airfoil_open.setVisible(假);
t_cup_open_airfoil_closed.setVisible(真正的);
active_robot.Pause (0.25);
//移动到固定刀片待机位置
active_robot.MoveL (p_stationary_blade_1);
/ / active_robot。setSpeed(300, 600, 60, 80);
active_robot.MoveL (p_stationary_blade_2);
active_robot。setSpeed(600, 1200, 120, 80);
active_robot.MoveJ (p_stationary_blade_standby);
/ /清洁叶片
active_robot.setRounding (0);
active_robot.MoveJ (p_blast_position);
active_robot.Pause (1);
active_robot。setSpeed(300, 1200, 18, 80);
active_robot.MoveJ (p_blast_position_finish);
/ / active_robot.setRounding (20);
//移动到固定刀片待机位置
active_robot。setSpeed(600, 1200, 120, 80);
active_robot.MoveJ (p_stationary_blade_standby);
//移动到固定杯位
active_robot.setPoseTool (t_cup_tool);
active_robot.MoveJ (p_stationary_cup_standby);
active_robot.MoveJ (p_stationary_cup_2);
active_robot。setSpeed(100, 1200, 120, 80);
active_robot.MoveL (p_stationary_cup_1);
active_robot.MoveL (p_stationary_cup_0);
//从固定夹具中取出杯子
active_robot.Pause (0.25);
t_cup_open_airfoil_closed.setVisible(假);
t_cup_closed_airfoil_closed.setVisible(真正的);
t_stationary_gripper_open.setVisible(真正的);
t_stationary_gripper_closed.setVisible(假);
active_robot.Pause (0.25);
//移动到静止的杯子待机位置
active_robot.MoveL (p_stationary_cup_1);
/ / active_robot。setSpeed(300, 600, 60, 80);
active_robot.MoveL (p_stationary_cup_2);
active_robot。setSpeed(600, 1200, 120, 80);
active_robot.MoveJ (p_stationary_cup_standby);
//再次移动到输入托盘杯口位置,将杯口放回输入托盘
active_robot.setPoseFrame (r_input_tray_active);
active_robot.MoveJ (p_input_cup_standby);
active_robot.MoveJ (p_tray_cup_2);
active_robot。setSpeed(100, 1200, 120, 80);
active_robot.MoveL (p_tray_cup_1);
active_robot.MoveL (p_tray_cup_0);
//将杯子放入输入托盘
active_robot.Pause (0.25);
t_cup_closed_airfoil_closed.setVisible(假);
t_cup_open_airfoil_closed.setVisible(真正的);
active_robot.Pause (0.25);
//移动到输入刀片待机位置
active_robot.MoveL (p_tray_cup_1);
/ / active_robot。setSpeed(300, 600, 60, 80);
active_robot.MoveL (p_tray_cup_2);
active_robot。setSpeed(600, 1200, 120, 80);
active_robot.MoveJ (p_input_cup_standby);
active_robot.MoveJ (p_input_blade_standby);
//移动到输出刀片位置
active_robot.setPoseTool (t_airfoil_tool);
active_robot.setPoseFrame (r_output_tray_active);
active_robot.MoveJ (p_tray_blade_2);
active_robot。setSpeed(100, 1200, 120, 80);
active_robot.MoveL (p_tray_blade_1);
active_robot.MoveL (p_tray_blade_0);
//将刀片放入输出托盘
active_robot.Pause (0.25);
t_cup_open_airfoil_closed.setVisible(假);
t_cup_open_airfoil_open.setVisible(真正的);
active_robot.Pause (0.25);
//移动到输出刀片待机位置
active_robot.MoveL (p_tray_blade_1);
/ / active_robot。setSpeed(300, 600, 60, 80);
active_robot.MoveL (p_tray_blade_2);
active_robot。setSpeed(600, 1200, 120, 80);
active_robot.MoveJ (p_output_blade_standby);
/ /}
//搬回家
/ / active_robot。setSpeed(100,1200,30,80);
/ / active_robot.setRounding (20);
/ / active_robot.MoveJ (p_home);
}
}
/ /方法名称:
/ /目标:
/ /输入:
/ /输出:
/ /步骤: