使用ChatGPT学习大象机器人六轴协作机械臂mechArm

2024-02-01 12:20

本文主要是介绍使用ChatGPT学习大象机器人六轴协作机械臂mechArm,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

引言

我是一名机器人方向的大学生,近期学校安排自主做一个机器人方面相关的项目。学校给我们提供了一个小型的六轴机械臂,mechArm 270M5Stack,我打算使用ChatGPT让它来辅助我学习如何使用这个机械臂并且做一个demo。

本篇文章将记录我是如何使用ChatGPT来学习机械臂的使用。

ChatGPT

ChatGPT 是由 OpenAI 开发的一个先进的人工智能对话系统。它基于大规模语言模型 GPT(Generative Pretrained Transformer)技术,能够理解和生成自然语言文本。ChatGPT 能够进行多种交互,包括回答问题、提供解释、撰写文本、编程协助等。它的设计目的是为了模拟人类在特定领域或对话中的表现,从而提供高质量的、类人的交流体验。

ChatGPT 如何帮助学习新知识:

  1. 个性化教学:根据用户的问题和回答,ChatGPT 能够个性化地提供信息,使学习过程更加符合用户的需求和水平。
  2. 理论与实例结合:ChatGPT 不仅能提供理论知识,还能结合实际案例来解释复杂概念,帮助用户更好地理解和记忆。
  3. 步骤指导:对于复杂任务或问题,ChatGPT 可以提供分步骤的指导和建议,帮助用户逐渐掌握技能。
  4. 资源推荐:ChatGPT 还能推荐书籍、在线课程、文章等资源,帮助用户深入学习。

学习的过程Process

首先我得赋予他一个身份,一个角色,这样的话它的回答才能不会特别的偏离我们的主题。

me:
You are now a senior teacher in robotics. I will ask you some questions to help me learn a robotic arm.ChatGPT:
That sounds great! I'm here to help with your questions about robotic arms. Whether it's about their design, operation, programming, or applications, feel free to ask. Let's get started!

在此之间我已经对机器人相关的知识有所了解了,直接让它给我调查我现在这款机械臂是什么该如何使用。然后它就提供了一些机械臂的参数,以及编程环境等等

me:
Do you know the mechArm 270 MechArm, a product of Elephant Robotics? My instructor gave us one to use for a case study. I wanted to know the basic information about this robotic arm first.ChatGPT:...
Specifications:
Payload Capacity: Up to 250 grams.
Reach: 270mm.
Degrees of Freedom (DoF): 6, via 6 magnetic encoder motors.
Movement Speed: Up to 120°/s.
Positioning Accuracy: ±1 mm.
Controller: Raspberry Pi 4 Model B, featuring quad-core Cortex-A72 processor, dual-band WiFi 5, and Bluetooth 5.0 connectivity.
Supported Cameras: Official Raspberry Pi cameras or third-party USB cameras.
USB Ports: 2 USB 3.0 ports, 2 USB 2.0 ports.
Power Input: 8-12V/5A DC jack.
Weight: Approximately 1 kilogram.
Expansion Options: 40-pin GPIO header
...

mechArm 270

经过较详细的汇总,我就得知这是一款桌面型的机械臂,工作半径270mm,能够支持多平台的编译,比较全面的是python编程语言,还附带一个丰富的API控制库方便用户们的使用。

有40个GPIO接口,比较适合做一一些非常小型的自动化任务,也可以做教育环境和研究等应用。

环境安装

基于他对于Python支持的比较多,所以我决定用python来进行这个机械臂的学习。

操作系统:window11
编程语言: python3.9+
主要使用的功能库:pymycobot

pymycobot的使用

ChatGPT介绍了一个基本的使用,从安装到使用都有。

安装库

pip install pymycobot

基础使用

导入使用的库

#import library

from pymycobot.mycobot import MyCobot

初始化机械臂,建立连接

#Initialize the Robot Arm

```

Connect the mechArm to your computer.

Initialize the robotic arm by specifying the port it's connected to and the baud rate

```

mc = MyCobot('com3',115200)

基础命令

Move the Arm: Use methods like send_angles to control the arm's position. For example, to move the arm to a specific angle:

mc.send_angles([0, 0, 0, 0, 0, 0], 100)  # Angles for each joint, Speed

Get Current Position: To read the current position of the arm:

angles = mc.get_angles()

print(angles)

Control the Gripper: To open or close the gripper:

mc.set_gripper_state(1, 50)  # 1 for open, 0 for close, Speed

以上是ChatGPT给我提供的一些使用的基础方法,我来尝试一下按照他的步骤来进行控制机械臂。

然后我自己尝试了使用代码控制机械臂做一个循环动作。

