Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef CALIBRATOR_HPP_
00009 #define CALIBRATOR_HPP_
00010
00011 #include <telekyb_defines/telekyb_defines.hpp>
00012 #include <tk_behavior/Behavior.hpp>
00013
00014
00015
00016
00017 #include <pluginlib/class_list_macros.h>
00018
00019
00020
00021
00022 #include <telekyb_base/Time.hpp>
00023
00024 #include <telekyb_interface/MKInterface.hpp>
00025 #include <boost/thread.hpp>
00026
00027
00028 #include <boost/accumulators/accumulators.hpp>
00029 #include <boost/accumulators/statistics/stats.hpp>
00030 #include <boost/accumulators/statistics/median.hpp>
00031
00032 using namespace TELEKYB_NAMESPACE;
00033 using namespace boost::accumulators;
00034
00035 namespace telekyb_behavior {
00036
00037 class Calibrator : public Behavior {
00038 protected:
00039
00040 Option<bool>* tDoMassEstimation;
00041 bool tDoMassEstimationSave;
00042 Option<double>* tPCIntegralGain;
00043 double tPCIntegralGainSave;
00044
00045
00046 Option<double>* tMaxInitialVelocity;
00047 Option<double>* tMaxInitialYawError;
00048
00049 Option<double>* tSettleTime;
00050 Option<int>* tValueRange;
00051 Option<int>* tCenterValueX;
00052 Option<int>* tCenterValueY;
00053
00054
00055 Eigen::MatrixXd errorMatrix;
00056
00057
00058 Eigen::Vector2i currentField;
00059
00060
00061
00062
00063
00064
00065
00066 bool initialSetup;
00067
00068
00069
00070
00071
00072
00073 Position3D calibrationPosition;
00074
00075
00076 Timer testTimer;
00077 Timer behaviorActiveTimer;
00078
00079 Timer transitionTimer;
00080
00081
00082 ros::NodeHandle nodeHandle;
00083
00084
00085 telekyb_interface::MKInterface* mkInterface;
00086 MKSingleValuePacket offsetRawAcc_X;
00087 MKSingleValuePacket offsetRawAcc_Y;
00088
00089 bool valuesSet;
00090 bool setValueThreadDone;
00091
00092 double jumpConstant;
00093
00094
00095 boost::thread setValueThread;
00096
00097
00098 accumulator_set<double, stats<tag::median > > acc;
00099
00100 accumulator_set<double, stats<tag::median > > accMedianX;
00101 accumulator_set<double, stats<tag::median > > accMedianY;
00102
00103 bool calibrationDone;
00104
00105 public:
00106 Calibrator();
00107
00108 virtual void initialize();
00109 virtual void destroy();
00110
00111
00112 virtual bool willBecomeActive(const TKState& currentState, const Behavior& previousBehavior);
00113
00114 virtual void didBecomeActive(const TKState& currentState, const Behavior& previousBehavior);
00115
00116 virtual void willBecomeInActive(const TKState& currentState, const Behavior& nextBehavior);
00117
00118 virtual void didBecomeInActive(const TKState& currentState, const Behavior& nextBehavior);
00119
00120
00121 virtual void trajectoryStepCreation(const TKState& currentState, TKTrajectory& generatedTrajInput);
00122
00123
00124 virtual void trajectoryStepActive(const TKState& currentState, TKTrajectory& generatedTrajInput);
00125
00126
00127 virtual void trajectoryStepTermination(const TKState& currentState, TKTrajectory& generatedTrajInput);
00128
00129
00130 virtual bool isValid(const TKState& currentState) const;
00131
00132
00133 void setValueThreadFunc();
00134
00135 };
00136
00137 }
00138
00139 #endif