TrajPlayback.hpp
Go to the documentation of this file.
00001 /*
00002  * TrajPlayback.hpp
00003  *
00004  *  Created on: Nov 12, 2011
00005  *      Author: mriedel
00006  */
00007 
00008 #ifndef TRAJPLAYBACK_HPP_
00009 #define TRAJPLAYBACK_HPP_
00010 
00011 #include <telekyb_defines/telekyb_defines.hpp>
00012 
00013 #include <tk_behavior/Behavior.hpp>
00014 
00015 // plugin stuff
00016 #include <pluginlib/class_list_macros.h>
00017 
00018 #include <telekyb_base/Time.hpp>
00019 
00020 #include <fstream>
00021 
00022 using namespace TELEKYB_NAMESPACE;
00023 
00024 namespace telekyb_behavior {
00025 
00026 class TrajPlayback : public Behavior{
00027 protected:
00028         Option<std::string>* tTrajectoryFilename;
00029 
00030         std::vector<std::string> fileFields;
00031 
00032         // File
00033         std::ifstream file;
00034 
00035         double nextTimeStep;
00036         unsigned int playbackPosition;
00037         Timer timer;
00038 
00039         TKTrajectory nextTrajInput;
00040 
00041         bool setNextTrajInput();
00042 
00043 public:
00044         TrajPlayback();
00045 
00046         virtual void initialize();
00047         virtual void destroy();
00048 
00049         // Called directly after Change Event is registered.
00050         virtual bool willBecomeActive(const TKState& currentState, const Behavior& previousBehavior);
00051         // Called after actual Switch. Note: During execution trajectoryStepCreation is used
00052         virtual void didBecomeActive(const TKState& currentState, const Behavior& previousBehavior);
00053         // Called directly after Change Event is registered: During execution trajectoryStepTermination is used
00054         virtual void willBecomeInActive(const TKState& currentState, const Behavior& nextBehavior);
00055         // Called after actual Switch. Runs in seperate Thread.
00056         virtual void didBecomeInActive(const TKState& currentState, const Behavior& nextBehavior);
00057 
00058         // called everytime a new TKState is available AND it is the NEW Behavior of an active Switch
00059         virtual void trajectoryStepCreation(const TKState& currentState, TKTrajectory& generatedTrajInput);
00060 
00061         // called everytime a new TKState is available. Should return false if invalid (swtich to next behavior, or Hover if undef).
00062         virtual void trajectoryStepActive(const TKState& currentState, TKTrajectory& generatedTrajInput);
00063 
00064         // called everytime a new TKState is available AND it is the OLD Behavior of an active Switch
00065         virtual void trajectoryStepTermination(const TKState& currentState, TKTrajectory& generatedTrajInput);
00066 
00067         // Return true if the active Behavior is (still) valid. Initiate Switch otherwise
00068         virtual bool isValid(const TKState& currentState) const;
00069 
00070 };
00071 
00072 }
00073 
00074 #endif /* TRAJPLAYBACK_HPP_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends


tk_be_common
Author(s): Martin Riedel
autogenerated on Mon Nov 11 2013 11:14:29