00001 #ifndef KUKA361_NAXES_VELOCITY_CONTROLLER_HPP
00002 #define KUKA361_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/Properties.hpp>
00011 #include <rtt/Command.hpp>
00012
00013
00014 #if defined (OROPKG_OS_LXRT)
00015 #include <rtt/dev/AnalogOutput.hpp>
00016 #include <rtt/dev/DigitalOutput.hpp>
00017
00018 #include "dev/SwitchDigitalInapci1032.hpp"
00019 #include "dev/RelayCardapci2200.hpp"
00020 #include "dev/EncoderSSIapci1710.hpp"
00021 #include "dev/ComediDevice.hpp"
00022 #include "dev/ComediSubDeviceAOut.hpp"
00023
00024 #include "dev/AbsoluteEncoderSensor.hpp"
00025 #include "dev/AnalogDrive.hpp"
00026 #include "dev/Axis.hpp"
00027 #endif
00028 #include "dev/SimulationAxis.hpp"
00029 #include <rtt/dev/AxisInterface.hpp>
00030
00031 #include <ocl/OCL.hpp>
00032 #include <ocl/VectorTemplateComposition.hpp>
00033
00034 #include <kdl/chain.hpp>
00035
00036 namespace OCL
00037 {
00048 class Kuka361nAxesVelocityController : public TaskContext
00049 {
00050 public:
00058 Kuka361nAxesVelocityController(std::string name);
00059 virtual ~Kuka361nAxesVelocityController();
00060
00061 protected:
00071 Method<bool(void)> startAllAxes_mtd;
00072
00083 Method<bool(void)> stopAllAxes_mtd;
00084
00092 Method<bool(void)> unlockAllAxes_mtd;
00093
00102 Method<bool(void)> lockAllAxes_mtd;
00103
00114 Command<bool(void)> prepareForUse_cmd;
00115
00120 Command<bool(void)> prepareForShutdown_cmd;
00121
00131 Method<bool(std::vector<double>)> addDriveOffset_mtd;
00132
00138 DataPort<std::vector<double> > driveValues_port;
00139
00146 DataPort<std::vector<double> > positionValues_port;
00147
00153 Property<std::vector <double> > driveLimits_prop;
00154
00158 Property<std::vector <double> > lowerPositionLimits_prop;
00159
00163 Property<std::vector <double> > upperPositionLimits_prop;
00164
00169 Property<std::vector <double> > initialPosition_prop;
00170
00175 Property<std::vector <double> > driveOffset_prop;
00176
00180 Property<bool > simulation_prop;
00181 bool simulation;
00182
00187 Property<bool > geometric_prop;
00188
00192 Property<std::vector<std::string> > EmergencyEvents_prop;
00193
00197 Constant<unsigned int> num_axes_attr;
00198
00202 Attribute<KDL::Chain> chain_attr;
00203 KDL::Chain kinematics;
00204
00210 Event< void(std::string) > driveOutOfRange_evt;
00211
00218 Event< void(std::string) > positionOutOfRange_evt;
00219
00220
00221
00222 private:
00223
00224 virtual bool startAllAxes();
00225 virtual bool stopAllAxes();
00226 virtual bool lockAllAxes();
00227 virtual bool unlockAllAxes();
00228 virtual bool addDriveOffset(const std::vector<double>& offset);
00229 virtual bool prepareForUse();
00230 virtual bool prepareForUseCompleted() const;
00231 virtual bool prepareForShutdown();
00232 virtual bool prepareForShutdownCompleted() const;
00233
00234 void EmergencyStop(std::string message)
00235 {
00236 log(Error) << "---------------------------------------------" << endlog();
00237 log(Error) << "--------- EMERGENCY STOP --------------------" << endlog();
00238 log(Error) << "---------------------------------------------" << endlog();
00239 log(Error) << message << endlog();
00240 this->fatal();
00241 };
00242 std::vector<RTT::Handle> EmergencyEventHandlers;
00243
00247 bool activated;
00248
00254 std::vector<double> positionConvertFactor;
00255
00256
00262 std::vector<double> driveConvertFactor;
00263
00264
00266 std::vector<double> positionValues, driveValues,
00267 positionValues_kin,driveValues_rob;
00268
00269 public:
00270
00271 virtual bool configureHook();
00272 virtual bool startHook();
00273 virtual void updateHook();
00274 virtual void stopHook();
00275 virtual void cleanupHook();
00276
00277 KDL::Chain getKinematics(){
00278 return kinematics;
00279 };
00280
00281 private:
00282
00283 void convertGeometric();
00284
00285
00286
00287
00288 #if (defined (OROPKG_OS_LXRT))
00289 std::vector<Axis*> axes_hardware;
00290
00291 ComediDevice* comediDev;
00292 ComediSubDeviceAOut* comediSubdevAOut;
00293 EncoderSSI_apci1710_board* apci1710;
00294 RelayCardapci2200* apci2200;
00295 SwitchDigitalInapci1032* apci1032;
00296
00297 std::vector<EncoderInterface*> encoderInterface;
00298 std::vector<AbsoluteEncoderSensor*> encoder;
00299 std::vector<AnalogOutput*> vref;
00300 std::vector<DigitalOutput*> enable;
00301 std::vector<AnalogDrive*> drive;
00302 std::vector<DigitalOutput*> brake;
00303
00304 #endif
00305 std::vector<AxisInterface*> axes;
00306
00307 };
00308
00309 }
00310 #endif // KUKA361NAXESVELOCITYCONTROLLER