00001 #ifndef YOUBOT_YOUBOTGRIPPERBAR_H 00002 #define YOUBOT_YOUBOTGRIPPERBAR_H 00003 00004 /**************************************************************** 00005 * 00006 * Copyright (c) 2011 00007 * All rights reserved. 00008 * 00009 * Hochschule Bonn-Rhein-Sieg 00010 * University of Applied Sciences 00011 * Computer Science Department 00012 * 00013 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00014 * 00015 * Author: 00016 * Jan Paulus, Nico Hochgeschwender, Michael Reckhaus, Azamat Shakhimardanov 00017 * Supervised by: 00018 * Gerhard K. Kraetzschmar 00019 * 00020 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00021 * 00022 * This sofware is published under a dual-license: GNU Lesser General Public 00023 * License LGPL 2.1 and BSD license. The dual-license implies that users of this 00024 * code may choose which terms they prefer. 00025 * 00026 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00027 * 00028 * Redistribution and use in source and binary forms, with or without 00029 * modification, are permitted provided that the following conditions 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 copyright 00034 * notice, this list of conditions and the following disclaimer in the 00035 * documentation and/or other materials provided with the distribution. 00036 * * Neither the name of the Hochschule Bonn-Rhein-Sieg nor the names of its 00037 * contributors may be used to endorse or promote products derived from 00038 * this software without specific prior written permission. 00039 * 00040 * This program is free software: you can redistribute it and/or modify 00041 * it under the terms of the GNU Lesser General Public License LGPL as 00042 * published by the Free Software Foundation, either version 2.1 of the 00043 * License, or (at your option) any later version or the BSD license. 00044 * 00045 * This program is distributed in the hope that it will be useful, 00046 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00047 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00048 * GNU Lesser General Public License LGPL and the BSD license for more details. 00049 * 00050 * You should have received a copy of the GNU Lesser General Public 00051 * License LGPL and BSD license along with this program. 00052 * 00053 ****************************************************************/ 00054 #include <vector> 00055 #include <sstream> 00056 #include "generic/Logger.hpp" 00057 #include "generic/Units.hpp" 00058 #include "generic/Time.hpp" 00059 #include "generic/Exceptions.hpp" 00060 #include "youbot/ProtocolDefinitions.hpp" 00061 #include "youbot/EthercatMasterInterface.hpp" 00062 #include "youbot/EthercatMasterWithThread.hpp" 00063 #include "youbot/EthercatMasterWithoutThread.hpp" 00064 #include "youbot/YouBotSlaveMsg.hpp" 00065 #include "youbot/YouBotSlaveMailboxMsg.hpp" 00066 #include "generic-gripper/Gripper.hpp" 00067 #include "generic-gripper/GripperData.hpp" 00068 #include "generic-gripper/GripperParameter.hpp" 00069 #include "one-dof-gripper/OneDOFGripper.hpp" 00070 #include "one-dof-gripper/OneDOFGripperData.hpp" 00071 #include "youbot/YouBotGripperParameter.hpp" 00072 00073 namespace youbot { 00074 00075 /////////////////////////////////////////////////////////////////////////////// 00076 /// One bar of the youBot gripper 00077 /////////////////////////////////////////////////////////////////////////////// 00078 class YouBotGripperBar { 00079 public: 00080 YouBotGripperBar(const unsigned int barNo, const unsigned int jointNo, const std::string& configFilePath = "../config/"); 00081 00082 virtual ~YouBotGripperBar(); 00083 00084 virtual void setConfigurationParameter(const MaxEncoderValue& parameter); 00085 00086 virtual void getConfigurationParameter(MaxEncoderValue& parameter) const; 00087 00088 virtual void getConfigurationParameter(MaxTravelDistance& parameter) const; 00089 00090 virtual void setConfigurationParameter(const MaxTravelDistance& parameter); 00091 00092 virtual void setConfigurationParameter(const BarSpacingOffset& parameter); 00093 00094 virtual void getConfigurationParameter(BarSpacingOffset& parameter) const; 00095 00096 virtual void setConfigurationParameter(const GripperBarName& parameter); 00097 00098 virtual void getConfigurationParameter(GripperBarName& parameter) const; 00099 00100 virtual void getConfigurationParameter(YouBotGripperParameter& parameter) const; 00101 00102 virtual void setConfigurationParameter(const YouBotGripperParameter& parameter); 00103 00104 virtual void getConfigurationParameter(YouBotSlaveMailboxMsg& parameter) const; 00105 00106 virtual void setData(const GripperBarEncoderSetpoint& encoderSetpoint); 00107 00108 virtual void getData(GripperSensedVelocity& barVelocity) const; 00109 00110 virtual void getData(GripperSensedBarPosition& barPosition) const; 00111 00112 virtual void setData(GripperBarPositionSetPoint& barPosition); 00113 00114 void parseGripperErrorFlags(const unsigned int& errosFlags); 00115 00116 00117 private: 00118 YouBotGripperBar(const YouBotGripperBar & source); 00119 00120 YouBotGripperBar & operator=(const YouBotGripperBar & source); 00121 00122 void parseMailboxStatusFlags(const YouBotSlaveMailboxMsg& mailboxMsg) const; 00123 00124 bool setValueToMotorContoller(const YouBotSlaveMailboxMsg& mailboxMsg) const; 00125 00126 bool retrieveValueFromMotorContoller(YouBotSlaveMailboxMsg& message) const; 00127 00128 quantity<si::length> maxTravelDistance; 00129 00130 unsigned int maxEncoderValue; 00131 00132 quantity<si::length> barSpacingOffset; 00133 00134 EthercatMasterInterface* ethercatMaster; 00135 00136 unsigned int timeTillNextMailboxUpdate; 00137 00138 unsigned int mailboxMsgRetries; 00139 00140 unsigned int jointNumber; 00141 00142 unsigned int barNo; 00143 00144 std::string name; 00145 00146 }; 00147 00148 } // namespace youbot 00149 #endif