import timefrom pymycobot.mycobot import MyCobot#Initialize the Robot Arm
mc = MyCobot('com13',115200)
time.sleep(3)
for count in range(3):
  mc.send_angles([57.21,(-2.1),19.33,(-81.29),(-73.65),(-1.14)],80)
  time.sleep(1)
  mc.send_angles([(-9.05),(-1.93),9.05,2.63,(-2.28),(-0.26)],80)
  time.sleep(1)
  mc.send_angles([5.36,(-41.57),(-17.31),11.07,(-55.54),(-1.49)],80)
  time.sleep(1)

这是一些角度控制机械臂运动,单独控制角度的话我觉得只能做一些固定的动作,对于一些应用场景应该不是特别的实用。于是我问,还有什么其他的控制方法能够适用于物体抓图的运动。

chat

me:
Controlling the movement of the angle is only applicable to some special points and postures. For some object grabbing scenes, these unfixed points should not be used. Is there any other method of control?Chatgpt:
Absolutely, for scenarios where controlling the robotic arm based on specific angles isn't practical, especially in object grabbing and manipulation tasks, there are alternative control methods that can be more effective:1. Cartesian (Coordinate) Control:
Description: This method involves controlling the robotic arm by specifying the position of the end effector in Cartesian coordinates (X, Y, Z), along with orientation (roll, pitch, yaw).
Usage: In Python, using the pymycobot library, you can command the robotic arm to move to a specific Cartesian coordinate. The command might look like:

让我来尝试send_coords()这个方法是怎么运转的,下面是我写的代码在机械臂的末端位置上作出运动。

class MechArm:    def __init__(self,port):
        #初始化链接
        self.mc = MyCobot(port, 115200)
        self.coords = [116.4, -0.1, 178.4, -179.68, 6.5, -179.43]
        self.speed = 40
        self.mode = 0    def increment_x_and_send(self, increment=20):
        # 增加x值并发送新坐标
        self.coords[0] += increment
        self.mc.send_coords(self.coords, self.speed, self.mode)    def increment_y_send(self,increment=20):        self.coords[1] += increment
        self.mc.send_coords(self.coords,self.speed, self.mode)

我发现在控制机械臂的时候,有些指令会被吞掉,导致机械臂没有办法运动。解决的办法就是需要添加一个等待时间,等待的时间需要大于机械臂运动的时间才能够保证运动完全执行完。

time.sleep(s)# run code
mc = RobotArmController('com13')
mc.init_p()
time.sleep(3)
mc.increment_x_and_send()
time.sleep(1)
mc.increment_y_send()
time.sleep(1)
mc.increment_x_and_send()
time.sleep(1)
mc.increment_y_send()

进阶使用

我打算用吸泵来抓取一些东西,之后想做一个视觉的场景结合起来。mechArm有40个IO接口可以外接一些设备使用,比如说吸泵,夹爪等等工具。

给末端装上吸泵然后就可以开始实践了。我得找到调用吸泵的方法,pymycobot里面的API太多了,我直接让ChatGPT来帮助我知道吸泵。

me:
How to call the suction pump?ChatGPT:
Control Commands:Activate the Suction Pump:
To turn on the suction pump, you might send a command to set a specific IO port to HIGH. The exact command will depend on how the suction pump is connected to the controller.
pythonmc.set_basic_output(1,0)  # Example: Setting pin 1 to HIGH (0)
Deactivate the Suction Pump:
To turn off the suction pump, you would send a command to set the IO port to LOW.
python
Copy code
mc.set_basic_output(1, 1)  # Example: Setting pin 1 to LOW (1)
Integrate with Movement Commands:You would typically integrate these commands into a sequence where the robotic arm moves to a target location, activates the suction pump to pick up an object, moves to a new location, and then deactivates the pump to release the object.

现在我们来创建函数来控制吸泵的开关。

    def pump_on(self):
        self.mc.set_basic_output(5,0)    def pump_off(self):
        self.mc.set_basic_output(5,1)mc.initial_position()
time.sleep(2)
mc.pick_up_postion()
time.sleep(2)
mc.pump_on()
time.sleep(1)
mc.increment_z_send()
time.sleep(3)
mc.pump_off()

本次先记录到这里,之后我打算结合摄像头做一些定位抓取的功能。

总结

随着人工智能的不断发展,它影响的不单单是科技方面,还影响着我们生活中的点点滴滴。它很大程度上提升了我们的学习效率,就拿我来说,如果我要了解一个新事物肯定得把相关文档全部通读一遍,甚至也不一定能理解到位,有了ChatGPT等许多人工智能的工具,学习的方式再也不像之前那样了,是全新的一种风格。及时是一无所知的机械臂,也能再很快的上手使用。

这篇关于使用ChatGPT学习大象机器人六轴协作机械臂mechArm的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/667270

相关文章

