成功调用了机械臂组件

This commit is contained in:
GitLab 2024-03-30 15:52:26 +08:00
parent 884ddf7fbb
commit 699c0c1ff0
59 changed files with 1774 additions and 229 deletions

Binary file not shown.

View File

@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.13 (graduation_design)" jdkType="Python SDK" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,10 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<Languages>
<language minSize="53" name="Python" />
</Languages>
</inspection_tool>
</profile>
</component>

4
.idea/misc.xml generated
View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.11 (graduation_design)" />
<option name="sdkName" value="Python 3.10 (graduation_design)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.13 (graduation_design)" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (graduation_design)" project-jdk-type="Python SDK" />
</project>

View File

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SaveActionSettings">
<option name="actions">
<set>
<option value="activate" />
<option value="reformat" />
</set>
</option>
</component>
</project>

120
.idea/workspace.xml generated
View File

@ -4,15 +4,66 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="84cc2bfb-62dd-4e3b-8b7e-c4595a290c7c" name="更改" comment="一点修改">
<change afterPath="$PROJECT_DIR$/.idea/copilot/chatSessions/00000000000.xd" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/copilot/chatSessions/blobs/version" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/saveactions_settings.xml" afterDir="false" />
<list default="true" id="ed9ba2d3-2366-49b5-9e96-c67755cbd3c6" name="更改" comment="">
<change afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/abandon_code/contour_line.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/img_process/take_photos.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/img_process/train/package-seg.yaml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/img_process/train/train.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/img_process/train/yolov8n-seg.pt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/img_process/train/yolov8n.pt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/FRRobot.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/ConveyorTrack.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/ConveyorTrackRecord.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/ConveyorTrackSet.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/TrajectoryJ_repetition.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/force_compliance.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/force_control.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/force_find_surface_calcenter.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/force_guard.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/force_load_identification.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/force_payload_identify.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/force_rot_insertion.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/force_sensor_set.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/force_spiral_search.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/froce_line_insertion.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/getDHcomp.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/get_robot_data.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/getversion.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/io_interface.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/jog.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/movec&amp;circle&amp;newspiral.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/movej&amp;movel&amp;movecart.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/offset.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/robot_basic_interface.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/robot_common_set.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/robot_external_device.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/robot_log_interface.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/robot_lua_test.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/robot_point_table_download.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/robot_point_table_switch.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/robot_point_table_upload.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/robot_safety_set.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/robot_updata_lua.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/servo.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/spline.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/tpd_record.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/tpd_repetition.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/webapp_program_use_interface.py" afterDir="false" />
<change afterPath="$PROJECT_DIR$/robot_control/examples/weld.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/copilot/chatSessions/00000000000.xd" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/copilot/chatSessions/00000000000.xd" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/graduation_design.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/graduation_design.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/saveactions_settings.xml" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/img_process/Log/OrbbecSDK.log.txt" beforeDir="false" afterPath="$PROJECT_DIR$/img_process/Log/OrbbecSDK.log.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/fairino_robot_control/MoveItDemo.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/fairino_robot_control/__init__.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/fairino_robot_control/fairino/Robot.pyd" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/fairino_robot_control/robot_basic_interface.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/img_process/Log/OrbbecSDK.log.txt" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/img_process/ObjectClassify.py" beforeDir="false" afterPath="$PROJECT_DIR$/img_process/ObjectClassify.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/img_process/orbbec_camera/OrbbecCamera.py" beforeDir="false" afterPath="$PROJECT_DIR$/img_process/orbbec_camera/OrbbecCamera.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/robot_control/control.py" beforeDir="false" afterPath="$PROJECT_DIR$/robot_control/control.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -21,28 +72,27 @@
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
<option name="UPDATE_TYPE" value="REBASE" />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectColorInfo">{
&quot;customColor&quot;: &quot;&quot;,
&quot;associatedIndex&quot;: 7
}</component>
<component name="ProjectId" id="2dQy59zNnKNFZ7jayKJA4B62ZrV" />
<component name="ProjectId" id="2eOTokNMuBujowqd2B2FN0Cy4oP" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"Python.ColorViewer.executor": "Run",
"Python.FRRobot.executor": "Run",
"Python.ObjectClassify.executor": "Run",
"Python.OrbbecCamera.executor": "Run",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"last_opened_file_path": "F:/Projects/PyCharmProjects/graduation_design/.venv/Lib/site-packages",
"last_opened_file_path": "F:/Projects/PyCharmProjects/graduation_design/img_process/orbbec_camera",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
@ -54,12 +104,10 @@
}]]></component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="F:\Projects\PyCharmProjects\graduation_design\.venv\Lib\site-packages" />
<recent name="F:\Projects\PyCharmProjects\graduation_design\img_process\orbbec_camera" />
</key>
<key name="MoveFile.RECENT_KEYS">
<recent name="F:\Projects\PyCharmProjects\graduation_design\abandon_code" />
<recent name="F:\Projects\PyCharmProjects\graduation_design\img_process\orbbec_camera" />
<recent name="F:\Projects\PyCharmProjects\graduation_design\img_process" />
<recent name="F:\Projects\PyCharmProjects\graduation_design\.venv\Lib\site-packages" />
</key>
</component>
<component name="SharedIndexes">
@ -72,47 +120,25 @@
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="应用程序级" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="默认任务">
<changelist id="84cc2bfb-62dd-4e3b-8b7e-c4595a290c7c" name="更改" comment="" />
<created>1709954410708</created>
<changelist id="ed9ba2d3-2366-49b5-9e96-c67755cbd3c6" name="更改" comment="" />
<created>1711774803960</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1709954410708</updated>
<workItem from="1709954412113" duration="122000" />
<workItem from="1709962300718" duration="10000" />
<workItem from="1709962407317" duration="276000" />
<workItem from="1709964790465" duration="236000" />
<workItem from="1710068496099" duration="2000" />
<workItem from="1710122374970" duration="76000" />
<workItem from="1710487637575" duration="384000" />
<workItem from="1710823028137" duration="189000" />
<workItem from="1710823225842" duration="1580000" />
<workItem from="1711185870102" duration="843000" />
<workItem from="1711186752259" duration="36000" />
<workItem from="1711186861314" duration="136000" />
<workItem from="1711198088313" duration="47000" />
<workItem from="1711243148074" duration="1422000" />
<updated>1711774803960</updated>
<workItem from="1711774807449" duration="391000" />
<workItem from="1711775397606" duration="189000" />
<workItem from="1711775744696" duration="1324000" />
<workItem from="1711782281772" duration="70000" />
<workItem from="1711784888401" duration="87000" />
</task>
<task id="LOCAL-00001" summary="一点修改">
<option name="closed" value="true" />
<created>1709954516162</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1709954516162</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="一点修改" />
<option name="LAST_COMMIT_MESSAGE" value="一点修改" />
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/graduation_design$ColorViewer.coverage" NAME="ColorViewer 覆盖结果" MODIFIED="1711186048389" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/img_process" />
<SUITE FILE_PATH="coverage/graduation_design$ObjectClassify.coverage" NAME="ObjectClassify 覆盖结果" MODIFIED="1711243586405" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/img_process" />
<SUITE FILE_PATH="coverage/graduation_design$OrbbecCamera.coverage" NAME="OrbbecCamera 覆盖结果" MODIFIED="1711244643941" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/img_process/orbbec_camera" />
<SUITE FILE_PATH="coverage/graduation_design$FRRobot.coverage" NAME="FRRobot 覆盖结果" MODIFIED="1711776143556" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/robot_control" />
<SUITE FILE_PATH="coverage/graduation_design$ObjectClassify.coverage" NAME="ObjectClassify 覆盖结果" MODIFIED="1711784964632" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/img_process" />
<SUITE FILE_PATH="coverage/graduation_design$OrbbecCamera.coverage" NAME="OrbbecCamera 覆盖结果" MODIFIED="1711784959884" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/img_process/orbbec_camera" />
</component>
</project>

View File

@ -0,0 +1,122 @@
from time import sleep
import cv2
import numpy as np
from orbbec_camera.OrbbecCamera import OrbbecCamera
# 图像预处理
def img_Threshold(src_gauss):
imgHSV = cv2.cvtColor(src_gauss, cv2.COLOR_BGR2HSV)
# cv2.imshow("imgHSV", imgHSV)
# # 三通道分割
h, s, v = cv2.split(imgHSV)
# 检测差值
hs_diff = cv2.absdiff(h, s)
# cv2.imshow("hs_diff", hs_diff)
sv_diff = cv2.absdiff(s, v)
# cv2.imshow("sv_diff", sv_diff)
hv_diff = cv2.absdiff(h, v)
# cv2.imshow("hv_diff", hv_diff)
v1 = np.mean(hs_diff) # 取每个通道的均值
v2 = np.mean(sv_diff)
v3 = np.mean(hv_diff)
v_max = (v1 if v1 > v2 else v2) if (v1 if v1 > v2 else v2) > v3 else v3 # 比较均值得到最大值
print(v_max, v3)
if v_max > 8:
if abs(v_max - v1) < 0.01:
gray = hs_diff.copy()
elif abs(v_max - v2) < 0.01:
gray = sv_diff.copy()
elif abs(v_max - v3) < 0.01:
gray = hv_diff.copy()
return gray
# 图像开运算和闭运算(形态学处理)
def img_dila_eros(src_img):
# 3. 膨胀和腐蚀操作的核函数
element1 = cv2.getStructuringElement(cv2.MORPH_RECT, (4, 3))
element2 = cv2.getStructuringElement(cv2.MORPH_RECT, (4, 3))
element3 = cv2.getStructuringElement(cv2.MORPH_RECT, (5, 5))
# 4. 膨胀一次,让轮廓突出
src_img = cv2.dilate(src_img, element2)
# 5. 腐蚀一次,去掉细节,如表格线等。注意这里去掉的是竖直的线
src_img = cv2.erode(src_img, element1)
# 6. 再次膨胀,让轮廓明显一些
# src_img = cv2.dilate(src_img, element2)
src_img = cv2.morphologyEx(src_img, cv2.MORPH_OPEN, element3) # 开运算去掉噪点
return src_img
# 定位和角度测量
def getContours(src, img):
# 查找轮廓cv2.RETR_ExTERNAL=获取外部轮廓点, CHAIN_APPROX_NONE = 得到所有的像素点,CHAIN_APPROX_SIMPLE=得到轮廓的四个点
contours, hierarchy = cv2.findContours(img, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
# 循环轮廓,判断每一个形状
for cnt in contours:
# 获取轮廓面积
area = cv2.contourArea(cnt)
print("轮廓像素面积:", area) # 打印所有轮廓面积
# 当面积大于20000代表有形状存在
if area < 20000:
pass
# print("轮廓像素面积:", area) # 打印符合条件轮廓面积
# 计算所有轮廓的周长,便于做多边形拟合
# 多边形拟合,获取每个形状的边
approx = cv2.approxPolyDP(cnt, 0.02 * cv2.arcLength(cnt, True), True) # 拟合的多边形的边数
print("approx:", len(approx))
objCor = len(approx) # 轮廓的边长
rect = cv2.minAreaRect(approx) # 最小外接矩形
box = cv2.boxPoints(rect) # boxPoints返回四个点顺序右下→左下→左上→右上
box = np.int0(box)
center = rect[0] # 中心坐标
center_array = np.array(center)
int_center = center_array.astype(int)
angle = rect[2] # 旋转角度
# 画出边界
if objCor > 4:
cv2.circle(src, (int(rect[0][0]), int(rect[0][1])), int(rect[1][0] / 2), (255, 255, 255), 5)
else:
cv2.drawContours(src, [box], 0, (255, 255, 255), 3) # 画出多边形形状
cv2.circle(src, (int(rect[0][0]), int(rect[0][1])), 3, (255, 255, 255), 5)
# 画中心,写角度
cv2.putText(src, "center:" + str(int_center), (10, 20), cv2.FONT_HERSHEY_COMPLEX, 0.5, (0, 0, 255), 1)
if objCor <= 4:
cv2.putText(src, "angle:" + str(round(angle)), (10, 40), cv2.FONT_HERSHEY_COMPLEX, 0.5, (0, 0, 255), 1)
else:
cv2.putText(src, "angle:" + "0", (10, 40), cv2.FONT_HERSHEY_COMPLEX, 0.5, (0, 0, 255), 1)
if __name__ == "__main__":
# 初始化摄像头
camera = OrbbecCamera('HW', True, image_width=640)
camera.run()
while True:
# 读取图片
image = camera.get_color_image()
if image is not None:
# 高斯滤波
gauss = cv2.GaussianBlur(image, (15, 15), 3)
# cv2.imshow("gauss", gauss)
# 图像预处理
gray = img_Threshold(gauss)
# 高斯滤波
gray = cv2.GaussianBlur(gray, (15, 15), 3)
# cv2.imshow("gray", gray)
# 自适应阈值二值化
binary = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY_INV, 11, 2)
# 图像形态学处理
binary = img_dila_eros(binary)
cv2.imshow("binary", binary)
# 获取轮廓 计算中心点坐标,尺寸;形状识别,颜色识别。
getContours(image, binary)
cv2.imshow("image", image)
sleep(1)
key = cv2.waitKey(1)
if key == ord('q'):
camera.stop()
break

