YouBotJoint.hpp
Go to the documentation of this file.
00001 #ifndef YOUBOT_YOUBOTJOINT_H
00002 #define YOUBOT_YOUBOTJOINT_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 <cmath>
00057 #include <boost/thread.hpp>
00058 #include <boost/scoped_ptr.hpp>
00059 #include <youbot_driver/generic/Logger.hpp>
00060 #include <youbot_driver/generic/Units.hpp>
00061 #include <youbot_driver/generic/Time.hpp>
00062 #include <youbot_driver/generic/Exceptions.hpp>
00063 #include <youbot_driver/generic-joint/Joint.hpp>
00064 #include <youbot_driver/generic-joint/JointData.hpp>
00065 #include <youbot_driver/youbot/YouBotJointStorage.hpp>
00066 #include <youbot_driver/youbot/ProtocolDefinitions.hpp>
00067 #include <youbot_driver/youbot/YouBotJointParameter.hpp>
00068 #include <youbot_driver/youbot/YouBotJointParameterPasswordProtected.hpp>
00069 #include <youbot_driver/youbot/YouBotSlaveMsg.hpp>
00070 #include <youbot_driver/youbot/YouBotSlaveMailboxMsg.hpp>
00071 #include <youbot_driver/youbot/EthercatMaster.hpp>
00072 #include <youbot_driver/youbot/EthercatMasterInterface.hpp>
00073 #include <youbot_driver/youbot/EthercatMasterWithThread.hpp>
00074 #include <youbot_driver/youbot/EthercatMasterWithoutThread.hpp>
00075 #include <youbot_driver/youbot/JointTrajectoryController.hpp>
00076 #include <youbot_driver/youbot/JointLimitMonitor.hpp>
00077 
00078 namespace youbot
00079 {
00080 
00085 class YouBotJoint : public Joint
00086 {
00087 public:
00088   YouBotJoint(const unsigned int jointNo, const std::string& configFilePath);
00089 
00090   ~YouBotJoint();
00091 
00092 private:
00093   YouBotJoint(const YouBotJoint & source);
00094 
00095   YouBotJoint & operator=(const YouBotJoint & source);
00096 
00097 protected:
00098   virtual void setConfigurationParameter(const JointParameter& parameter);
00099 
00100   virtual void getConfigurationParameter(JointParameter& parameter);
00101 
00102 public:
00103   virtual void getConfigurationParameter(YouBotJointParameterReadOnly& parameter);
00104 
00105   virtual void getConfigurationParameter(YouBotJointParameter& parameter);
00106 
00107   virtual void setConfigurationParameter(const YouBotJointParameter& parameter);
00108 
00109   virtual void getConfigurationParameter(JointName& parameter);
00110 
00111   virtual void setConfigurationParameter(const JointName& parameter);
00112 
00113   virtual void getConfigurationParameter(GearRatio& parameter);
00114 
00115   virtual void setConfigurationParameter(const GearRatio& parameter);
00116 
00117   virtual void getConfigurationParameter(EncoderTicksPerRound& parameter);
00118 
00119   virtual void setConfigurationParameter(const EncoderTicksPerRound& parameter);
00120 
00121   virtual void setConfigurationParameter(const CalibrateJoint& parameter);
00122 
00123   virtual void setConfigurationParameter(const InverseMovementDirection& parameter);
00124 
00125   virtual void getConfigurationParameter(InverseMovementDirection& parameter);
00126 
00127   virtual void setConfigurationParameter(const JointLimits& parameter);
00128 
00129   virtual void getConfigurationParameter(JointLimits& parameter);
00130 
00131   virtual void getConfigurationParameter(JointLimitsRadian& parameter);
00132 
00134   virtual void setConfigurationParameter(const InitializeJoint& parameter);
00135 
00136   virtual void getConfigurationParameter(FirmwareVersion& parameter);
00137 
00139   virtual void setConfigurationParameter(const YouBotSlaveMailboxMsg& parameter);
00140 
00142   virtual void getConfigurationParameter(YouBotSlaveMailboxMsg& parameter);
00143 
00144   virtual void getConfigurationParameter(TorqueConstant& parameter);
00145 
00146   virtual void setConfigurationParameter(const TorqueConstant& parameter);
00147 
00150   void storeConfigurationParameterPermanent(const YouBotJointParameter& parameter);
00151 
00153   void restoreConfigurationParameter(YouBotJointParameter& parameter);
00154 
00155 protected:
00156   virtual void setData(const JointDataSetpoint& data);
00157 
00158   virtual void getData(JointData& data);
00159 
00160 public:
00163   virtual void setData(const JointAngleSetpoint& data);
00164 
00167   virtual void setData(const JointEncoderSetpoint& data);
00168 
00171   virtual void getData(JointSensedAngle& data);
00172 
00175   virtual void setData(const JointVelocitySetpoint& data);
00176 
00179   virtual void getData(JointSensedVelocity& data);
00180 
00183   virtual void getData(JointSensedRoundsPerMinute& data);
00184 
00187   virtual void setData(const JointRoundsPerMinuteSetpoint& data);
00188 
00191   virtual void getData(JointSensedCurrent& data);
00192 
00195   virtual void setData(const JointCurrentSetpoint& data);
00196 
00199   virtual void getData(JointSensedEncoderTicks& data);
00200 
00204   virtual void setData(const SlaveMessageOutput& data);
00205 
00209   virtual void getData(YouBotSlaveMsg& data);
00210 
00213   virtual void setData(const JointTorqueSetpoint& data);
00214 
00217   virtual void getData(JointSensedTorque& data);
00218 
00221   virtual void getData(JointAngleSetpoint& data);
00222 
00225   virtual void getData(JointVelocitySetpoint& data);
00226 
00229   virtual void getData(JointCurrentSetpoint& data);
00230 
00233   virtual void getData(JointRampGeneratorVelocity& data);
00234 
00235   void getUserVariable(const unsigned int index, int& data);
00236 
00237   void setUserVariable(const unsigned int index, const int data);
00238 
00240   virtual void getStatus(std::vector<std::string>& statusMessages);
00241 
00261   virtual void getStatus(unsigned int& statusFlags);
00262 
00264   void setEncoderToZero();
00265 
00266   void noMoreAction();
00267 
00268   void stopJoint();
00269 
00270   unsigned int getJointNumber();
00271 
00272 private:
00273   void parseYouBotErrorFlags(const YouBotSlaveMsg& messageBuffer);
00274 
00275   void parseMailboxStatusFlags(const YouBotSlaveMailboxMsg& mailboxMsg);
00276 
00277   bool retrieveValueFromMotorContoller(YouBotSlaveMailboxMsg& message);
00278 
00279   bool setValueToMotorContoller(const YouBotSlaveMailboxMsg& mailboxMsg);
00280 
00281 public:
00282   JointTrajectoryController trajectoryController;
00283 
00284 private:
00285   EthercatMasterInterface* ethercatMaster;
00286 
00287   bool positionReferenceToZero;
00288 
00289   unsigned int timeTillNextMailboxUpdate;
00290 
00291   unsigned int mailboxMsgRetries;
00292 
00293   YouBotJointStorage storage;
00294 
00295   YouBotSlaveMsg messageBuffer;
00296 
00297   quantity<si::angular_velocity> lastVelocity;
00298 
00299   quantity<plane_angle> lastPosition;
00300 
00301   boost::scoped_ptr<JointLimitMonitor> limitMonitor;
00302 
00303 };
00304 
00305 } // namespace youbot
00306 #endif


youbot_driver
Author(s): Jan Paulus
autogenerated on Mon Oct 6 2014 09:08:02