|
selfdriving
|
#include <mpp/algos/NavEngine.h>
Classes | |
| struct | AboutToReachWpInfo |
| struct | AlignStatus |
| struct | Configuration |
| struct | CurrentNavInternalState |
| struct | PathPlannerInput |
| struct | PathPlannerOutput |
Public Member Functions | |
| NavEngine () | |
| virtual | ~NavEngine () |
| void | send_planner_output_to_viz (const PathPlannerOutput &ppo) |
| void | send_path_to_viz_and_navlog (const MotionPrimitivesTreeSE2 &tree, const std::optional< TNodeID > &finalNode, const PlannerInput &originalPlanInput, const std::vector< CostEvaluator::Ptr > &costEvaluators) |
| void | send_current_state_to_viz_and_navlog () |
Protected Attributes | |
| NavStatus | navigationStatus_ = NavStatus::IDLE |
| NavStatus | lastNavigationState_ = NavStatus::IDLE |
| NavErrorReason | navErrorReason_ |
| mrpt::system::output_logger_callback_t | loggerToNavlog_ |
| bool | initialized_ = false |
| std::recursive_mutex | navMtx_ |
| VehicleLocalizationState | lastVehicleLocalization_ |
| VehicleOdometryState | lastVehicleOdometry_ |
| double | lastVehiclePosRobotTime_ = 0 |
| std::list< std::function< void(void)> > | pendingEvents_ |
| std::optional< mrpt::io::CFileGZOutputStream > | navlog_output_file_ |
| Created in internal_start_navlog_file() More... | |
| bool | navlogOutputFirstEntry_ = true |
| mrpt::WorkerThreadsPool | pathPlannerPool_ |
| CurrentNavInternalState | innerState_ |
| mrpt::kinematics::CVehicleVelCmd::TVelCmdParams | absoluteSpeedLimits_ |
Initialization and parameters | |
| Configuration | config_ |
| virtual void | initialize () |
| const mrpt::kinematics::CVehicleVelCmd::TVelCmdParams & | absoluteSpeedLimits () const |
| void | absoluteSpeedLimits (const mrpt::kinematics::CVehicleVelCmd::TVelCmdParams &newLimits) |
Waypoint navigation control API | |
| mrpt::system::CTimeLogger | navProfiler_ {true , "NavEngine"} |
| virtual void | request_navigation (const WaypointSequence &navRequest) |
| virtual void | navigation_step () |
| virtual void | cancel () |
| virtual void | resume () |
| virtual void | suspend () |
| virtual void | reset_nav_error () |
| NavStatus | current_status () const |
| const NavErrorReason & | error_reason () const |
| WaypointStatusSequence | waypoint_nav_status () const |
| WaypointStatusSequence & | beginWaypointsAccess () |
| void | end_waypoints_access () |
The top-level interface for users to control the vehicle navigation.
This class is based and extends mrpt::nav::CAbstractNavigator with the capability of following a list of waypoints. By default, waypoints are followed one by one, but, refer to Waypoint for a discussion on allow_skip.
How to use:
initialize() must be called before running any actual navigation.config_. Note they may be actual functions, or lambdas.navigation_step() must be called periodically in order to effectively run the navigation. This method will internally call the callbacks to gather sensor data and robot positioning data.This class implements the following state machine (see current_status()):
All methods are thread-safe, in the sense that mutexes are internally used to ensure no undefined navigation state is possible if invoking an object of this class from more than one thread.
|
inline |
ctor
|
virtual |
dtor
|
inline |
Read access to current absolute speed limits
| void mpp::NavEngine::absoluteSpeedLimits | ( | const mrpt::kinematics::CVehicleVelCmd::TVelCmdParams & | newLimits | ) |
Changes the current speed limits
|
protected |
Special behavior: if we are about to reach a WP with a stop condition, handle it specially if there's an obvious free path towards it.
|
inline |
Gets a write-enabled reference to the list of waypoints, simultaneously acquiring the critical section mutex. Caller must call endWaypointsAccess() when done editing the waypoints.
|
virtual |
Cancel current navegation.
|
protected |
Returns true if all waypoints has been reached successfully.
|
protected |
Checks whether we need to launch a new RRT* path planner
|
protected |
Checks whether the current motion leads us into an obstacle
|
protected |
Checks whether the A* planner finished, then send a new active trajectory to the path tracker
|
inline |
Returns the current navigator status.
|
protected |
|
inline |
Must be called after beginWaypointsAccess()
|
protected |
Enqueues a task in pathPlannerPool_ running path_planner_function() and saving future results into pathPlannerFuture.
If this is a path refining, startingFrom and startingFromNodeID must be supplied, with the latter being the nodeId of the the plan starting state in activePlanOutput, activePlanPath, activePlanPathEdges.
|
inline |
In case of status=NAV_ERROR, this returns the reason for the error. Error status is reseted every time a new navigation starts with a call to navigate(), or when reset_nav_error() is called.
|
protected |
Finds the next waypt index up to which we should find a new RRT* plan
|
protectedvirtual |
The actual action that happens inside navigation_step() for the case of state being NAVIGATING.
|
virtual |
Must be called before any other navigation command, and after filling in all the required data into config_
|
protected |
Checks whether the robot is within maxDistanceForTargetApproach meters of the next non-skippable waypoint. This does not check for potential obstacles, just the physical nearness.
|
protected |
|
protected |
Implements the way to waypoint is free function in children classes: true must be returned if, according to the information gathered at the last navigation step, there is a free path to the given point; false otherwise: if way is blocked or there is missing information, the point is out of range, etc.
|
protected |
|
protected |
|
protected |
|
virtual |
This method must be called periodically in order to effectively run the navigation
|
protected |
|
virtual |
Waypoint navigation request. This immediately cancels any other previous on-going navigation.
|
virtual |
Resets a NAV_ERROR state back to IDLE
|
virtual |
Continues with suspended navigation.
| void mpp::NavEngine::send_current_state_to_viz_and_navlog | ( | ) |
Update current path plan visualization details in the GUI, or in the opengl object buffered to be writen to navlog files.
|
protected |
Checks and send next motion command, or NOP, if we are on track
| void mpp::NavEngine::send_path_to_viz_and_navlog | ( | const MotionPrimitivesTreeSE2 & | tree, |
| const std::optional< TNodeID > & | finalNode, | ||
| const PlannerInput & | originalPlanInput, | ||
| const std::vector< CostEvaluator::Ptr > & | costEvaluators | ||
| ) |
Update the GUI with a partial or final path only (no whole tree)
| void mpp::NavEngine::send_planner_output_to_viz | ( | const PathPlannerOutput & | ppo | ) |
Use the callbacks above and render_tree() to update a visualization with a given plan output
|
virtual |
Suspend current navegation.
|
protectedvirtual |
Call to the robot getCurrentPoseAndSpeeds() and updates members m_curPoseVel accordingly. If an error is returned by the user callback, first, it calls robot.stop() ,then throws an std::runtime_error exception.
| WaypointStatusSequence mpp::NavEngine::waypoint_nav_status | ( | ) | const |
Get a copy of the control structure which describes the progress status of the waypoint navigation.
|
protected |
Speed limits: If not defined, the values from the first PTG will be copied here upon initialize()
| Configuration mpp::NavEngine::config_ |
|
protected |
|
protected |
Navigation state variables, protected by navMtx_
|
protected |
|
protected |
Current robot kinematic state; Updated in navigation_step() with a minimum period of MIN_TIME_BETWEEN_POSE_UPDATES.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Current and last internal state of navigator:
|
protected |
Created in internal_start_navlog_file()
|
protected |
|
protected |
mutex for all navigation methods
| mrpt::system::CTimeLogger mpp::NavEngine::navProfiler_ {true , "NavEngine"} |
Publicly available time profiling object. Default: disabled
|
protected |
|
protected |
Events generated during navigation_step(), enqueued to be called at the end of the method execution to avoid user code to change the navigator state.
1.8.13