LinearFlyTo.cpp
Go to the documentation of this file.
00001 /*
00002  * LinearFlyTo.cpp
00003  *
00004  *  Created on: Nov 22, 2011
00005  *      Author: mriedel
00006  */
00007 
00008 #include "LinearFlyTo.hpp"
00009 
00010 // Declare
00011 PLUGINLIB_DECLARE_CLASS(tk_be_common, LinearFlyTo, telekyb_behavior::LinearFlyTo, TELEKYB_NAMESPACE::Behavior);
00012 
00013 namespace telekyb_behavior {
00014 
00015 LinearFlyTo::LinearFlyTo()
00016         : Behavior("tk_be_common/LinearFlyTo", BehaviorType::Air)
00017 {
00018 
00019 }
00020 
00021 void LinearFlyTo::initialize()
00022 {
00023         tFlyToDestination = addOption<Position3D>("tFlyToDestination",
00024                         "Specifies the Destination of the LinearFlyTo Behavior",
00025                         Position3D(0.0,0.0,-1.0), false, false);
00026         tFlyToVelocity = addOption<double>("tFlyToVelocity",
00027                         "Defines the Velocity of the LinearFlyTo Behavior",
00028                         1.0, false, false);
00029         tFlyToDestinationRadius = addOption<double>("tFlyToDestinationRadius",
00030                         "Defines the Radius from the Destination, at which the LinearFlyTo Behavior turns invalid",
00031                         0.25, false, false);
00032 
00033         //parameterInitialized = true; // not parameter Initialized by default.
00034 }
00035 
00036 void LinearFlyTo::destroy()
00037 {
00038 
00039 }
00040 
00041 bool LinearFlyTo::willBecomeActive(const TKState& currentState, const Behavior& previousBehavior)
00042 {
00043         yawAngle = currentState.getEulerRPY()(2);
00044         //ROS_INFO("LinearFlyTo: Storing yawAngle: %f ", yawAngle);
00045         return true;
00046 }
00047 
00048 void LinearFlyTo::didBecomeActive(const TKState& currentState, const Behavior& previousBehavior)
00049 {
00050         // not used
00051 }
00052 
00053 void LinearFlyTo::willBecomeInActive(const TKState& currentState, const Behavior& nextBehavior)
00054 {
00055         // not used
00056 }
00057 
00058 void LinearFlyTo::didBecomeInActive(const TKState& currentState, const Behavior& nextBehavior)
00059 {
00060         // not used
00061 }
00062 
00063 // called everytime a new TKState is available AND it is the NEW Behavior of an active Switch
00064 void LinearFlyTo::trajectoryStepCreation(const TKState& currentState, TKTrajectory& generatedTrajInput)
00065 {
00066         trajectoryStepActive(currentState, generatedTrajInput);
00067 }
00068 
00069 // called everytime a new TKState is available. Should return false if invalid (swtich to next behavior, or Hover if undef).
00070 void LinearFlyTo::trajectoryStepActive(const TKState& currentState, TKTrajectory& generatedTrajInput)
00071 {
00072         Vector3D direction = tFlyToDestination->getValue() - currentState.position;
00073         generatedTrajInput.setVelocity( direction.normalized() * tFlyToVelocity->getValue() );
00074         generatedTrajInput.setYawAngle( yawAngle );
00075 }
00076 
00077 // called everytime a new TKState is available AND it is the OLD Behavior of an active Switch
00078 void LinearFlyTo::trajectoryStepTermination(const TKState& currentState, TKTrajectory& generatedTrajInput)
00079 {
00080         generatedTrajInput.setVelocity( Velocity3D::Zero() );
00081         generatedTrajInput.setYawAngle( yawAngle );
00082 }
00083 
00084 // Return true if the active Behavior is (still) valid. Initiate Switch otherwise
00085 bool LinearFlyTo::isValid(const TKState& currentState) const
00086 {
00087         Vector3D direction = tFlyToDestination->getValue() - currentState.position;
00088         return direction.norm() > tFlyToDestinationRadius->getValue();
00089 }
00090 
00091 
00092 } /* namespace telekyb_behavior */
 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