00001 #ifndef LIAS_NAXES_VELOCITY_CONTROLLER_HPP
00002 #define LIAS_NAXES_VELOCITY_CONTROLLER_HPP
00003 #include <vector>
00004 #include <rtt/RTT.hpp>
00005
00006 #include <rtt/TaskContext.hpp>
00007 #include <rtt/Ports.hpp>
00008 #include <rtt/Event.hpp>
00009 #include <rtt/Properties.hpp>
00010
00011
00012 #include <rtt/RTT.hpp>
00013
00014 #include "IP_Encoder_6_EncInterface.hpp"
00015 #include "dev/SimulationAxis.hpp"
00016
00017
00018 #if defined (OROPKG_OS_LXRT)
00019
00020 #include "CombinedDigitalOutInterface.hpp"
00021
00022 #include <rtt/dev/AnalogOutput.hpp>
00023 #include <rtt/dev/DigitalOutput.hpp>
00024 #include <rtt/dev/DigitalInput.hpp>
00025 #include <rtt/dev/AxisInterface.hpp>
00026
00027 #include "dev/AnalogDrive.hpp"
00028 #include "dev/Axis.hpp"
00029 #include "dev/IncrementalEncoderSensor.hpp"
00030 #endif
00031
00032 #include "LiASConstants.hpp"
00033
00034 #include <ocl/OCL.hpp>
00035
00036 namespace OCL {
00037
00038 class CRSnAxesVelocityController : public RTT::TaskContext
00039 {
00040 public:
00041 CRSnAxesVelocityController(const std::string& name,const std::string& propertyfilename="cpf/crs.cpf");
00042 virtual ~CRSnAxesVelocityController();
00043
00044 protected:
00045
00046
00047
00048
00049
00050
00051
00052
00057 virtual bool startAxis(int axis);
00058 virtual bool startAxisCompleted(int axis) const;
00059
00063 virtual bool startAllAxes();
00064 virtual bool startAllAxesCompleted() const;
00065
00070 virtual bool stopAxis(int axis);
00071 virtual bool stopAxisCompleted(int axis) const;
00072
00076 virtual bool stopAllAxes();
00077 virtual bool stopAllAxesCompleted() const;
00078
00083 virtual bool lockAxis(int axis);
00084 virtual bool lockAxisCompleted(int axis) const;
00085
00089 virtual bool lockAllAxes();
00090 virtual bool lockAllAxesCompleted() const;
00091
00095 virtual bool unlockAxis(int axis);
00096 virtual bool unlockAxisCompleted(int axis) const;
00097
00101 virtual bool unlockAllAxes();
00102 virtual bool unlockAllAxesCompleted() const;
00103
00104 virtual bool addDriveOffset(int axis,double offset);
00105 virtual bool addDriveOffsetCompleted(int axis,double offset) const;
00106
00107
00108 virtual bool initPosition(int axis);
00109 virtual bool initPositionCompleted(int axis) const;
00110
00111 virtual bool prepareForUse();
00112 virtual bool prepareForUseCompleted() const;
00113 virtual bool prepareForShutdown();
00114 virtual bool prepareForShutdownCompleted() const;
00115
00116
00117 virtual bool isDriven(int axis);
00118
00119 private:
00120 std::vector<RTT::ReadDataPort<double>*> driveValue;
00121
00122 std::vector<RTT::WriteDataPort<bool>*> reference;
00123 std::vector<RTT::WriteDataPort<double>*> positionValue;
00124 std::vector<RTT::WriteDataPort<double>*> output;
00125
00126 private:
00131 const std::string _propertyfile;
00132
00138 RTT::Property<std::vector <double> > driveLimits;
00139
00143 RTT::Property<std::vector <double> > lowerPositionLimits;
00144
00148 RTT::Property<std::vector <double> > upperPositionLimits;
00149
00154 RTT::Property<std::vector <double> > initialPosition;
00155
00159 RTT::Property<std::vector<double> > signAxes;
00160
00164 RTT::Property<std::vector<double> > offset;
00165
00166
00172 RTT::Event< void(int,double) > driveOutOfRange;
00173
00180 RTT::Event< void(int,double) > positionOutOfRange;
00181
00186 virtual bool startup();
00187
00191 virtual void update();
00192
00196 virtual void shutdown();
00197
00198 private:
00199
00200
00201
00202
00203
00221 RTT::Constant<unsigned int> _num_axes;
00222
00223 private:
00224
00225 std::vector<bool> _homed;
00226
00227
00228
00229
00230 RTT::Property<std::vector <double> > servoGain;
00231 std::vector<double> _servoGain;
00232
00233
00234
00235 RTT::Property<std::vector <double> > servoIntegrationFactor;
00236 std::vector<double> _servoIntegrationFactor;
00237
00238
00239
00240
00241
00242 RTT::Property<std::vector <double> > servoFFScale;
00243 std::vector<double> _servoFFScale;
00244
00248 RTT::Property<std::vector<double> > servoDerivTime;
00249
00250
00251
00252
00253 std::vector<double> servoIntVel;
00254 std::vector<double> servoIntError;
00255 bool servoInitialized;
00256 RTT::TimeService::ticks previousTime;
00257 std::vector<double> previousPos;
00258
00259
00260
00261
00262 virtual bool changeServo();
00263 virtual bool changeServoCompleted() const;
00264
00265 private:
00266
00267
00268
00269 #if !defined (OROPKG_OS_LXRT)
00270 std::vector<OCL::SimulationAxis*> _axes;
00271 std::vector<RTT::AxisInterface*> _axesInterface;
00272 #else
00273 std::vector<OCL::Axis*> _axes;
00274
00275 std::vector<RTT::AxisInterface*> _axesInterface;
00276
00277 RTT::DigitalOutInterface* _IP_Digital_24_DOut;
00278 IP_Encoder_6_Task* _IP_Encoder_6_task;
00279 RTT::AnalogOutInterface* _IP_FastDac_AOut;
00280 RTT::DigitalInInterface* _IP_OptoInput_DIn;
00281
00282 RTT::DigitalOutput* _enable;
00283 RTT::DigitalOutput* _combined_enable[LiAS_NUM_AXIS];
00284 RTT::CombinedDigitalOutInterface* _combined_enable_DOutInterface;
00285 RTT::DigitalOutput* _brake;
00286 RTT::DigitalOutput* _combined_brake[2];
00287 RTT::CombinedDigitalOutInterface* _combined_brake_DOutInterface;
00288
00289 RTT::EncoderInterface* _encoderInterface[LiAS_NUM_AXIS];
00290 RTT::IncrementalEncoderSensor* _encoder[LiAS_NUM_AXIS];
00291 RTT::AnalogOutput* _vref[LiAS_NUM_AXIS];
00292 RTT::AnalogDrive* _drive[LiAS_NUM_AXIS];
00293 RTT::DigitalInput* _reference[LiAS_NUM_AXIS];
00294 #endif
00295
00296 bool _activate_axis2, _activate_axis3, _deactivate_axis2, _deactivate_axis3;
00297
00298 };
00299
00300 }
00301
00302 #endif // LIAS_HARDWARE_HPP