Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "LinearFlyTo.hpp"
00009
00010
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
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
00045 return true;
00046 }
00047
00048 void LinearFlyTo::didBecomeActive(const TKState& currentState, const Behavior& previousBehavior)
00049 {
00050
00051 }
00052
00053 void LinearFlyTo::willBecomeInActive(const TKState& currentState, const Behavior& nextBehavior)
00054 {
00055
00056 }
00057
00058 void LinearFlyTo::didBecomeInActive(const TKState& currentState, const Behavior& nextBehavior)
00059 {
00060
00061 }
00062
00063
00064 void LinearFlyTo::trajectoryStepCreation(const TKState& currentState, TKTrajectory& generatedTrajInput)
00065 {
00066 trajectoryStepActive(currentState, generatedTrajInput);
00067 }
00068
00069
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
00078 void LinearFlyTo::trajectoryStepTermination(const TKState& currentState, TKTrajectory& generatedTrajInput)
00079 {
00080 generatedTrajInput.setVelocity( Velocity3D::Zero() );
00081 generatedTrajInput.setYawAngle( yawAngle );
00082 }
00083
00084
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 }