View File

@ -1,79 +0,0 @@
import rospy, sys
import moveit_commander
from geometry_msgs.msg import PoseStamped, Pose
class MoveItIkDemo:
def __init__(self):
# 初始化move_group的API
moveit_commander.roscpp_initialize(sys.argv)
# 初始化ROS节点
rospy.init_node('moveit_ik_demo')
# 初始化需要使用move group控制的机械臂中的arm group
arm = moveit_commander.MoveGroupCommander('manipulator')
# 获取终端link的名称这个在setup assistant中设置过了
end_effector_link = arm.get_end_effector_link()
# 设置目标位置所使用的参考坐标系
reference_frame = 'base_link'
arm.set_pose_reference_frame(reference_frame)
# 当运动规划失败后,允许重新规划
arm.allow_replanning(True)
# 设置位置(单位:米)和姿态(单位:弧度)的允许误差
arm.set_goal_position_tolerance(0.001)
arm.set_goal_orientation_tolerance(0.01)
# 设置允许的最大速度和加速度
arm.set_max_acceleration_scaling_factor(0.5)
arm.set_max_velocity_scaling_factor(0.5)
# 控制机械臂先回到初始化位置
arm.set_named_target('home')
arm.go()
rospy.sleep(1)
# 设置机械臂工作空间中的目标位姿位置使用x、y、z坐标描述
# 姿态使用四元数描述基于base_link坐标系
target_pose = PoseStamped()
# 参考坐标系,前面设置了
target_pose.header.frame_id = reference_frame
target_pose.header.stamp = rospy.Time.now()
# 末端位置
target_pose.pose.position.x = 0.2593
target_pose.pose.position.y = 0.0636
target_pose.pose.position.z = 0.1787
# 末端姿态,四元数
target_pose.pose.orientation.x = 0.70692
target_pose.pose.orientation.y = 0.0
target_pose.pose.orientation.z = 0.0
target_pose.pose.orientation.w = 0.70729
# 设置机器臂当前的状态作为运动初始状态
arm.set_start_state_to_current_state()
# 设置机械臂终端运动的目标位姿
arm.set_pose_target(target_pose)
# arm.set_pose_target()
# 规划运动路径,返回虚影的效果
traj = arm.plan()
# 按照规划的运动路径控制机械臂运动
arm.execute(traj)
rospy.sleep(1) # 执行完成后休息1s
# 控制机械臂回到初始化位置
arm.set_named_target('home')
arm.go()
# 关闭并退出moveit
moveit_commander.roscpp_shutdown()
moveit_commander.os._exit(0)
if __name__ == "__main__":
MoveItIkDemo()

View File

@ -1,55 +0,0 @@
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
print("与机器人控制器建立连接", robot)
ret, version = robot.GetSDKVersion() # 查询SDK版本号
if ret == 0:
print("SDK版本号为", version)
else:
print("查询失败,错误码为", ret)
ret, ip = robot.GetControllerIP() # 查询控制器IP
if ret == 0:
print("控制器IP为", ip)
else:
print("查询失败,错误码为", ret)
#
# # 机器人进入或退出拖动示教模式
# ret = robot.Mode(1) # 机器人切入手动模式
# print("机器人切入手动模式", ret)
# time.sleep(1)
# ret = robot.DragTeachSwitch(1) # 机器人切入拖动示教模式,必须在手动模式下才能切入拖动示教模式
# print("机器人切入拖动示教模式", ret)
# time.sleep(1)
# ret, state = robot.IsInDragTeach() # 查询是否处于拖动示教模式1-拖动示教模式0-非拖动示教模式
# if ret == 0:
# print("当前拖动示教模式状态:", state)
# else:
# print("查询失败,错误码为:", ret)
# time.sleep(3)
# ret = robot.DragTeachSwitch(0) # 机器人切入非拖动示教模式,必须在手动模式下才能切入非拖动示教模式
# print("机器人切入非拖动示教模式", ret)
# time.sleep(1)
# ret, state = robot.IsInDragTeach() # 查询是否处于拖动示教模式1-拖动示教模式0-非拖动示教模式
# if ret == 0:
# print("当前拖动示教模式状态:", state)
# else:
# print("查询失败,错误码为:", ret)
# time.sleep(3)
#
# # 机器人上使能或下使能
# ret = robot.RobotEnable(0.5) # 机器人下使能
# print("机器人下使能", ret)
# time.sleep(3)
# ret = robot.RobotEnable(1) # 机器人上使能,机器人上电后默认自动上使能
# print("机器人上使能", ret)
#
# # 机器人手自动模式切换
# ret = robot.Mode(0) # 机器人切入自动运行模式
# print("机器人切入自动运行模式", ret)
# time.sleep(1)
# ret = robot.Mode(1) # 机器人切入手动模式
# print("机器人切入手动模式", ret)

Binary file not shown.

View File

@ -1,3 +1,5 @@
from time import sleep
from ultralytics import YOLO
import cv2
from orbbec_camera.OrbbecCamera import OrbbecCamera
@ -22,13 +24,17 @@ if __name__ == '__main__':
# imgsz: 图像的尺寸
# half: 是否使用FP16,可有效提升速度
# vid_stride: 帧预测间隔可降低算力消耗间隔x帧进行一次预测
classify.model.predict(source=color_image,
show=True,
conf=0.5,
half=True,
imgsz=classify.image_width,
verbose=False)
print("中心点的深度值: ", camera.get_center_distance(), "mm")
results = classify.model.predict(source=color_image,
show=True,
conf=0.5,
half=True,
imgsz=classify.image_width,
verbose=False,
vid_stride=1000)
# for r in results:
# print(r.boxes) # print the Boxes object containing the detection bounding boxes
# print("中心点的深度值: ", camera.get_center_distance(), "mm")
key = cv2.waitKey(1)
if key == ord('q'):
camera.stop()

View File

@ -30,7 +30,7 @@ class OrbbecCamera:
self.active = False # 控制捕获循环的标志
# 显示设置
self.width = image_width # 图像宽度
self.fps = 30 # 帧率
self.fps = 15 # 帧率
# 初始化相机设置
device_info = self.device.get_device_info() # 获取设备信息
@ -93,7 +93,7 @@ class OrbbecCamera:
return
while self.active:
try:
frames: FrameSet = self.pipeline.wait_for_frames(500) # 等待获取帧
frames: FrameSet = self.pipeline.wait_for_frames(500) # 等待获取帧,注意前面设计的帧率太低的话可能会报等待超时
if frames is None:
continue

View File

@ -0,0 +1,18 @@
from orbbec_camera.OrbbecCamera import OrbbecCamera
import cv2
camera = OrbbecCamera('HW', True, image_width=640)
camera.run()
counter = 0
while True:
color_image = camera.get_color_image()
if color_image is not None:
cv2.imwrite('image_' + str(counter) + '.png', color_image)
counter += 1
cv2.imshow('img', color_image)
key = cv2.waitKey(100)
if key == ord('q'):
camera.stop()
# cw.stop()
break

View File

@ -0,0 +1,21 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license
# Package-seg dataset by Ultralytics
# Documentation: https://docs.ultralytics.com/datasets/segment/package-seg/
# Example usage: yolo train data=package-seg.yaml
# parent
# ├── ultralytics
# └── datasets
# └── package-seg ← downloads here (102 MB)
# Train/val/test sets as 1) dir: path/to/imgs, 2) file: path/to/imgs.txt, or 3) list: [path/to/imgs1, path/to/imgs2, ..]
path: ../datasets/package-seg # dataset root dir
train: train/images # train images (relative to 'path') 1920 images
val: valid/images # val images (relative to 'path') 89 images
test: test/images # test images (relative to 'path') 188 images
# Classes
names:
0: package
# Download script/URL (optional)
download: https://ultralytics.com/assets/package-seg.zip

View File

@ -0,0 +1,5 @@
from ultralytics import YOLO
model = YOLO('yolov8n-seg.pt')
result = model.train(data='package-seg.yaml', epochs=100, imgsz=640)

Binary file not shown.

Binary file not shown.

33
robot_control/FRRobot.py Normal file
View File

