总结记录ros kinetic控制UR3机械臂

本文详细记录了使用ROS Kinetic在Ubuntu 16.04环境下控制UR3机械臂的过程,包括工作环境配置、UR功能包的安装与修改、与UR3的连接以及运行程序的步骤。主要涉及了ur_modern_driver的使用,以适应UR3的最新操作系统。
摘要由CSDN通过智能技术生成

前言

复习并记录一下如何用ros kinetic控制UR3机械臂。

一、工作环境配置

ubuntu16.04.6
ros-kinetic
ros kinetic-moveit
universal_robot
UR3机械臂

二、步骤

1.建立工作空间

1.新建名为lyur3的工作空间:

mkdir -p ~/lyur3/src

2.进入文件目录:

cd ~/lyur3/src

3.初始化工作空间:

catkin_init_workspace

4.进入文件目录lyur3:

cd ~/lyur3

5.首次编译:

catkin_make

在这里插入图片描述

6.打开环境变量配置文件:

gedit ~/.bashrc 

7.将下列添加到最后边并运行(其中ryain为电脑用户名,lyur3为工作区名称):

source /home/ryain/lyur3/devel/setup.bash

在这里插入图片描述
7.确认配置的环境变量:

echo $ROS_PACKAGE_PATH

在这里插入图片描述

2.配置UR功能包

1.下载universal_robot的功能包:

git clone https://github.com/ros-industrial/universal_robot.git

将universal_robot功能包拷贝到刚刚建立的lyur3工作空间src文件目录下

在这里插入图片描述2.因为不同的UR机械臂操作系统所对应的驱动不同,而UR功能包中只有ur_driver旧版本,而实验室所用UR3的ployscope版本为3.5,
在这里插入图片描述
所以需将ur_driver替换为ur_modern_driver。

下载ur_modern_driver

git clone https://github.com/ros-industrial/ur_modern_driver.git

需要被替换的文件
需要替换的文件
3.更改ur_hardware_interface.cpp文件。
将ur_modern_driver中的ur_hardware_interface.cpp打开,对比如下网址更改。
https://github.com/iron-ox/ur_modern_driver/commit/883070d0b6c0c32b78bb1ca7155b8f3a1ead416c

在这里插入图片描述更改完毕后:

/*
 * ur_hardware_control_loop.cpp
 *
 * Copyright 2015 Thomas Timm Andersen
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* Based on original source from University of Colorado, Boulder. License copied below. */

/*********************************************************************
 * Software License Agreement (BSD License)
 *
 *  Copyright (c) 2015, University of Colorado, Boulder
 *  All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above
 *     copyright notice, this list of conditions and the following
 *     disclaimer in the documentation and/or other materials provided
 *     with the distribution.
 *   * Neither the name of the Univ of CO, Boulder nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 *  POSSIBILITY OF SUCH DAMAGE.
 *********************************************************************

 Author: Dave Coleman
 */

#include <ur_modern_driver/ur_hardware_interface.h>

namespace ros_control_ur {
   

UrHardwareInterface::UrHardwareInterface(ros::NodeHandle& nh, UrDriver* robot) :
		nh_(nh), robot_(robot) {
   
	// Initialize shared memory and interfaces here
	init(); // this implementation loads from rosparam

	max_vel_change_ = 0.12; // equivalent of an acceleration of 15 rad/sec^2

	ROS_INFO_NAMED("ur_hardware_interface", "Loaded ur_hardware_interface.");
}

void UrHardwareInterface::init() {
   
	ROS_INFO_STREAM_NAMED("ur_hardware_interface",
			"Reading rosparams from namespace: " << nh_.getNamespace());

	// Get joint names
	nh_.getParam("hardware_interface/joints", joint_names_);
	if (joint_names_.size() == 0) {
   
		ROS_FATAL_STREAM_NAMED("ur_hardware_interface",
				"No joints found on parameter server for controller, did you load the proper yaml file?" << " Namespace: " 
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值