NormalBrake.cpp
Go to the documentation of this file.
00001 /*
00002  * NormalBrake.cpp
00003  *
00004  *  Created on: Nov 11, 2011
00005  *      Author: mriedel
00006  */
00007 
00008 #include <behaviors/NormalBrake.hpp>
00009 
00010 // Declare
00011 PLUGINLIB_DECLARE_CLASS(tk_behavior, NormalBrake, telekyb_behavior::NormalBrake, TELEKYB_NAMESPACE::Behavior);
00012 
00013 namespace telekyb_behavior {
00014 
00015 NormalBrake::NormalBrake()
00016         : Behavior("tk_behavior/NormalBrake", BehaviorType::Air)
00017 {
00018 
00019 }
00020 
00021 void NormalBrake::initialize()
00022 {
00023         // NormalBrake MUST operate on default Parameters
00024         tBrakeMinVelocity = addOption<double>("tBrakeMinVelocity",
00025                         "Minimum Velocity for NormalBrake Behavior.",0.1, false, false);
00026 
00027 
00028         // This MUST be true!
00029         parameterInitialized = true;
00030 }
00031 
00032 void NormalBrake::destroy()
00033 {
00034 
00035 }
00036 
00038 bool NormalBrake::willBecomeActive(const TKState& currentState, const Behavior& previousBehavior)
00039 {
00040         yawAngle = currentState.getEulerRPY()(2);
00041 
00042         return true;
00043 }
00044 
00045 void NormalBrake::didBecomeActive(const TKState& currentState, const Behavior& previousBehavior)
00046 {
00047         // not used
00048 }
00049 
00050 void NormalBrake::willBecomeInActive(const TKState& currentState, const Behavior& nextBehavior)
00051 {
00052         // not used
00053 }
00054 
00055 void NormalBrake::didBecomeInActive(const TKState& currentState, const Behavior& nextBehavior)
00056 {
00057         // not used
00058 }
00059 
00060 // called everytime a new TKState is available AND it is the NEW Behavior of an active Switch
00061 void NormalBrake::trajectoryStepCreation(const TKState& currentState, TKTrajectory& generatedTrajInput)
00062 {
00063         // Same as active
00064         trajectoryStepActive(currentState,generatedTrajInput);
00065 }
00066 
00067 // called everytime a new TKState is available. Should return false if invalid (swtich to next behavior, or Hover if undef).
00068 void NormalBrake::trajectoryStepActive(const TKState& currentState, TKTrajectory& generatedTrajInput)
00069 {
00070         generatedTrajInput.setVelocity( Velocity3D::Zero() );
00071         generatedTrajInput.setYawAngle( yawAngle );
00072 }
00073 
00074 // called everytime a new TKState is available AND it is the OLD Behavior of an active Switch
00075 void NormalBrake::trajectoryStepTermination(const TKState& currentState, TKTrajectory& generatedTrajInput)
00076 {
00077         // Same as active
00078         trajectoryStepActive(currentState,generatedTrajInput);
00079 }
00080 
00081 // Return true if the active Behavior is (still) valid. Initiate Switch otherwise
00082 bool NormalBrake::isValid(const TKState& currentState) const
00083 {
00084         return currentState.linVelocity.norm() > tBrakeMinVelocity->getValue();
00085 }
00086 
00087 
00088 
00089 }
 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