.. _program_listing_file_fields2cover_path_planning_turning_base.h: Program Listing for File turning_base.h ======================================= |exhale_lsh| :ref:`Return to documentation for file ` (``fields2cover/path_planning/turning_base.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp //============================================================================= // Copyright (C) 2021-2024 Wageningen University - All Rights Reserved // Author: Gonzalo Mier // BSD-3 License //============================================================================= #pragma once #ifndef FIELDS2COVER_PATH_PLANNING_TURNING_BASE_H_ #define FIELDS2COVER_PATH_PLANNING_TURNING_BASE_H_ #include #include #include #include #include #include "fields2cover/types.h" #include "fields2cover/utils/random.h" namespace f2c::pp { class TurningBase { public: F2CPath createTurn(const F2CRobot& robot, const F2CPoint& start_pos, double start_angle, const F2CPoint& end_pos, double end_angle); F2CPath createTurnIfNotCached(const F2CRobot& robot, double dist_start_pos, double start_angle, double end_angle); virtual F2CPath createSimpleTurn(const F2CRobot& robot, double dist_start_pos, double start_angle, double end_angle) = 0; static std::vector transformToNormalTurn(const F2CPoint& start_pos, double start_angle, const F2CPoint& end_pos, double end_angle); static bool isTurnValid(const F2CPath& path, double dist_start_end, double end_angle, double max_dist_error = 0.05, double max_rot_error = 0.1); double getDiscretization() const; void setDiscretization(double d); bool getUsingCache() const; void setUsingCache(bool c); virtual ~TurningBase() = default; private: static void correctPath(F2CPath& path, const F2CPoint& start_pos, const F2CPoint& end_pos, float max_error_dist = 0.05); protected: // To prevent memory consumption and comparative errors because of doubles // ints are used multiplied by 1000. std::map, F2CPath> path_cache_; double discretization {0.01}; bool using_cache {true}; }; } // namespace f2c::pp #endif // FIELDS2COVER_PATH_PLANNING_TURNING_BASE_H_