Demo (C, C++):
Basic demo of building a project via CMake 1. Project introduction
This project provides a demo based on building with CMake, utilizing the RealMan robotic arm C language development package to complete basic functions such as robotic arm connection, robotic arm version acquisition, API version acquisition, Movej motion, and disconnection. It aims to help users quickly create a cross-platform project built with CMake.
2. Code structure
RMDemo_SimpleProcess
├── build # Output directory generated by CMake build (Makefile, build file, etc.)
├── include # Custom header file storage directory
├── Robotic_Arm # RealMan robotic arm secondary development package
│ ├── include
│ │ ├── rm_define.h # Header file of the robotic arm secondary development package, containing defined data types and structures
│ │ └── rm_interface.h # Header file of the robotic arm secondary development package, declaring all operation interfaces of the robotic arm口
│ ├── lib
│ │ ├── api_c.dll # API library for Windows 64bit
│ │ ├── api_c.lib # API library for Windows 64bit
│ │ └── libapi_c.so # API library for Linux x86
├── src
│ ├── main.c # Main function
├── CMakeLists.txt # Top-level CMake configuration file of the project
├── readme.md # Project description document
├── run.bat # Windows quick run script
└── run.sh # linux quick run script
3. Project download
Download RM_API2
locally via the link: development package download. Then, navigate to the RM_API2\Demo\RMDemo_C
directory, where you will find RMDemo_SimpleProcess.
4. Environment configuration
Required environment and dependencies for running in Windows and Linux environments:
Item | Linux | Windows |
---|---|---|
System architecture | x86 architecture | - |
Compiler | GCC 7.5 or higher | MSVC2015 or higher 64bit |
CMake version | 3.10 or higher | 3.10 or higher |
Specific dependency | RMAPI Linux version library (located in the Robotic_Arm/lib directory) | RMAPI Windows version library (located in the Robotic_Arm/lib directory) |
Linux configuration
1. Compiler (GCC) In most Linux distributions, GCC is installed by default, but the version may not be the latest. If a specific version of GCC (such as 7.5 or higher) is required, it can be installed via the package manager. For example, on Ubuntu, you can use the following commands to install or update GCC:
# Check GCC version
gcc --version
sudo apt update
sudo apt install gcc-7 g++-7
Note: If the GCC version installed by default on the system meets or exceeds the required version, no additional installation is necessary.
2. CMake CMake can also be installed through the package manager in most Linux distributions. For example, on Ubuntu:
sudo apt update
sudo apt install cmake
# Check CMake version
cmake --version
Windows configuration
Compiler (MSVC2015 or higher): The MSVC (Microsoft Visual C++) compiler is typically installed with Visual Studio. You can install it by following these steps:
- Visit the Visual Studio official website to download and install Visual Studio.
- During installation, select the "Desktop development with C++" workload, which will include the MSVC compiler.
- Select additional components as needed, such as CMake (if not already installed).
- After installation, open the Visual Studio command prompt (available in the start menu) and enter the
cl
command to check if the MSVC compiler is installed successfully.
CMake: If CMake was not included during the Visual Studio installation, you can download and install CMake separately.
- Visit the CMake official website to download the installer for Windows.
- Run the installer and follow the on-screen instructions to complete the installation.
- After installation, add the CMake bin directory to the system's PATH environment variable (this is typically asked during installation).
- Open the command prompt or PowerShell and enter
cmake --version
to check if CMake has been installed successfully.
5. User guide
5.1 Quick run
Follow these steps to quickly run the code:
Configuration of the IP address of the robotic arm: Open the
main.c
file and modify the parameters of therobot_ip_address
in themain
function to the current IP address of the robotic arm. The default IP address is"192.168.1.18"
.Cconst char *robot_ip_address = "192.168.1.18"; int robot_port = 8080; rm_robot_handle *robot_handle = rm_create_robot_arm(robot_ip_address, robot_port);
Running via linux command line: Navigate to the
RMDemo_SimoleProcess
directory in the terminal, and enter the following command to run the C program:bashchmod +x run.sh ./run.sh
The running result is as follows:
bashAPI Version: 1.0.0. Robot handle created successfully: 1 ================== Arm Software Information ================== Arm Model: RM65-BI Algorithm Library Version: 1.4.4 Control Layer Software Version: V1.6.1 Dynamics Version: 2 Planning Layer Software Version: V1.6.1 ==============================================================
Running on Windows: double-click the run.bat script to run The running result is as follows:
API Version: 1.0.0.
Robot handle created successfully: 1
================== Arm Software Information ==================
Arm Model: RM65-BI
Algorithm Library Version: 1.4.4
Control Layer Software Version: V1.6.1
Dynamics Version: 2
Planning Layer Software Version: V1.6.1
==============================================================
Press any key to continue...
5.2 Description of key codes
The following are the main functions of the main.c
:
Define parameter arrays of different models of robotic arms
CArmModelData arm_data[9] = { [RM_MODEL_RM_65_E] = { .joint_angles = {0, 20, 70, 0, 90, 0}, .movej_pose1 = { .position = {0.3, 0, 0.3}, .euler = {3.14, 0, 0} }, .movel_pose = { .position = {0.3, 0, 0.3}, .euler = {3.14, 0, 0} }, .movej_pose2 = { .position = {0.3, 0, 0.3}, .euler = {3.14, 0, 0} }, .movec_pose_via = { .position = {0.2, 0.05, 0.3}, .euler = {3.14, 0, 0} }, .movec_pose_to = { .position = {0.2, -0.05, 0.3}, .euler = {3.14, 0, 0} } }, [RM_MODEL_RM_75_E] = { .joint_angles = {0, 20, 0, 70, 0, 90, 0}, .movej_pose1 = { .position = {0.297557, 0, 0.337061}, .euler = {3.142, 0, 3.142} } , .movel_pose = { .position = {0.097557, 0, 0.337061}, .euler = {3.142, 0, 3.142} } , .movej_pose2 = { .position = {0.297557, 0, 0.337061}, .euler = {3.142, 0, 3.142} } , .movec_pose_via = { .position = {0.257557, -0.08, 0.337061}, .euler = {3.142, 0, 3.142} } , .movec_pose_to = { .position = {0.257557, 0.08, 0.337061}, .euler = {3.142, 0, 3.142} } }, [RM_MODEL_RM_63_II_E] = { .joint_angles = {0, 20, 70, 0, 90, 0}, .movej_pose1 = { .position = {0.448968, 0, 0.345083}, .euler = {3.142, 0, 3.142} }, .movel_pose = { .position = {0.248968, 0, 0.345083}, .euler = {3.142, 0, 3.142} }, .movej_pose2 = { .position = {0.448968, 0, 0.345083}, .euler = {3.142, 0, 3.142} }, .movec_pose_via = { .position = {0.408968, -0.1, 0.345083}, .euler = {3.142, 0, 3.142} }, .movec_pose_to = { .position = {0.408968, 0.1, 0.345083}, .euler = {3.142, 0, 3.142} } }, [RM_MODEL_ECO_65_E] = { .joint_angles = {0, 20, 70, 0, -90, 0}, .movej_pose1 = { .position = {0.352925, -0.058880, 0.327320}, .euler = {3.141, 0, -1.57} } , .movel_pose = { .position = {0.152925, -0.058880, 0.327320}, .euler = {3.141, 0, -1.57} } , .movej_pose2 = { .position = {0.352925, -0.058880, 0.327320}, .euler = {3.141, 0, -1.57} } , .movec_pose_via = { .position = {0.302925, -0.158880, 0.327320}, .euler = {3.141, 0, -1.57} } , .movec_pose_to = { .position = {0.302925, 0.058880, 0.327320}, .euler = {3.141, 0, -1.57} } }, [RM_MODEL_GEN_72_E] = { .joint_angles = {0, 0, 0, -90, 0, 0, 0}, .movej_pose1 = { .position = {0.1, 0, 0.4}, .euler = {3.14, 0, 0} } , .movel_pose = { .position = {0.3, 0, 0.4}, .euler = {3.14, 0, 0} } , .movej_pose2 = { .position = {0.3595, 0, 0.4265}, .euler = {3.14, 0, 0} } , .movec_pose_via = { .position = {0.3595, 0.03, 0.4265}, .euler = {3.14, 0, 0} } , .movec_pose_to = { .position = {0.3595, 0.03, 0.4665}, .euler = {3.14, 0, 0} } }, [RM_MODEL_ECO_63_E] = { .joint_angles = {0, 20, 70, 0, -90, 0}, .movej_pose1 = { .position = {0.544228, -0.058900, 0.468274}, .euler = {3.14, 0, -1.571} }, .movel_pose = { .position = {0.344228, -0.058900, 0.468274}, .euler = {3.14, 0, -1.571} }, .movej_pose2 = { .position = {0.544228, -0.058900, 0.468274}, .euler = {3.14, 0, -1.571} }, .movec_pose_via = { .position = {0.504228, -0.108900, 0.468274}, .euler = {3.14, 0, -1.571} }, .movec_pose_to = { .position = {0.504228, -0.008900, 0.468274}, .euler = {3.14, 0, -1.571} } } };
Connect the robotic arm
Crm_robot_handle *robot_handle = rm_create_robot_arm(robot_ip_address, robot_port);
Connect the robotic arm to the specified IP address and port.
Get the API version
Cchar *api_version = rm_api_version(); printf("API Version: %s.\n", api_version);
Get and display the API version.
Get the software information of the robotic arm
Cget_robot_software_info(robot_handle);
Get and display the basic information of the robotic arm, including product version, algorithm library version, control layer software version, dynamics version, and planning layer software version.
Execute the movej motion
Crm_movej(robot_handle, arm_data[arm_info.arm_model].joint_angles, 20, 0, 0, 1);
Execute the movej_p motion
Crm_movej_p(robot_handle, arm_data[arm_info.arm_model].movej_pose1, 20, 0, 0, 1);
Execute the movel motion
Crm_movel(robot_handle, arm_data[arm_info.arm_model].movel_pose, 20, 0, 0, 1);
Execute the movec motion
Crm_movec(robot_handle, arm_data[arm_info.arm_model].movec_pose_via, arm_data[arm_info.arm_model].movec_pose_to, 20, 2, 0, 0, 1);
Disconnect from the robotic arm
Cdisconnect_robot_arm(robot_handle);
6. License information
- This project is subject to the MIT license.