Formation.hpp
Go to the documentation of this file.
00001 /*
00002  * Formation.hpp
00003  *
00004  *  Created on: Nov 12, 2011
00005  *      Author: mriedel
00006  */
00007 
00008 #ifndef FORMATION_HPP_
00009 #define FORMATION_HPP_
00010 
00011 #include <telekyb_defines/telekyb_defines.hpp>
00012 #include "AbstractGraphNode.hpp"
00013 
00014 #include <telekyb_base/Spaces/Angle.hpp>
00015 
00016 // plugin stuff
00017 #include <pluginlib/class_list_macros.h>
00018 
00019 // sensormsgs
00020 #include <sensor_msgs/Joy.h>
00021 // Input Velocity
00022 #include <geometry_msgs/Vector3Stamped.h>
00023 
00024 #include <telekyb_msgs/StampedPointArray.h>
00025 
00026 #include <obs_avoidance/ObstacleAvoidancePotential.hpp>
00027 
00028 // PotentialFunctions
00029 #include <telekyb_calculus/Potentials/CoTanPotentialFunctions.hpp>
00030 
00031 using namespace TELEKYB_NAMESPACE;
00032 
00033 namespace telekyb_behavior {
00034 
00035 class Formation : public AbstractGraphNode {
00036 protected:
00037         Option< std::vector<int>  >* tNeighbors;
00038         //Option< std::vector<double> >* tNeighborDistances;
00039 
00040         Option< std::string >* tJoystickTopic;
00041         Option< bool >* tVelocityInputEnabled;
00042         Option< std::string >* tVelocityInputTopic;
00043 
00044         //Option<bool>* tFormationUsePositionMode;
00045         //Option<double>* tJoystickYawRateScale;
00046 
00047         Option< std::string >* tObsPointsTopicName;
00048         std::vector<Position3D> lastObstaclePoints;
00049 
00050 
00051         Option<double>* tMaxYawRate;
00052 
00053         // Distance Map to Neighbors
00054         std::vector<double> distanceVector;
00055 
00056         // Virtual Point of Formation
00057         Position3D virtualPoint;
00058 
00059         // ROS
00060         ros::Subscriber userInputSub;
00061         ros::Subscriber joySub;
00062         ros::Subscriber obsPointSub;
00063 
00064         void joystickCB(const sensor_msgs::Joy::ConstPtr& msg);
00065         void userVelocityCB(const geometry_msgs::Vector3Stamped::ConstPtr& msg);
00066 
00067         Velocity3D lastVelocityInput;
00068         //double lastYawRateInput;
00069 
00070         // Integrated Position for Velocity Mode
00071         //Position3D posModeCurPosition;
00072         //Angle yawAngle;
00073         Time posModeLastInputTime;
00074 
00075         // Dead Man
00076         bool deadManPressed;
00077 
00078         // Outputfield
00079         bool valid;
00080 
00081 
00082 
00083         void obsPointCB(const telekyb_msgs::StampedPointArray::ConstPtr& obsPointsMsg);
00084 
00085         ObstacleAvoidancePotential obsPotential;
00086 
00087         // Algorithm related
00088         Option<double>* tFormationRepulMinDist;
00089         Option<double>* tFormationAttrGain;
00090         Option<double>* tFormationRepulGain;
00091         Option<bool>* tFormationDoYawControl;
00092 
00093         double tFormationInitialYawAngle;
00094 
00095 
00096         // PotentialFunctions
00097         std::vector< CoTanRepulsiveGradient*> formationRepulsiveGradientVector;
00098         std::vector< CoTanAttractiveGradient*> formationAttractiveGradientVector;
00099 
00100         Velocity3D getFormationVirtPointVel();
00101 
00102 public:
00103         Formation();
00104 
00105         virtual void initialize();
00106         virtual void destroy();
00107 
00108         //virtual bool trajectoryStep(const TKState& currentState, TKTrajectory& generatedTrajInput);
00109 
00110         // Called directly after Change Event is registered.
00111         virtual bool willBecomeActive(const TKState& currentState, const Behavior& previousBehavior);
00112         // Called after actual Switch. Note: During execution trajectoryStepCreation is used
00113         virtual void didBecomeActive(const TKState& currentState, const Behavior& previousBehavior);
00114         // Called directly after Change Event is registered: During execution trajectoryStepTermination is used
00115         virtual void willBecomeInActive(const TKState& currentState, const Behavior& nextBehavior);
00116         // Called after actual Switch. Runs in seperate Thread.
00117         virtual void didBecomeInActive(const TKState& currentState, const Behavior& nextBehavior);
00118 
00119         // called everytime a new TKState is available AND it is the NEW Behavior of an active Switch
00120         virtual void trajectoryStepCreation(const TKState& currentState, TKTrajectory& generatedTrajInput);
00121 
00122         // called everytime a new TKState is available. Should return false if invalid (swtich to next behavior, or Hover if undef).
00123         virtual void trajectoryStepActive(const TKState& currentState, TKTrajectory& generatedTrajInput);
00124 
00125         // called everytime a new TKState is available AND it is the OLD Behavior of an active Switch
00126         virtual void trajectoryStepTermination(const TKState& currentState, TKTrajectory& generatedTrajInput);
00127 
00128         // Return true if the active Behavior is (still) valid. Initiate Switch otherwise
00129         virtual bool isValid(const TKState& currentState) const;
00130 };
00131 
00132 }
00133 
00134 #endif /* FORMATION_HPP_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Defines


tk_formation
Author(s): Martin Riedel
autogenerated on Mon Nov 11 2013 11:14:18