Main MRPT website > C++ reference for MRPT 1.9.9
List of all members | Classes | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions
mrpt::nav::CNavigatorManualSequence Class Reference

Detailed Description

"Fake navigator" for tests: it just sends out a pre-programmed sequence of commands to the robot.

For a short discussion of the API, see CNavigatorVirtualBase

Definition at line 23 of file CNavigatorManualSequence.h.

#include <mrpt/nav/reactive/CNavigatorManualSequence.h>

Inheritance diagram for mrpt::nav::CNavigatorManualSequence:
Inheritance graph

Classes

struct  TVelCmd
 

Public Member Functions

 CNavigatorManualSequence (CRobot2NavInterface &react_iterf_impl)
 
virtual ~CNavigatorManualSequence ()
 
void navigationStep () override
 Overriden in this class to ignore the cancel/pause/... More...
 
const mrpt::utils::CTimeLoggergetDelaysTimeLogger () const
 Gives access to a const-ref to the internal time logger used to estimate delays. More...
 
Initialization API
virtual void loadConfigFile (const mrpt::utils::CConfigFileBase &c) override
 Loads all params from a file. More...
 
virtual void saveConfigFile (mrpt::utils::CConfigFileBase &c) const override
 Saves all current options to a config file. More...
 
void initialize () override
 Must be called for loading collision grids, etc. More...
 

Public Attributes

std::map< double, TVelCmdprogrammed_orders
 map [time_in_secs_since_beginning] -> orders. More...
 
TAbstractNavigatorParams params_abstract_navigator
 

Protected Member Functions

virtual void onStartNewNavigation () override
 Called whenever a new navigation has been started. More...
 
void dispatchPendingNavEvents ()
 
virtual void onNavigateCommandReceived ()
 Called after each call to CAbstractNavigator::navigate() More...
 
void updateCurrentPoseAndSpeeds ()
 Call to the robot getCurrentPoseAndSpeeds() and updates members m_curPoseVel accordingly. More...
 
virtual void performNavigationStepNavigating (bool call_virtual_nav_method=true)
 Factorization of the part inside navigationStep(), for the case of state being NAVIGATING. More...
 
void processNavigateCommand (const TNavigationParams *params)
 Does the job of navigate(), except the call to onNavigateCommandReceived() More...
 
void doEmergencyStop (const std::string &msg)
 Stops the robot and set navigation state to error. More...
 
virtual bool changeSpeeds (const mrpt::kinematics::CVehicleVelCmd &vel_cmd)
 Default: forward call to m_robot.changeSpeed(). More...
 
virtual bool changeSpeedsNOP ()
 Default: forward call to m_robot.changeSpeedsNOP(). More...
 
virtual bool stop (bool isEmergencyStop)
 Default: forward call to m_robot.stop(). More...
 
virtual bool checkHasReachedTarget (const double targetDist) const
 Default implementation: check if target_dist is below the accepted distance. More...
 
virtual bool checkCollisionWithLatestObstacles (const mrpt::math::TPose2D &relative_robot_pose) const
 Checks whether the robot shape, when placed at the given pose (relative to the current pose), is colliding with any of the latest known obstacles. More...
 

Protected Attributes

std::vector< std::function< void(void)> > m_pending_events
 Events generated during navigationStep(), enqueued to be called at the end of the method execution to avoid user code to change the navigator state. More...
 
TState m_navigationState
 Current internal state of navigator: More...
 
std::unique_ptr< TNavigationParamsm_navigationParams
 Current navigation parameters. More...
 
CRobot2NavInterfacem_robot
 The navigator-robot interface. More...
 
mrpt::poses::FrameTransformer< 2 > * m_frame_tf
 Optional, user-provided frame transformer. More...
 
std::recursive_mutex m_nav_cs
 mutex for all navigation methods More...
 
TRobotPoseVel m_curPoseVel
 Current robot pose (updated in CAbstractNavigator::navigationStep() ) More...
 
double m_last_curPoseVelUpdate_robot_time
 
std::string m_last_curPoseVelUpdate_pose_frame_id
 
