Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include <behaviors/TakeOff.hpp>
00009
00010
00011
00012 PLUGINLIB_DECLARE_CLASS(tk_behavior, TakeOff, telekyb_behavior::TakeOff, TELEKYB_NAMESPACE::Behavior);
00013
00014 namespace telekyb_behavior {
00015
00016 TakeOff::TakeOff()
00017 : Behavior("tk_behavior/TakeOff", BehaviorType::TakeOff)
00018 {
00019
00020 }
00021
00022 void TakeOff::initialize()
00023 {
00024 tTakeOffDestination = addOption<Position3D>("tTakeOffDestination",
00025 "Specifies the Destination of the TakeOff Behavior",
00026 Position3D(0.0,0.0,-1.0), false, false);
00027 tTakeOffVelocity = addOption<double>("tTakeOffVelocity",
00028 "Defines the Velocity of the TakeOff Behavior",
00029 0.3, false, false);
00030 tTakeOffDestinationRadius = addOption<double>("tTakeOffDestinationRadius",
00031 "Defines the Radius from the Destination, at which the TakeOff Behavior turns invalid",
00032 0.1, false, false);
00033 tTakeOffVertically = addOption<bool>("tTakeOffVertically",
00034 "Take off vertically to the z-Component of the Destination",
00035 false, false, false);
00036
00037
00038 }
00039
00040 void TakeOff::destroy()
00041 {
00042
00043 }
00044
00045 bool TakeOff::willBecomeActive(const TKState& currentState, const Behavior& previousBehavior)
00046 {
00047
00048
00049 if (tTakeOffVertically->getValue()) {
00050 actualTakeOffDestination = currentState.position;
00051 actualTakeOffDestination(2) = tTakeOffDestination->getValue()(2);
00052 } else {
00053 actualTakeOffDestination = tTakeOffDestination->getValue();
00054 }
00055
00056 yawAngle = currentState.getEulerRPY()(2);
00057 return true;
00058 }
00059
00060 void TakeOff::didBecomeActive(const TKState& currentState, const Behavior& previousBehavior)
00061 {
00062
00063 }
00064
00065 void TakeOff::willBecomeInActive(const TKState& currentState, const Behavior& nextBehavior)
00066 {
00067
00068 }
00069
00070 void TakeOff::didBecomeInActive(const TKState& currentState, const Behavior& nextBehavior)
00071 {
00072
00073 }
00074
00075
00076 void TakeOff::trajectoryStepCreation(const TKState& currentState, TKTrajectory& generatedTrajInput)
00077 {
00078
00079 trajectoryStepActive(currentState,generatedTrajInput);
00080 }
00081
00082
00083 void TakeOff::trajectoryStepActive(const TKState& currentState, TKTrajectory& generatedTrajInput)
00084 {
00085 Vector3D direction = actualTakeOffDestination - currentState.position;
00086 generatedTrajInput.setVelocity( direction.normalized() * tTakeOffVelocity->getValue() );
00087 generatedTrajInput.setYawAngle( yawAngle );
00088 }
00089
00090
00091 void TakeOff::trajectoryStepTermination(const TKState& currentState, TKTrajectory& generatedTrajInput)
00092 {
00093
00094 trajectoryStepActive(currentState,generatedTrajInput);
00095 }
00096
00097
00098 bool TakeOff::isValid(const TKState& currentState) const
00099 {
00100 Vector3D direction = actualTakeOffDestination - currentState.position;
00101 return direction.norm() > tTakeOffDestinationRadius->getValue();
00102 }
00103
00104 }