Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include <behaviors/Hover.hpp>
00009
00010 #define MAX_INITIAL_VELOCITY 0.05
00011
00012
00013
00014 PLUGINLIB_DECLARE_CLASS(tk_behavior, Hover, telekyb_behavior::Hover, TELEKYB_NAMESPACE::Behavior);
00015
00016 namespace telekyb_behavior {
00017
00018 Hover::Hover()
00019 : Behavior("tk_behavior/Hover", BehaviorType::Air)
00020 {
00021
00022 }
00023
00024 void Hover::initialize()
00025 {
00026
00027 tHoverMaxInitialVelocity = addOption<double>("tHoverMaxInitialVelocity",
00028 "Defines the Maximal Initial Velocity to be able to switch into Hover",
00029 0.2, false, true);
00030
00031
00032
00033 parameterInitialized = true;
00034 }
00035
00036 void Hover::destroy()
00037 {
00038
00039 }
00040
00041
00042 bool Hover::willBecomeActive(const TKState& currentState, const Behavior& previousBehavior)
00043 {
00044
00045 if (currentState.linVelocity.norm() > tHoverMaxInitialVelocity->getValue()) {
00046 ROS_ERROR_STREAM("Too fast to switch into Hover! Current Velocity Norm: " << currentState.linVelocity.norm());
00047 return false;
00048 }
00049
00050 hoverPosition = currentState.position;
00051 yawAngle = currentState.getEulerRPY()(2);
00052
00053 ROS_INFO_STREAM("Setting Position: " << std::endl << currentState.position << " Angle: " << currentState.getEulerRPY()(2));
00054
00055
00056 return true;
00057 }
00058
00059 void Hover::didBecomeActive(const TKState& currentState, const Behavior& previousBehavior)
00060 {
00061
00062
00063
00064 }
00065
00066 void Hover::willBecomeInActive(const TKState& currentState, const Behavior& nextBehavior)
00067 {
00068
00069 }
00070
00071 void Hover::didBecomeInActive(const TKState& currentState, const Behavior& nextBehavior)
00072 {
00073
00074 }
00075
00076
00077 void Hover::trajectoryStepCreation(const TKState& currentState, TKTrajectory& generatedTrajInput)
00078 {
00079
00080 trajectoryStepActive(currentState,generatedTrajInput);
00081 }
00082
00083
00084 void Hover::trajectoryStepActive(const TKState& currentState, TKTrajectory& generatedTrajInput)
00085 {
00086 generatedTrajInput.setPosition(hoverPosition);
00087 generatedTrajInput.setYawAngle(yawAngle);
00088 }
00089
00090
00091 void Hover::trajectoryStepTermination(const TKState& currentState, TKTrajectory& generatedTrajInput)
00092 {
00093
00094 trajectoryStepActive(currentState,generatedTrajInput);
00095 }
00096
00097
00098 bool Hover::isValid(const TKState& currentState) const
00099 {
00100
00101 return true;
00102 }
00103
00104
00105
00106 }