@ -0,0 +1,33 @@
import Robot
import time
class FRRobot:
def __init__(self):
self.robotCTL = Robot.RPC('192.168.3.102')
self.speed = 20 # 速度百分比,[0~100]默认20
self.home = [] # 回零点
self.tool = 1 # 工具坐标系编号
self.user = 1 # 工件坐标系编号
# 工具坐标系参数
self.t_coord = [0, 0, 170, -180, 0, -45]
speed_error_code = self.robotCTL.SetSpeed(self.speed)
if speed_error_code != 0:
print("初始化全局速度错误:", speed_error_code)
tool_error_code = self.robotCTL.SetToolCoord(1, self.t_coord, 0, 0)
if tool_error_code != 0:
print("初始化工具坐标系错误:", tool_error_code)
if __name__ == '__main__':
robot = FRRobot()
# joint_pos1 = [-286, -456, 673, -179, 0, 90]
# ret = robot.robotCTL.SplineStart() # 样条运动开始
# if ret == 0:
# print("样条运动开始:", ret)
#
# ret = robot.robotCTL.SplinePTP(joint_pos1, robot.tool, robot.user, vel=2) # 样条运动PTP

View File

@ -1,26 +1,3 @@
# TODO: 导入机械臂控制相关的库根据实际使用的SDK
import FRRobot
# 机械臂控制
def initialize_arm_control():
# TODO: 初始化机械臂控制
pass
def move_arm_to_position(x, y, z):
# TODO: 移动机械臂到指定位置
pass
def grab_object():
# TODO: 控制机械臂抓取物体
pass
def release_object():
# TODO: 控制机械臂释放物体
pass
def move_object_to_location(object_coords, target_coords):
# TODO: 将物体从当前位置移动到目标位置
pass
robot = FRRobot.FRRobot()

View File

@ -0,0 +1,25 @@
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
#传送带跟踪抓取
robot.MoveL([-333.597, 60.354, 404.341, -179.143, -0.778, 91.275],0,0)
error =robot.ConveyorIODetect(1000)
print("传送带工件IO检测错误码",error)
error =robot.ConveyorGetTrackData(1)
print("获取物体当前位置错误码",error)
error =robot.ConveyorTrackStart(1)
print("传动带跟踪开始错误码",error)
error =robot.ConveyorTrackMoveL("cvrCatchPoint",0,0,vel = 60.0)
print("直线运动错误码",error)
error =robot.MoveGripper(1,55,20,20,30000,0)
print("夹爪控制错误码",error)
error =robot.ConveyorTrackMoveL("cvrRaisePoint",0,0,vel = 60.0)
print("直线运动错误码",error)
error = robot.ConveyorTrackEnd()
print("传动带跟踪结束错误码错误码",error)
error = robot.MoveL([-333.625, -229.039, 404.340, -179.141, -0.778, 91.276], 0, 0,vel =30)
error = robot.MoveL([-333.564, 332.204, 342.217, -179.145, -0.780, 91.268], 0, 0,vel =30)
error = robot.MoveGripper(1,100,10,21,30000,0)
print("夹爪控制错误码",error)

View File

@ -0,0 +1,18 @@
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
#传送带运动1-运动0-停止
status = 1
robot.ConveyorStartEnd(status)
#点记录
ret = robot.ConveyorPointIORecord()
print("记录IO检测点",ret)
ret = robot.ConveyorPointARecord()
print("记录A点",ret)
ret = robot.ConveyorRefPointRecord()
print("记录参考点",ret)
ret = robot.ConveyorPointBRecord()
print("记录B点",ret)

View File

@ -0,0 +1,13 @@
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
#参数配置
param=[1,10000,200,0,0,20]
ret = robot.ConveyorSetParam(param)
print("传送带参数配置错误码",ret)
time.sleep(1)
#抓取点补偿
comp = [0.00, 0.00, 0.00]
ret1 = robot.ConveyorCatchPointComp(comp)
print("传动带抓取点补偿错误码",ret1)

View File

@ -0,0 +1,45 @@
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
name = "/fruser/traj/trajHelix_aima_1.txt" #轨迹名
blend = 1 #是否平滑1-平滑0-不平滑
ovl = 50.0 #速度缩放
ft =[0.5, 0.5, 0.5, 0.5, 0.5, 0.5]
ret = robot.LoadTrajectoryJ(name,ovl) #轨迹预加载
print("轨迹预加载错误码",ret)
ret,P1 = robot.GetTrajectoryStartPose(name) #获取轨迹起始位姿
print ("获取轨迹起始位姿错误码",ret,"起始位姿",P1)
ret = robot.MoveL(P1,1,0) #运动到起始点
print("运动到起始点错误码",ret)
ret = robot.GetTrajectoryPointNum() #获取轨迹点编号
print("获取轨迹点编号错误码",ret)
time.sleep(10)
ret = robot.MoveTrajectoryJ() #轨迹复现
print("轨迹复现错误码",ret)
time.sleep(10)
ret = robot.SetTrajectoryJSpeed(ovl) #设置轨迹运行中的速度
print("设置轨迹运行中的速度错误码",ret)
time.sleep(1)
ret = robot.SetTrajectoryJForceTorque(ft) #设置轨迹运行中的力和扭矩
print("设置轨迹运行中的力和扭矩错误码",ret)
time.sleep(1)
ret = robot.SetTrajectoryJForceFx(0) #设置轨迹运行中的沿x方向的力
print("设置轨迹运行中的沿x方向的力错误码",ret)
time.sleep(1)
ret = robot.SetTrajectoryJForceFy(0) #设置轨迹运行中的沿y方向的力
print("设置轨迹运行中的沿y方向的力错误码",ret)
time.sleep(1)
ret = robot.SetTrajectoryJForceFz(0) #设置轨迹运行中的沿z方向的力
print("设置轨迹运行中的沿z方向的力错误码",ret)
time.sleep(1)
ret = robot.SetTrajectoryJTorqueTx(0) #设置轨迹运行中的绕x轴的扭矩
print("设置轨迹运行中的绕x轴的扭矩错误码",ret)
time.sleep(1)
ret = robot.SetTrajectoryJTorqueTy(0) #设置轨迹运行中的绕y轴的扭矩
print("设置轨迹运行中的绕y轴的扭矩错误码",ret)
time.sleep(1)
ret = robot.SetTrajectoryJTorqueTz(0) #设置轨迹运行中的绕z轴的扭矩
print("设置轨迹运行中的绕z轴的扭矩错误码",ret)
time.sleep(1)

View File

@ -0,0 +1,37 @@
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
J1=[75.005,-46.434,90.687,-133.708,-90.315,-27.139]
P2=[-77.24,-679.599,38.328,179.373,-0.028,-167.849]
P3=[77.24,-679.599,38.328,179.373,-0.028,-167.849]
#恒力控制参数
status = 1 #恒力控制开启标志0-关1-开
sensor_num = 1 #力传感器编号
is_select = [1,1,1,0,0,0] #六个自由度选择[fx,fy,fz,mx,my,mz]0-不生效1-生效
force_torque = [-10.0,-10.0,-10.0,0.0,0.0,0.0]
gain = [0.0005,0.0,0.0,0.0,0.0,0.0] #力PID参数力矩PID参数
adj_sign = 0 #自适应启停状态0-关闭1-开启
ILC_sign = 0 #ILC控制启停状态0-停止1-训练2-实操
max_dis = 1000.0 #最大调整距离
max_ang = 0.0 #最大调整角度
error = robot.MoveJ(J1,1,0)
print("关节空间运动到点1错误码",error)
#柔顺控制
error = robot.FT_Control(status,sensor_num,is_select,force_torque,gain,adj_sign,ILC_sign,max_dis,max_ang)
print("恒力控制开始错误码",error)
p = 0.00005 #位置调节系数或柔顺系数
force = 30.0 #柔顺开启力阈值单位N
error = robot.FT_ComplianceStart(p,force)
print("柔顺控制开始错误码",error)
error = robot.MoveL(P2,1,0,vel =10) #笛卡尔空间直线运动
print("笛卡尔空间直线运动到点2错误码", error)
error = robot.MoveL(P3,1,0,vel =10)
print("笛卡尔空间直线运动到点3错误码", error)
time.sleep(1)
error = robot.FT_ComplianceStop()
print("柔顺控制结束错误码",error)
status = 0
error = robot.FT_Control(status,sensor_num,is_select,force_torque,gain,adj_sign,ILC_sign,max_dis,max_ang)
print("恒力控制关闭错误码",error)

View File

@ -0,0 +1,28 @@
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
#恒力控制
status = 1 #恒力控制开启标志0-关1-开
sensor_num = 1 #力传感器编号
is_select = [0,0,1,0,0,0] #六个自由度选择[fx,fy,fz,mx,my,mz]0-不生效1-生效
force_torque = [0.0,0.0,-10.0,0.0,0.0,0.0]
gain = [0.0005,0.0,0.0,0.0,0.0,0.0] #力PID参数力矩PID参数
adj_sign = 0 #自适应启停状态0-关闭1-开启
ILC_sign = 0 #ILC控制启停状态0-停止1-训练2-实操
max_dis = 100.0 #最大调整距离
max_ang = 0.0 #最大调整角度
J1=[70.395, -46.976, 90.712, -133.442, -87.076, -27.138]
P2=[-123.978, -674.129, 44.308, -178.921, 2.734, -172.449]
P3=[123.978, -674.129, 42.308, -178.921, 2.734, -172.449]
error = robot.MoveJ(J1,1,0)
print("关节空间运动指令错误码",error)
error = robot.MoveL(P2,1,0)
print("笛卡尔空间直线运动指令错误码",error)
error = robot.FT_Control(status,sensor_num,is_select,force_torque,gain,adj_sign,ILC_sign,max_dis,max_ang)
print("恒力控制开启错误码",error)
error = robot.MoveL(P3,1,0) #笛卡尔空间直线运动
print("笛卡尔空间直线运动指令错误码",error)
status = 0
error = robot.FT_Control(status,sensor_num,is_select,force_torque,gain,adj_sign,ILC_sign,max_dis,max_ang)
print("恒力控制结束错误码",error)

View File