mrpt::poses::CPose2DInterpolator m_latestPoses
 Latest robot poses (updated in CAbstractNavigator::navigationStep() ) More...
 
mrpt::poses::CPose2DInterpolator m_latestOdomPoses
 
mrpt::utils::CTimeLogger m_timlog_delays
 Time logger to collect delay-related stats. More...
 
double m_badNavAlarm_minDistTarget
 For sending an alarm (error event) when it seems that we are not approaching toward the target in a while... More...
 
mrpt::system::TTimeStamp m_badNavAlarm_lastMinDistTime
 

Private Member Functions

virtual void navigate (const TNavigationParams *params) override
 Navigation request to a single target location. More...
 
virtual void performNavigationStep () override
 To be implemented in derived classes. More...
 

Navigation control API

virtual void cancel ()
 Cancel current navegation. More...
 
virtual void resume ()
 Continues with suspended navigation. More...
 
virtual void suspend ()
 Suspend current navegation. More...
 
virtual void resetNavError ()
 Resets a NAV_ERROR state back to IDLE More...
 
TState getCurrentState () const
 Returns the current navigator state. More...
 
void setFrameTF (mrpt::poses::FrameTransformer< 2 > *frame_tf)
 Sets a user-provided frame transformer object; used only if providing targets in a frame ID different than the one in which robot odometry is given (both IDs default to "map"). More...
 
const mrpt::poses::FrameTransformer< 2 > * getFrameTF () const
 Get the current frame tf object (defaults to nullptr) More...
 
enum  TState { IDLE = 0, NAVIGATING, SUSPENDED, NAV_ERROR }
 The different states for the navigation system. More...
 

Member Enumeration Documentation

◆ TState

The different states for the navigation system.

Enumerator
IDLE 
NAVIGATING 
SUSPENDED 
NAV_ERROR 

Definition at line 172 of file CAbstractNavigator.h.

Constructor & Destructor Documentation

◆ CNavigatorManualSequence()

CNavigatorManualSequence::CNavigatorManualSequence ( CRobot2NavInterface react_iterf_impl)

Definition at line 20 of file CNavigatorManualSequence.cpp.

◆ ~CNavigatorManualSequence()

CNavigatorManualSequence::~CNavigatorManualSequence ( )
virtual

Definition at line 27 of file CNavigatorManualSequence.cpp.

Member Function Documentation

◆ cancel()

void CAbstractNavigator::cancel ( )
virtualinherited

Cancel current navegation.

Reimplemented in mrpt::nav::CWaypointsNavigator.

Definition at line 114 of file CAbstractNavigator.cpp.

References mrpt::nav::CAbstractNavigator::IDLE, mrpt::nav::CAbstractNavigator::m_nav_cs, mrpt::nav::CAbstractNavigator::m_navigationState, MRPT_LOG_DEBUG, and mrpt::nav::CAbstractNavigator::stop().

Referenced by mrpt::nav::CWaypointsNavigator::cancel().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ changeSpeeds()

bool CAbstractNavigator::changeSpeeds ( const mrpt::kinematics::CVehicleVelCmd vel_cmd)
protectedvirtualinherited

Default: forward call to m_robot.changeSpeed().

Can be overriden.

Definition at line 414 of file CAbstractNavigator.cpp.

References mrpt::nav::CRobot2NavInterface::changeSpeeds(), and mrpt::nav::CAbstractNavigator::m_robot.

Referenced by navigationStep(), mrpt::nav::CAbstractPTGBasedReactive::performNavigationStep(), and mrpt::nav::CWaypointsNavigator::waypoints_navigationStep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ changeSpeedsNOP()

bool CAbstractNavigator::changeSpeedsNOP ( )
protectedvirtualinherited

Default: forward call to m_robot.changeSpeedsNOP().

Can be overriden.

Definition at line 420 of file CAbstractNavigator.cpp.

References mrpt::nav::CRobot2NavInterface::changeSpeedsNOP(), and mrpt::nav::CAbstractNavigator::m_robot.

Referenced by mrpt::nav::CAbstractPTGBasedReactive::performNavigationStep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkCollisionWithLatestObstacles()

