00001 #ifndef KUKA160_NAXES_VELOCITY_CONTROLLER_HPP
00002 #define KUKA160_NAXES_VELOCITY_CONTROLLER_HPP
00003
00004 #include <vector>
00005 #include <rtt/RTT.hpp>
00006
00007 #include <rtt/TaskContext.hpp>
00008 #include <rtt/Ports.hpp>
00009 #include <rtt/Event.hpp>
00010 #include <rtt/Command.hpp>
00011 #include <rtt/Properties.hpp>
00012
00013 #if defined (OROPKG_OS_LXRT)
00014 #include "dev/ComediDevice.hpp"
00015 #include "dev/ComediSubDeviceAOut.hpp"
00016 #include "dev/ComediSubDeviceDIn.hpp"
00017 #include "dev/ComediSubDeviceDOut.hpp"
00018 #include "dev/ComediEncoder.hpp"
00019 #include "dev/IncrementalEncoderSensor.hpp"
00020 #include <rtt/dev/AnalogOutput.hpp>
00021 #include <rtt/dev/DigitalOutput.hpp>
00022 #include <rtt/dev/DigitalInput.hpp>
00023 #include "dev/AnalogDrive.hpp"
00024 #include "dev/Axis.hpp"
00025 #endif
00026 #include "dev/SimulationAxis.hpp"
00027 #include <rtt/dev/AxisInterface.hpp>
00028
00029 #include <ocl/OCL.hpp>
00030 #include <ocl/VectorTemplateComposition.hpp>
00031
00032 #include <kdl/chain.hpp>
00033 namespace OCL
00034 {
00045 class Kuka160nAxesVelocityController : public RTT::TaskContext
00046 {
00047 public:
00057 Kuka160nAxesVelocityController(std::string name);
00058 virtual ~Kuka160nAxesVelocityController();
00059
00060
00061 protected:
00067 RTT::ReadDataPort<std::vector<double> > driveValues_port;
00073 RTT::DataPort<std::vector<bool> > referenceValues_port;
00080 RTT::DataPort<std::vector<double> > positionValues_port;
00081
00082
00088 Property<std::vector<double> > driveLimits_prop;
00089
00093 Property<std::vector<double> > lowerPositionLimits_prop;
00094
00098 Property<std::vector<double> > upperPositionLimits_prop;
00099
00104 Property<std::vector <double> > initialPosition_prop;
00105
00110 Property<std::vector <double> > driveOffset_prop;
00111
00115 Property<bool > simulation_prop;
00116 bool simulation;
00117
00121 Property<std::vector<std::string> > EmergencyEvents_prop;
00122
00123
00127 RTT::Constant<unsigned int> num_axes_attr;
00128
00132 Attribute<KDL::Chain> chain_attr;
00133 KDL::Chain kinematics;
00134
00140 RTT::Event< void(std::string) > driveOutOfRange_evt;
00141
00148 RTT::Event< void(std::string) > positionOutOfRange_evt;
00149
00150 private:
00151
00152
00153
00154
00155
00156
00157
00158
00159 virtual bool startAllAxes();
00160 virtual bool stopAllAxes();
00161 virtual bool lockAllAxes();
00162 virtual bool unlockAllAxes();
00163 virtual bool addDriveOffset(const std::vector<double>& offset);
00164
00165 virtual bool initPosition(const std::vector<double>& switchposition);
00166
00167 virtual bool prepareForUse();
00168 virtual bool prepareForUseCompleted() const;
00169
00170 virtual bool prepareForShutdown();
00171 virtual bool prepareForShutdownCompleted() const;
00172
00173 void EmergencyStop(std::string message)
00174 {
00175 log(Error) << "---------------------------------------------" << endlog();
00176 log(Error) << "--------- EMERGENCY STOP --------------------" << endlog();
00177 log(Error) << "---------------------------------------------" << endlog();
00178 log(Error) << message << endlog();
00179 this->fatal();
00180 };
00181 std::vector<RTT::Handle> EmergencyEventHandlers;
00182
00186 bool activated;
00187
00193 std::vector<double> positionConvertFactor;
00194
00200 std::vector<double> driveConvertFactor;
00201 std::vector<double> driveValues,positionValues;
00202 std::vector<bool> references;
00203
00204
00205 public:
00206 virtual bool configureHook();
00207 virtual bool startHook();
00208 virtual void updateHook();
00209 virtual void stopHook();
00210 virtual void cleanupHook();
00211
00212
00213
00214
00215 #if (defined (OROPKG_OS_LXRT))
00216 ComediDevice* comediDevAOut;
00217 ComediDevice* comediDevEncoder;
00218 ComediDevice* comediDevDInOut;
00219 ComediSubDeviceAOut* comediSubdevAOut;
00220 ComediSubDeviceDIn* comediSubdevDIn;
00221 ComediSubDeviceDOut* comediSubdevDOut;
00222 std::vector<RTT::EncoderInterface*> encoderInterface;
00223
00224 std::vector<RTT::AnalogOutput*> vref;
00225 std::vector<OCL::IncrementalEncoderSensor*> encoder;
00226 std::vector<RTT::DigitalOutput*> enable;
00227 std::vector<OCL::AnalogDrive*> drive;
00228 std::vector<RTT::DigitalOutput*> brake;
00229 std::vector<RTT::DigitalInput*> reference;
00230 std::vector<OCL::Axis*> axes_hardware;
00231 #endif
00232 std::vector<OCL::AxisInterface*> axes;
00233 std::vector<OCL::SimulationAxis*> axes_simulation;
00234
00235
00236 };
00237 }
00238 #endif // KUKA160NAXESVELOCITYCONTROLLER