selfdriving
Public Member Functions | Private Member Functions | Private Attributes | List of all members
mpp::MVSIM_VehicleInterface Class Reference

#include <mpp/interfaces/MVSIM_VehicleInterface.h>

Inheritance diagram for mpp::MVSIM_VehicleInterface:
mpp::VehicleMotionInterface mpp::LidarSource

Public Member Functions

 MVSIM_VehicleInterface ()
 
void connect ()
 
VehicleLocalizationState get_localization () override
 
VehicleOdometryState get_odometry () override
 
bool motion_execute (const std::optional< CVehicleVelCmd::Ptr > &immediate, const std::optional< EnqueuedMotionCmd > &next) override
 
void stop ([[maybe_unused]] const STOP_TYPE stopType) override
 
mrpt::obs::CObservation2DRangeScan::Ptr last_lidar_obs () const override
 Returns a copy of the last lidar observation. More...
 
- Public Member Functions inherited from mpp::VehicleMotionInterface
 VehicleMotionInterface ()
 
virtual ~VehicleMotionInterface ()
 
virtual bool supports_enqeued_motions () const
 
virtual bool enqeued_motion_pending () const
 
virtual bool enqeued_motion_timed_out () const
 
virtual std::optional< VehicleOdometryStateenqued_motion_last_odom_when_triggered () const
 
virtual void stop (const STOP_TYPE stopType)=0
 
virtual void stop_watchdog ()
 
virtual void start_watchdog ([[maybe_unused]] const size_t periodMilliseconds)
 
virtual double robot_time () const
 
virtual void on_nav_end_due_to_error ()
 Callback if current navigation ended due to some error. More...
 
virtual void on_nav_start ()
 Callback upon starting a new waypointsequence navigation. More...
 
virtual void on_nav_end ()
 Callback if navigation ended by an accepted trigger or reached the last specified waypoint. More...
 
virtual void on_path_seems_blocked ()
 Callback for when NavEngine cannot make progress to get increasingly closer to the final target during a certain period of time. It may indicate that the high-level path the vehicle is trying to follow is no longer valid due to a blocked way. On your user side, you could call NavEngine::cancel() and/or re-compute an alternative path and issue a new set of navigation waypoints or just report the error to the user. More...
 
virtual void on_apparent_collision ()
 Callback when the NavEngine predicts a collision with an obstacle and needed to issue a stop command. More...
 
virtual void on_waypoint_reached (const size_t waypoint_index, bool reached_skipped)
 Callback upon reaching a waypoint in a waypoint sequeunce. Mostly used for logging. More...
 
virtual void on_cannot_get_closer_to_blocked_target ()
 Callback when NavEngine cannot reach a specified target location because there are obstacles at the specified target. More...
 

Private Member Functions

void onLidar (const mvsim_msgs::GenericObservation &o)
 

Private Attributes

mvsim::Client connection_ {"MVSIM_VehicleInterface"}
 
std::string robotName_ = "r1"
 
std::string lidarName_ = "laser1"
 
std::mutex lastLidarObsMtx_
 
mrpt::obs::CObservation2DRangeScan::Ptr lastLidarObs_
 

Detailed Description

Vehicle adaptor class for the MVSIM simulator.

Motion commands implemented here in motion_execute():

Note
This file must be implemented in the .h to avoid a direct dependency of this library on mvsim headers. Only if the user project uses this, it must then depend on mvsim.

Constructor & Destructor Documentation

◆ MVSIM_VehicleInterface()

mpp::MVSIM_VehicleInterface::MVSIM_VehicleInterface ( )
inline

Member Function Documentation

◆ connect()

void mpp::MVSIM_VehicleInterface::connect ( )
inline

Connect to the MVSIM server.

◆ get_localization()

VehicleLocalizationState mpp::MVSIM_VehicleInterface::get_localization ( )
inlineoverridevirtual

Provides access to the vehicle localization data.

The implementation should not take too much time to return, so if it might take more than ~10ms to ask the robot for the instantaneous data, it may be good enough to return the latest cached values, updated in a parallel thread.

In case of a hardware/communication error, leave valid=false in the return structure.

Implements mpp::VehicleMotionInterface.

◆ get_odometry()

VehicleOdometryState mpp::MVSIM_VehicleInterface::get_odometry ( )
inlineoverridevirtual

Provides access to the vehicle odometry data.

The implementation should not take too much time to return, so if it might take more than ~10ms to ask the robot for the instantaneous data, it may be good enough to return the latest cached values, updated in a parallel thread.

In case of a hardware/communication error, leave valid=false in the return structure.

Implements mpp::VehicleMotionInterface.

◆ last_lidar_obs()

mrpt::obs::CObservation2DRangeScan::Ptr mpp::MVSIM_VehicleInterface::last_lidar_obs ( ) const
inlineoverridevirtual

Returns a copy of the last lidar observation.

Implements mpp::LidarSource.

◆ motion_execute()

bool mpp::MVSIM_VehicleInterface::motion_execute ( const std::optional< CVehicleVelCmd::Ptr > &  immediate,
const std::optional< EnqueuedMotionCmd > &  next 
)
inlineoverridevirtual

Sends a motion command to the vehicle "immediate" and "next" slots.

A vehicle may accept one or more different implementation-specific CVehicleVelCmd classes.

This method resets the watchdog timer started with startWatchdog()

The vehicle should be able to execute a motion primitive ("immediate" slot) and holding a pending one ("next" slot) which will be moved to the immediate slot when a given condition holds, leaving the "next" slot free.

Possible combinations of calls to this method:

1) immediate set, next not set: replaces whatever the vehicle was doing and executes the given immediate command, dropping possible former immediate and next commands.

2) immediate set, next set: replaces both vehicle execution "slots" with the given commands.

3) immediate not set, next set: should be received by a vehicle only while there is an "immediate" motion command under execution, and the "next" slot is free. This stores a new "next" motion command, leaving the currently-executing one untouched. When the "next condition" holds true, the "next" slot will replace the "immediate" slot and "next" will be free again.

4) immediate not set, next not set: This is a "NOP" motion command, which does not change anything but let the vehicle platform know that there is someone in charge checking the path following and the way is obstacles free and safe to keep moving.

Returns
false on any error.
See also
startWatchdog(), supports_enqeued_motions()

Implements mpp::VehicleMotionInterface.

◆ onLidar()

void mpp::MVSIM_VehicleInterface::onLidar ( const mvsim_msgs::GenericObservation &  o)
inlineprivate

◆ stop()

void mpp::MVSIM_VehicleInterface::stop ( [[maybe_unused] ] const STOP_TYPE  stopType)
inlineoverride

Member Data Documentation

◆ connection_

mvsim::Client mpp::MVSIM_VehicleInterface::connection_ {"MVSIM_VehicleInterface"}
private

◆ lastLidarObs_

mrpt::obs::CObservation2DRangeScan::Ptr mpp::MVSIM_VehicleInterface::lastLidarObs_
private

◆ lastLidarObsMtx_

std::mutex mpp::MVSIM_VehicleInterface::lastLidarObsMtx_
private

◆ lidarName_

std::string mpp::MVSIM_VehicleInterface::lidarName_ = "laser1"
private

◆ robotName_

std::string mpp::MVSIM_VehicleInterface::robotName_ = "r1"
private

The documentation for this class was generated from the following file: