kuka_hardware_interface.h
Go to the documentation of this file.
00001 /*********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  *  Copyright (c) 2014 Norwegian University of Science and Technology
00005  *  All rights reserved.
00006  *
00007  *  Redistribution and use in source and binary forms, with or without
00008  *  modification, are permitted provided that the following conditions
00009  *  are met:
00010  *
00011  *   * Redistributions of source code must retain the above copyright
00012  *     notice, this list of conditions and the following disclaimer.
00013  *   * Redistributions in binary form must reproduce the above
00014  *     copyright notice, this list of conditions and the following
00015  *     disclaimer in the documentation and/or other materials provided
00016  *     with the distribution.
00017  *   * Neither the name of the Norwegian University of Science and
00018  *     Technology, nor the names of its contributors may be used to
00019  *     endorse or promote products derived from this software without
00020  *     specific prior written permission.
00021  *
00022  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033  *  POSSIBILITY OF SUCH DAMAGE.
00034  *********************************************************************/
00035 
00036 /*
00037  * Author: Lars Tingelstad
00038  */
00039 
00040 #ifndef KUKA_RSI_HARDWARE_INTERFACE_KUKA_HARDWARE_INTERFACE_
00041 #define KUKA_RSI_HARDWARE_INTERFACE_KUKA_HARDWARE_INTERFACE_
00042 
00043 // STL
00044 #include <vector>
00045 #include <string>
00046 
00047 // ROS
00048 #include <ros/ros.h>
00049 #include <std_msgs/String.h>
00050 
00051 
00052 // ros_control
00053 #include <realtime_tools/realtime_publisher.h>
00054 #include <controller_manager/controller_manager.h>
00055 #include <hardware_interface/joint_command_interface.h>
00056 #include <hardware_interface/joint_state_interface.h>
00057 #include <hardware_interface/robot_hw.h>
00058 
00059 // Timers
00060 #include <chrono>
00061 
00062 // UDP server
00063 #include <kuka_rsi_hw_interface/udp_server.h>
00064 
00065 // RSI
00066 #include <kuka_rsi_hw_interface/rsi_state.h>
00067 #include <kuka_rsi_hw_interface/rsi_command.h>
00068 
00069 namespace kuka_rsi_hw_interface
00070 {
00071 
00072 static const double RAD2DEG = 57.295779513082323;
00073 static const double DEG2RAD = 0.017453292519943295;
00074 
00075 class KukaHardwareInterface : public hardware_interface::RobotHW
00076 {
00077 
00078 private:
00079 
00080   // ROS node handle
00081   ros::NodeHandle nh_;
00082 
00083   unsigned int n_dof_;
00084 
00085   std::vector<std::string> joint_names_;
00086 
00087   std::vector<double> joint_position_;
00088   std::vector<double> joint_velocity_;
00089   std::vector<double> joint_effort_;
00090   std::vector<double> joint_position_command_;
00091   std::vector<double> joint_velocity_command_;
00092   std::vector<double> joint_effort_command_;
00093 
00094   // RSI
00095   RSIState rsi_state_;
00096   RSICommand rsi_command_;
00097   std::vector<double> rsi_initial_joint_positions_;
00098   std::vector<double> rsi_joint_position_corrections_;
00099   unsigned long long ipoc_;
00100 
00101   std::unique_ptr<realtime_tools::RealtimePublisher<std_msgs::String> > rt_rsi_pub_;
00102 
00103   std::unique_ptr<UDPServer> server_;
00104   std::string local_host_;
00105   int local_port_;
00106   std::string remote_host_;
00107   std::string remote_port_;
00108   std::string in_buffer_;
00109   std::string out_buffer_;
00110 
00111   // Timing
00112   ros::Duration control_period_;
00113   ros::Duration elapsed_time_;
00114   double loop_hz_;
00115 
00116   // Interfaces
00117   hardware_interface::JointStateInterface joint_state_interface_;
00118   hardware_interface::PositionJointInterface position_joint_interface_;
00119 
00120 public:
00121 
00122   KukaHardwareInterface();
00123   ~KukaHardwareInterface();
00124 
00125   void start();
00126   void configure();
00127   bool read(const ros::Time time, const ros::Duration period);
00128   bool write(const ros::Time time, const ros::Duration period);
00129 
00130 };
00131 
00132 } // namespace kuka_rsi_hw_interface
00133 
00134 #endif


kuka_rsi_hw_interface
Author(s): Lars Tingelstad
autogenerated on Thu Jun 6 2019 17:56:48