Skip to content

Commit

Permalink
reorganize classes in subdirectories
Browse files Browse the repository at this point in the history
  • Loading branch information
jlblancoc committed Jun 3, 2021
1 parent ccf78b6 commit c705a2b
Show file tree
Hide file tree
Showing 38 changed files with 530 additions and 47 deletions.
6 changes: 3 additions & 3 deletions apps/path-planner-cli/path-planner-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#include <mrpt/serialization/CArchive.h>
#include <mrpt/system/filesystem.h>
#include <mrpt/system/os.h> // plugins
#include <selfdriving/CostEvaluatorCostMap.h>
#include <selfdriving/TPS_RRTstar.h>
#include <selfdriving/viz.h>
#include <selfdriving/algos/CostEvaluatorCostMap.h>
#include <selfdriving/algos/TPS_RRTstar.h>
#include <selfdriving/algos/viz.h>

#include <fstream>
#include <iostream>
Expand Down
8 changes: 4 additions & 4 deletions apps/selfdriving-simulator-gui/selfdriving-simulator-gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
#include <mvsim/Comms/Server.h>
#include <mvsim/World.h>
#include <mvsim/WorldElements/OccupancyGridMap.h>
#include <selfdriving/CostEvaluator.h>
#include <selfdriving/CostEvaluatorCostMap.h>
#include <selfdriving/TPS_RRTstar.h>
#include <selfdriving/viz.h>
#include <selfdriving/algos/CostEvaluator.h>
#include <selfdriving/algos/CostEvaluatorCostMap.h>
#include <selfdriving/algos/TPS_RRTstar.h>
#include <selfdriving/algos/viz.h>

#include <rapidxml_utils.hpp>
#include <thread>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#pragma once

#include <mrpt/rtti/CObject.h>
#include <selfdriving/MoveEdgeSE2_TPS.h>
#include <selfdriving/data/MoveEdgeSE2_TPS.h>

#include <functional>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <mrpt/containers/CDynamicGrid.h>
#include <mrpt/maps/CPointsMap.h>
#include <selfdriving/CostEvaluator.h>
#include <selfdriving/algos/CostEvaluator.h>

namespace selfdriving
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

#include <mrpt/system/COutputLogger.h>
#include <mrpt/system/CTimeLogger.h>
#include <selfdriving/CostEvaluator.h>
#include <selfdriving/PlannerInput.h>
#include <selfdriving/PlannerOutput.h>
#include <selfdriving/algos/CostEvaluator.h>
#include <selfdriving/data/PlannerInput.h>
#include <selfdriving/data/PlannerOutput.h>

namespace selfdriving
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#pragma once

#include <mrpt/system/COutputLogger.h>
#include <selfdriving/MoveEdgeSE2_TPS.h>
#include <selfdriving/TrajectoriesAndRobotShape.h>
#include <selfdriving/data/MoveEdgeSE2_TPS.h>
#include <selfdriving/data/TrajectoriesAndRobotShape.h>

#include <optional>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#pragma once

#include <mrpt/opengl/opengl_frwds.h>
#include <selfdriving/MotionPrimitivesTree.h>
#include <selfdriving/PlannerInput.h>
#include <selfdriving/RenderOptions.h>
#include <selfdriving/data/MotionPrimitivesTree.h>
#include <selfdriving/data/PlannerInput.h>
#include <selfdriving/data/RenderOptions.h>

#include <memory>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

#pragma once

#include <selfdriving/PlannerOutput.h>
#include <selfdriving/RenderOptions.h>
#include <selfdriving/data/PlannerOutput.h>
#include <selfdriving/data/RenderOptions.h>

namespace selfdriving
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
#include <mrpt/math/wrap2pi.h>
#include <mrpt/nav/tpspace/CParameterizedTrajectoryGenerator.h>
#include <mrpt/poses/CPose2D.h>
#include <selfdriving/MoveEdgeSE2_TPS.h>
#include <selfdriving/SE2_KinState.h>
#include <selfdriving/ptg_t.h>
#include <selfdriving/data/MoveEdgeSE2_TPS.h>
#include <selfdriving/data/SE2_KinState.h>
#include <selfdriving/data/ptg_t.h>

#include <cstdint>
#include <deque>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#pragma once

#include <mrpt/graphs/TNodeID.h>
#include <selfdriving/SE2_KinState.h>
#include <selfdriving/ptg_t.h>
#include <selfdriving/data/SE2_KinState.h>
#include <selfdriving/data/ptg_t.h>

#include <cstdint>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#pragma once

