00001 /* 00002 * PMObsAvoid.hpp 00003 * 00004 * Created on: Dec 15, 2011 00005 * Author: mriedel 00006 */ 00007 00008 #ifndef PMOBSAVOID_HPP_ 00009 #define PMOBSAVOID_HPP_ 00010 00011 #include <telekyb_defines/telekyb_defines.hpp> 00012 #include <tk_trajprocessor/TrajectoryModule.hpp> 00013 00014 #include <telekyb_base/Options.hpp> 00015 00016 #include <ros/ros.h> 00017 #include <boost/thread/mutex.hpp> 00018 00019 #include <telekyb_msgs/StampedPointArray.h> 00020 00021 #include <obs_avoidance/ObstacleAvoidancePotential.hpp> 00022 00023 #include <telekyb_base/Time.hpp> 00024 00025 using namespace TELEKYB_NAMESPACE; 00026 00027 namespace telekyb_traj { 00028 00029 class PMObsAvoidOptions : public OptionContainer { 00030 public: 00031 Option<std::string>* tObsPointsTopicName; 00032 Option<double>* tPMObsDerivgain; 00033 Option<double>* tPMObsVelocitySaturation; 00034 Option<double>* tPMObsAccelerationSaturation; 00035 00036 PMObsAvoidOptions(); 00037 }; 00038 00039 class PMObsAvoid : public TrajectoryModule { 00040 protected: 00041 PMObsAvoidOptions options; 00042 00043 ObstacleAvoidancePotential obsAvoidPotentialAlg; 00044 00045 // ros 00046 ros::Subscriber obsPointSub; 00047 00048 // CB 00049 void obsPointCB(const telekyb_msgs::StampedPointArray::ConstPtr& obsPointsMsg); 00050 00051 std::vector<Position3D> lastObstaclePoints; 00052 boost::mutex lastObstaclePointsMutex; 00053 00054 // bool active 00055 bool obsAvoidActive; 00056 00057 Timer timeStep; 00058 00059 Position3D lastPosition; // k-1 for Alg 00060 Velocity3D lastVelocity; // k-1 for Alg 00061 Acceleration3D lastAcceleration; // unsure about this 00062 00063 public: 00064 PMObsAvoid(); 00065 00066 virtual void initialize(); 00067 virtual void destroy(); 00068 00069 // set back to intial conditions 00070 virtual void willTurnActive(); 00071 00072 // called after turning inactive 00073 virtual void didTurnInactive(); 00074 00075 // actual step 00076 virtual bool trajectoryStep(const TKState& currentState, TKTrajectory& trajInput); 00077 }; 00078 00079 } /* namespace telekyb_traj */ 00080 #endif /* PMOBSAVOID_HPP_ */