I am a university student specializing in robotics. Recently, our school arranged for us to independently work on a robotics-related project. We were provided with a small six-axis robotic arm, the mechArm 270 M5Stack. My plan is to use ChatGPT to assist me in learning how to operate this robotic arm and to create a demo.
This article will document how I used ChatGPT to learn about operating the mechanical arm.
ChatGPTChatGPT is an advanced artificial intelligence conversational system developed by OpenAI. It is based on the large-scale language model technology known as GPT (Generative Pretrained Transformer), capable of understanding and generating natural language text. ChatGPT can engage in various interactions, including answering questions, providing explanations, writing texts, and assisting in programming. Its design goal is to simulate human-like performance in specific fields or conversations, thereby offering a high-quality, human-like communication experience.
How ChatGPT Can Help in Learning New Knowledge:1. Personalized Teaching: ChatGPT can provide information personalized to the user's questions and responses, making the learning process more suited to the user's needs and level.
2. Combining Theory with Examples: ChatGPT is not only capable of providing theoretical knowledge but can also explain complex concepts with practical examples, aiding users in better understanding and memorizing.
3. Step-by-Step Guidance: For complex tasks or questions, ChatGPT can offer step-by-step guidance and suggestions, helping users gradually master skills.
4. Resource Recommendations: ChatGPT can also recommend books, online courses, articles, and other resources to help users delve deeper into their studies.
Learning ProcessFirst, I needed to assign it an identity, a role, so that its responses would not deviate too much from our topic.
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!
In the meantime, I had already gained some knowledge about robotics. I directly asked it to research my current model of the robotic arm and how to use it. It then provided some parameters of the robotic arm, as well as information about the programming environment, etc.
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 270After its detailed summary, I learned that this is a desktop-type robotic arm with a working radius of 270mm. It supports compilation on multiple platforms, with Python programming language being particularly comprehensive. It also comes with a rich API control library for ease of use by users.
It has 40 GPIO interfaces, making it quite suitable for very small-scale automation tasks, and can also be used for educational and research applications.
Given the extensive support for Python, I decided to use Python for learning about this robotic arm.
- Operating System: Windows 11
- Programming Language: Python 3.9 or higher
- Primary Library Used: pymycobot
ChatGPT provided a basic guide on pymycobot, from installation to usage.
pip install pymycobot
Basic Usage#import library
from pymycobot.mycobot import MyCobot
#Initializing the robotic arm and establishing a connection
#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)
# Basic commands
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
These are some basic methods provided by ChatGPT for using the robotic arm. I will try to control the robotic arm following these steps.
Then I tried to use code to control the robotic arm to make a circular motion.
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)
This involves controlling the movement of the robotic arm through specific angles. I feel that controlling angles individually could only facilitate fixed movements, which might not be very practical for some application scenarios. Therefore, I asked if there are other control methods suitable for object grasping movements.
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:
I will try to understand how the send_coords() method operates. Below is the code I wrote to make movements at the end of the robotic arm.
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):
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)
I noticed that while controlling the robotic arm, some commands were getting lost, resulting in the arm not moving as expected. The solution I found was to add a waiting period. This waiting time needs to be longer than the movement time of the robotic arm to ensure that the motion is fully executed.
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()
Advanced UsageI plan to use a suction pump to grasp objects and later integrate this with a visual scenario. The mechArm has 40 IO interfaces for connecting external devices, such as suction pumps, grippers, and other tools.
After attaching the suction pump to the end of the arm, I can start practicing. I need to find the method to control the suction pump. The pymycobot library has a vast array of APIs, so I directly asked ChatGPT for assistance in understanding the suction pump control.
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.
Now, let's create a function to control the on/off state of the suction pump.
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()
I will record up to this point for now. Later, I plan to combine this with a camera to implement some positioning and grasping functions.
SummaryWith the continuous development of artificial intelligence, its impact extends beyond just technology, affecting every aspect of our lives. It significantly enhances our learning efficiency. Take my experience, for example. To understand something new, I would normally have to read through all the relevant documents, and even then, I might not fully grasp the concept. With the advent of AI tools like ChatGPT, the way we learn has fundamentally changed, adopting a completely new style. Even with something I was completely unfamiliar with, like the robotic arm, I was able to quickly learn how to use it.
Here is the chat history:https://chat.openai.com/share/655c6fe5-aef7-486c-add7-96f4e745aabf
Comments
Please log in or sign up to comment.