#include <mrpt/math/TPose2D.h>
#include <selfdriving/ObstacleSource.h>
#include <selfdriving/SE2_KinState.h>
#include <selfdriving/TrajectoriesAndRobotShape.h>
#include <selfdriving/data/SE2_KinState.h>
#include <selfdriving/data/TrajectoriesAndRobotShape.h>
#include <selfdriving/interfaces/ObstacleSource.h>

namespace selfdriving
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#pragma once

#include <mrpt/graphs/TNodeID.h>
#include <selfdriving/MotionPrimitivesTree.h>
#include <selfdriving/PlannerInput.h>
#include <selfdriving/data/MotionPrimitivesTree.h>
#include <selfdriving/data/PlannerInput.h>

#include <set>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <mrpt/config/CConfigFileBase.h>
#include <mrpt/containers/yaml.h>
#include <mrpt/math/TPolygon2D.h>
#include <selfdriving/ptg_t.h>
#include <selfdriving/data/ptg_t.h>

#include <memory>
#include <variant>
Expand Down
222 changes: 222 additions & 0 deletions libselfdriving/include/selfdriving/data/Waypoints.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
/* +------------------------------------------------------------------------+
| Mobile Robot Programming Toolkit (MRPT) |
| https://www.mrpt.org/ |
| |
| Copyright (c) 2005-2021, Individual contributors, see AUTHORS file |
| See: https://www.mrpt.org/Authors - All rights reserved. |
| Released under BSD License. See: https://www.mrpt.org/License |
+------------------------------------------------------------------------+ */
#pragma once

#include <mrpt/config/CConfigFileBase.h>
#include <mrpt/img/TColor.h>
#include <mrpt/math/TPoint2D.h>
#include <mrpt/math/TPose2D.h>
#include <mrpt/opengl/opengl_frwds.h>
#include <mrpt/system/datetime.h>

#include <any>
#include <optional>
#include <string>
#include <vector>