bool CAbstractNavigator::checkCollisionWithLatestObstacles ( const mrpt::math::TPose2D relative_robot_pose) const
protectedvirtualinherited

Checks whether the robot shape, when placed at the given pose (relative to the current pose), is colliding with any of the latest known obstacles.

Default implementation: always returns false.

Reimplemented in mrpt::nav::CReactiveNavigationSystem3D, and mrpt::nav::CReactiveNavigationSystem.

Definition at line 671 of file CAbstractNavigator.cpp.

Referenced by mrpt::nav::CAbstractNavigator::performNavigationStepNavigating().

Here is the caller graph for this function:

◆ checkHasReachedTarget()

bool CAbstractNavigator::checkHasReachedTarget ( const double  targetDist) const
protectedvirtualinherited

Default implementation: check if target_dist is below the accepted distance.

If true is returned here, the end-of-navigation event will be sent out (only for non-intermediary targets).

Reimplemented in mrpt::nav::CWaypointsNavigator.

Definition at line 481 of file CAbstractNavigator.cpp.

Referenced by mrpt::nav::CAbstractNavigator::performNavigationStepNavigating().

Here is the caller graph for this function:

◆ dispatchPendingNavEvents()

void CAbstractNavigator::dispatchPendingNavEvents ( )
protectedinherited

◆ doEmergencyStop()

void CAbstractNavigator::doEmergencyStop ( const std::string msg)
protectedinherited

Stops the robot and set navigation state to error.

Definition at line 262 of file CAbstractNavigator.cpp.

References mrpt::nav::CAbstractNavigator::m_navigationState, MRPT_LOG_ERROR, mrpt::nav::CAbstractNavigator::NAV_ERROR, and mrpt::nav::CAbstractNavigator::stop().

Referenced by mrpt::nav::CAbstractPTGBasedReactive::performNavigationStep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCurrentState()

TState mrpt::nav::CAbstractNavigator::getCurrentState ( ) const
inlineinherited

Returns the current navigator state.

Definition at line 181 of file CAbstractNavigator.h.

References mrpt::nav::CAbstractNavigator::m_navigationState.

◆ getDelaysTimeLogger()

const mrpt::utils::CTimeLogger& mrpt::nav::CAbstractNavigator::getDelaysTimeLogger ( ) const
inlineinherited

Gives access to a const-ref to the internal time logger used to estimate delays.

See also
getTimeLogger() in derived classes

Definition at line 229 of file CAbstractNavigator.h.

References mrpt::nav::CAbstractNavigator::m_timlog_delays.

◆ getFrameTF()

const mrpt::poses::FrameTransformer<2>* mrpt::nav::CAbstractNavigator::getFrameTF ( ) const
inlineinherited

Get the current frame tf object (defaults to nullptr)

See also
setFrameTF

Definition at line 195 of file CAbstractNavigator.h.

References mrpt::nav::CAbstractNavigator::m_frame_tf.

◆ initialize()

void CNavigatorManualSequence::initialize ( void  )
overridevirtual

Must be called for loading collision grids, etc.

before invoking any navigation command

Implements mrpt::nav::CAbstractNavigator.

Definition at line 80 of file CNavigatorManualSequence.cpp.

References ASSERT_, mrpt::nav::CAbstractNavigator::m_robot, programmed_orders, and mrpt::nav::CRobot2NavInterface::resetNavigationTimer().

Here is the call graph for this function:

◆ loadConfigFile()

void CNavigatorManualSequence::loadConfigFile ( const mrpt::utils::CConfigFileBase c)
overridevirtual

Loads all params from a file.

To be called before initialize(). Each derived class MUST load its own parameters, and then call ITS PARENT'S overriden method to ensure all params are loaded.

Reimplemented from mrpt::nav::CAbstractNavigator.

Definition at line 33 of file CNavigatorManualSequence.cpp.

References ASSERTMSG_, mrpt::nav::CNavigatorManualSequence::TVelCmd::cmd_vel, mrpt::make_aligned_shared(), programmed_orders, THROW_EXCEPTION, and mrpt::system::tokenize().

Here is the call graph for this function:

◆ navigate()

