From ea00ab2c89e441296b9ae8718cb0b714ccfeda6f Mon Sep 17 00:00:00 2001 From: bernatx Date: Mon, 1 Jul 2019 16:46:34 +0200 Subject: [PATCH] Change some comments --- LibCarla/source/carla/nav/Navigation.cpp | 5 ++-- LibCarla/source/carla/nav/Navigation.h | 36 +++++++++++++----------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/LibCarla/source/carla/nav/Navigation.cpp b/LibCarla/source/carla/nav/Navigation.cpp index e55113821..1bc44b824 100644 --- a/LibCarla/source/carla/nav/Navigation.cpp +++ b/LibCarla/source/carla/nav/Navigation.cpp @@ -88,7 +88,7 @@ namespace nav { } // load navigation data from memory - bool Navigation::Load( std::vector content) { + bool Navigation::Load(std::vector content) { const int NAVMESHSET_MAGIC = 'M' << 24 | 'S' << 16 | 'E' << 8 | 'T'; // 'MSET'; const int NAVMESHSET_VERSION = 1; #pragma pack(push, 1) @@ -357,7 +357,8 @@ namespace nav { params.obstacleAvoidanceType = 3; params.separationWeight = 0.5f; - // from Unreal coordinates (subtract half height to move pivot from center (unreal) to bottom (recast)) + // from Unreal coordinates (subtract half height to move pivot from center + // (unreal) to bottom (recast)) float PointFrom[3] = { from.x, from.z - (AGENT_HEIGHT / 2.0f), from.y }; // add walker int index = _crowd->addAgent(PointFrom, ¶ms); diff --git a/LibCarla/source/carla/nav/Navigation.h b/LibCarla/source/carla/nav/Navigation.h index b2ffc93b2..695b42b3d 100644 --- a/LibCarla/source/carla/nav/Navigation.h +++ b/LibCarla/source/carla/nav/Navigation.h @@ -21,6 +21,10 @@ namespace carla { namespace nav { + /// Manage the pedestrians navigation, using the Recast & Detour library for low level calculations. + /// + /// This class gets the binary content of the map from the server, which is required for the path finding. + /// Then this class can add or remove pedestrians, and also set target points to walk for each one. class Navigation : private NonCopyable { public: @@ -28,32 +32,32 @@ namespace nav { Navigation() = default; ~Navigation(); - // load navigation data + /// load navigation data bool Load(const std::string &filename); - // load navigation data from memory + /// load navigation data from memory bool Load(std::vector content); - // return the path points to go from one position to another + /// return the path points to go from one position to another bool GetPath(carla::geom::Location from, carla::geom::Location to, dtQueryFilter * filter, std::vector &path); - // create the crowd object + /// create the crowd object void CreateCrowd(void); - // create a new walker + /// create a new walker bool AddWalker(ActorId id, carla::geom::Location from); - // remove a walker + /// remove a walker bool RemoveWalker(ActorId id); - // set new max speed + /// set new max speed bool SetWalkerMaxSpeed(ActorId id, float max_speed); - // set a new target point to go + /// set a new target point to go bool SetWalkerTarget(ActorId id, carla::geom::Location to); bool SetWalkerTargetIndex(int index, carla::geom::Location to, bool use_lock = true); - // get the walker current transform + /// get the walker current transform bool GetWalkerTransform(ActorId id, carla::geom::Transform &trans); - // get the walker current transform + /// get the walker current transform float GetWalkerSpeed(ActorId id); - // update all walkers in crowd + /// update all walkers in crowd void UpdateCrowd(const client::detail::EpisodeState &state); - // get a random location for navigation + /// get a random location for navigation bool GetRandomLocation(carla::geom::Location &location, float maxHeight = -1.0f, dtQueryFilter * filter = nullptr, bool use_lock = true); @@ -62,14 +66,14 @@ namespace nav { bool _ready { false }; std::vector _binaryMesh; double _delta_seconds; - // meshes + /// meshes dtNavMesh *_navMesh { nullptr }; dtNavMeshQuery *_navQuery { nullptr }; - // crowd + /// crowd dtCrowd *_crowd { nullptr }; - // mapping Id + /// mapping Id std::unordered_map _mappedId; - // Store walkers yaw angle from previous tick + /// Store walkers yaw angle from previous tick std::unordered_map _yaw_walkers; std::mutex _mutex;