FormationReconfiguration.hpp
Go to the documentation of this file.
00001 /*
00002  * FormationReconfiguration.hpp
00003  *
00004  *  Created on: Nov 12, 2011
00005  *      Author: mriedel
00006  */
00007 
00008 #ifndef FORMATIONRECONFIGURATION_HPP_
00009 #define FORMATIONRECONFIGURATION_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 FormationReconfiguration : public AbstractGraphNode {
00036 protected:
00037         Option< std::vector<int>  >* tNeighbors;
00038         Option< std::vector<double> >* tNeighborDistances;
00039 
00040 
00041         Option< std::string >* tObsPointsTopicName;
00042         std::vector<Position3D> lastObstaclePoints;
00043 
00044 
00045         Option<double>* tMaxYawRate;
00046 
00047         // Distance Map to Neighbors
00048         std::vector<double> distanceVector;
00049 
00050         // Virtual Point of Formation
00051         Position3D virtualPoint;
00052 
00053         // ROS
00054         ros::Subscriber obsPointSub;
00055 
00056         //double lastYawRateInput;
00057 
00058         // Integrated Position for Velocity Mode
00059         //Position3D posModeCurPosition;
00060         //Angle yawAngle;
00061         Time posModeLastInputTime;
00062 
00063 
00064         // Outputfield
00065         bool valid;
00066 
00067         void obsPointCB(const telekyb_msgs::StampedPointArray::ConstPtr& obsPointsMsg);
00068 
00069         ObstacleAvoidancePotential obsPotential;
00070 
00071         // Algorithm related
00072         Option<double>* tFormationRepulMinDist;
00073         Option<double>* tFormationAttrGain;
00074         Option<double>* tFormationRepulGain;
00075         Option<double>* tFormationReconfFinalYawAngle;
00076 
00077 
00078         // PotentialFunctions
00079         std::vector< CoTanRepulsiveGradient*> formationRepulsiveGradientVector;
00080         std::vector< CoTanAttractiveGradient*> formationAttractiveGradientVector;
00081 
00082 //      std::vector< PotentialFunction<PotentialFunctionImpl::CoTanRepulsiveGradient>* > formationRepulsiveGradientVector;
00083 //      PotentialFunction<PotentialFunctionImpl::CoTanAttractiveGradient>* formationAttractiveGradient;
00084 
00085         Velocity3D getFormationVirtPointVel();
00086         double getMeanDistanceError() const;
00087 
00088 public:
00089         FormationReconfiguration();
00090 
00091         virtual void initialize();
00092         virtual void destroy();
00093 
00094         //virtual bool trajectoryStep(const TKState& currentState, TKTrajectory& generatedTrajInput);
00095 
00096         // Called directly after Change Event is registered.
00097         virtual bool willBecomeActive(const TKState& currentState, const Behavior& previousBehavior);
00098         // Called after actual Switch. Note: During execution trajectoryStepCreation is used
00099         virtual void didBecomeActive(const TKState& currentState, const Behavior& previousBehavior);
00100         // Called directly after Change Event is registered: During execution trajectoryStepTermination is used
00101         virtual void willBecomeInActive(const TKState& currentState, const Behavior& nextBehavior);
00102         // Called after actual Switch. Runs in seperate Thread.
00103         virtual void didBecomeInActive(const TKState& currentState, const Behavior& nextBehavior);
00104 
00105         // called everytime a new TKState is available AND it is the NEW Behavior of an active Switch
00106         virtual void trajectoryStepCreation(const TKState& currentState, TKTrajectory& generatedTrajInput);
00107 
00108         // called everytime a new TKState is available. Should return false if invalid (swtich to next behavior, or Hover if undef).
00109         virtual void trajectoryStepActive(const TKState& currentState, TKTrajectory& generatedTrajInput);
00110 
00111         // called everytime a new TKState is available AND it is the OLD Behavior of an active Switch
00112         virtual void trajectoryStepTermination(const TKState& currentState, TKTrajectory& generatedTrajInput);
00113 
00114         // Return true if the active Behavior is (still) valid. Initiate Switch otherwise
00115         virtual bool isValid(const TKState& currentState) const;
00116 };
00117 
00118 }
00119 
00120 #endif /* FORMATIONRECONFIGURATION_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