clearpath.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2012, Daniel Claes, Maastricht University
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Maastricht University nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
00028  */
00029 
00030 #ifndef COLLVOID_CLEARPATH_H
00031 #define COLLVOID_CLEARPATH_H
00032 
00033 #include "collvoid_local_planner/Utils.h"
00034 
00035 
00036 #define RAYRAY 0
00037 #define RAYSEGMENT 1
00038 #define SEGMENTSEGMENT 2
00039 #define SEGMENTLINE 3
00040 #define RAYLINE 4
00041 #define LINELINE 5
00042 
00043 #define HRVOS 0
00044 #define RVOS 1
00045 #define VOS 2
00046 
00047 
00048 
00049 namespace collvoid {
00050 
00051   VO createObstacleVO(Vector2& position1, const std::vector<Vector2>& footprint1, Vector2& vel1, Vector2& position2, const std::vector<Vector2>& footprint2);
00052   VO createObstacleVO(Vector2& position1, double radius1,Vector2& vel1,  Vector2& position2, double radius2);
00053 
00054   VO createObstacleVO(Vector2& position1, double radius1, const std::vector<Vector2>& footprint1, Vector2& obst1, Vector2& obst2);
00055 
00056   
00057   //Footprint based:
00058   VO createVO(Vector2& position1, const std::vector<Vector2>& footprint1, Vector2& position2, const std::vector<Vector2>& footprint2, Vector2& vel2);
00059   VO createRVO(Vector2& position1, const std::vector<Vector2>& footprint1, Vector2& vel1, Vector2& position2, const std::vector<Vector2>& footprint2, Vector2& vel2);
00060   VO createHRVO(Vector2& position1, const std::vector<Vector2>& footprint1, Vector2& vel1, Vector2& position2, const std::vector<Vector2>& footprint2, Vector2& vel2);
00061 
00062   VO createVO(Vector2& position1, const std::vector<Vector2>& footprint1, Vector2& vel1, Vector2& position2, const std::vector<Vector2>& footprint2, Vector2& vel2, int TYPE); 
00063 
00064 
00065   //Radius based VOs
00066   VO createVO(Vector2& position1, double radius1, Vector2& vel1, Vector2& position2, double radius2, Vector2& vel2, int TYPE);
00067  
00068   VO createVO(Vector2& position1, double radius1, Vector2& position2, double radius2, Vector2& vel2);
00069   VO createRVO(Vector2& position1, double radius1, Vector2& vel1, Vector2& position2, double radius2, Vector2& vel2);
00070   VO createHRVO(Vector2& position1, double radius1, Vector2& vel1, Vector2& position2, double radius2, Vector2& vel2);
00071 
00072 
00073   //Truncate
00074   VO createTruncVO (VO& vo, double time);//, double combinedRadius, Vector2 relPosition);
00075 
00076 
00077 
00078   //Clearpath
00079   bool isInsideVO(VO vo, Vector2 point, bool use_truncation);
00080   bool isWithinAdditionalConstraints(const std::vector<Line>& additional_constraints, const Vector2& point);
00081   void addCircleLineIntersections(std::vector<VelocitySample>& samples, const Vector2& pref_vel, double max_speed, bool use_truncation, const Vector2& point, const Vector2& dir);
00082   void addIntersectPoint(std::vector<VelocitySample>& samples, const Vector2& pref_vel, double max_speed, bool use_truncation, Vector2 point, const std::vector<VO>& truncated_vos);
00083   void addRayVelocitySamples(std::vector<VelocitySample>& samples, const Vector2& pref_vel, Vector2 point1, Vector2 dir1, Vector2 point2, Vector2 dir2, double max_speed, int TYPE);
00084 
00085   Vector2 calculateClearpathVelocity(std::vector<VelocitySample>& samples, const std::vector<VO>& truncated_vos, const std::vector<Line>& additional_constraints, const Vector2&  pref_vel, double max_speed, bool use_truncation);
00086 
00087   //Sample based
00088   void createSamplesWithinMovementConstraints(std::vector<VelocitySample>& samples, double  cur_vel_x, double cur_vel_y, double cur_vel_theta,  double acc_lim_x, double acc_lim_y, double acc_lim_theta, double min_vel_x, double max_vel_x, double min_vel_y, double max_vel_y, double min_vel_theta, double max_vel_theta, double heading, Vector2 pref_vel, double sim_period, int num_samples, bool holo_robot);
00089 
00090 
00091   double calculateVelCosts(const Vector2& test_vel, const std::vector<VO>& truncated_vos, const Vector2& pref_vel, double max_speed, bool use_truncation); 
00092   Vector2 calculateNewVelocitySampled(std::vector<VelocitySample>& samples, const std::vector<VO>& truncated_vos, const Vector2& pref_vel,double max_speed, bool use_truncation);
00093 
00094 
00095 
00096 
00097 
00098 
00099   
00100 
00101   std::vector<Vector2> minkowskiSum(const std::vector<Vector2> polygon1, const std::vector<Vector2> polygon2);
00102   
00103   //convex hull algorithm
00104   bool compareVectorsLexigraphically(const ConvexHullPoint& v1, const ConvexHullPoint& v2);
00105   double cross(const ConvexHullPoint& O, const ConvexHullPoint& A, const ConvexHullPoint& B);
00106     // Returns a list of points on the convex hull in counter-clockwise order.
00107   // Note: the last point in the returned list is the same as the first one.
00108   //Wikipedia Monotone chain...   
00109   std::vector<ConvexHullPoint> convexHull(std::vector<ConvexHullPoint> P, bool sorted);
00110                           
00111   bool compareVelocitySamples(const VelocitySample& p1, const VelocitySample& p2);
00112 
00113   Vector2 intersectTwoLines(Vector2 point1, Vector2 dir1, Vector2 point2, Vector2 dir2);
00114   Vector2 intersectTwoLines(Line line1, Line line2);
00115 
00116   
00117 }
00118 
00119 
00120 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


collvoid_local_planner
Author(s): Daniel Claes
autogenerated on Sun Aug 25 2013 10:10:23