一点修改
This commit is contained in:
parent
2e77f05678
commit
a491ad0f3d
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1 @@
|
||||
/.venv/
|
||||
|
||||
|
6
.idea/graduation_design.iml
generated
6
.idea/graduation_design.iml
generated
@ -1,10 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.11 (graduation_design)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@ -1,7 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Black">
|
||||
<option name="sdkName" value="Python 3.11 (graduation_design)" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (graduation_design)" project-jdk-type="Python SDK" />
|
||||
</project>
|
11
.idea/saveactions_settings.xml
generated
11
.idea/saveactions_settings.xml
generated
@ -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>
|
2
.idea/vcs.xml
generated
2
.idea/vcs.xml
generated
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
172
.idea/workspace.xml
generated
172
.idea/workspace.xml
generated
@ -1,176 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoImportSettings">
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="5de6e434-16d8-46ca-a50f-5cce2ce0877f" name="更改" comment="1. 完成了对相机深度信息的封装,但是深度获取还有点问题">
|
||||
<change afterPath="$PROJECT_DIR$/abandon_code/test.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/distance_measurement/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/img_process/orbbec_camera/OrbbecCamera.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/distance_measurement/stereo_vision.py" 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/ColorViewer.py" beforeDir="false" afterPath="$PROJECT_DIR$/abandon_code/ColorViewer.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/img_process/orbbec_camera/DepthViewer.py" beforeDir="false" afterPath="$PROJECT_DIR$/abandon_code/DepthViewer.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/img_process/test.py" beforeDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
<option value="Python Script" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="MarkdownSettingsMigration">
|
||||
<option name="stateVersion" value="1" />
|
||||
</component>
|
||||
<component name="ProjectColorInfo">{
|
||||
"associatedIndex": 7
|
||||
}</component>
|
||||
<component name="ProjectId" id="2cl92QEZTLSO2Isqs0rCxgPI1yS" />
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"Python.ColorViewer.executor": "Run",
|
||||
"Python.DepthViewer.executor": "Run",
|
||||
"Python.ObjectClassify.executor": "Run",
|
||||
"Python.OrbbecCamera.executor": "Run",
|
||||
"Python.color_viewer.executor": "Run",
|
||||
"Python.depth_color_sync_align_viewer.executor": "Run",
|
||||
"Python.depth_viewer.executor": "Run",
|
||||
"Python.image_processing.executor": "Run",
|
||||
"Python.test.executor": "Run",
|
||||
"Python.yolo.executor": "Run",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"WebServerToolWindowFactoryState": "false",
|
||||
"ignore_missing_gitignore": "true",
|
||||
"last_opened_file_path": "F:/Projects/PyCharmProjects/pyorbbecsdk",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"settings.editor.selected.configurable": "settings.saveactions",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"last_opened_file_path": "F:/Jetbrains/PyCharm Professional"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="F:\Projects\PyCharmProjects\graduation_design\img_process\orbbec_camera" />
|
||||
<recent name="F:\Projects\PyCharmProjects\graduation_design\.venv\Lib\site-packages" />
|
||||
<recent name="F:\Projects\PyCharmProjects\graduation_design\camera\orbbec_camera" />
|
||||
<recent name="F:\Projects\PyCharmProjects\graduation_design\camera" />
|
||||
<recent name="F:\Projects\PyCharmProjects\graduation_design\lib" />
|
||||
</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\camera\orbbec_camera" />
|
||||
<recent name="F:\Projects\PyCharmProjects\graduation_design\camera" />
|
||||
<recent name="F:\Projects\PyCharmProjects\graduation_design\lib" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="SharedIndexes">
|
||||
<attachedChunks>
|
||||
<set>
|
||||
<option value="bundled-python-sdk-d68999036c7f-b11f5e8da5ad-com.jetbrains.pycharm.pro.sharedIndexes.bundled-PY-233.14475.56" />
|
||||
</set>
|
||||
</attachedChunks>
|
||||
</component>
|
||||
<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="5de6e434-16d8-46ca-a50f-5cce2ce0877f" name="更改" comment="" />
|
||||
<created>1708675135052</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1708675135052</updated>
|
||||
<workItem from="1708676369490" duration="2293000" />
|
||||
<workItem from="1708772527207" duration="4012000" />
|
||||
<workItem from="1708831408424" duration="3086000" />
|
||||
<workItem from="1708912830842" duration="533000" />
|
||||
<workItem from="1708913406749" duration="4000" />
|
||||
<workItem from="1708913419694" duration="1196000" />
|
||||
<workItem from="1708915341673" duration="14000" />
|
||||
<workItem from="1708915370802" duration="660000" />
|
||||
<workItem from="1708917617291" duration="82000" />
|
||||
<workItem from="1708917707818" duration="36000" />
|
||||
<workItem from="1708917750778" duration="29000" />
|
||||
<workItem from="1708917838563" duration="18000" />
|
||||
<workItem from="1708917889599" duration="5000" />
|
||||
<workItem from="1708917964846" duration="246000" />
|
||||
<workItem from="1708918220728" duration="85000" />
|
||||
<workItem from="1708918314610" duration="999000" />
|
||||
<workItem from="1708925007136" duration="10070000" />
|
||||
<workItem from="1708953749808" duration="6400000" />
|
||||
<workItem from="1708996202967" duration="9931000" />
|
||||
<workItem from="1709092700145" duration="11067000" />
|
||||
<workItem from="1709201263936" duration="3447000" />
|
||||
<workItem from="1709206411719" duration="1390000" />
|
||||
<workItem from="1709210454458" duration="710000" />
|
||||
<workItem from="1709258808137" duration="2791000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="1. 成功允运行了Yolo的分类模型,大体了解了使用方式 2. 成功运行了Gemini2摄像头 3. 成功将摄像头与Yolo模型整合运行">
|
||||
<option name="closed" value="true" />
|
||||
<created>1708960272915</created>
|
||||
<option name="number" value="00001" />
|
||||
<option name="presentableId" value="LOCAL-00001" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1708960272915</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00002" summary="1. 完成了对相机和模型调用的封装">
|
||||
<option name="closed" value="true" />
|
||||
<created>1709015553553</created>
|
||||
<option name="number" value="00002" />
|
||||
<option name="presentableId" value="LOCAL-00002" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1709015553553</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00003" summary="1. 完成了对相机深度信息的封装,但是深度获取还有点问题">
|
||||
<option name="closed" value="true" />
|
||||
<created>1709103859741</created>
|
||||
<option name="number" value="00003" />
|
||||
<option name="presentableId" value="LOCAL-00003" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1709103859741</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="4" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="1. 成功允运行了Yolo的分类模型,大体了解了使用方式 2. 成功运行了Gemini2摄像头 3. 成功将摄像头与Yolo模型整合运行" />
|
||||
<MESSAGE value="1. 完成了对相机和模型调用的封装" />
|
||||
<MESSAGE value="1. 完成了对相机深度信息的封装,但是深度获取还有点问题" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="1. 完成了对相机深度信息的封装,但是深度获取还有点问题" />
|
||||
</component>
|
||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
||||
<SUITE FILE_PATH="coverage/graduation_design$depth_viewer.coverage" NAME="depth_viewer 覆盖结果" MODIFIED="1709095443171" 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$yolo.coverage" NAME="yolo 覆盖结果" MODIFIED="1709010274059" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/camera" />
|
||||
<SUITE FILE_PATH="coverage/graduation_design$ColorViewer.coverage" NAME="ColorViewer 覆盖结果" MODIFIED="1709210701965" 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$DepthViewer.coverage" NAME="DepthViewer 覆盖结果" MODIFIED="1709204380257" 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$image_processing.coverage" NAME="image_processing 覆盖结果" MODIFIED="1708957639566" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/camera" />
|
||||
<SUITE FILE_PATH="coverage/graduation_design$test.coverage" NAME="test 覆盖结果" MODIFIED="1709202296879" 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$ObjectClassify.coverage" NAME="ObjectClassify 覆盖结果" MODIFIED="1709261495229" 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$color_viewer.coverage" NAME="color_viewer 覆盖结果" MODIFIED="1708957257852" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/camera/orbbec_camera" />
|
||||
<SUITE FILE_PATH="coverage/graduation_design$depth_color_sync_align_viewer.coverage" NAME="depth_color_sync_align_viewer 覆盖结果" MODIFIED="1709093655863" 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$OrbbecCamera.coverage" NAME="OrbbecCamera 覆盖结果" MODIFIED="1709261493426" 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>
|
||||
}</component>
|
||||
</project>
|
104
abandon_code/yolo.py
Normal file
104
abandon_code/yolo.py
Normal file
@ -0,0 +1,104 @@
|
||||
import cv2
|
||||
from ultralytics import YOLO
|
||||
from pyorbbecsdk import Pipeline, FrameSet
|
||||
from pyorbbecsdk import Config
|
||||
from pyorbbecsdk import OBSensorType, OBFormat
|
||||
from pyorbbecsdk import OBError
|
||||
from pyorbbecsdk import VideoStreamProfile
|
||||
from img_process.orbbec_camera.utils import frame_to_bgr_image
|
||||
|
||||
|
||||
def load_model():
|
||||
# 载入 YOLOv8 模型
|
||||
model = YOLO('../img_process/yolov8n.pt')
|
||||
return model
|
||||
|
||||
|
||||
# 参数说明
|
||||
# --img: 输入图片的路径
|
||||
# --is_save_video: 是否保存识别后的视频
|
||||
def process_img(img=None):
|
||||
# 暂时性配置
|
||||
video_path = "output_video.mp4"
|
||||
|
||||
# 加载模型
|
||||
model = load_model()
|
||||
if img is not None:
|
||||
# 对图像运行 YOLOv8 推理
|
||||
results = model(img)
|
||||
|
||||
# 在图像上可视化结果
|
||||
annotated_img = results[0].plot()
|
||||
|
||||
# 显示带有标注的图像
|
||||
cv2.imshow("YOLOv8 推理", annotated_img)
|
||||
cv2.waitKey(0)
|
||||
cv2.destroyAllWindows()
|
||||
else:
|
||||
# 获取本机摄像头内容
|
||||
cap = cv2.VideoCapture(0)
|
||||
|
||||
# 奥比中光摄像头
|
||||
# ESC键的键值
|
||||
ESC_KEY = 27
|
||||
# 创建配置对象
|
||||
config = Config()
|
||||
# 创建Pipeline对象
|
||||
pipeline = Pipeline()
|
||||
|
||||
try:
|
||||
# 获取颜色传感器的流配置列表
|
||||
profile_list = pipeline.get_stream_profile_list(OBSensorType.COLOR_SENSOR)
|
||||
try:
|
||||
# 尝试获取指定分辨率、格式和帧率的颜色配置
|
||||
color_profile: VideoStreamProfile = profile_list.get_video_stream_profile(700, 0, OBFormat.RGB, 30)
|
||||
except OBError as e:
|
||||
# 如果出错,打印错误信息并使用默认的颜色配置
|
||||
print(e)
|
||||
color_profile = profile_list.get_default_video_stream_profile()
|
||||
|
||||
# 启用颜色流
|
||||
config.enable_stream(color_profile)
|
||||
except Exception as e:
|
||||
# 如果出现异常,打印错误信息并返回
|
||||
print(e)
|
||||
return
|
||||
# 启动Pipeline
|
||||
pipeline.start(config)
|
||||
|
||||
while True:
|
||||
try:
|
||||
# 等待获取帧集,最多等待100毫秒
|
||||
frames: FrameSet = pipeline.wait_for_frames(100)
|
||||
if frames is None:
|
||||
continue
|
||||
|
||||
# 获取颜色帧
|
||||
color_frame = frames.get_color_frame()
|
||||
|
||||
if color_frame is None:
|
||||
continue
|
||||
|
||||
# 将帧转换为BGR格式的图像
|
||||
color_image = frame_to_bgr_image(color_frame)
|
||||
|
||||
model.predict(source=color_image, show=True)
|
||||
|
||||
if color_image is None:
|
||||
print("failed to convert frame to image")
|
||||
continue
|
||||
key = cv2.waitKey(1)
|
||||
if key == ord('q') or key == ESC_KEY:
|
||||
break
|
||||
except KeyboardInterrupt:
|
||||
# 如果捕获到键盘中断信号,则退出循环
|
||||
break
|
||||
# 释放视频捕获对象并关闭显示窗口
|
||||
cap.release()
|
||||
cv2.destroyAllWindows()
|
||||
# 停止Pipeline
|
||||
pipeline.stop()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
process_img()
|
79
fairino_robot_control/MoveItDemo.py
Normal file
79
fairino_robot_control/MoveItDemo.py
Normal file
@ -0,0 +1,79 @@
|
||||
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()
|
0
fairino_robot_control/__init__.py
Normal file
0
fairino_robot_control/__init__.py
Normal file
BIN
fairino_robot_control/fairino/Robot.pyd
Normal file
BIN
fairino_robot_control/fairino/Robot.pyd
Normal file
Binary file not shown.
55
fairino_robot_control/robot_basic_interface.py
Normal file
55
fairino_robot_control/robot_basic_interface.py
Normal file
@ -0,0 +1,55 @@
|
||||
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)
|
BIN
img_process/Log/OrbbecSDK.log.txt
Normal file
BIN
img_process/Log/OrbbecSDK.log.txt
Normal file
Binary file not shown.
@ -1,49 +1,35 @@
|
||||
from ultralytics import YOLO
|
||||
import cv2
|
||||
from abandon_code.ColorViewer import ColorViewer
|
||||
from orbbec_camera.OrbbecCamera import OrbbecCamera
|
||||
|
||||
|
||||
class ObjectClassify:
|
||||
def __init__(self):
|
||||
def __init__(self, image_width=640):
|
||||
self.model = YOLO('yolov8n.pt')
|
||||
|
||||
def image_classify(self, path=None):
|
||||
res = self.model(path)
|
||||
|
||||
predicted_img = res[0].plot()
|
||||
|
||||
cv2.imshow("分类结果", predicted_img)
|
||||
cv2.waitKey(0)
|
||||
cv2.destroyAllWindows()
|
||||
|
||||
def video_classify(self):
|
||||
cw = ColorViewer()
|
||||
frame = cw.get_current_frame()
|
||||
self.model(source=frame, show=True)
|
||||
# 输入的视频的宽度
|
||||
self.image_width = image_width
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
oc = ObjectClassify()
|
||||
ob = OrbbecCamera('HW', True)
|
||||
ob.run()
|
||||
classify = ObjectClassify()
|
||||
camera = OrbbecCamera('HW', True, image_width=classify.image_width)
|
||||
camera.run()
|
||||
# 处理循环
|
||||
while True:
|
||||
color_image = ob.get_color_image()
|
||||
if color_image is None:
|
||||
continue
|
||||
cv2.imshow("彩色图像", color_image)
|
||||
if ob.get_depth_image() is None:
|
||||
continue
|
||||
cv2.imshow("深度图像", ob.get_depth_image())
|
||||
if ob.get_combined_image() is None:
|
||||
continue
|
||||
cv2.imshow("合成图像", ob.get_combined_image())
|
||||
print(f"中心点的深度值: {ob.get_center_distance()}mm")
|
||||
color_image = camera.get_color_image()
|
||||
if color_image is not None:
|
||||
oc.model.predict(source=color_image, show=True)
|
||||
# conf: 置信度,小于该值的框将被过滤
|
||||
# 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)
|
||||
key = cv2.waitKey(1)
|
||||
if key == ord('q'):
|
||||
ob.stop()
|
||||
camera.stop()
|
||||
# cw.stop()
|
||||
break
|
||||
|
@ -12,7 +12,7 @@ class OrbbecCamera:
|
||||
# 定义一个类常量作为退出键
|
||||
ESC_KEY = 27
|
||||
|
||||
def __init__(self, mode='HW', enable_sync=True):
|
||||
def __init__(self, mode='HW', enable_sync=True, image_width=640):
|
||||
# 构造函数:初始化Orbbec相机和配置
|
||||
self.pipeline = Pipeline() # 创建Pipeline对象
|
||||
self.device = self.pipeline.get_device() # 获取设备对象
|
||||
@ -29,7 +29,7 @@ class OrbbecCamera:
|
||||
self.thread = None # 线程对象,用于并行执行捕获循环
|
||||
self.active = False # 控制捕获循环的标志
|
||||
# 显示设置
|
||||
self.width = 640 # 图像宽度
|
||||
self.width = image_width # 图像宽度
|
||||
self.fps = 30 # 帧率
|
||||
|
||||
# 初始化相机设置
|
||||
@ -147,6 +147,24 @@ class OrbbecCamera:
|
||||
def get_center_distance(self):
|
||||
return self.center_distance
|
||||
|
||||
# 将像素坐标转换为相机坐标系下的坐标
|
||||
def covert_pixel_to_carmera_coordinates(self, u, v, depth):
|
||||
# u: 像素坐标x
|
||||
# v: 像素坐标y
|
||||
# depth: 深度值
|
||||
# K[0]为相机参数
|
||||
# fx = self.depth_intrinsics.K[0]
|
||||
# fy = self.depth_intrinsics.K[4]
|
||||
# cx = self.depth_intrinsics.K[2]
|
||||
# cy = self.depth_intrinsics.K[5]
|
||||
|
||||
# 单位是毫米
|
||||
# camera_x = (u - cx) * depth / fx
|
||||
# camera_y = (v - cy) * depth / fy
|
||||
# return camera_x, camera_y, depth
|
||||
# 返回值: 相机坐标(x, y, z)
|
||||
return None
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
|
BIN
img_process/yolov8n-seg.pt
Normal file
BIN
img_process/yolov8n-seg.pt
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user