00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "CalibratedWrenchSensor.hpp"
00023
00024 #define G 9.811
00025 namespace OCL{
00026 using namespace RTT;
00027 using namespace KDL;
00028
00029 CalibratedWrenchSensor::CalibratedWrenchSensor(const std::string& name):
00030 RTT::TaskContext(name,PreOperational),
00031 wrench_in("WrenchData"),
00032 mount_position("MountPosition"),
00033 wrench_out("CalibratedWrench",Wrench::Zero()),
00034 WF_prop("SensorFrame","Pose between the Mount Position and the WrenchSensor Frame",Frame::Identity()),
00035 CF_prop("ComplianceFrame","Pose between the Mount Position and the Frame in which to express the wrench",Frame::Identity()),
00036 cog_prop("cog","Center of Gravity of attached tool",Vector::Zero()),
00037 mass_prop("mass","Mass of attached tool",0.0)
00038 {
00039 ports()->addPort(&mount_position);
00040 ports()->addPort(&wrench_in);
00041 ports()->addPort(&wrench_out);
00042
00043 properties()->addProperty(&WF_prop);
00044 properties()->addProperty(&CF_prop);
00045 properties()->addProperty(&cog_prop);
00046 properties()->addProperty(&mass_prop);
00047
00048 }
00049
00050 bool CalibratedWrenchSensor::configureHook(){
00051 mass=mass_prop.rvalue();
00052 cog=cog_prop.rvalue();
00053 F_m_comp=CF_prop.rvalue();
00054 F_m_ws=WF_prop.rvalue();
00055
00056 return true;
00057 }
00058
00059 bool CalibratedWrenchSensor::startHook(){
00060 return true;
00061 }
00062
00063 void CalibratedWrenchSensor::updateHook(){
00064
00065 Wrench measurement(wrench_in.Get());
00066 Frame F_b_m(mount_position.Get());
00067
00068
00069
00070 Wrench gravity;
00071
00072 gravity.force = F_m_ws.M.Inverse(F_b_m.M.Inverse(Vector(0.0, 0.0, -mass*G)));
00073 gravity.torque = cog * gravity.force;
00074
00075 wrench_out.Set(F_m_comp.Inverse(F_m_ws * (measurement - gravity)));
00076
00077 }
00078 void CalibratedWrenchSensor::stopHook(){
00079 wrench_out.Set(Wrench::Zero());
00080 }
00081
00082 }