selfdriving
TargetApproachController.h
Go to the documentation of this file.
1 /* -------------------------------------------------------------------------
2  * SelfDriving C++ library based on PTGs and mrpt-nav
3  * Copyright (C) 2019-2022 Jose Luis Blanco, University of Almeria
4  * See LICENSE for license information.
5  * ------------------------------------------------------------------------- */
6 
7 #pragma once
8 
12 #include <mpp/data/Waypoints.h>
13 #include <mpp/data/const_ref_t.h>
16 #include <mrpt/kinematics/CVehicleVelCmd.h>
17 #include <mrpt/rtti/CObject.h>
18 #include <mrpt/system/COutputLogger.h>
19 
20 namespace mpp
21 {
22 using mrpt::kinematics::CVehicleVelCmd;
23 
25 {
28  mrpt::kinematics::CVehicleVelCmd::TVelCmdParams speedLimits;
30  std::optional<Waypoint> previous;
33  VehicleMotionInterface::Ptr vehicleMotionInterface;
34 };
35 
37 {
38  TargetApproachOutput() = default;
39 
40  /** Should be set to true if the controller actually did its job, false to
41  * let the parent NavEngine in control of the robot motion (and then ignore
42  * the rest of fields in this struct). */
43  bool handled = false;
44 
45  bool reachedDetected = false;
46 
47  /** If `handled==true`, this should be a motion primitive to execute on the
48  * robot, or an empty pointer if we are still waiting for the completion of
49  * a former motion command.
50  */
51  CVehicleVelCmd::Ptr generatedMotion;
52 };
53 
54 /** Virtual interface for custom policies to take a robot towards a nearby
55  * goal point with a final speed of zero (stopped). This is done without path
56  * planning to avoid obstacles, just moving straight to the goal.
57  *
58  * Called by NavEngine, if provided by the user in the configuration file.
59  */
60 class TargetApproachController : public mrpt::system::COutputLogger,
61  public mrpt::rtti::CObject
62 {
63  DEFINE_VIRTUAL_MRPT_OBJECT(TargetApproachController)
64 
65  public:
67  : mrpt::system::COutputLogger("TargetApproachController")
68  {
69  }
70  virtual ~TargetApproachController();
71 
72  virtual TargetApproachOutput execute(const TargetApproachInput& in) = 0;
73 
74  /** Will be called in navigation steps where this interface is not required.
75  * Use it to reset any flag about pending or past maneuvering.
76  */
77  virtual void reset_state() = 0;
78 };
79 
80 } // namespace mpp
Definition: TargetApproachController.h:24
Definition: TargetApproachController.h:60
CVehicleVelCmd::Ptr generatedMotion
Definition: TargetApproachController.h:51
VehicleMotionInterface::Ptr vehicleMotionInterface
Definition: TargetApproachController.h:33
ObstacleSource::Ptr localSensedObstacleSource
Definition: TargetApproachController.h:32
Definition: bestTrajectory.h:15
const_ref_t< VehicleOdometryState > vos
Definition: TargetApproachController.h:27
TargetApproachController()
Definition: TargetApproachController.h:66
Definition: TargetApproachController.h:36
const_ref_t< VehicleLocalizationState > vls
Definition: TargetApproachController.h:26
std::shared_ptr< ObstacleSource > Ptr
Definition: ObstacleSource.h:20
mrpt::kinematics::CVehicleVelCmd::TVelCmdParams speedLimits
Definition: TargetApproachController.h:28
Definition: Waypoints.h:28
std::optional< Waypoint > previous
Definition: TargetApproachController.h:30
std::optional< std::reference_wrapper< const T > > const_ref_t
Definition: const_ref_t.h:16
const_ref_t< TrajectoriesAndRobotShape > ptgsAndShape
Definition: TargetApproachController.h:31
Waypoint target
Definition: TargetApproachController.h:29