(二)moveit控制KUKA真实机械臂

在(一)中我讲了然后将KUKA和ROS实现通讯,接下来就是用moveit控制KUKA机械臂。

首先是配置moveit文件,这里就不在赘述了,网上教程很多且适用于任何的机械臂。

我的Ubuntu是18.04故ROS是melodic版本,之前我用20.04noetic版本配置出的moveit文件相比melodic版本多生成出了一些control文件,并且一些参数也有点不一样。当时我对moveit里面的控制原理还不太熟悉所以导致搞不出来,遂换成melodic版本,但如果你是noetic可以在看完我的配置尝试一下。

在生成的moveit配置文件里修改。

1.修改move_group.launch文件参数

fake_execution的值改为false;在node name ="move_group"下添加两个参数来延长允许执行轨迹的时间.

<arg name="fake_execution" default="false"/>
  <!-- Start the actual move_group node/action server -->
  <node name="move_group" launch-prefix="$(arg launch_prefix)" pkg="moveit_ros_move_group" type="move_group" respawn="false" output="screen" args="$(arg command_args)">
  <param name="trajectory_execution/allowed_execution_duration_scaling" value="6"/>      //允许轨迹执行时间的一个放大倍数,可以根据实际情况自行修改
  <param name="trajectory_execution/allowed_goal_duration_margin" value="0.5"/>            //超时的一个百分比范围

2. 在kuka_kr6r700sixx_moveit_controller_manager.launch文件中我的自动生成了,我看网上有人里面是空的。

<launch>
  <!-- Define the controller manager plugin to use for trajectory execution -->
  <param name="moveit_controller_manager" value="moveit_simple_controller_manager/MoveItSimpleControllerManager" />

  <!-- loads controller list to the param server -->
  <rosparam file="$(find kuka_moveit_config)/config/ros_controllers.yaml"/>
</launch>

3.修改config文件下的ros_controllers.yaml文件将里面内容替换成如下:(切忌最好一样,不然控制不了,具体原因可以去看hw_interface文件里的参数)

controller_list:
  - name: ""
    action_ns: joint_trajectory_action
    type: FollowJointTrajectory
    joints: [joint_a1, joint_a2, joint_a3, joint_a4, joint_a5, joint_a6]

4.最后一步,在launch文件夹下新建一个lanch文件:moveit_planning_execution.launch。这个launch文件包含了kuka关节名字节点、kuka的ip、moveit启动节点、eki_hw_interface硬件通讯节点、tf坐标发布节点、rviz节点。

<launch>
  <!-- The planning and execution components of MoveIt! configured to run -->
  <!-- using the ROS-Industrial interface. -->
  <!-- Non-standard joint names:
       - Create a file [robot_moveit_config]/config/joint_names.yaml
           controller_joint_names: [joint_1, joint_2, ... joint_N] 
       - Update with joint names for your robot (in order expected by rbt controller)
       - and uncomment the following line: -->

  <rosparam command="load" file="$(find kuka_kr6_support)/config/joint_names_kr6r700sixx.yaml"/>  # 改成你机械臂的关节
 <arg name="debug" default="false" />

  <!-- the "sim" argument controls whether we connect to a Simulated or Real robot -->
  <!--  - if sim=false, a robot_ip argument is required -->
  <arg name="sim" default="false" />                # 这个表示不是仿真,开始实战了
  <arg name="robot_ip" default="10.11.146.10" />    # 改成你机械臂的ip

  <!--arg name="robot_ip" unless="$(arg sim)" /-->

  <!-- load the robot_description parameter before launching ROS-I nodes -->
  <include file="$(find kuka_moveit_config)/launch/planning_context.launch" >
    <arg name="load_robot_description" value="true" />
  </include>

  <!-- run the robot simulator and action interface nodes -->
  <group if="$(arg sim)">
    <include file="$(find industrial_robot_simulator)/launch/robot_interface_simulator.launch" />
  </group>

  <!-- run the "real robot" interface nodes -->
  <!--   - this typically includes: robot_state, motion_interface, and joint_trajectory_action nodes -->
  <!--   - replace these calls with appropriate robot-specific calls or launch files -->
  <group unless="$(arg sim)">
    <include file="$(find kuka_eki_hw_interface)/launch/robot_interface_streaming.launch" >
      <arg name="robot_ip" value="$(arg robot_ip)"/>
    </include>
    </group>
  <!-- publish the robot state (tf transforms) -->
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" />

  <include file="$(find kuka_moveit_config)/launch/move_group.launch">
    <arg name="publish_monitored_planning_scene" value="true" />
  </include>

  <include file="$(find kuka_moveit_config)/launch/moveit_rviz.launch">
     <arg name="rviz_config" value="$(find kuka_moveit_config)/launch/moveit.rviz"/>
    <arg name="debug" value="$(arg debug)"/>
  </include>

  <include file="$(find kuka_moveit_config)/launch/default_warehouse_db.launch" />

</launch>

然后你就可以运行这个launch文件开心的玩耍你的机械臂了!

最后总结一下可能遇到的问题

1.Unable to identify any set of controllers that can actuate the specified joints: [ joint_a1 joint_a2 joint_a3 joint_a4 joint_a5 joint_a6 ]

解决办法:安装ros-controllers库

sudo apt install ros-melodic-ros-controllers

2.忘记是啥问题了反正是装一个功能包

git clone https://github.com/ros-controls/ros_control.git

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值