@ -0,0 +1,89 @@
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
#恒力控制
status = 1 #恒力控制开启标志0-关1-开
sensor_num = 1 #力传感器编号
is_select = [1,0,0,0,0,0] #六个自由度选择[fx,fy,fz,mx,my,mz]0-不生效1-生效
force_torque = [-2.0,0.0,0.0,0.0,0.0,0.0]
gain = [0.0002,0.0,0.0,0.0,0.0,0.0] #力PID参数力矩PID参数
adj_sign = 0 #自适应启停状态0-关闭1-开启
ILC_sign = 0 #ILC控制启停状态0-停止1-训练2-实操
max_dis = 15.0 #最大调整距离
max_ang = 0.0 #最大调整角度
#表面定位参数
rcs = 0 #参考坐标系0-工具坐标系1-基坐标系
direction = 1 #移动方向1-正方向2-负方向
axis = 1 #移动轴1-X,2-Y,3-Z
lin_v = 3.0 #探索直线速度单位mm/s
lin_a = 0.0 #探索直线加速度单位mm/s^2
disMax = 50.0 #最大探索距离单位mm
force_goal = 2.0 #动作终止力阈值单位N
P1=[-77.24,-679.599,58.328,179.373,-0.028,-167.849]
Robot.MoveCart(P1,1,0) #关节空间点到点运动
#x方向寻找中心
#第1个表面
error = robot.FT_CalCenterStart()
print("计算中间平面开始错误码",error)
error = robot.FT_Control(status,sensor_num,is_select,force_torque,gain,adj_sign,ILC_sign,max_dis,max_ang)
print("恒力控制开始错误码",error)
error = robot.FT_FindSurface(rcs,direction,axis,disMax,force_goal)
print("寻找X+表面错误码",error)
status = 0
error = robot.FT_Control(status,sensor_num,is_select,force_torque,gain,adj_sign,ILC_sign,max_dis,max_ang)
print("恒力控制结束错误码",error)
time.sleep(2)
error = robot.MoveCart(P1,1,0) #关节空间点到点运动
print("关节空间点到点运动错误码",error)
time.sleep(5)
#第2个表面
error = robot.FT_Control(status,sensor_num,is_select,force_torque,gain,adj_sign,ILC_sign,max_dis,max_ang)
print("恒力控制开始错误码",error)
direction = 2 #移动方向1-正方向2-负方向
error = robot.FT_FindSurface(rcs,direction,axis,disMax,force_goal)
print("寻找X—表面错误码",error)
status = 0
error = robot.FT_Control(status,sensor_num,is_select,force_torque,gain,adj_sign,ILC_sign,max_dis,max_ang)
print("恒力控制结束错误码",error)
#计算x方向中心位置
error,xcenter = robot.FT_CalCenterEnd()
print("计算X方向中间平面结束错误码",xcenter)
error = robot.MoveCart(xcenter,1,0)
print("关节空间点到点运动错误码",error)
time.sleep(1)
#y方向寻找中心
#第1个表面
error =robot.FT_CalCenterStart()
print("计算中间平面开始错误码",error)
error =robot.FT_Control(status,sensor_num,is_select,force_torque,gain,adj_sign,ILC_sign,max_dis,max_ang)
print("恒力控制开始错误码",error)
direction = 1 #移动方向1-正方向2-负方向
axis = 2 #移动轴1-X,2-Y,3-Z
disMax = 150.0 #最大探索距离单位mm
lin_v = 6.0 #探索直线速度单位mm/s
error =robot.FT_FindSurface(rcs,direction,axis,disMax,force_goal)
print("寻找表面Y+错误码",error)
status = 0
error =robot.FT_Control(status,sensor_num,is_select,force_torque,gain,adj_sign,ILC_sign,max_dis,max_ang)
print("恒力控制结束错误码",error)
error =robot.MoveCart(P1,1,0) #关节空间点到点运动
print("关节空间点到点运动错误码",error)
Robot.WaitMs(1000)
#第2个表面
error =robot.FT_Control(status,sensor_num,is_select,force_torque,gain,adj_sign,ILC_sign,max_dis,max_ang)
print("恒力控制开始错误码",error)
direction = 2 #移动方向1-正方向2-负方向
error =robot.FT_FindSurface(rcs,direction,axis,disMax,force_goal)
print("寻找表面Y-错误码",error)
status = 0
error =robot.FT_Control(status,sensor_num,is_select,force_torque,gain,adj_sign,ILC_sign,max_dis,max_ang)
print("恒力控制结束错误码",error)
#计算y方向中心位置
error,ycenter=robot.FT_CalCenterEnd()
print("计算中间平面Y方向结束错误码",ycenter)
error =robot.MoveCart(ycenter,1,0)
print("关节空间点到点运动错误码",error)

View File

@ -0,0 +1,24 @@
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
#碰撞守护
actFlag = 1 #开启标志0-关闭碰撞守护1-开启碰撞守护
sensor_num = 1 #力传感器编号
is_select = [1,1,1,1,1,1] #六个自由度选择[fx,fy,fz,mx,my,mz]0-不生效1-生效
force_torque = [0.0,0.0,0.0,0.0,0.0,0.0] #碰撞检测力和力矩检测范围force_torque-min_threshold,force_torque+max_threshold
max_threshold = [10.0,10.0,10.0,10.0,10.0,10.0] #最大阈值
min_threshold = [5.0,5.0,5.0,5.0,5.0,5.0] #最小阈值
P1=[-160.619,-586.138,384.988,-170.166,-44.782,169.295]
P2=[-87.615,-606.209,556.119,-102.495,10.118,178.985]
P3=[41.479,-557.243,484.407,-125.174,46.995,-132.165]
error = robot.FT_Guard(actFlag, sensor_num, is_select, force_torque, max_threshold, min_threshold) #开启碰撞守护
print("开启碰撞守护错误码",error)
error = robot.MoveL(P1,1,0) #笛卡尔空间直线运动
print("笛卡尔空间直线运动错误码",error)
error = robot.MoveL(P2,1,0)
print("笛卡尔空间直线运动错误码",error)
error = robot.MoveL(P3,1,0)
print("笛卡尔空间直线运动错误码",error)
actFlag = 0
error = robot.FT_Guard(actFlag, sensor_num, is_select, force_torque, max_threshold, min_threshold) #关闭碰撞守护
print("关闭碰撞守护错误码",error)

View File

@ -0,0 +1,27 @@
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
#负载辨识滤波初始化
error = robot.LoadIdentifyDynFilterInit()
print("LoadIdentifyDynFilterInit:",error)
#负载辨识变量初始化
error = robot.LoadIdentifyDynVarInit()
print("LoadIdentifyDynVarInit:",error)
joint_torque= [0,0,0,0,0,0]
joint_pos= [0,0,0,0,0,0]
gain=[0,0.05,0,0,0,0,0,0.02,0,0,0,0]
t =10
error,joint_pos=robot.GetActualJointPosDegree(1)
joint_pos[1] = joint_pos[1]+10
error,joint_torque=robot.GetJointTorques(1)
joint_torque[1] = joint_torque[1]+2
#负载辨识主程序
error = robot.LoadIdentifyMain(joint_torque, joint_pos, t)
print("LoadIdentifyMain:",error)
#获取负载辨识结果
error = robot.LoadIdentifyGetResult(gain)
print("LoadIdentifyGetResult:",error)

View File

@ -0,0 +1,47 @@
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
#负载辨识,此时末端安装要辨识的工具,工具安装在力传感器下方,末端竖直向下
error = robot.FT_SetRCS(0) #设置参考坐标系为工具坐标系0-工具坐标系1-基坐标系
print('设置参考坐标系错误码',error)
time.sleep(1)
tool_id = 10 #传感器坐标系编号
tool_coord = [0.0,0.0,35.0,0.0,0.0,0.0] # 传感器相对末端法兰位姿
tool_type = 1 # 0-工具1-传感器
tool_install = 0 # 0-安装末端1-机器人外部
error = robot.SetToolCoord(tool_id,tool_coord,tool_type,tool_install) #设置传感器坐标系,传感器相对末端法兰位姿
print('设置传感器坐标系错误码',error)
time.sleep(1)
error = robot.FT_PdIdenRecord(tool_id) #记录辨识数据
print('记录负载重量错误码',error)
time.sleep(1)
error = robot.FT_PdIdenRecord() #计算负载重量单位kg
print('计算负载重量错误码',error)
#负载质心辨识,机器人需要示教三个不同的姿态,然后记录辨识数据,最后计算负载质心
robot.Mode(1)
ret = robot.DragTeachSwitch(1) #机器人切入拖动示教模式,必须在手动模式下才能切入拖动示教模式
time.sleep(5)
ret = robot.DragTeachSwitch(0)
time.sleep(1)
error = robot.FT_PdCogIdenRecord(tool_id,1)
print('负载质心1错误码',error)#记录辨识数据
ret = robot.DragTeachSwitch(1) #机器人切入拖动示教模式,必须在手动模式下才能切入拖动示教模式
time.sleep(5)
ret = robot.DragTeachSwitch(0)
time.sleep(1)
error = robot.FT_PdCogIdenRecord(tool_id,2)
print('负载质心2错误码',error)
ret = robot.DragTeachSwitch(1) #机器人切入拖动示教模式,必须在手动模式下才能切入拖动示教模式
time.sleep(5)
ret = robot.DragTeachSwitch(0)
time.sleep(1)
error = robot.FT_PdCogIdenRecord(tool_id,3)
print('负载质心3错误码',error)
time.sleep(1)
error = robot.FT_PdCogIdenCompute()
print('负载质心计算错误码',error)

View File

@ -0,0 +1,33 @@
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
P = [36.794,-675.119, 65.379, -176.938, 2.535, -179.829]
#恒力参数
status = 1 #恒力控制开启标志0-关1-开
sensor_num = 1 #力传感器编号
is_select = [0,0,1,0,0,0] #六个自由度选择[fx,fy,fz,mx,my,mz]0-不生效1-生效
force_torque = [0.0,0.0,-10.0,0.0,0.0,0.0] #碰撞检测力和力矩检测范围force_torque-min_threshold,force_torque+max_threshold
gain = [0.0001,0.0,0.0,0.0,0.0,0.0] #力PID参数力矩PID参数
adj_sign = 0 #自适应启停状态0-关闭1-开启
ILC_sign = 0 #ILC控制启停状态0-停止1-训练2-实操
max_dis = 100.0 #最大调整距离
max_ang = 5.0 #最大调整角度
#旋转插入参数
rcs = 0 #参考坐标系0-工具坐标系1-基坐标系
forceInsertion = 2.0 #力或力矩阈值0~100单位N或Nm
orn = 1 #力的方向1-fz,2-mz
#默认参数 angVelRot旋转角速度单位 °/s 默认 3
#默认参数 angleMax最大旋转角度单位 ° 默认 5
#默认参数 angAccmax最大旋转加速度单位 °/s^2暂不使用 默认0
#默认参数 rotorn旋转方向1-顺时针2-逆时针 默认1
error = robot.MoveL(P,1,0) #笛卡尔空间直线运动至初始点
print("笛卡尔空间直线运动至初始点",error)
error = robot.FT_Control(status,sensor_num,is_select,force_torque,gain,adj_sign,ILC_sign,max_dis,max_ang)
print("恒力控制开启错误码",error)
error = robot.FT_RotInsertion(rcs,1,orn)
print("旋转插入错误码",error)
status = 0
error = robot.FT_Control(status,sensor_num,is_select,force_torque,gain,adj_sign,ILC_sign,max_dis,max_ang)
print("恒力控制关闭错误码",error)

View File

