Go to the documentation of this file.00001
00002
00003
00004
00005
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
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 }
00030
00031 ObstacleAvoidancePotential::ObstacleAvoidancePotential(const std::string& identifier_)
00032 : options(identifier_),
00033 obstaclePotentialGradient(NULL)
00034 {
00035
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
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
00055
00056
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
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
00078 }
00079
00080
00081
00082
00083
00084 return accumVelocity;
00085 }
00086
00087
00088
00089
00090
00091
00092
00093
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 }