ur_hardware_interface.h
Go to the documentation of this file.
00001 /*
00002  * ur_hardware_control_loop.cpp
00003  *
00004  * Copyright 2015 Thomas Timm Andersen
00005  *
00006  * Licensed under the Apache License, Version 2.0 (the "License");
00007  * you may not use this file except in compliance with the License.
00008  * You may obtain a copy of the License at
00009  *
00010  *     http://www.apache.org/licenses/LICENSE-2.0
00011  *
00012  * Unless required by applicable law or agreed to in writing, software
00013  * distributed under the License is distributed on an "AS IS" BASIS,
00014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  * See the License for the specific language governing permissions and
00016  * limitations under the License.
00017  */
00018 
00019 /* Based on original source from University of Colorado, Boulder. License copied below. */
00020 
00021 /*********************************************************************
00022  * Software License Agreement (BSD License)
00023  *
00024  *  Copyright (c) 2015, University of Colorado, Boulder
00025  *  All rights reserved.
00026  *
00027  *  Redistribution and use in source and binary forms, with or without
00028  *  modification, are permitted provided that the following conditions
00029  *  are met:
00030  *
00031  *   * Redistributions of source code must retain the above copyright
00032  *     notice, this list of conditions and the following disclaimer.
00033  *   * Redistributions in binary form must reproduce the above
00034  *     copyright notice, this list of conditions and the following
00035  *     disclaimer in the documentation and/or other materials provided
00036  *     with the distribution.
00037  *   * Neither the name of the Univ of CO, Boulder nor the names of its
00038  *     contributors may be used to endorse or promote products derived
00039  *     from this software without specific prior written permission.
00040  *
00041  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00042  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00043  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00044  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00045  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00046  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00047  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00048  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00049  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00050  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00051  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00052  *  POSSIBILITY OF SUCH DAMAGE.
00053  *********************************************************************
00054 
00055  Author: Dave Coleman
00056  */
00057 
00058 #ifndef UR_ROS_CONTROL_UR_HARDWARE_INTERFACE_H
00059 #define UR_ROS_CONTROL_UR_HARDWARE_INTERFACE_H
00060 
00061 #include <hardware_interface/joint_state_interface.h>
00062 #include <hardware_interface/joint_command_interface.h>
00063 #include <hardware_interface/force_torque_sensor_interface.h>
00064 #include <hardware_interface/robot_hw.h>
00065 #include <controller_manager/controller_manager.h>
00066 #include <boost/scoped_ptr.hpp>
00067 #include <ros/ros.h>
00068 #include <math.h>
00069 #include "do_output.h"
00070 #include "ur_driver.h"
00071 
00072 namespace ros_control_ur {
00073 
00074 // For simulation only - determines how fast a trajectory is followed
00075 static const double POSITION_STEP_FACTOR = 1;
00076 static const double VELOCITY_STEP_FACTOR = 1;
00077 
00079 class UrHardwareInterface: public hardware_interface::RobotHW {
00080 public:
00081 
00086         UrHardwareInterface(ros::NodeHandle& nh, UrDriver* robot);
00087 
00089         virtual void init();
00090 
00092         virtual void read();
00093 
00095         virtual void write();
00096 
00097         void setMaxVelChange(double inp);
00098 
00099         bool canSwitch(
00100                         const std::list<hardware_interface::ControllerInfo> &start_list,
00101                         const std::list<hardware_interface::ControllerInfo> &stop_list) const;
00102         void doSwitch(const std::list<hardware_interface::ControllerInfo>&start_list,
00103                         const std::list<hardware_interface::ControllerInfo>&stop_list);
00104 
00105 protected:
00106 
00107         // Startup and shutdown of the internal node inside a roscpp program
00108         ros::NodeHandle nh_;
00109 
00110         // Interfaces
00111         hardware_interface::JointStateInterface joint_state_interface_;
00112         hardware_interface::ForceTorqueSensorInterface force_torque_interface_;
00113         hardware_interface::PositionJointInterface position_joint_interface_;
00114         hardware_interface::VelocityJointInterface velocity_joint_interface_;
00115         bool velocity_interface_running_;
00116         bool position_interface_running_;
00117         // Shared memory
00118         std::vector<std::string> joint_names_;
00119         std::vector<double> joint_position_;
00120         std::vector<double> joint_velocity_;
00121         std::vector<double> joint_effort_;
00122         std::vector<double> joint_position_command_;
00123         std::vector<double> joint_velocity_command_;
00124         std::vector<double> prev_joint_velocity_command_;
00125                 std::size_t num_joints_;
00126         double robot_force_[3] = { 0., 0., 0. };
00127         double robot_torque_[3] = { 0., 0., 0. };
00128 
00129         double max_vel_change_;
00130 
00131         // Robot API
00132         UrDriver* robot_;
00133 
00134 };
00135 // class
00136 
00137 }// namespace
00138 
00139 #endif


ur_modern_driver
Author(s): Thomas Timm Andersen
autogenerated on Wed Apr 3 2019 02:55:31