@ -0,0 +1,36 @@
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
company = 17 #传感器厂商17-坤维科技
device = 0 #传感器设备号
error = robot.FT_SetConfig(company, device) #配置力传感器
print("配置力传感器错误码",error)
config = robot.FT_GetConfig() #获取力传感器配置信息厂商编号下发比反馈大1
print('获取力传感器配置信息',config)
time.sleep(1)
error = robot.FT_Activate(0) #传感器复位
print("传感器复位错误码",error)
time.sleep(1)
error = robot.FT_Activate(1) #传感器激活
print("传感器激活错误码",error)
time.sleep(1)
error = robot.SetLoadWeight(0.0) #末端负载设置为零
print("末端负载设置为零错误码",error)
time.sleep(1)
error = robot.SetLoadCoord(0.0,0.0,0.0) #末端负载质心设置为零
print("末端质心设置为零错误码",error)
time.sleep(1)
error = robot.FT_SetZero(0) #传感器去除零点
print("传感器去除零点错误码",error)
time.sleep(1)
error = robot.FT_GetForceTorqueOrigin() #查询传感器原始数据
print("查询传感器原始数据",error)
error = robot.FT_SetZero(1) #传感器零点矫正,注意此时末端不能安装工具,只有力传感器
print("传感器零点矫正",error)
time.sleep(1)
error = robot.FT_GetForceTorqueRCS() #查询传感器坐标系下数据
print("查询传感器坐标系下数据",error)

View File

@ -0,0 +1,29 @@
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
P = [36.794,-675.119, 65.379, -176.938, 2.535, -179.829]
#恒力参数
status = 1 #恒力控制开启标志0-关1-开
sensor_num = 1 #力传感器编号
is_select = [0,0,1,0,0,0] #六个自由度选择[fx,fy,fz,mx,my,mz]0-不生效1-生效
force_torque = [0.0,0.0,-10.0,0.0,0.0,0.0]
gain = [0.0001,0.0,0.0,0.0,0.0,0.0] #力PID参数力矩PID参数
adj_sign = 0 #自适应启停状态0-关闭1-开启
ILC_sign = 0 #ILC控制启停状态0-停止1-训练2-实操
max_dis = 100.0 #最大调整距离
max_ang = 5.0 #最大调整角度
#螺旋线探索参数
rcs = 0 #参考坐标系0-工具坐标系1-基坐标系
fFinish = 10 #力或力矩阈值0~100单位N或Nm
error = robot.MoveL(P,1,0) #笛卡尔空间直线运动至初始点
print("笛卡尔空间直线运动至初始点",error)
is_select = [0,0,1,1,1,0] #六个自由度选择[fx,fy,fz,mx,my,mz]0-不生效1-生效
error = robot.FT_Control(status,sensor_num,is_select,force_torque,gain,adj_sign,ILC_sign,max_dis,max_ang)
print("恒力控制开启错误码",error)
error = robot.FT_SpiralSearch(rcs,fFinish,max_vel=3)
print("螺旋线探索错误码",error)
status = 0
error = robot.FT_Control(status,sensor_num,is_select,force_torque,gain,adj_sign,ILC_sign,max_dis,max_ang)
print("恒力控制关闭错误码",error)

View File

@ -0,0 +1,31 @@
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
P = [36.794,-675.119, 65.379, -176.938, 2.535, -179.829]
#恒力参数
status = 1 #恒力控制开启标志0-关1-开
sensor_num = 1 #力传感器编号
is_select = [0,0,1,0,0,0] #六个自由度选择[fx,fy,fz,mx,my,mz]0-不生效1-生效
force_torque = [0.0,0.0,-10.0,0.0,0.0,0.0]
gain = [0.0001,0.0,0.0,0.0,0.0,0.0] #力PID参数力矩PID参数
adj_sign = 0 #自适应启停状态0-关闭1-开启
ILC_sign = 0 #ILC控制启停状态0-停止1-训练2-实操
max_dis = 100.0 #最大调整距离
max_ang = 5.0 #最大调整角度
#直线插入参数
rcs = 0 #参考坐标系0-工具坐标系1-基坐标系
force_goal = 10.0 #力或力矩阈值0~100单位N或Nm
disMax = 100.0 #最大插入距离单位mm
linorn = 1 #插入方向1-正方向2-负方向
#默认参数 lin_v直线速度单位 mm/s 默认1
#默认参数 lin_a直线加速度单位 mm/s^2暂不使用 默认0
error = robot.MoveL(P,1,0) #笛卡尔空间直线运动至初始点
print("笛卡尔空间直线运动至初始点",error)
error = robot.FT_Control(status,sensor_num,is_select,force_torque,gain,adj_sign,ILC_sign,max_dis,max_ang)
print("恒力控制开启错误码",error)
error = robot.FT_LinInsertion(rcs,force_goal,disMax,linorn)
print("直线插入错误码",error)
status = 0
error = robot.FT_Control(status,sensor_num,is_select,force_torque,gain,adj_sign,ILC_sign,max_dis,max_ang)
print("恒力控制关闭错误码",error)

View File

@ -0,0 +1,5 @@
import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
error = robot.GetDHCompensation()
print(error)

View File

@ -0,0 +1,74 @@
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
# 查询状态
ret = robot.GetRobotInstallAngle()
print("获取机器人安装角度", ret)
ret = robot.GetActualJointPosDegree()
print("获取当前关节位置 (角度)", ret)
ret = robot.GetActualJointPosRadian()
print("获取当前关节位置 (弧度)", ret)
ret = robot.GetActualJointSpeedsDegree()
print("获取关节反馈速度-deg/s", ret)
ret = robot.GetTargetTCPCompositeSpeed()
print("获取TCP指令合速度", ret)
ret = robot.GetActualTCPCompositeSpeed()
print("获取TCP反馈合速度", ret)
ret = robot.GetTargetTCPSpeed()
print("获取TCP指令速度", ret)
ret = robot.GetActualTCPSpeed()
print("获取TCP反馈速度", ret)
ret = robot.GetActualTCPPose()
print("获取当前工具位姿", ret)
ret = robot.GetActualTCPNum()
print("获取当前工具坐标系编号", ret)
ret = robot.GetActualWObjNum()
print("获取当前工件坐标系编号", ret)
ret = robot.GetActualToolFlangePose()
print("获取当前末端法兰位姿", ret)
ret = robot.GetJointTorques()
print("获取当前关节转矩", ret)
ret = robot.GetTargetPayload(0)
print("获取当前负载的质量", ret)
ret = robot.GetTargetPayloadCog(0)
print("获取当前负载的质心", ret)
ret = robot.GetRobotCurJointsConfig()
print("获取机器人当前关节配置", ret)
ret = robot.GetSystemClock()
print("获取系统时间", ret)
ret = robot.GetDefaultTransVel()
print("获取默认速度", ret)
ret = robot.GetTCPOffset()
print("获取当前工具坐标系", ret)
ret = robot.GetWObjOffset()
print("获取当前工件坐标系", ret)
ret = robot.GetJointSoftLimitDeg()
print("获取关节软限位角度", ret)
ret = robot.GetRobotMotionDone()
print("查询机器人运动是否完成", ret)
ret = robot.GetRobotErrorCode()
print("查询机器人错误码", ret)
ret = robot.GetRobotTeachingPoint("11")
print("查询机器人示教管理点位数据错误码", ret)
J1=[90.442,-100.149,-90.699,-60.347,90.580,-47.174]
P1=[70.414,368.526,338.135,-178.348,-0.930,52.611]
ret = robot.GetInverseKin(0,P1,config=-1)
print("逆运动学,笛卡尔位姿求解关节位置", ret)
ret = robot.GetInverseKinRef(0,P1,J1)
print("逆运动学,工具位姿求解关节位置,参考指定关节位置求解", ret)
ret = robot.GetInverseKinHasSolution(0,P1,J1)
print("逆运动学,工具位姿求解关节位置是否有解", ret)
ret = robot.GetForwardKin(J1)
print("正运动学,关节位置求解工具位姿", ret)
ret = robot.GetRobotInstallAngle()
print("获取机器人安装角度", ret)
ret = robot.GetSSHKeygen() #获取SSH
print("获取SSH", ret)
ret = robot.ComputeFileMD5("/fruser/11.lua") #计算指定路径下文件的MD5值
print("计算指定路径下文件的MD5值", ret)

View File

@ -0,0 +1,17 @@
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
ret = robot.GetSoftwareVersion()
print("GetSoftwareVersion()", ret)
ret = robot.GetSlaveHardVersion()
print("GetSlaveHardVersion()", ret)
ret = robot.GetSlaveFirmVersion()
print("GetSlaveFirmVersion()", ret[0])
print("GetSlaveFirmVersion()driver1", ret[1])
print("GetSlaveFirmVersion()driver2", ret[2])
print("GetSlaveFirmVersion()driver3", ret[3])
print("GetSlaveFirmVersion()driver4", ret[4])
print("GetSlaveFirmVersion()driver5", ret[5])
print("GetSlaveFirmVersion()driver6", ret[6])
print("GetSlaveFirmVersion()end", ret[7])

View File

@ -0,0 +1,72 @@
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
# 设置控制箱DO
for i in range(0,16):
error = robot.SetDO(i,1) #打开控制箱DO
error = robot.WaitMs(1000)
print("WaitMs错误码:",error)
for i in range(0,16):
robot.SetDO(i,0) #关闭控制箱DO
robot.WaitMs(1000)
# 设置工具DO
error_tooldo = 0
for i in range(0,2):
error = robot.SetToolDO(i,1) #打开工具DO
robot.WaitMs(1000)
for i in range(0,2):
error = robot.SetToolDO(i,0) #关闭工具DO
# 设置控制箱AO
error = robot.SetAO(0,100.0)
print("设置AO0错误码:", error)
error = robot.SetAO(1,100.0)
print("设置AO1错误码:", error)
# 设置工具AO
error = robot.SetToolAO(0,100.0)
print("设置ToolAO0错误码:", error)
robot.WaitMs(1000)
error = robot.SetToolAO(0,0.0)
print("设置ToolAO0错误码:", error)
# 获取控制箱DI
error = robot.GetDI(0,0)
print("获取DI0",error)
# 获取工具DI
tool_di = robot.GetToolDI(1,0)
print("获取ToolDI",tool_di)
# 获取控制箱AI
error = robot.GetAI(0)
print("获取控制箱AI0",error)
# 获取工具AI
error = robot.GetToolAI(0)
print("获取ToolAI0",error)
max_waittime = 2000
#等待控制箱DI
error = robot.WaitDI(0,1,max_waittime,0)
print("WaitDI错误码",error)
#等待控制箱多路DI
error = robot.WaitMultiDI(1,3,1,max_waittime,0)
print("WaitMultiDI错误码",error)
#等待工具DI
error = robot.WaitToolDI(1,1,max_waittime,0)
print("WaitToolDI错误码",error)
#等待控制箱AI
error = robot.WaitAI(0,0,50,max_waittime,1) #忽略超时提示程序继续执行
print("WaitAI错误码",error)
#等待工具AI
error = robot.WaitToolAI(0,0,50,max_waittime,0)
print("WaitToolAI错误码",error)

