Starai Arm 机械臂-ROS2 Moveit 使用教程 Starai Arm Manipulator – ROS2 MoveIt Guide

环境依赖/Dependent Environment
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.5 LTS
Release: 22.04
Codename: Jammy
ROS2: Humble
安装ROS2 Humble/Install ROS2 Humble
安装Moveit2/Install Moveit2
sudo apt install ros-humble-moveit*
安装舵机SDK库/Install servo’s SDK
sudo pip install pyserial
sudo pip install fashionstar-uart-sdk
克隆star-arm-moveit2功能包/Clone star-arm-moveit2 Ros2’s Package
cd ~/
git clone https://github.com/Welt-liu/star-arm-moveit2.git
cd ~/star-arm-moveit2
colcon build
echo "source ~/star-arm-moveit2/install/setup.bash" >> ~/.bashrc
source ~/.bashrc
https://github.com/user-attachments/assets/33fa3722-f0d4-4521-818d-a49d7f6b4909
MoveIt2
激活机械臂&MoveIt2/Activate the robotic arm & MoveIt2
使用虚拟机械臂/Using a virtual robotic arm
Viola
ros2 launch viola_moveit_config demo.launch.py
Cello
ros2 launch cello_moveit_config demo.launch.py
使用真实的机械臂/Using a real robotic arm
终端1:启动手臂硬件驱动/Terminal 1: Start the arm hardware driver
手臂会移动到零位/The Arm Will Move to The Zero Position.
Viola
ros2 launch viola_moveit_config driver.launch.py
Cello
ros2 launch cello_moveit_config driver.launch.py
终端2:启动moveit2/Terminal 2:Starthe Moveit2
Viola
ros2 launch viola_moveit_config actual_robot_demo.launch.py
Cello
ros2 launch cello_moveit_config actual_robot_demo.launch.py
到此可实现虚拟机械臂控制真实机械臂的功能/At this point, you can control the real robotic arm with the virtual robotic arm.
手臂末端位姿读写示例/End-effector pose read/write demo
终端3:启动末端位姿读写示例/Terminal 3: Start the end-effector pose read/write demo
Viola
ros2 launch viola_moveit_config moveit_write_read.launch.py
Cello
ros2 launch cello_moveit_config moveit_write_read.launch.py
位姿话题发送节点示例/Position and orientation topic sending node demo
请更新文件/update here
src/arm_moveit_write/src/topic_publisher.cpp
// viola
// dataset1_ = {
// {0.35, -0.00, 0.23}, // position
// {-0.499, 0.500, -0.500, 0.500}, // orientation
// "open" // gripper_state
// };
// dataset2_ = {
// {0.15, -0.00, 0.299}, // position
// {0.500, -0.500, 0.500, -0.499}, // orientation
// "close" // gripper_state
// };
//cello
dataset1_ = {
{0.278, 0.000, 0.438}, // position
{-0.506, 0.507, -0.496, 0.491}, // orientation
"open" // gripper_state
};
dataset2_ = {
{0.479, -0.000, 0.369}, // position
{-0.506, 0.507, -0.496, 0.491}, // orientation
"close" // gripper_state
};
终端4:启动位姿话题发送节点/Terminal 4: Start the position and orientation topic sending node
colcon build
source install/setup.sh
ros2 run arm_moveit_write topic_publisher
MoveIt2-gazebo仿真机械臂例程/MoveIt2-Gazebo Simulation Robot Arm Example
[!TIP]
在关闭gazebo图形界面后,建议在终端使用
pkill -9 -f gazebo命令彻底关闭
在运行例程前,需要关闭其他所有正在运行的节点。
安装gazebo/Install gazebo
bash
sudo apt install gazebo
sudo apt install ros-humble-moveit*
终端1:启动gazebo图形界面/Terminal 1: Launch the Gazebo graphical user interface
Viola
ros2 launch viola_gazebo viola_gazebo.launch.py
Cello
ros2 launch cello_gazebo cello_gazebo.launch.py
终端2:启动moveit2界面/Terminal 2:Launch the MoveIt2 interface
Viola
ros2 launch viola_moveit_config gazebo_demo.launch.py
Cello
ros2 launch cello_moveit_config gazebo_demo.launch.py
机械臂示教模式/Teaching Mode for the Robotic Arm
[!TIP]
需要重新录制轨迹,可将record-test文件夹删除or新建终端文件名record-test1/Delete the record-test folder, or create a new terminal file name record-test1
终端1:启动手臂硬件驱动(示教模式)/Terminal 1: Start the arm hardware driver (teaching mode)
ros2 run robo_driver driver --ros-args -p lock:='disable'
终端2:记录手臂轨迹/Terminal 2: Record arm trajectory
按下回车开始录制,再按下回车结束录制,通过dataset参数指定保存路径/Press Enter to start recording, press Enter to end recording, and specify the save path through the dataset parameter.
ros2 run ros2_bag_recorder bag_recorder --ros-args -p dataset:=star/record-test
终端3:重播运行轨迹/Terminal 3: Replay the recorded trajectory
ros2 bag play ./star/record-test
FAQ
如果rivz2界面出现频闪,可以尝试以下指令/
If you experience flickering in the RViz2 interface, try the following commands:
bash
export QT_AUTO_SCREEN_SCALE_FACTOR=0