Demo (python):
Usage Demo of Robotic Arm IO Function 1. Project introduction
This project, via the RealMan Python development package, implements drag teaching. It saves the trajectory to a folder, concatenates it into an online programming file, and then saves it to the online programming list. It is set as the programming file that the IO runs by default. The online programming can be run, paused, resumed, or emergency stopped through the IO multiplexing mode.
2. Code structure
RMDemo_IOControl/
│
├── README.md <- Core project document
├── requirements.txt <- List of project dependencies
├── setup.py <- Project installation script
│
├── src/ <- Project source code
│ ├── main.py <- Main procedure entry
│ └── core/ <- Core function or business logic code
│ └── demo_io_control.py <- Demo that implements drag teaching. It saves the trajectory to a folder, concatenates it into an online programming file, and then saves it to the online programming list. It is set as the programming file that the IO runs by default. The online programming can be run, paused, resumed, or emergency stopped through the IO multiplexing mode.
└── Robotic_Arm/ <- RealMan robotic arm secondary development package
3. Project download
Download RM_API2
locally via the link: development package download. Then, navigate to the RM_API2\Demo\RMDemo_Python
directory, where you will find RMDemo_IOControl.
4. Environment configuration
Required environment and dependencies for running in Windows and Linux environments:
Item | Linux | Windows |
---|---|---|
System architecture | x86 architecture | - |
python | 3.9 or higher | 3.9 or higher |
Specific dependency | - | - |
Linux configuration
Refer to the python official website - linux to download and install python3.9.
After entering the project directory, open the terminal and run the following command to install dependencies:
pip install -r requirements.txt
Windows configuration
Refer to the python official website - Windows to download and install python3.9.
After entering the project directory, open the terminal and run the following command to install dependencies:
pip install -r requirements.txt
5. Notes
This demo uses the RM65-B robotic arm as an example. Please modify the data in the code according to your actual situation.
6. User guide
6.1 Quick run
Parameter configuration
Open the
demo_algo_interface.py
file, and modify the following configurations in the main function:- Configure the IP address of the robotic arm to connect (
"192.168.1.18"
by default): If you have changed the IP address of the robotic arm, modify the initialization parameters of theRobotArmController
class to the current IP address of the robotic arm. - Configure the id for saving the file to the online programming list (100 by default): modify the id used when saving the file to the online programming list by modifying the
test_id
parameter. Please check the online programming list and, if necessary, modify the id to ensure that the id is available in your online programming list. - Configure the controller IO multiplexing function (default settings: IO1: start running the online programming file, IO2: pause running the online programming file, IO3: resume running the online programming file, IO4: emergency stop): modify the multiplexing mode of each IO port through the
set_io_mode
method.
- Configure the IP address of the robotic arm to connect (
Running via command line
Navigate to the
RMDemo_IOControl
directory in the terminal, and enter the following command to run the C program:pythonpython ./src/main.py
Drag the robotic arm for teaching
When the terminal prints the following information, the robotic arm has entered drag teaching mode. You can drag the robotic arm to complete the required trajectory. After finishing the drag, you can press the Enter key to exit drag teaching mode and save the trajectory to the trajectory.txt file in the data folder.
Control the running, pause, resumption, and emergency stop of the trajectory file through the IO multiplexing mode
After the program finishes running, the trajectory file saved from drag teaching has been saved to the online programming file list with the specified id and set as the online programming file that the IO runs by default. At this point, the controller IO is set to:
- IO1: start running the online programming file;
- IO2: pause running the online programming file;
- IO3: resume running the online programming file;
- IO4: emergency stop;
The IO is triggered by a high-level signal. After completing the IO wiring according to "9. Controller and end effector interface diagram," you can activate the corresponding IO function by applying a high-level signal to the respective IO port.
Running result
After running the script, the output result is as follows:
Successfully connected to the robot arm: 1
API Version: 0.3.0
Drag teaching started
Drag teaching has started, complete the drag operation and press Enter to continue...
Drag teaching stopped
Trajectory saved successfully, total number of points: 100
Project send successfully but not run, data length verification failed
Set default running program successfully: Program ID 100
IO mode set successfully: IO number 1
IO mode set successfully: IO number 2
IO mode set successfully: IO number 3
IO mode set successfully: IO number 4
Successfully disconnected from the robot arm
6.2 Code description
The following are the main functions of the demo_io_control.py
file:
Drag for teaching
pythonrobot_controller.drag_teach(1)
Start drag teaching and record the trajectory.
Save the trajectory
pythonlines = robot_controller.save_trajectory(file_path_test)
Save the recorded trajectory to a file.
Add header information to the file
pythonrobot_controller.add_lines_to_file(file_path_test, 6, lines)
Add the specified information to the trajectory file.
Send the project file
pythonrobot_controller.send_project(file_path_test, only_save=1, save_id=test_id)
Send the project file to the robotic arm.
Set the default running program
pythonrobot_controller.set_default_run_program(test_id)
Set the default online programming file.
Set the IO mode
pythonrobot_controller.set_io_mode(1, 2) # Set IO mode to input start function multiplexing mode robot_controller.set_io_mode(2, 3) # Set IO mode to input pause function multiplexing mode robot_controller.set_io_mode(3, 4) # Set IO mode to input continue function multiplexing mode robot_controller.set_io_mode(4, 5) # Set IO mode to input emergency stop function multiplexing mode
Set the mode of IO ports.
Set the digital IO output state
pythonrobot_controller.set_do_state(io_num, io_state)
Set the output state of digital IO ports.
Get the digital IO input state
pythonrobot_controller.get_io_input(io_num)
Get the input state of digital IO ports.
7. License information
- This project is subject to the MIT license.
8. Controller and end effector interface diagram
Controller IO Interface Diagram
The definitions of wires are explained in the following Table.
No. | First-generation cable wiring sequence | Second-generation cable wiring sequence | Definition | Description | Wire number (for second-generation cables only) | Remarks |
---|---|---|---|---|---|---|
1 | Pink and brown | Black stripe brown/brown | VOUT | External output + | NO.1 | 12 V/24 V |
2 | Gray and purple | Gray/purple | P_IO_GND | External output - | NO.2 | |
3 | Yellow | Yellow | 485A | NO.3 | ||
4 | Yellow and green | Black stripe yellow | 485B | NO.4 | ||
5 | Purple and white | Black stripe white | IO1 | Igital input/output bidirectional channel | NO.5 | |
6 | Red and white | White stripe red | IO2 | Igital input/output bidirectional channel | NO.6 | |
7 | Green and white | Black stripe green | IO3 | Igital input/output bidirectional channel | NO.7 | |
8 | Yellow and white | White stripe black | IO4 | Igital input/output bidirectional channel | NO.8 | |
9 | Blue and white | Black stripe orange | OUT_P_IN | Digital power supply for external input | NO.9 | 0−24 V |
10 | Light blue | Black stripe blue | OUT_P_OUT | Digital power supply for external output | NO.10 | 0−24 V |
11 | Deep blue | Blue | OUT_P_GND | External digital ground | NO.11 | |
12 | Green | Green | FDCAN_A | CAN_H | NO.12 | |
13 | Red | Red | FDCAN_B | CAN_L | NO.13 | |
14 | White | White | Blank | Reserved | NO.14 | |
15 | Black | Black | Blank | Reserved | NO.15 | |
16 | Orange | Orange | Blank | Reserved | NO.16 |
Note
The voltage of digital I/O is determined based on the reference voltage connected, and the 16-core extension interface cable of robotic arm provides only 12 V and 24 V power supply voltages. If other output voltages are required for the digital I/O, then reference voltages need to be led in from the pins OUT_P_OUT+, OUT_P_IN+, and OUT_P_GND.
End Effector IO Interface Diagram
The end effector IO interface connects external tools through a 6-core aerial plug. The pins and definitions of the aerial plug are as follows.
Pin No. | Wiring color | Function |
---|---|---|
1 | Yellow | RS485_A |
2 | White | RS485_B |
3 | Red | Digital interface 1 (DI1/DO1) |
4 | Black | Digital interface 2 (DI2/DO2) |
5 | Green | Power GND |
6 | Blue | Power output: 0 V/5 V/12 V/24 V, controllable by program |
Note
The multiplexing functions in the table above are switched by program commands. Pin 3 and pin 4 are digital input channels (DI1 and DI2) by default before delivery, and the power output of pin 6 is 0 V (programmed).