View File

@ -0,0 +1,107 @@
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
# 机器人单轴点动
robot.StartJOG(0,1,0,20.0,20.0,30.0) # 单关节运动,StartJOG为非阻塞指令运动状态下接收其他运动指令包含StartJOG会被丢弃
time.sleep(1)
#机器人单轴点动减速停止
# ret = robot.StopJOG(1)
# print(ret)
#机器人单轴点动立即停止
robot.ImmStopJOG()
robot.StartJOG(0,2,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(0,3,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(0,4,1,20.0,vel=40)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(0,5,1,20.0,acc=50)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(0,6,1,20.0,20.0,30.0)
time.sleep(1)
robot.ImmStopJOG()
# 基坐标
robot.StartJOG(2,1,0,20.0) #基坐标系下点动
time.sleep(1)
#机器人单轴点动减速停止
# Robot.StopJOG(3)
# #机器人单轴点动立即停止
robot.ImmStopJOG()
robot.StartJOG(2,1,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(2,2,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(2,3,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(2,4,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(2,5,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(2,6,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
# 工具坐标
robot.StartJOG(4,1,0,20.0,20.0,100.0) #工具坐标系下点动
time.sleep(1)
#机器人单轴点动减速停止
# Robot.StopJOG(5)
# #机器人单轴点动立即停止
robot.ImmStopJOG()
robot.StartJOG(4,1,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(4,2,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(4,3,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(4,4,1,20.0,20.0,100.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(4,5,1,20.0,vel=10.0,acc=20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(4,6,1,20.0,acc=40.0)
time.sleep(1)
robot.ImmStopJOG()
# 工件坐标
robot.StartJOG(8,1,0,20.0,20.0,100.0) #工件坐标系下点动
time.sleep(1)
#机器人单轴点动减速停止
# Robot.StopJOG(9)
# #机器人单轴点动立即停止
robot.ImmStopJOG()
robot.StartJOG(8,1,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(8,2,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(8,3,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(8,4,1,20.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(8,5,1,20.0,vel=30.0)
time.sleep(1)
robot.ImmStopJOG()
robot.StartJOG(8,6,1,20.0,20.0,acc=90.0)
time.sleep(1)
robot.ImmStopJOG()

View File

@ -0,0 +1,39 @@
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.3.102')
desc_pos1 = [236.794, -475.119, 65.379, -176.938, 2.535, -179.829]
desc_posc1 = [266.794, -455.119, 65.379, -176.938, 2.535, -179.829] # MoveC过渡点
desc_posc2 = [286.794, -475.119, 65.379, -176.938, 2.535, -179.829] # MoveC目标点
desc_pos2 = [236.794, -475.119, 65.379, -176.938, 2.535, -179.829]
desc_posc3 = [256.794, -435.119, 65.379, -176.938, 2.535, -179.829] # Circle路径点
desc_posc4 = [286.794, -475.119, 65.379, -176.938, 2.535, -179.829] # Circle目标点
desc_pos3 = [236.794, -475.119, 65.379, -176.938, 2.535, -179.829]
desc_pos_spiral = [236.794, -475.119, -65.379, -176.938, 2.535, -179.829] # Spiral目标点
# 螺旋线参数[circle_num,circle_angle,rad_init,rad_add,rotaxis_add,rot_direction]
# circle_num:螺旋圈数circle_angle:螺旋倾角rad_init:螺旋初始半径rad_add:半径增量,
# rotaxis_add:转轴方向增量rot_direction:旋转方向0-顺时针1-逆时针
param = [5.0, 10, 30, 10, 5, 0]
tool = 0 # 工具坐标系编号
user = 0 # 工件坐标系编号
ret = robot.MoveL(desc_pos1, tool, user, vel=30, acc=100)
print("笛卡尔空间直线运动:错误码", ret)
ret = robot.MoveC(desc_posc1, tool, user, desc_posc2, tool, user) # 笛卡尔空间圆弧运动
print("笛卡尔空间圆弧运动:错误码", ret)
robot.MoveL(desc_pos2, tool, user, vel=40, acc=100)
print("笛卡尔空间直线运动:错误码", ret)
ret = robot.Circle(desc_posc3, tool, user, desc_posc4, tool, user, vel_t=40, offset_flag=1,
offset_pos=[5, 10, 15, 0, 0, 1]) # 笛卡尔空间圆弧运动
print("笛卡尔空间圆弧运动:错误码", ret)
ret = robot.NewSpiral(desc_pos_spiral, tool, user, param, vel=40) # 笛卡尔空间螺旋线运动
print("笛卡尔空间螺旋线运动:错误码", ret)

View File

@ -0,0 +1,45 @@
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.3.102')
desc_pos1 = [36.794, -475.119, 65.379, -176.938, 2.535, -179.829]
desc_pos2 = [136.794, -475.119, 65.379, -176.938, 2.535, -179.829]
desc_pos3 = [236.794, -475.119, 65.379, -176.938, 2.535, -179.829]
joint_pos4 = [-83.24, -96.476, 93.688, -114.079, -62, -100]
joint_pos5 = [-43.24, -70.476, 93.688, -114.079, -62, -80]
joint_pos6 = [-83.24, -96.416, 43.188, -74.079, -80, -10]
desc_pos7 = [236.794, -475.119, 65.379, -176.938, 2.535, -179.829]
desc_pos8 = [236.794, -575.119, 165.379, -176.938, 2.535, -179.829]
desc_pos9 = [236.794, -475.119, 265.379, -176.938, 2.535, -179.829]
tool = 0 # 工具坐标系编号
user = 0 # 工件坐标系编号
ret = robot.MoveL(desc_pos1, tool, user) # 笛卡尔空间直线运动
print("笛卡尔空间直线运动点1:错误码", ret)
robot.MoveL(desc_pos2, tool, user, vel=30, acc=100)
print("笛卡尔空间直线运动点2:错误码", ret)
robot.MoveL(desc_pos3, tool, user, offset_flag=1, offset_pos=[10, 10, 10, 0, 0, 0])
print("笛卡尔空间直线运动点3:错误码", ret)
ret = robot.MoveJ(joint_pos4, tool, user, vel=30) # 关节空间运动
print("关节空间运动点4:错误码", ret)
ret = robot.MoveJ(joint_pos5, tool, user)
print("关节空间运动点5:错误码", ret)
robot.MoveJ(joint_pos6, tool, user, offset_flag=1, offset_pos=[10, 10, 10, 0, 0, 0])
print("关节空间运动点6:错误码", ret)
robot.MoveCart(desc_pos7, tool, user)
print("笛卡尔空间点到点运动点7:错误码", ret)
robot.MoveCart(desc_pos8, tool, user, vel=30)
print("笛卡尔空间点到点运动点8:错误码", ret)
robot.MoveCart(desc_pos9, tool, user, )
print("笛卡尔空间点到点运动点9:错误码", ret)

View File

@ -0,0 +1,39 @@
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.3.102')
desc_pos1 = [-187.519, 319.248, 397, -157.278, -31.188, 107.199]
desc_pos2 = [-187.519, 310.248, 297, -157.278, -31.188, 107.199]
desc_pos3 = [-127.519, 256.248, 312, -147.278, -51.588, 107.199]
joint_pos1 = [-83.24, -96.476, 93.688, -114.079, -62, -100]
desc_pos4 = [-140.519, 219.248, 300, -137.278, -11.188, 127.199]
desc_pos5 = [-187.519, 319.248, 397, -157.278, -31.188, 107.199]
desc_pos6 = [-207.519, 229.248, 347, -157.278, -31.188, 107.199]
tool = 0 # 工具坐标系编号
user = 0 # 工件坐标系编号
flag = 0 # 0-基坐标系下/工件坐标系下偏移2-工具坐标系下偏移
offset_pos = [10, 20, 30, 0, 0, 0] # 位姿偏移量
ret = robot.MoveL(desc_pos1, tool, user, joint_pos=joint_pos1) # 笛卡尔空间直线运动
print("笛卡尔空间直线运动点1:错误码", ret)
ret = robot.StopMotion() # 终止运动
print("终止运动:错误码", ret)
robot.MoveL(desc_pos2, tool, user, vel=40, acc=100)
print("笛卡尔空间直线运动点2:错误码", ret)
ret = robot.PointsOffsetEnable(flag, offset_pos)
print("点位整体偏移开始:错误码", ret)
robot.MoveL(desc_pos3, tool, user, offset_flag=1, offset_pos=[10, 10, 10, 0, 0, 0])
print("笛卡尔空间直线运动点3:错误码", ret)
robot.MoveL(desc_pos4, tool, user, vel=30, acc=100)
print("笛卡尔空间直线运动点4:错误码", ret)
robot.MoveL(desc_pos5, tool, user)
print("笛卡尔空间直线运动点5:错误码", ret)
ret = robot.PointsOffsetDisable()
print("点位整体偏移结束:错误码", ret)

View File

@ -0,0 +1,57 @@
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
print("与机器人控制器建立连接",robot)
ret,version = robot.GetSDKVersion() #查询SDK版本号
if ret ==0:
print("SDK版本号为", version )
else:
print("查询失败,错误码为",ret)
ret,ip = robot.GetControllerIP() #查询控制器IP
if ret ==0:
print("控制器IP为", ip)
else:
print("查询失败,错误码为",ret)
#机器人进入或退出拖动示教模式
ret = robot.Mode(1) #机器人切入手动模式
print("机器人切入手动模式", ret)
time.sleep(1)
ret = robot.DragTeachSwitch(1) #机器人切入拖动示教模式,必须在手动模式下才能切入拖动示教模式
print("机器人切入拖动示教模式", ret)
time.sleep(1)
ret,state = robot.IsInDragTeach() #查询是否处于拖动示教模式1-拖动示教模式0-非拖动示教模式
if ret == 0:
print("当前拖动示教模式状态:", state)
else:
print("查询失败,错误码为:",ret)
time.sleep(3)
ret = robot.DragTeachSwitch(0) #机器人切入非拖动示教模式,必须在手动模式下才能切入非拖动示教模式
print("机器人切入非拖动示教模式", ret)
time.sleep(1)
ret,state = robot.IsInDragTeach() #查询是否处于拖动示教模式1-拖动示教模式0-非拖动示教模式
if ret == 0:
print("当前拖动示教模式状态:", state)
else:
print("查询失败,错误码为:",ret)
time.sleep(3)
#机器人上使能或下使能
ret = robot.RobotEnable(0.5) #机器人下使能
print("机器人下使能", ret)
time.sleep(3)
ret = robot.RobotEnable(1) #机器人上使能,机器人上电后默认自动上使能
print("机器人上使能", ret)
#机器人手自动模式切换
ret = robot.Mode(0) #机器人切入自动运行模式
print("机器人切入自动运行模式", ret)
time.sleep(1)
ret = robot.Mode(1) #机器人切入手动模式
print("机器人切入手动模式", ret)

View File

@ -0,0 +1,88 @@
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
error = robot.SetSpeed(20)
print("设置全局速度错误码:",error)
error_value = 0
for i in range(1,21):
error = robot.SetSysVarValue(i,10)
if error != 0:
error_value =error
print("设置系统变量1-21为10,错误码",error_value)
robot.WaitMs(1000)
for i in range(1,21):
sys_var = robot.GetSysVarValue(i)
print("系统变量编号:",i,"",sys_var)
t_coord = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
robot.SetToolList(0,[0,0,0,0,0,0],0,0)#设置参考点前应当将工具和工件号坐标系切换至0
robot.SetWObjList(0,[0,0,0,0,0,0])
for i in range(1, 7):
robot.DragTeachSwitch(1)
error = robot.SetToolPoint(i) # 实际应当控制机器人按照要求移动到合适位置后再发送指令
print("六点法设置工具坐标系,记录点", i, "错误码", error)
time.sleep(1)
robot.DragTeachSwitch(0)
time.sleep(1)
error, t_coord = robot.ComputeTool()
print("六点法计算工具坐标系错误码", error, "工具TCP", t_coord)
robot.SetToolList(0,[0,0,0,0,0,0],0,0)#设置参考点前应当将工具和工件号坐标系切换至0
robot.SetWObjList(0,[0,0,0,0,0,0])
for i in range(1, 5):
robot.DragTeachSwitch(1) # 切入拖动示教模式
time.sleep(1)
error = robot.SetTcp4RefPoint(i) # 应当控制机器人按照要求移动到合适位置后再发送指令
print("四点法设置工具坐标系,记录点", i, "错误码", error)
robot.DragTeachSwitch(0)
time.sleep(1)
error, t_coord = robot.ComputeTcp4()
print("四点法设置工具坐标系错误码", error, "工具TCP", t_coord)
error = robot.SetToolCoord(10,t_coord,0,0)
print("设置工具坐标系错误码",error)
error = robot.SetToolList(10,t_coord,0,0)
print("设置工具坐标系列表错误码",error)
etcp = [1.0,2.0,3.0,4.0,5.0,6.0]
etool = [21.0,22.0,23.0,24.0,25.0,26.0]
robot.SetToolList(0,[0,0,0,0,0,0],0,0)#设置参考点前应当将工具和工件号坐标系切换至0
robot.SetWObjList(0,[0,0,0,0,0,0])
for i in range(1,4):
error = robot.SetExTCPPoint(i) #应当控制机器人按照要求移动到合适位置后再发送指令
print("三点法设置外部工具坐标系,记录点",i,"错误码",error)
time.sleep(1)
error,etcp = robot.ComputeExTCF()
print("三点法设置外部工具坐标系错误码",error,"外部工具TCP",etcp)
error = robot.SetExToolCoord(10,etcp,etool)
print("设置外部工具坐标系错误码",error)
error = robot.SetExToolList(10,etcp,etool)
print("设置外部工具坐标系列表错误码",error)
w_coord = [11.0,12.0,13.0,14.0,15.0,16.0]
robot.SetToolList(0,[0,0,0,0,0,0],0,0)#设置参考点前应当将工具和工件号坐标系切换至0
robot.SetWObjList(0,[0,0,0,0,0,0])
for i in range(1,4):
error = robot.SetWObjCoordPoint(i) #实际应当控制机器人按照要求移动到合适位置后再发送指令
print("三点法设置工件坐标系,记录点",i,"错误码",error)
time.sleep(1)
error, w_coord = robot.ComputeWObjCoord(1)
print("三点法计算工件坐标系错误码",error,"工件坐标系", w_coord)
error = robot.SetWObjCoord(11,w_coord)
print("设置工件坐标系错误码",error)
error = robot.SetWObjList(11,w_coord)
print("设置工件坐标系列表错误码",error)
error = robot.SetLoadWeight(0)#!!!负载重量设置应于实际相符(错误负载重量设置可能会导致拖动模式下机器人失控)
print("设置负载重量错误码",error)
error = robot.SetLoadCoord(3.0,4.0,5.0)
print("设置负载质心错误码",error)#!!!负载质心设置应于实际相符(错误负载质心设置可能会导致拖动模式下机器人失控)
error = robot.SetRobotInstallPos(0) #!!!安装方式设置应与实际一致 0-正装1-侧装2-倒装 (错误安装方式设置会导致拖动模式下机器人失控)
print("设置机器人安装方式错误码",error)
error = robot.SetRobotInstallAngle(0.0,0.0) #!!!安装角度设置应与实际一致 (错误安装角度设置会导致拖动模式下机器人失控)
print("设置机器人安装角度错误码",error)

View File

@ -0,0 +1,36 @@
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
desc_pos1=[-333.683,-228.968,404.329,-179.138,-0.781,91.261]
desc_pos2=[-333.683,-100.8,404.329,-179.138,-0.781,91.261]
zlength1 =10
zlength2 =15
zangle1 =10
zangle2 =15
#测试外设指令
ret = robot.SetGripperConfig(4,0) #配置夹爪
print("配置夹爪错误码", ret)
time.sleep(1)
config = robot.GetGripperConfig() #获取夹爪配置
print("获取夹爪配置",config)
error = robot.ActGripper(1,0) #激活夹爪
print("激活夹爪错误码",error)
time.sleep(1)
error = robot.ActGripper(1,1)#激活夹爪
print("激活夹爪错误码",error)
time.sleep(2)
error = robot.MoveGripper(1,100,48,46,30000,0) #控制夹爪
print("控制夹爪错误码",error)
time.sleep(3)
error = robot.MoveGripper(1,0,50,0,30000,0) #控制夹爪
print("控制夹爪错误码",error)
time.sleep(5)
error = robot.GetGripperMotionDone() #获取夹爪运动状态
print("获取夹爪运动状态错误码",error)
error = robot.ComputePrePick(desc_pos1, zlength1, zangle1) #计算预抓取点-视觉
print("计算预抓取点",error)
error = robot.ComputePrePick(desc_pos2, zlength2, zangle2) #计算撤退点-视觉
print("计算撤退点",error)

View File

@ -0,0 +1,19 @@
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
robot.LoggerInit()
robot.SetLoggerLevel(4)
i=0
while(i<20):
ret = robot.GetRobotInstallAngle()
ret = robot.GetActualJointPosDegree()
ret = robot.GetActualJointPosRadian()
ret = robot.GetActualJointSpeedsDegree()
ret = robot.GetTargetTCPCompositeSpeed()
ret = robot.GetActualTCPCompositeSpeed()
time.sleep(0.1)
i=i+1

View File

@ -0,0 +1,18 @@
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
robot.LuaDownLoad("test.lua", "D://Desktop/test_download/")
time.sleep(1)
robot.LuaUpload("D://Desktop/test_download/test1.lua")
time.sleep(1)
robot.LuaDelete("test2.lua")
time.sleep(1)
ret,num,name = robot.GetLuaList()
print(num)
print(name)

View File

@ -0,0 +1,7 @@
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
error = robot.PointTableDownLoad("point_table_a.db","D://Desktop/testPoint/download/")
print("PointTableDownLoad错误码:",error)

View File

@ -0,0 +1,6 @@
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
error = robot.PointTableSwitch("point_table_a.db")
print("PointTableSwitch:",error)

View File

@ -0,0 +1,6 @@
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
error = robot.PointTableUpLoad("D://Desktop/testPoint/point_table_a.db")
print("PointTableUpLoad错误码:",error)

View File

@ -0,0 +1,39 @@
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
level = [1.0,2.0,3.0,4.0,5.0,6.0]
error = robot.SetAnticollision(0,level,1)
print("设置碰撞等级错误码:",error)
level = [50.0,20.0,30.0,40.0,50.0,60.0]
error = robot.SetAnticollision(1,level,1)
print("设置碰撞等级错误码:",error)
error = robot.SetCollisionStrategy(1)
print("设置碰撞后策略错误码:",error)
p_limit = [170.0,80.0,150.0,80.0,170.0,160.0]
n_limit = [-170.0,-260.0,-150.0,-260.0,-170.0,-160.0]
error = robot.SetLimitPositive(p_limit)
print("设置正限位错误码:",error)
error = robot.SetLimitNegative(n_limit)
print("设置负限位错误码:",error)
error = robot.ResetAllError()
print("错误状态清除:",error)
error = robot.FrictionCompensationOnOff(1)
print("关节摩擦力补偿开关错误码:",error)
lcoeff = [0.9,0.9,0.9,0.9,0.9,0.9]
wcoeff = [0.4,0.4,0.4,0.4,0.4,0.4]
ccoeff = [0.6,0.6,0.6,0.6,0.6,0.6]
fcoeff = [0.5,0.5,0.5,0.5,0.5,0.5]
error = robot.SetFrictionValue_level(lcoeff)
print("设置关节摩擦力补偿系数-正装错误码:",error)
error =robot.SetFrictionValue_wall(wcoeff)
print("设置关节摩擦力补偿系数-侧装错误码:",error)
error =robot.SetFrictionValue_ceiling(ccoeff)
print("设置关节摩擦力补偿系数-倒装错误码:",error)
error =robot.SetFrictionValue_freedom(fcoeff)
print("设置关节摩擦力补偿系数-自由装错误码:",error)
robot.SetFrictionValue_level(lcoeff)

View File

@ -0,0 +1,6 @@
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
error = robot.PointTableUpdateLua("point_table_a.db","testpoint.lua")
print("PointTableUpdateLua:",error)

View File

@ -0,0 +1,41 @@
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
error,joint_pos = robot.GetActualJointPosDegree()
print("机器人当前关节位置",joint_pos)
joint_pos = [joint_pos[0],joint_pos[1],joint_pos[2],joint_pos[3],joint_pos[4],joint_pos[5]]
error_joint = 0
count =100
error = robot.ServoMoveStart() #伺服运动开始
print("伺服运动开始错误码",error)
while(count):
error = robot.ServoJ(joint_pos) #关节空间伺服模式运动
if error!=0:
error_joint =error
joint_pos[0] = joint_pos[0] + 0.1 #每次1轴运动0.1度运动100次
count = count - 1
time.sleep(0.008)
print("关节空间伺服模式运动错误码",error_joint)
error = robot.ServoMoveEnd() #伺服运动结束
print("伺服运动结束错误码",error)
mode = 2 #[0]-绝对运动(基坐标系)[1]-增量运动(基坐标系)[2]-增量运动(工具坐标系)
n_pos = [0.0,0.0,0.5,0.0,0.0,0.0] #笛卡尔空间位姿增量
error,desc_pos = robot.GetActualTCPPose()
print("机器人当前笛卡尔位置",desc_pos)
count = 100
error_cart =0
error = robot.ServoMoveStart() #伺服运动开始
print("伺服运动开始错误码",error)
while(count):
error = robot.ServoCart(mode, n_pos, vel=40) #笛卡尔空间伺服模式运动
if error!=0:
error_cart =error
count = count - 1
time.sleep(0.008)
print("笛卡尔空间伺服模式运动错误码", error_cart)
error = robot.ServoMoveEnd() #伺服运动开始
print("伺服运动结束错误码",error)
print("关节扭矩控制错误码",error_torques)

View File

@ -0,0 +1,39 @@
from fairino import Robot
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
tool = 0 #工具坐标系编号
user = 0 #工件坐标系编号
lastFlag= 0 # 是否为最后一个点0-否1-是
joint_pos1 = [116.489,-85.278,111.501,-112.486,-85.561,24.693]
joint_pos2 = [86.489,-65.278,101.501,-112.486,-85.561,24.693]
joint_pos3 = [116.489,-45.278,91.501,-82.486,-85.561,24.693]
desc_pos4 = [236.794,-375.119, 65.379, -176.938, 2.535, -179.829]
desc_pos5 = [236.794,-275.119, 165.379, -176.938, 2.535, -179.829]
desc_pos6 = [286.794,-375.119, 265.379, -176.938, 2.535, -179.829]
ret = robot.SplineStart() #样条运动开始
print("样条运动开始:错误码", ret)
ret = robot.SplinePTP(joint_pos1, tool, user) #样条运动PTP
print("样条运动PTP运动点1:错误码", ret)
ret = robot.SplinePTP(joint_pos2, tool, user) #样条运动PTP
print("样条运动PTP运动点2:错误码", ret)
ret = robot.SplinePTP(joint_pos3, tool, user) #样条运动PTP
print("样条运动PTP运动点3:错误码", ret)
ret = robot.SplineEnd() #样条运动结束
print("样条运动结束:错误码", ret)
ret = robot.NewSplineStart(1) #新样条运动开始
print("新样条运动开始:错误码", ret)
ret = robot.NewSplinePoint(desc_pos4, tool, user, lastFlag)#新样条指令点
print("新样条指令点4:错误码", ret)
ret = robot.NewSplinePoint(desc_pos5, tool, user, lastFlag, vel=30)#新样条指令点
print("新样条指令点5:错误码", ret)
lastFlag = 1
ret = robot.NewSplinePoint(desc_pos6, tool, user, lastFlag, vel=30)#新样条指令点
print("新样条指令点6:错误码", ret)
ret = robot.NewSplineEnd() #新样条运动结束
print("新样条运动结束:错误码", ret)

View File

@ -0,0 +1,28 @@
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
type = 1 # 数据类型1-关节位置
name = 'tpd2023' # 轨迹名
period = 4 #采样周期2ms或4ms或8ms
di = 0 # di输入配置
do = 0 # do输出配置
ret = robot.SetTPDParam(name, period, di_choose=di) #配置TPD参数
print("配置TPD参数错误码", ret)
robot.Mode(1) # 机器人切入手动模式
time.sleep(1)
robot.DragTeachSwitch(1) #机器人切入拖动示教模式
ret = robot.GetActualTCPPose()
print("获取当前工具位姿", ret)
time.sleep(1)
ret = robot.SetTPDStart(name, period, do_choose=do) # 开始记录示教轨迹
print("开始记录示教轨迹错误码", ret)
time.sleep(15)
ret = robot.SetWebTPDStop() # 停止记录示教轨迹
print("停止记录示教轨迹错误码", ret)
robot.DragTeachSwitch(0) #机器人切入非拖动示教模式
# robot.SetTPDDelete('tpd2023') # 删除TPD轨迹

View File

@ -0,0 +1,17 @@
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
# P1=[-321.821, 125.694, 282.556, 174.106, -15.599, 152.669]
name = 'tpd2023' #轨迹名
blend = 1 #是否平滑1-平滑0-不平滑
ovl = 100.0 #速度缩放
ret = robot.LoadTPD(name) #轨迹预加载
print("轨迹预加载错误码",ret)
ret,P1 = robot.GetTPDStartPose(name) #获取轨迹起始位姿
print ("获取轨迹起始位姿错误码",ret,"起始位姿",P1)
ret = robot.MoveL(P1,0,0) #运动到起始点
print("运动到起始点错误码",ret)
time.sleep(10)
ret = robot.MoveTPD(name, blend, ovl) #轨迹复现
print("轨迹复现错误码",ret)

View File

@ -0,0 +1,41 @@
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
def print_program_state():
pstate = robot.GetProgramState() #查询程序运行状态,1-程序停止或无程序运行2-程序运行中3-程序暂停
linenum = robot.GetCurrentLine() #查询当前作业程序执行的行号
name = robot.GetLoadedProgram() #查询已加载的作业程序名
print("the robot program state is:",pstate[1])
print("the robot program line number is:",linenum[1])
print("the robot program name is:",name[1])
time.sleep(1)
#机器人webapp程序使用接口
robot.Mode(0) #机器人切入自动运行模式
print_program_state()
ret = robot.ProgramLoad('/fruser/testPTP.lua') #加载要执行的机器人程序testPTP.lua程序需要先在webapp上编写好
print("加载要执行的机器人程序错误码", ret)
ret = robot.ProgramRun() #执行机器人程序
print("执行机器人程序错误码", ret)
time.sleep(2)
print_program_state()
ret = robot.ProgramPause() #暂停正在执行的机器人程序
print("暂停正在执行的机器人程序错误码", ret)
time.sleep(2)
print_program_state()
ret = robot.ProgramResume() #恢复暂停执行的机器人程序
print("恢复暂停执行的机器人程序错误码", ret)
time.sleep(2)
print_program_state()
ret = robot.ProgramStop() #停止正在执行的机器人程序
print("停止正在执行的机器人程序", ret)
time.sleep(2)
print_program_state()
flag = 1 #0-开机不自动加载默认程序1-开机自动加载默认程序
ret = robot.LoadDefaultProgConfig(flag,'/fruser/testPTP.lua') #设置开机自动加载默认程序
print("设置开机自动加载默认程序", ret)

View File

@ -0,0 +1,144 @@
from fairino import Robot
import time
# 与机器人控制器建立连接,连接成功返回一个机器人对象
robot = Robot.RPC('192.168.58.2')
weldIOType =0
arcNum =0
weldTimeout=5000
weaveNum =0
tool =1
user =0
weaveType = 0
weaveFraquency = 1
weavelncStayTime = 0
weaveRange = 10
weaveLeftStayTime = 10
weaveRightStayTime = 10
weaveCircleRadio =0
weaveStationary =1
#起弧
ret = robot.ARCStart(weldIOType,arcNum,weldTimeout)
print("ARCStart", ret)
time.sleep(3)
#收弧
ret = robot.ARCEnd(weldIOType,arcNum,weldTimeout)
print("ARCEnd", ret)
time.sleep(3)
#设置焊接电流与模拟量线性关系
ret = robot.WeldingSetCurrentRelation(0,400,0,10)
print("WeldingSetCurrentRelation", ret)
time.sleep(1)
#获取焊接电流与模拟量线性关系
ret = robot.WeldingGetCurrentRelation()
print("WeldingGetCurrentRelation", ret)
time.sleep(1)
#设置焊接电压与模拟量线性关系
ret = robot.WeldingSetVoltageRelation(0,400,0,10)
print("WeldingSetVoltageRelation", ret)
time.sleep(1)
#获取焊接电压与模拟量线性关系
ret = robot.WeldingGetVoltageRelation()
print("WeldingGetVoltageRelation", ret)
time.sleep(1)
#设置焊接电流
ret = robot.WeldingSetCurrent(weldIOType,100,0)
print("WeldingSetCurrent", ret)
time.sleep(1)
#设置焊接电压
ret = robot.WeldingSetVoltage(weldIOType,19,1)
print("WeldingSetVoltage", ret)
time.sleep(1)
#设置摆动参数
ret = robot.WeaveSetPara(weaveNum,weaveType,weaveFraquency,weavelncStayTime,weaveRange,weaveLeftStayTime,weaveRightStayTime,weaveCircleRadio,weaveStationary)
print("WeaveSetPara", ret)
time.sleep(1)
#摆动开始
ret = robot.WeaveStart(0)
print("WeaveStart", ret)
time.sleep(1)
ret,pose =robot.GetActualTCPPose(1)
print(ret,pose)
pose[2]=pose[2]+50
ret = robot.MoveL(pose,tool,user)
print("MoveL", ret)
time.sleep(1)
#即时设置摆动参数
ret = robot.WeaveOnlineSetPara (weaveNum,weaveType,weaveFraquency,weavelncStayTime,weaveRange,weaveLeftStayTime,weaveRightStayTime,weaveCircleRadio,weaveStationary)
print("WeaveOnlineSetPara ", ret)
time.sleep(1)
#摆动结束
ret = robot.WeaveEnd(0)
print("WeaveEnd", ret)
time.sleep(1)
#正向送丝
ret = robot.SetForwardWireFeed(weldIOType,1)
print("SetForwardWireFeed", ret)
time.sleep(1)
ret = robot.SetForwardWireFeed(weldIOType,0)
print("SetForwardWireFeed", ret)
time.sleep(1)
#反向送丝
ret = robot.SetReverseWireFeed(weldIOType,1)
print("SetReverseWireFeed", ret)
time.sleep(1)
ret = robot.SetReverseWireFeed(weldIOType,0)
print("SetReverseWireFeed", ret)
time.sleep(1)
#送气
ret = robot.SetAspirated(weldIOType,1)
print("SetAspirated", ret)
time.sleep(1)
ret = robot.SetAspirated(weldIOType,0)
print("SetAspirated", ret)
time.sleep(1)
start_desc=[0,0,0,0,0,0]
end_desc=[0,0,0,0,0,0]
start_joint=[0,0,0,0,0,0]
end_joint=[0,0,0,0,0,0]
ret,start_desc =robot.GetActualTCPPose(1)
print("start_desc",start_desc)
ret,end_desc =robot.GetActualTCPPose(1)
end_desc[1]=end_desc[1]+200
print("start_desc",start_desc)
print("end_desc",end_desc)
ret,start_joint=robot.GetInverseKin(0,start_desc)
ret,end_joint=robot.GetInverseKin(0,end_desc)
print("start_joint",start_joint)
print("end_joint",end_joint)
weldLength =40
noweldLength =40
weaveType = 0
weaveFraquency = 1
weavelncStayTime = 0
weaveRange = 10
weaveLeftStayTime = 10
weaveRightStayTime = 10
weaveCircleRadio =0
weaveStationary =1
#段焊
ret = robot.SegmentWeldStart(start_desc,end_desc,start_joint,end_joint,weldLength,noweldLength,weldIOType,arcNum,weldTimeout,True,weaveNum,tool,user)
print("SegmentWeldStart", ret)