virtual void mrpt::nav::CNavigatorManualSequence::navigate ( const TNavigationParams params)
inlineoverrideprivatevirtual

Navigation request to a single target location.

It starts a new navigation.

Parameters
[in]paramsPointer to structure with navigation info (its contents will be copied, so the original can be freely destroyed upon return if it was dynamically allocated.)
Note
A pointer is used so the passed object can be polymorphic with derived types.

Reimplemented from mrpt::nav::CAbstractNavigator.

Definition at line 57 of file CNavigatorManualSequence.h.

◆ navigationStep()

void CNavigatorManualSequence::navigationStep ( )
overridevirtual

◆ onNavigateCommandReceived()

void CAbstractNavigator::onNavigateCommandReceived ( )
protectedvirtualinherited

◆ onStartNewNavigation()

virtual void mrpt::nav::CNavigatorManualSequence::onStartNewNavigation ( )
inlineoverrideprotectedvirtual

Called whenever a new navigation has been started.

Can be used to reset state variables, etc.

Implements mrpt::nav::CAbstractNavigator.

Definition at line 54 of file CNavigatorManualSequence.h.

◆ performNavigationStep()

virtual void mrpt::nav::CNavigatorManualSequence::performNavigationStep ( )
inlineoverrideprivatevirtual

To be implemented in derived classes.

Implements mrpt::nav::CAbstractNavigator.

Definition at line 58 of file CNavigatorManualSequence.h.

◆ performNavigationStepNavigating()

void CAbstractNavigator::performNavigationStepNavigating ( bool  call_virtual_nav_method = true)
protectedvirtualinherited

Factorization of the part inside navigationStep(), for the case of state being NAVIGATING.

Performs house-hold tasks like raising events in case of starting/ending navigation, timeout reaching destination, etc. call_virtual_nav_method can be set to false to avoid calling the virtual method performNavigationStep()

Definition at line 496 of file CAbstractNavigator.cpp.

References ASSERT_, mrpt::nav::CAbstractNavigator::checkCollisionWithLatestObstacles(), mrpt::nav::CAbstractNavigator::checkHasReachedTarget(), mrpt::nav::CAbstractNavigator::TAbstractNavigatorParams::dist_check_target_is_blocked, mrpt::nav::CAbstractNavigator::TAbstractNavigatorParams::dist_to_target_for_sending_event, mrpt::math::TSegment2D::distance(), mrpt::poses::CPoseInterpolatorBase< DIM >::empty(), mrpt::mrpt::format(), mrpt::system::getCurrentTime(), mrpt::nav::CAbstractNavigator::TAbstractNavigatorParams::hysteresis_check_target_is_blocked, mrpt::nav::CAbstractNavigator::IDLE, mrpt::nav::CAbstractNavigator::internal_onStartNewNavigation(), mrpt::nav::CAbstractNavigator::m_badNavAlarm_lastMinDistTime, mrpt::nav::CAbstractNavigator::m_badNavAlarm_minDistTarget, mrpt::nav::CAbstractNavigator::m_counter_check_target_is_blocked, mrpt::nav::CAbstractNavigator::m_curPoseVel, mrpt::nav::CAbstractNavigator::m_lastNavigationState, mrpt::nav::CAbstractNavigator::m_latestPoses, mrpt::nav::CAbstractNavigator::m_navigationEndEventSent, mrpt::nav::CAbstractNavigator::m_navigationParams, mrpt::nav::CAbstractNavigator::m_navigationState, mrpt::nav::CAbstractNavigator::m_pending_events, mrpt::nav::CAbstractNavigator::m_robot, MRPT_LOG_DEBUG, MRPT_LOG_ERROR, MRPT_LOG_ERROR_FMT, MRPT_LOG_INFO, MRPT_LOG_THROTTLE_WARN, MRPT_LOG_WARN, mrpt::nav::CAbstractNavigator::NAV_ERROR, mrpt::nav::CAbstractNavigator::NAVIGATING, mrpt::nav::CAbstractNavigator::params_abstract_navigator, mrpt::nav::CAbstractNavigator::performNavigationStep(), mrpt::nav::CAbstractNavigator::TRobotPoseVel::pose, mrpt::poses::CPoseInterpolatorBase< DIM >::rbegin(), mrpt::nav::CRobot2NavInterface::sendNavigationEndEvent(), mrpt::nav::CRobot2NavInterface::sendNavigationStartEvent(), mrpt::nav::CRobot2NavInterface::sendWaySeemsBlockedEvent(), mrpt::poses::CPoseInterpolatorBase< DIM >::size(), mrpt::nav::CAbstractNavigator::stop(), mrpt::system::timeDifference(), and mrpt::nav::CAbstractNavigator::updateCurrentPoseAndSpeeds().

