Esempio n. 1
0
 def __init__(self):
     super(MainWindow, self).__init__()
     # 机器人驱动
     self.ur = UR()
     # 连接
     self.ur.connect()
     # 设置标题
     self.setWindowTitle('机器人绘制')
     # 设置窗口大小
     self.setFixedSize(640, 480)
     # 创建整体布局
     wholeLayout = QVBoxLayout()
     # 设置布局
     self.setLayout(wholeLayout)
     # 创建上部布局
     topLayout = QHBoxLayout()
     # 添加布局到整体布局中
     wholeLayout.addLayout(topLayout)
     # 创建两个按钮
     clearBtn = QPushButton('清理')
     paintBtn = QPushButton('绘制')
     # 按钮添加到布局中
     topLayout.addWidget(clearBtn)
     topLayout.addWidget(paintBtn)
     # 创建自定义控件
     self.paintWidget = PaintWidget()
     # 添加到整体布局中
     wholeLayout.addWidget(self.paintWidget)
     # 设置按钮点击事件
     # 槽函数可以是普通函数 也可以是类的方法
     clearBtn.clicked.connect(self.clear)
     # 绘制事件
     paintBtn.clicked.connect(self.paint)
from sdk.ur import UR

# 创建驱动
ur = UR()

# 连接机械臂
ur.connect()

# 放松姿态
ur.move_j([-84.56, -87.06, -89.02, -96.33, 90.87, 89.87])

# 定义四个点
pos = [0.3, 0, 0, 180, 0, 90]

ur.clear_points()
ur.disable_trail()

ur.show_point((0, 0, 0), 0.1, [0, 255, 0, 0])  # 原点
ur.show_point((0.3, 0, 0))

# 移动到第一个点
# ur.move_p(pos)
# 开启线路显示
ur.enable_trail()

pos_1 = [0, 0, 0, 0, 0, 0]
pos_2 = [0, 0, 0, 0, 0, 0]
pos_3 = [0, 0, 0, 0, 0, 0]
pos_4 = [0, 0, 0, 0, 0, 0]

alpha = 0.5
Esempio n. 3
0
'''
分析:
1.移动机器人到放松姿势
2.点头 抬头 做100次
'''
from sdk.ur import UR

# 创建机器人驱动
ur = UR()
# 连接机器人
ur.connect()
# 移动到放松的姿势
ur.move_j([-90,-101.50,-77.50,-13.50,91.50,0])
# 点头点的位 置和姿态
downPos = [-0.107,-0.57773,0.38707,-102.49585,0.32462,-178.53554]
ur.move_l(downPos)
# 控制点头和抬头100次
for index in range(1,100):
        if index%2==0:
            # 向下
            downPos[2]-=0.4
            ur.move_l(downPos, v=1)
        else:
            # 向上
            downPos[2]+=0.4
            ur.move_l(downPos, v=1)
Esempio n. 4
0
class MainWindow(QWidget):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.ur = None
        # self.whole_layout = None
        self.clear_button = None
        self.paint_button = None
        self.paint_widget = None
        self._init_sdk()
        self._init_window()
        self._init_widget()  # widget 在 layout 前面
        self._init_layout()

    def _init_sdk(self):
        self.ur = UR()
        self.ur.connect()

    def _init_window(self):
        self.setWindowTitle('robot paint self')
        self.setFixedSize(640, 480)

    def _init_layout(self):
        whole_layout = QVBoxLayout()
        top_layout = QHBoxLayout()
        self.setLayout(whole_layout)
        whole_layout.addLayout(top_layout)
        whole_layout.addWidget(self.paint_widget)
        top_layout.addWidget(self.clear_button)
        top_layout.addWidget(self.paint_button)

    def _init_widget(self):
        self.paint_widget = MyPaintWidget()
        self.clear_button = QPushButton('清理')
        self.paint_button = QPushButton('绘制')
        self.clear_button.clicked.connect(self.clear)
        self.paint_button.clicked.connect(self.paint)

    def clear(self):
        self.paint_widget.clear()

    def scale_data(self, x, y):
        """
        画板坐标映射到机器人坐标
        :param x: 画板 x 坐标
        :param y: 画板 y 坐标
        :return: 机器人 x,y 坐标
        """
        x = 0.3 - 0.6 * x / 640
        y = -0.5 + 0.4 * y / 480
        return x, y

    def paint(self):
        """
        调用机器人sdk
        :return:
        """
        # 使用move_j移动至放松位置
        self.ur.move_j([-84.56, -87.06, -89.02, -96.33, 90.87, 89.87])
        # PaintWidget(自定义)对象paint_widget 获取所有绘画点
        points = self.paint_widget.points[::10]  # 每隔十个点选取
        # 开启sdk轨迹
        self.ur.enable_trail()
        # 绘制这些点
        for point in points:  # points 字典吗?
            px = point['x']
            py = point['y']
            # 使用move_p 方式移动可以提高效率的同时精确画图
            x, y = self.scale_data(px, py)
            self.ur.move_p([x, y, 0.45422, 180, 0, 90])