namespace selfdriving
{
/** A single waypoint within WaypointSequence. */
struct Waypoint
{
/** Ctor with default values */
Waypoint() = default;

Waypoint(
double target_x, double target_y, double allowed_distance,
bool allow_skip = true,
std::optional<double> target_heading_ = std::nullopt,
double speed_ratio_ = 1.0);

/** [Must be set by the user] Coordinates of desired target location
* (world/global coordinates).
* \sa target_heading */
mrpt::math::TPoint2D target{INVALID_NUM, INVALID_NUM};

/** [Default=any heading] Optionally, set to the desired orientation
* [radians]
* of the robot at this waypoint. Some navigator implementations may ignore
* this preferred heading anyway, read the docs of each implementation to
* find it out. */
std::optional<double> targetHeading;

/** (Default="map") Frame ID in which target is given. Optional, use only
* for submapping applications. */
std::string targetFrameId = "map";

/** [Must be set by the user] How close should the robot get to this
* waypoint for it to be considered reached. */
double allowedDistance{INVALID_NUM};

/** (Default=1.0) Desired robot speed at the target, as a ratio of the full
* robot speed. That is: speed_ratio=1 means that the user wants the robot
* to navigate to the target and smoothly continue to the next one when
* reached. speed_ratio=0 on the other hand means that the robot should
* approach this waypoint slowing down and end up totally stopped.
*/
double speedRatio = 1.0;

/** [Default=true] Whether it is allowed to the navigator to proceed to a
* more advanced waypoint
* in the sequence if it determines that it is easier to skip this one
* (e.g. it seems blocked by dynamic obstacles).
* This value is ignored for the last waypoint in a sequence, since it is
* always considered to be the
* ultimate goal and hence not subject to be skipped.
*/
bool allowSkip = true;

/**
* This modifies the behavior of mrpt::nav::TWaypoint::allow_skip according
* to:
*
* \verbatim
* +------------+-----------------+---------------------------+
* | allow_skip | preferNotToSkip | Waypoint obstructed |
* | | | with obstacles? |
* | | +------------+--------------+
* | | | Yes | No |
* +------------+-----------------+------------+--------------+
* | false | false | Trigger | Pass through |
* | (default) +-----------------+ rnav error | waypoint |
* | | true | | |
* +------------+-----------------+------------+--------------+
* | true | false(default) | Skipped | Skipped |
* +------------+-----------------+ +--------------+
* | true | true | | Not skipped |
* +------------+-----------------+------------+--------------+
* \endverbatim
*
*/
bool preferNotToSkip = false;

/** Check whether all the minimum mandatory fields have been filled by the
* user. */
bool isValid() const;

/** get in human-readable format */
std::string getAsText() const;

/** The default value of fields (used to detect non-set values) */
static constexpr int INVALID_NUM{-100000};
};

/** used in getAsOpenglVisualization() */
struct WaypointsRenderingParams
{
WaypointsRenderingParams();

double outter_radius{.3}, inner_radius{.2};
double outter_radius_non_skippable{.3}, inner_radius_non_skippable{.0};
double outter_radius_reached{.2}, inner_radius_reached{.1};
double heading_arrow_len{1.0};
mrpt::img::TColor color_regular, color_current_goal, color_reached;
bool show_labels{true};
};

/** The struct for requesting navigation requests for a sequence of waypoints.
* Used in CWaypointsNavigator::navigateWaypoints().
* Users can directly fill in the list of waypoints manipulating the public
* field `waypoints`.
*/
struct WaypointSequence
{
std::vector<Waypoint> waypoints;

/** Ctor with default values */
WaypointSequence();

void clear() { waypoints.clear(); }

/** Gets navigation params as a human-readable format */
std::string getAsText() const;

/** Renders the sequence of waypoints (previous contents of `obj` are
* cleared) */
void getAsOpenglVisualization(
mrpt::opengl::CSetOfObjects& obj,
const WaypointsRenderingParams& params = {}) const;

/** Saves waypoints to a config file section */
void save(mrpt::config::CConfigFileBase& c, const std::string& s) const;

/** Loads waypoints to a config file section */
void load(const mrpt::config::CConfigFileBase& c, const std::string& s);
};

/** A waypoint with an execution status. \ingroup nav_reactive */
struct WaypointStatus : public Waypoint
{
WaypointStatus() = default;

/** Whether this waypoint has been reached already (to within the allowed
* distance as per user specifications) or skipped. */
bool reached{false};

/** If `reached==true` this boolean tells whether the waypoint was
* physically reached (false) or marked as reached because it was skipped
* (true). */
bool skipped{false};

/** Timestamp of when this waypoint was reached. (Default=INVALID_TIMESTAMP
* means not reached so far) */
mrpt::system::TTimeStamp timestamp_reach = INVALID_TIMESTAMP;

/** (Initialized to 0 automatically) How many times this waypoint has been
* seen as "reachable" before it being the current active waypoint. */
int counter_seen_reachable{0};

/** Any user-stored custom status data */
std::any user_status_data;

/** Only copies the base class Waypoint data fields */
WaypointStatus& operator=(const Waypoint& wp);

/** Gets navigation params as a human-readable format */
std::string getAsText() const;
};

/** The struct for querying the status of waypoints navigation. Used in
* CWaypointsNavigator::getWaypointNavStatus().
* \ingroup nav_reactive */
struct WaypointStatusSequence
{
WaypointStatusSequence() = default;

/** Waypoints parameters and status (reached, skipped, etc.) */
std::vector<WaypointStatus> waypoints;

/** Timestamp of user navigation command. */
mrpt::system::TTimeStamp timestamp_nav_started = INVALID_TIMESTAMP;

/** Whether the final waypoint has been reached successfuly. */
bool final_goal_reached{false};

/** Index in `waypoints` of the waypoint the navigator is currently trying
* to reach.
* This will point to the last waypoint after navigation ends successfully.
* Its value is `-1` if navigation has not started yet */
int waypoint_index_current_goal{-1};

/** Robot pose at last time step (has INVALID_NUM fields upon
* initialization) */
mrpt::math::TPose2D last_robot_pose{
Waypoint::INVALID_NUM, Waypoint::INVALID_NUM, Waypoint::INVALID_NUM};

/** Ctor with default values */
/** Gets navigation params as a human-readable format */
std::string getAsText() const;

/** Renders the sequence of waypoints (previous contents of `obj` are
* cleared) */
void getAsOpenglVisualization(
mrpt::opengl::CSetOfObjects& obj,
const WaypointsRenderingParams& params = {}) const;
};
} // namespace selfdriving
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See LICENSE for license information.
* ------------------------------------------------------------------------- */

#include <selfdriving/CostEvaluator.h>
#include <selfdriving/algos/CostEvaluator.h>

using namespace selfdriving;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* See LICENSE for license information.
* ------------------------------------------------------------------------- */

#include <selfdriving/CostEvaluatorCostMap.h>
#include <selfdriving/algos/CostEvaluatorCostMap.h>

using namespace selfdriving;

Expand Down

0 comments on commit c705a2b

Please sign in to comment.