Referenced by mrpt::nav::CAbstractNavigator::navigationStep(), and mrpt::nav::CWaypointsNavigator::waypoints_navigationStep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processNavigateCommand()

void CAbstractNavigator::processNavigateCommand ( const TNavigationParams params)
protectedinherited

◆ resetNavError()

void CAbstractNavigator::resetNavError ( )
virtualinherited

◆ resume()

void CAbstractNavigator::resume ( )
virtualinherited

◆ saveConfigFile()

void CNavigatorManualSequence::saveConfigFile ( mrpt::utils::CConfigFileBase c) const
overridevirtual

Saves all current options to a config file.

Each derived class MUST save its own parameters, and then call ITS PARENT'S overriden method to ensure all params are saved.

Reimplemented from mrpt::nav::CAbstractNavigator.

Definition at line 28 of file CNavigatorManualSequence.cpp.

◆ setFrameTF()

void CAbstractNavigator::setFrameTF ( mrpt::poses::FrameTransformer< 2 > *  frame_tf)
inherited

Sets a user-provided frame transformer object; used only if providing targets in a frame ID different than the one in which robot odometry is given (both IDs default to "map").

Ownership of the pointee object remains belonging to the user, which is responsible of deleting it and ensuring its a valid pointer during the lifetime of this navigator object.

Todo:
[MRPT 2.0: Make this a weak_ptr]

Definition at line 154 of file CAbstractNavigator.cpp.

References mrpt::nav::CAbstractNavigator::m_frame_tf.

◆ stop()

bool CAbstractNavigator::stop ( bool  isEmergencyStop)
protectedvirtualinherited

◆ suspend()

void CAbstractNavigator::suspend ( )
virtualinherited

◆ updateCurrentPoseAndSpeeds()

void CAbstractNavigator::updateCurrentPoseAndSpeeds ( )
protectedinherited

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.

Definition at line 325 of file CAbstractNavigator.cpp.

References mrpt::poses::CPoseInterpolatorBase< DIM >::begin(), mrpt::poses::CPoseInterpolatorBase< DIM >::clear(), mrpt::poses::CPoseInterpolatorBase< DIM >::erase(), mrpt::nav::CRobot2NavInterface::getCurrentPoseAndSpeeds(), mrpt::nav::CRobot2NavInterface::getNavigationTime(), mrpt::poses::CPoseInterpolatorBase< DIM >::insert(), mrpt::nav::CAbstractNavigator::m_curPoseVel, mrpt::nav::CAbstractNavigator::m_last_curPoseVelUpdate_pose_frame_id, mrpt::nav::CAbstractNavigator::m_last_curPoseVelUpdate_robot_time, mrpt::nav::CAbstractNavigator::m_latestOdomPoses, mrpt::nav::CAbstractNavigator::m_latestPoses, mrpt::nav::CAbstractNavigator::m_navigationState, mrpt::nav::CAbstractNavigator::m_robot, mrpt::nav::CAbstractNavigator::m_timlog_delays, MRPT_LOG_ERROR, MRPT_LOG_THROTTLE_DEBUG_FMT, mrpt::nav::CAbstractNavigator::NAV_ERROR, mrpt::math::TPose2D::phi, mrpt::nav::CAbstractNavigator::TRobotPoseVel::pose, mrpt::nav::CAbstractNavigator::TRobotPoseVel::pose_frame_id, PREVIOUS_POSES_MAX_AGE, mrpt::nav::CAbstractNavigator::TRobotPoseVel::rawOdometry, mrpt::poses::CPoseInterpolatorBase< DIM >::rbegin(), mrpt::math::TTwist2D::rotate(), mrpt::poses::CPoseInterpolatorBase< DIM >::size(), mrpt::nav::CAbstractNavigator::stop(), mrpt::system::timeDifference(), mrpt::nav::CAbstractNavigator::TRobotPoseVel::timestamp, mrpt::nav::CAbstractNavigator::TRobotPoseVel::velGlobal, and mrpt::nav::CAbstractNavigator::TRobotPoseVel::velLocal.