C语言中联合体union的使用

本文编辑整理自: http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=179471 一、前言 “联合体”(union)与“结构体”(struct)有一些相似之处。但两者有本质上的不同。在结构体中,各成员有各自的内存空间, 一个结构变量的总长度是各成员长度之和。而在“联合”中,各成员共享一段内存空间, 一个联合变量

51单片机学习记录———定时器

文章目录 前言一、定时器介绍二、STC89C52定时器资源三、定时器框图四、定时器模式五、定时器相关寄存器六、定时器练习 前言 一个学习嵌入式的小白~ 有问题评论区或私信指出~ 提示:以下是本篇文章正文内容,下面案例可供参考 一、定时器介绍 定时器介绍:51单片机的定时器属于单片机的内部资源,其电路的连接和运转均在单片机内部完成。 定时器作用: 1.用于计数系统,可

问题:第一次世界大战的起止时间是 #其他#学习方法#微信

问题:第一次世界大战的起止时间是 A.1913 ~1918 年 B.1913 ~1918 年 C.1914 ~1918 年 D.1914 ~1919 年 参考答案如图所示

揭秘未来艺术:AI绘画工具全面介绍

📑前言 随着科技的飞速发展,人工智能(AI)已经逐渐渗透到我们生活的方方面面。在艺术创作领域,AI技术同样展现出了其独特的魅力。今天,我们就来一起探索这个神秘而引人入胜的领域,深入了解AI绘画工具的奥秘及其为艺术创作带来的革命性变革。 一、AI绘画工具的崛起 1.1 颠覆传统绘画模式 在过去,绘画是艺术家们通过手中的画笔,蘸取颜料,在画布上自由挥洒的创造性过程。然而,随着AI绘画工

[word] word设置上标快捷键 #学习方法#其他#媒体

word设置上标快捷键 办公中,少不了使用word,这个是大家必备的软件,今天给大家分享word设置上标快捷键,希望在办公中能帮到您! 1、添加上标 在录入一些公式,或者是化学产品时,需要添加上标内容,按下快捷键Ctrl+shift++就能将需要的内容设置为上标符号。 word设置上标快捷键的方法就是以上内容了,需要的小伙伴都可以试一试呢!

Tolua使用笔记(上)

目录   1.准备工作 2.运行例子 01.HelloWorld:在C#中,创建和销毁Lua虚拟机 和 简单调用。 02.ScriptsFromFile:在C#中,对一个lua文件的执行调用 03.CallLuaFunction:在C#中,对lua函数的操作 04.AccessingLuaVariables:在C#中,对lua变量的操作 05.LuaCoroutine:在Lua中,

AssetBundle学习笔记

AssetBundle是unity自定义的资源格式,通过调用引擎的资源打包接口对资源进行打包成.assetbundle格式的资源包。本文介绍了AssetBundle的生成,使用,加载,卸载以及Unity资源更新的一个基本步骤。 目录 1.定义: 2.AssetBundle的生成: 1)设置AssetBundle包的属性——通过编辑器界面 补充:分组策略 2)调用引擎接口API

Javascript高级程序设计(第四版)--学习记录之变量、内存

原始值与引用值 原始值:简单的数据即基础数据类型,按值访问。 引用值:由多个值构成的对象即复杂数据类型,按引用访问。 动态属性 对于引用值而言,可以随时添加、修改和删除其属性和方法。 let person = new Object();person.name = 'Jason';person.age = 42;console.log(person.name,person.age);//'J

一份LLM资源清单围观技术大佬的日常;手把手教你在美国搭建「百万卡」AI数据中心;为啥大模型做不好简单的数学计算? | ShowMeAI日报

👀日报&周刊合集 | 🎡ShowMeAI官网 | 🧡 点赞关注评论拜托啦! 1. 为啥大模型做不好简单的数学计算?从大模型高考数学成绩不及格说起 司南评测体系 OpenCompass 选取 7 个大模型 (6 个开源模型+ GPT-4o),组织参与了 2024 年高考「新课标I卷」的语文、数学、英语考试,然后由经验丰富的判卷老师评判得分。 结果如上图所

大学湖北中医药大学法医学试题及答案,分享几个实用搜题和学习工具 #微信#学习方法#职场发展

今天分享拥有拍照搜题、文字搜题、语音搜题、多重搜题等搜题模式,可以快速查找问题解析,加深对题目答案的理解。 1.快练题 这是一个网站 找题的网站海量题库,在线搜题,快速刷题~为您提供百万优质题库,直接搜索题库名称,支持多种刷题模式:顺序练习、语音听题、本地搜题、顺序阅读、模拟考试、组卷考试、赶快下载吧! 2.彩虹搜题 这是个老公众号了 支持手写输入,截图搜题,详细步骤,解题必备