创建工作空间
cd ~
mkdir -p catkin_ws/src
cd ~/catkin_ws/src
下载代码
~/catkin_ws/src$ git clone https://github.com/dairal/ur5-joint-position-control.git
~/catkin_ws/src$ cd ..
~/catkin_ws$ catkin_make
~/catkin_ws$ source devel/setup.bash
安装ros-control
sudo apt-get install ros-$ROS_DISTRO-ros-control ros-$ROS_DISTRO-ros-controllers
安装universal_robot package
~/catkin_ws/src$ git clone -b <distro>-devel https://github.com/ros-industrial/universal_robot.git $ cd $HOME/catkin_ws
$ rosdep update
$ rosdep install --rosdistro $ROS_DISTRO --ignore-src --from-paths src
注意这里替换 <distro> 为你的ubuntu版本
build工作空间
~/catkin_ws$ catkin_make
~/catkin_ws$ source devel/setup.bash
打开一个terminal,打开gazebo
roslaunch gazebo_ros empty_world.launch
再打开另一个终端,别忘了先source一下
rosrun gazebo_ros spawn_model -file `rospack find ur5-joint-position-control`/urdf/ur5_jnt_pos_ctrl.urdf -urdf -x 0 -y 0 -z 0.1 -model ur5
-file后面是机械臂urdf文件的路径
如果我们足够幸运的话,会看到这样
[INFO] [1702729261.847239, 0.000000]: Loading model XML from file /home/robotics/ur5_tutorial/src/ur5-joint-position-control/urdf/ur5_jnt_pos_ctrl.urdf
[INFO] [1702729261.852031, 34.933000]: Waiting for service /gazebo/spawn_urdf_model
[INFO] [1702729261.854868, 34.937000]: Calling service /gazebo/spawn_urdf_model
[INFO] [1702729262.149281, 35.137000]: Spawn status: SpawnModel: Successfully spawned entity
还是在这个terminal中,输入
roslaunch ur5-joint-position-control ur5_joint_position_control.launch
这时会看到一个趴在地上的机械臂
下面我们让这个机械臂立起来
关掉这两个正在运行的terminal。重新打开一个terminal,打开gazebo
roslaunch gazebo_ros empty_world.launch
这时注意,先点击gazebo窗口下面位置的暂停键。然后再打开一个terminal,source一下,输入
rosrun gazebo_ros spawn_model -file `rospack find ur5-joint-position-control`/urdf/ur5_jnt_pos_ctrl.urdf -urdf -x 0 -y 0 -z 0.1 -model ur5 -J shoulder_lift_joint -1.5 -J elbow_joint 1.0
然后还是在这个terminal,输入
roslaunch ur5-joint-position-control ur5_joint_position_control.launch
然后在gazebo中取消暂停,就会看到机械臂立起来了
再打开一个terminal
rosrun rqt_gui rqt_gui
就可以发布节点位置控制器的指令了
?
至此,实现ur5机械臂的手动控制。