Referenced by mrpt::nav::CAbstractNavigator::performNavigationStepNavigating(), mrpt::nav::CAbstractNavigator::processNavigateCommand(), and mrpt::nav::CWaypointsNavigator::waypoints_navigationStep().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_badNavAlarm_lastMinDistTime

mrpt::system::TTimeStamp mrpt::nav::CAbstractNavigator::m_badNavAlarm_lastMinDistTime
protectedinherited

◆ m_badNavAlarm_minDistTarget

double mrpt::nav::CAbstractNavigator::m_badNavAlarm_minDistTarget
protectedinherited

For sending an alarm (error event) when it seems that we are not approaching toward the target in a while...

Definition at line 348 of file CAbstractNavigator.h.

Referenced by mrpt::nav::CAbstractNavigator::performNavigationStepNavigating(), and mrpt::nav::CAbstractNavigator::processNavigateCommand().

◆ m_curPoseVel

TRobotPoseVel mrpt::nav::CAbstractNavigator::m_curPoseVel
protectedinherited

◆ m_frame_tf

mrpt::poses::FrameTransformer<2>* mrpt::nav::CAbstractNavigator::m_frame_tf
protectedinherited

Optional, user-provided frame transformer.

Note: We dont have ownership of the pointee object!

Definition at line 318 of file CAbstractNavigator.h.

Referenced by mrpt::nav::CAbstractNavigator::getFrameTF(), mrpt::nav::CAbstractPTGBasedReactive::performNavigationStep(), and mrpt::nav::CAbstractNavigator::setFrameTF().

◆ m_last_curPoseVelUpdate_pose_frame_id

std::string mrpt::nav::CAbstractNavigator::m_last_curPoseVelUpdate_pose_frame_id
protectedinherited

◆ m_last_curPoseVelUpdate_robot_time

double mrpt::nav::CAbstractNavigator::m_last_curPoseVelUpdate_robot_time
protectedinherited

◆ m_latestOdomPoses

mrpt::poses::CPose2DInterpolator mrpt::nav::CAbstractNavigator::m_latestOdomPoses
protectedinherited

◆ m_latestPoses

mrpt::poses::CPose2DInterpolator mrpt::nav::CAbstractNavigator::m_latestPoses
protectedinherited

◆ m_nav_cs

std::recursive_mutex mrpt::nav::CAbstractNavigator::m_nav_cs
protectedinherited

◆ m_navigationParams

std::unique_ptr<TNavigationParams> mrpt::nav::CAbstractNavigator::m_navigationParams
protectedinherited

◆ m_navigationState

TState mrpt::nav::CAbstractNavigator::m_navigationState
protectedinherited

◆ m_pending_events

std::vector<std::function<void(void)> > mrpt::nav::CAbstractNavigator::m_pending_events
protectedinherited

◆ m_robot

CRobot2NavInterface& mrpt::nav::CAbstractNavigator::m_robot
protectedinherited

◆ m_timlog_delays

mrpt::utils::CTimeLogger mrpt::nav::CAbstractNavigator::m_timlog_delays
protectedinherited

◆ params_abstract_navigator

TAbstractNavigatorParams mrpt::nav::CAbstractNavigator::params_abstract_navigator
inherited

◆ programmed_orders

std::map<double, TVelCmd> mrpt::nav::CNavigatorManualSequence::programmed_orders

map [time_in_secs_since_beginning] -> orders.

Definition at line 51 of file CNavigatorManualSequence.h.

Referenced by initialize(), loadConfigFile(), and navigationStep().




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019