引言
我是一名機器人方向的大學生,近期學校安排自主做一個機器人方面相關的項目。學校給我們提供了一個小型的六軸機械臂,mechArm 270M5Stack,我打算使用ChatGPT讓它來輔助我學習如何使用這個機械臂并且做一個demo。
本篇文章將記錄我是如何使用ChatGPT來學習機械臂的使用。
ChatGPT
ChatGPT 是由 OpenAI 開發的一個先進的人工智能對話系統。它基于大規模語言模型 GPT(Generative Pretrained Transformer)技術,能夠理解和生成自然語言文本。ChatGPT 能夠進行多種交互,包括回答問題、提供解釋、撰寫文本、編程協助等。它的設計目的是為了模擬人類在特定領域或對話中的表現,從而提供高質量的、類人的交流體驗。
ChatGPT 如何幫助學習新知識:
個性化教學:根據用戶的問題和回答,ChatGPT 能夠個性化地提供信息,使學習過程更加符合用戶的需求和水平。
理論與實例結合:ChatGPT 不僅能提供理論知識,還能結合實際案例來解釋復雜概念,幫助用戶更好地理解和記憶。
步驟指導:對于復雜任務或問題,ChatGPT 可以提供分步驟的指導和建議,幫助用戶逐漸掌握技能。
資源推薦: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 time from 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. python mc.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等許多人工智能的工具,學習的方式再也不像之前那樣了,是全新的一種風格。及時是一無所知的機械臂,也能再很快的上手使用。
審核編輯 黃宇
-
機器人
+關注
關注
213文章
31079瀏覽量
222258 -
人工智能
+關注
關注
1817文章
50098瀏覽量
265381 -
python
+關注
關注
57文章
4876瀏覽量
90032 -
機械臂
+關注
關注
14文章
596瀏覽量
26125 -
大象機器人
+關注
關注
0文章
86瀏覽量
376
發布評論請先 登錄
大象機器人產品賦能全球尖端科研與教育實踐
復合機器人對比傳統AGV和機械臂的優勢何在?
高精度機器人控制的核心——基于 MYD-LT536 開發板的精密運動控制方案
發那科推出全新M-710iD系列六軸多功能機器人
協作機械臂產品介紹
機器人看點:越疆機器人正式發布六足仿生機器狗 智元公布機器人運動控制模型專利
RDK × 腿臂機器人:這只 “機械汪” 竟會說人話、走花路!
極海G32R501工業六軸機械臂參考方案釋放工業4.0產業價值
工業機器人與協作機器人概念不同
大象機器人×進迭時空聯合發布全球首款RISC-V全棧開源小六軸機械臂
大象機器人攜手地瓜機器人打造全國產輕量級教育協作機械臂新標桿
大象機器人推出myCobot 280 RDK X5,攜手地瓜機器人共建智能教育機
使用ChatGPT學習大象機器人六軸協作機械臂mechArm!
評論