Land.cpp
Go to the documentation of this file.
00001 /*
00002  * Land.cpp
00003  *
00004  *  Created on: Nov 10, 2011
00005  *      Author: mriedel
00006  */
00007 
00008 #include <behaviors/Land.hpp>
00009 
00010 // Declare
00011 PLUGINLIB_DECLARE_CLASS(tk_behavior, Land, telekyb_behavior::Land, TELEKYB_NAMESPACE::Behavior);
00012 
00013 namespace telekyb_behavior {
00014 
00015 Land::Land()
00016         : Behavior("tk_behavior/Land", BehaviorType::Land)
00017 {
00018 
00019 }
00020 
00021 void Land::initialize()
00022 {
00023         tLandDestination = addOption<Position3D>("tLandDestination",
00024                         "Specifies the Destination of the Land Behavior",
00025                         Position3D(0.0,0.0,0.0), false, false);
00026         tLandVelocity = addOption<double>("tLandVelocity",
00027                         "Defines the Velocity of the Land Behavior",
00028                         0.5, false, false);
00029         tLandDestinationHeight = addOption<double>("tLandDestinationHeight",
00030                         "Defines the Height from the Ground, at which the Land Behavior turns invalid. (Beware Z is down!)",
00031                         -0.25, false, false);
00032         tLandVertically = addOption<bool>("tLandVertically",
00033                         "Land vertically to the z-Component of the Destination",
00034                         true, false, false);
00035 
00036         // Not parameter Initalized by default
00037         // parameterInitialized = true;
00038 }
00039 
00040 void Land::destroy()
00041 {
00042 
00043 }
00044 
00045 bool Land::willBecomeActive(const TKState& currentState, const Behavior& previousBehavior)
00046 {
00047         if (tLandVertically->getValue()) {
00048                 actualLandDestination = currentState.position;
00049                 actualLandDestination(2) = tLandDestination->getValue()(2);
00050         } else {
00051                 actualLandDestination = tLandDestination->getValue();
00052         }
00053 
00054         yawAngle = currentState.getEulerRPY()(2);
00055         return true;
00056 }
00057 
00058 void Land::didBecomeActive(const TKState& currentState, const Behavior& previousBehavior)
00059 {
00060         // not used
00061 }
00062 
00063 void Land::willBecomeInActive(const TKState& currentState, const Behavior& nextBehavior)
00064 {
00065         // not used
00066 }
00067 
00068 void Land::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 Land::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 Land::trajectoryStepActive(const TKState& currentState, TKTrajectory& generatedTrajInput)
00082 {
00083         Vector3D direction = actualLandDestination - currentState.position;
00084         generatedTrajInput.setVelocity( direction.normalized() * tLandVelocity->getValue() );
00085         generatedTrajInput.setYawAngle( yawAngle );
00086 }
00087 
00088 // called everytime a new TKState is available AND it is the OLD Behavior of an active Switch
00089 void Land::trajectoryStepTermination(const TKState& currentState, TKTrajectory& generatedTrajInput)
00090 {
00091         // Same as active
00092         trajectoryStepActive(currentState,generatedTrajInput);
00093 }
00094 
00095 // Return true if the active Behavior is (still) valid. Initiate Switch otherwise
00096 bool Land::isValid(const TKState& currentState) const
00097 {
00098         return currentState.position(2) < tLandDestination->getValue()(2) + tLandDestinationHeight->getValue();
00099 }
00100 
00101 
00102 }
 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