ObstacleAvoidancePotential.cpp
Go to the documentation of this file.
00001 /*
00002  * ObstacleAvoidancePotential.cpp
00003  *
00004  *  Created on: Dec 14, 2011
00005  *      Author: mriedel
00006  */
00007 
00008 #include <obs_avoidance/ObstacleAvoidancePotential.hpp>
00009 
00010 namespace TELEKYB_NAMESPACE {
00011 
00012 ObstacleAvoidancePotentialOptions::ObstacleAvoidancePotentialOptions(const std::string& identifier_)
00013         : OptionContainer(identifier_)
00014 {
00015         tObsAPUavSemiDims = addOption("tObsAPUavSemiDims",
00016                         "Semi-axes of an ellipsoid approximation the uav.", Vector3D(0.4,0.4,0.15), false, false);
00017 //      tObsAPRepulMaxDist = addOption("tObsAPRepulMaxDist",
00018 //                      "Max Distance to Obstacle Point, so that it is considered.", 0.6, false, false);
00019 //      tObsAPRepulMinDist = addOption("tObsAPRepulMinDist",
00020 //                      "Min Distance to Obstacle Point, so that it is considered. Afterwards it has a constant influence",
00021 //                      0.1, false, false);
00022 //      tObsAPRepulGain = addOption("tObsAPRepulGain",
00023 //                      "Gain for Obstacle Potential", 0.5, false, false);
00024 //      tObsAPSaturationVel = addOption<double>("tObsAPSaturationVel",
00025 //                      "Velocity Saturation if Distance < tObsAPRepulMinDist", 4.0, false, false);
00026 //      tObsAPSaturationAcc = addOption<double>("tObsAPSaturationAcc",
00027 //                      "Acceleration Saturation if Distance < tObsAPRepulMinDist", 6.0, false, false);
00028 
00029 }
00030 
00031 ObstacleAvoidancePotential::ObstacleAvoidancePotential(const std::string& identifier_)
00032         : options(identifier_),
00033           obstaclePotentialGradient(NULL)
00034 {
00035         // Add Default Options to RawOptionContainer
00036         std::string gradientIdentifier = identifier_ + "_gradient";
00037         telekyb::RawOptionsContainer::addOption(gradientIdentifier + "/tPotFuncZeroD","0.5");
00038         telekyb::RawOptionsContainer::addOption(gradientIdentifier + "/tPotFuncInfD","0.2");
00039         telekyb::RawOptionsContainer::addOption(gradientIdentifier + "/tPotFuncSatValue","4.0");
00040         telekyb::RawOptionsContainer::addOption(gradientIdentifier + "/tPotFuncGain","100.0");
00041 
00042         // Note: Reads Parameters from RawOptionContainer!
00043         obstaclePotentialGradient = new CoTanRepulsiveGradient(gradientIdentifier);
00044 
00045 }
00046 
00047 ObstacleAvoidancePotential::~ObstacleAvoidancePotential() {
00048         if (obstaclePotentialGradient) {
00049                 delete obstaclePotentialGradient;
00050         }
00051 }
00052 
00053 double ObstacleAvoidancePotential::getEffectiveUAVDistance(const Position3D& relObstaclePositon) const {
00054         // The clearance of a uav is modelled as an ellipsoid
00055         // TODO this ellipsoid should take care of the uav attitude
00056         //Position3D relObstaclePositon = -positionDifference;
00057         double azimuth = R3Helper::azimuth(relObstaclePositon);
00058         double zenith  = R3Helper::zenith(relObstaclePositon);
00059         Position3D uavSemiDims = options.tObsAPUavSemiDims->getValue();
00060         double xClearance = uavSemiDims(0) * sin(zenith) * cos(azimuth);
00061         double yClearance = uavSemiDims(1) * sin(zenith) * sin(azimuth);
00062         double zClearance = uavSemiDims(2) * cos(zenith);
00063         double uavClearance = sqrt(xClearance*xClearance + yClearance*yClearance + zClearance*zClearance);
00064 
00065         return relObstaclePositon.norm() - uavClearance;
00066 }
00067 
00068 Velocity3D ObstacleAvoidancePotential::getObstacleVelocity(const Position3D& position, const std::vector< Position3D >& obstaclePoints) {
00069         Velocity3D accumVelocity(0.0,0.0,0.0);
00070 
00071 
00072         //int obsNum = input.obsPositions.size();
00073         for(unsigned int i = 0; i < obstaclePoints.size(); i++){
00074                 Position3D positionDifference = position - obstaclePoints[i];
00075                 double d = getEffectiveUAVDistance(-positionDifference);
00076                 accumVelocity += obstaclePotentialGradient->getPotential(d) * positionDifference.normalized();
00077 //              ROS_WARN("Distance: %f", d);
00078         }
00079 
00080 
00081 //      if (accumVelocity.norm() > 0.01) {
00082 //              ROS_WARN("Calculated Obstaclevelocity: (%f,%f,%f)", accumVelocity(0),accumVelocity(1),accumVelocity(2));
00083 //      }
00084         return accumVelocity;
00085 }
00086 
00087 //Acceleration3D ObstacleAvoidancePotential::getObstacleAcceleration(const Position3D& position, const std::vector< Position3D >& obstaclePoints) {
00088 //      Acceleration3D accumAcceleration(0.0,0.0,0.0);
00089 //
00090 //      for(unsigned int i = 0; i < obstaclePoints.size(); i++){
00091 //              Position3D positionDifference = position - obstaclePoints[i];
00092 //              double d = getEffectiveUAVDistance(-positionDifference);
00093 //              accumAcceleration += obstaclePotentialHassian.getPotential(d) * positionDifference.normalized();
00095 //      }
00096 //
00097 //
00098 //      if (accumAcceleration.norm() > 0.01) {
00099 //              ROS_WARN("Calculated ObstacleAcceleration: (%f,%f,%f)", accumAcceleration(0),accumAcceleration(1),accumAcceleration(2));
00100 //      }
00101 //      return accumAcceleration;
00102 //
00103 //}
00104 
00105 } /* namespace telekyb */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends


tk_obstacle
Author(s): Martin Riedel
autogenerated on Mon Nov 11 2013 11:13:22