Ground.cpp
Go to the documentation of this file.
00001 /*
00002  * Ground.cpp
00003  *
00004  *  Created on: Nov 11, 2011
00005  *      Author: mriedel
00006  */
00007 
00008 #include <behaviors/Ground.hpp>
00009 
00010 #include <telekyb_defines/physic_defines.hpp>
00011 
00012 // Declare
00013 PLUGINLIB_DECLARE_CLASS(tk_behavior, Ground, telekyb_behavior::Ground, TELEKYB_NAMESPACE::Behavior);
00014 
00015 namespace telekyb_behavior {
00016 
00017 Ground::Ground()
00018         : Behavior("tk_behavior/Ground", BehaviorType::Ground)
00019 {
00020 
00021 }
00022 
00023 void Ground::initialize()
00024 {
00025         controller = TrajectoryController::InstancePtr();
00026         tDoMassEstimation = OptionContainer::getGlobalOptionByName<bool>("TrajectoryController","tDoMassEstimation");
00027         if (!tDoMassEstimation) {
00028                 ROS_ERROR("Unable to get Option TrajectoryController/tDoMassEstimation. Quitting...");
00029                 ros::shutdown();
00030         } else {
00031                 // no Parameters
00032                 parameterInitialized = true;
00033         }
00034 }
00035 
00036 void Ground::destroy()
00037 {
00038 
00039 }
00040 
00041 
00042 // GROUND MUST ALWAYS RETURN TRUE!!!
00043 bool Ground::willBecomeActive(const TKState& currentState, const Behavior& previousBehavior)
00044 {
00045         // DEBUG.
00046         //ROS_INFO("Ground: Storing yawAngle: %f ", yawAngle);
00047 
00048         // Deactivate MassEstimation
00049         // TODO: Change this to Option Access!
00050         tDoMassEstimation->setValue(false);
00051         //controller->toggleMassEstimation(false);
00052 
00053         return true;
00054 }
00055 
00056 void Ground::didBecomeActive(const TKState& currentState, const Behavior& previousBehavior)
00057 {
00058         // not used
00059 }
00060 
00061 void Ground::willBecomeInActive(const TKState& currentState, const Behavior& nextBehavior)
00062 {
00063         // Activate MassEstimation
00064         //controller->toggleMassEstimation(true);
00065         tDoMassEstimation->setValue(true);
00066 }
00067 
00068 void Ground::didBecomeInActive(const TKState& currentState, const Behavior& nextBehavior)
00069 {
00070         // not used
00071 }
00072 
00073 // called everytime a new TKState is available AND it is the NEW Behavior of an active Switch
00074 void Ground::trajectoryStepCreation(const TKState& currentState, TKTrajectory& generatedTrajInput)
00075 {
00076         // Same as active
00077         trajectoryStepActive(currentState,generatedTrajInput);
00078 }
00079 
00080 // called everytime a new TKState is available. Should return false if invalid (swtich to next behavior, or Hover if undef).
00081 void Ground::trajectoryStepActive(const TKState& currentState, TKTrajectory& generatedTrajInput)
00082 {
00083         generatedTrajInput.setAcceleration( Acceleration3D(0.0, 0.0, GRAVITY) );
00084         generatedTrajInput.setYawRate(0.0);
00085 }
00086 
00087 // called everytime a new TKState is available AND it is the OLD Behavior of an active Switch
00088 void Ground::trajectoryStepTermination(const TKState& currentState, TKTrajectory& generatedTrajInput)
00089 {
00090         // Same as active
00091         trajectoryStepActive(currentState,generatedTrajInput);
00092 }
00093 
00094 // Return true if the active Behavior is (still) valid. Initiate Switch otherwise
00095 bool Ground::isValid(const TKState& currentState) const
00096 {
00097         // never turns invalid
00098         return true;
00099 }
00100 
00101 
00102 
00103 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Defines


tk_behavior
Author(s): Dr. Antonio Franchi and Martin Riedel
autogenerated on Mon Nov 11 2013 11:13:36