00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "CartesianControllerPosVel.hpp"
00022 #include <rtt/Logger.hpp>
00023 #include <assert.h>
00024 #include <ocl/ComponentLoader.hpp>
00025
00026 ORO_LIST_COMPONENT_TYPE( OCL::CartesianControllerPosVel );
00027
00028 namespace OCL
00029 {
00030 using namespace RTT;
00031 using namespace KDL;
00032 using namespace std;
00033
00034 CartesianControllerPosVel::CartesianControllerPosVel(string name)
00035 : TaskContext(name,PreOperational),
00036 _gain_local(6,0.0),
00037 _position_meas("CartesianSensorPosition"),
00038 _position_desi("CartesianDesiredPosition"),
00039 _velocity_desi("CartesianDesiredVelocity"),
00040 _velocity_out("CartesianOutputVelocity"),
00041 _controller_gain("K", "Proportional Gain",vector<double>(6,0.0))
00042 {
00043
00044
00045
00046 this->ports()->addPort(&_position_meas);
00047 this->ports()->addPort(&_position_desi);
00048 this->ports()->addPort(&_velocity_desi);
00049 this->ports()->addPort(&_velocity_out);
00050
00051
00052 this->properties()->addProperty(&_controller_gain);
00053
00054 }
00055
00056
00057 CartesianControllerPosVel::~CartesianControllerPosVel(){};
00058
00059 bool CartesianControllerPosVel::configureHook()
00060 {
00061
00062
00063
00064 if(_controller_gain.value().size()!=6)
00065 return false;
00066
00067 _gain_local=_controller_gain.value();
00068 return true;
00069 }
00070
00071
00072 bool CartesianControllerPosVel::startHook()
00073 {
00074 return true;
00075 }
00076
00077 void CartesianControllerPosVel::updateHook()
00078 {
00079
00080 _position_meas_local = _position_meas.Get();
00081 _position_desi_local = _position_desi.Get();
00082 _velocity_desi_local = _velocity_desi.Get();
00083
00084
00085 _velocity_feedback = diff(_position_meas_local, _position_desi_local);
00086 for(unsigned int i=0; i<6; i++)
00087 _velocity_feedback(i) *= _gain_local[i];
00088
00089
00090 _velocity_out_local = _velocity_desi_local + _velocity_feedback;
00091
00092 _velocity_out.Set(_velocity_out_local);
00093 }
00094
00095
00096 void CartesianControllerPosVel::stopHook()
00097 {
00098 }
00099
00100 void CartesianControllerPosVel::cleanupHook()
00101 {
00102 }
00103
00104 }
00105