Esempio n. 5
0
 def _init_sdk(self):
     self.ur = UR()
     self.ur.connect()
from sdk.ur import UR

# 创建机器人驱动
ur = UR()
# 连接机器人
ur.connect()
# 移动机器人
ur.move_j([-84.56, -87.06, -89.02, -96.33, 90.87, 89.87])  # J0下 - J5上

# ahkdfa TODO
#TODO
# prit("hello")
Esempio n. 7
0
from sdk.ur import UR

# 创建机器人驱动
ur = UR()
# 连接机器人
ur.connect()
# 显示点
ur.show_point((0.3, 0.4, 0))
from sdk.ur import UR

# 创建驱动
ur = UR()

# 连接机械臂
ur.connect()

# 放松姿态
ur.move_j([-84.56,-87.06,-89.02,-96.33,90.87,89.87])

# 清除点
ur.clear_points()

# 定义四个点
pos1 = [0.3,0,0,180,0,90]
pos2 = [0.3,0.3,0,180,0,90]
pos3 = [0.6,0.3,0,180,0,90]
pos4 = [0.6,0,0,180,0,90]

# 显示点
ur.show_point((0.6,0.3,0))
ur.show_point((0.3,0.3,0))
ur.show_point((0.3,0,0))
ur.show_point((0.6,0,0))

# 绘制
while True:
    ur.move_l(pos1)
    # 显示路线
Esempio n. 9
0
class MainWindow(QWidget):
    def __init__(self):
        super(MainWindow, self).__init__()
        # 机器人驱动
        self.ur = UR()
        # 连接
        self.ur.connect()
        # 设置标题
        self.setWindowTitle('机器人绘制')
        # 设置窗口大小
        self.setFixedSize(640, 480)
        # 创建整体布局
        wholeLayout = QVBoxLayout()
        # 设置布局
        self.setLayout(wholeLayout)
        # 创建上部布局
        topLayout = QHBoxLayout()
        # 添加布局到整体布局中
        wholeLayout.addLayout(topLayout)
        # 创建两个按钮
        clearBtn = QPushButton('清理')
        paintBtn = QPushButton('绘制')
        # 按钮添加到布局中
        topLayout.addWidget(clearBtn)
        topLayout.addWidget(paintBtn)
        # 创建自定义控件
        self.paintWidget = PaintWidget()
        # 添加到整体布局中
        wholeLayout.addWidget(self.paintWidget)
        # 设置按钮点击事件
        # 槽函数可以是普通函数 也可以是类的方法
        clearBtn.clicked.connect(self.clear)
        # 绘制事件
        paintBtn.clicked.connect(self.paint)

    def clear(self):
        '''
        清理
        :return:
        '''
        self.paintWidget.clear()

    def scaleData(self, x, y):
        '''
        对数据缩放处理
        :param cal:
        :return:
        '''
        x = 0.3 - 0.6 * x / 640
        y = -0.5 + 0.4 * y / 480
        return x, y

    def paint(self):
        '''
        调用机器人绘制
        :return:
        '''
        self.ur.disable_trail()
        self.ur.move_j([-84.56, -87.06, -89.02, -96.33, 90.87, 89.87])
        # 获取所有的点
        points = self.paintWidget.points[::10]
        self.ur.enable_trail()
        # 绘制点的数量
        # 遍历所有的点,移动过去
        for point in points:
            px = point['x']
            py = point['y']
            # print(px, py)
            # 移动 采用哪一种移动方式? movel movep
            # pose:[x,y,z,rx,ry,rz]
            # 缩放x和y
            x, y = self.scaleData(px, py)
            # print(x, y)
            print("(px, py)::({}, {}), (x, y)::({}, {})".format(px, py, x, y))
            # x y z 单位:m
            self.ur.move_p([x, y, 0.45422, 180, 0, 90])
Esempio n. 10
0
'''
定义一个点的变量,移动机械臂到这个点
'''
from sdk.ur import UR
# 6个关节角
joints = [-84.56, -87.06, -89.02, -96.33, 90.87, 89.87]

# 创建驱动
ur = UR()
# 连接机械臂
ur.connect()
# 移动机械臂达到对应的位置
ur.move_j(joints)