Main MRPT website > C++ reference for MRPT 1.9.9
CRobot2NavInterfaceForSimulator.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
14 
15 namespace mrpt
16 {
17 namespace nav
18 {
19 /** CRobot2NavInterface implemented for a simulator object based on
20  * mrpt::kinematics::CVehicleSimul_Holo.
21  * Only `senseObstacles()` remains virtual for the user to implement it.
22  *
23  * \sa CReactiveNavigationSystem, CAbstractNavigator,
24  * mrpt::kinematics::CVehicleSimulVirtualBase
25  * \ingroup nav_reactive
26  */
28 {
29  private:
31  /** for getNavigationTime */
33 
34  public:
37  : m_simul(simul), m_simul_time_start(.0)
38  {
39  }
40 
42  mrpt::math::TPose2D& curPose, mrpt::math::TTwist2D& curVel,
43  mrpt::system::TTimeStamp& timestamp, mrpt::math::TPose2D& curOdometry,
44  std::string& frame_id) override
45  {
46  curPose = m_simul.getCurrentGTPose();
47  curVel = m_simul.getCurrentGTVel();
48  timestamp = mrpt::system::now();
49  curOdometry = m_simul.getCurrentOdometricPose();
50  return true; // ok
51  }
52 
53  virtual bool changeSpeeds(
54  const mrpt::kinematics::CVehicleVelCmd& vel_cmd) override
55  {
56  m_simul.sendVelCmd(vel_cmd);
57  return true; // ok
58  }
59 
60  bool stop(bool isEmergencyStop) override
61  {
63  0.0 /*vel*/, 0 /*dir*/, isEmergencyStop ? 0.1 : 1.0 /* ramp_time */,
64  0.0 /*rot speed */);
65  return true;
66  }
67 
69  {
71  new mrpt::kinematics::CVehicleVelCmd_Holo(0.0, 0.0, 0.1, 0.0));
72  }
73 
75  {
77  new mrpt::kinematics::CVehicleVelCmd_Holo(0.0, 0.0, 1.0, 0.0));
78  }
79 
81  const double relative_heading_radians) override
82  {
85  0.0, // vel
86  relative_heading_radians, // local_dir
87  0.5, // ramp_time
88  mrpt::signWithZero(relative_heading_radians) *
89  mrpt::DEG2RAD(40.0) // rotvel
90  ));
91  }
92 
93  /** See CRobot2NavInterface::getNavigationTime(). In this class, simulation
94  * time is returned instead of wall-clock time. */
95  double getNavigationTime() override
96  {
98  }
99  /** See CRobot2NavInterface::resetNavigationTimer() */
100  void resetNavigationTimer() override
101  {
103  }
104 };
105 
106 /** CRobot2NavInterface implemented for a simulator object based on
107  * mrpt::kinematics::CVehicleSimul_DiffDriven
108  * Only `senseObstacles()` remains virtual for the user to implement it.
109  *
110  * \sa CReactiveNavigationSystem, CAbstractNavigator,
111  * mrpt::kinematics::CVehicleSimulVirtualBase
112  * \ingroup nav_reactive
113  */
115 {
116  private:
118  /** for getNavigationTime */
120 
121  public:
124  : m_simul(simul), m_simul_time_start(.0)
125  {
126  }
127 
129  mrpt::math::TPose2D& curPose, mrpt::math::TTwist2D& curVel,
130  mrpt::system::TTimeStamp& timestamp, mrpt::math::TPose2D& curOdometry,
131  std::string& frame_id) override
132  {
133  curPose = m_simul.getCurrentGTPose();
134  curVel = m_simul.getCurrentGTVel();
135  timestamp = mrpt::system::now();
136  curOdometry = m_simul.getCurrentOdometricPose();
137  return true; // ok
138  }
139 
140  bool changeSpeeds(const mrpt::kinematics::CVehicleVelCmd& vel_cmd) override
141  {
142  m_simul.sendVelCmd(vel_cmd);
143  return true; // ok
144  }
145 
146  bool stop(bool isEmergencyStop) override
147  {
149  cmd.setToStop();
150  m_simul.sendVelCmd(cmd);
151  return true;
152  }
153 
155  {
158  cmd->setToStop();
159  return cmd;
160  }
162  {
163  return getStopCmd();
164  }
165 
166  /** See CRobot2NavInterface::getNavigationTime(). In this class, simulation
167  * time is returned instead of wall-clock time. */
168  double getNavigationTime() override
169  {
171  }
172  /** See CRobot2NavInterface::resetNavigationTimer() */
173  void resetNavigationTimer() override
174  {
176  }
177 };
178 }
179 }
mrpt::nav::CRobot2NavInterfaceForSimulator_Holo::getCurrentPoseAndSpeeds
bool getCurrentPoseAndSpeeds(mrpt::math::TPose2D &curPose, mrpt::math::TTwist2D &curVel, mrpt::system::TTimeStamp &timestamp, mrpt::math::TPose2D &curOdometry, std::string &frame_id) override
Get the current pose and velocity of the robot.
Definition: CRobot2NavInterfaceForSimulator.h:41
mrpt::nav::CRobot2NavInterfaceForSimulator_Holo::resetNavigationTimer
void resetNavigationTimer() override
See CRobot2NavInterface::resetNavigationTimer()
Definition: CRobot2NavInterfaceForSimulator.h:100
mrpt::nav::CRobot2NavInterfaceForSimulator_DiffDriven::m_simul
mrpt::kinematics::CVehicleSimul_DiffDriven & m_simul
Definition: CRobot2NavInterfaceForSimulator.h:117
mrpt::kinematics::CVehicleSimulVirtualBase::getCurrentOdometricPose
const mrpt::math::TPose2D & getCurrentOdometricPose() const
Returns the current pose according to (noisy) odometry.
Definition: CVehicleSimulVirtualBase.h:52
mrpt::nav::CRobot2NavInterfaceForSimulator_Holo
CRobot2NavInterface implemented for a simulator object based on mrpt::kinematics::CVehicleSimul_Holo.
Definition: CRobot2NavInterfaceForSimulator.h:27
mrpt::kinematics::CVehicleSimul_Holo::sendVelCmd
void sendVelCmd(const CVehicleVelCmd &cmd_vel) override
Sends a velocity command to the robot.
Definition: CVehicleSimul_Holo.h:41
mrpt::nav::CRobot2NavInterfaceForSimulator_DiffDriven::getStopCmd
mrpt::kinematics::CVehicleVelCmd::Ptr getStopCmd() override
Gets the emergency stop command for the current robot.
Definition: CRobot2NavInterfaceForSimulator.h:154
mrpt::nav::CRobot2NavInterfaceForSimulator_DiffDriven::stop
bool stop(bool isEmergencyStop) override
Stop the robot right now.
Definition: CRobot2NavInterfaceForSimulator.h:146
mrpt::kinematics::CVehicleSimul_DiffDriven::sendVelCmd
void sendVelCmd(const CVehicleVelCmd &cmd_vel) override
Sends a velocity command to the robot.
Definition: CVehicleSimul_DiffDriven.h:50
mrpt::system::now
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
Definition: datetime.h:75
mrpt::signWithZero
int signWithZero(T x)
Returns the sign of X as "0", "1" or "-1".
Definition: core/include/mrpt/core/bits_math.h:75
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::nav::CRobot2NavInterfaceForSimulator_Holo::CRobot2NavInterfaceForSimulator_Holo
CRobot2NavInterfaceForSimulator_Holo(mrpt::kinematics::CVehicleSimul_Holo &simul)
Definition: CRobot2NavInterfaceForSimulator.h:35
mrpt::nav::CRobot2NavInterface
The pure virtual interface between a real or simulated robot and any CAbstractNavigator-derived class...
Definition: CRobot2NavInterface.h:44
mrpt::kinematics::CVehicleVelCmd_DiffDriven::setToStop
void setToStop() override
Set to a command that means "do not move" / "stop".
Definition: CVehicleVelCmd_DiffDriven.cpp:73
mrpt::system::TTimeStamp
uint64_t TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1,...
Definition: datetime.h:31
CRobot2NavInterface.h
mrpt::nav::CRobot2NavInterfaceForSimulator_DiffDriven::CRobot2NavInterfaceForSimulator_DiffDriven
CRobot2NavInterfaceForSimulator_DiffDriven(mrpt::kinematics::CVehicleSimul_DiffDriven &simul)
Definition: CRobot2NavInterfaceForSimulator.h:122
mrpt::nav::CRobot2NavInterfaceForSimulator_DiffDriven::getCurrentPoseAndSpeeds
bool getCurrentPoseAndSpeeds(mrpt::math::TPose2D &curPose, mrpt::math::TTwist2D &curVel, mrpt::system::TTimeStamp &timestamp, mrpt::math::TPose2D &curOdometry, std::string &frame_id) override
Get the current pose and velocity of the robot.
Definition: CRobot2NavInterfaceForSimulator.h:128
mrpt::nav::CRobot2NavInterfaceForSimulator_Holo::getEmergencyStopCmd
mrpt::kinematics::CVehicleVelCmd::Ptr getEmergencyStopCmd() override
Gets the emergency stop command for the current robot.
Definition: CRobot2NavInterfaceForSimulator.h:68
mrpt::nav::CRobot2NavInterfaceForSimulator_DiffDriven
CRobot2NavInterface implemented for a simulator object based on mrpt::kinematics::CVehicleSimul_DiffD...
Definition: CRobot2NavInterfaceForSimulator.h:114
mrpt::kinematics::CVehicleSimul_Holo
Kinematic simulator of a holonomic 2D robot capable of moving in any direction, with "blended" veloci...
Definition: CVehicleSimul_Holo.h:24
mrpt::nav::CRobot2NavInterfaceForSimulator_Holo::m_simul_time_start
double m_simul_time_start
for getNavigationTime
Definition: CRobot2NavInterfaceForSimulator.h:32
mrpt::nav::CRobot2NavInterfaceForSimulator_Holo::getNavigationTime
double getNavigationTime() override
See CRobot2NavInterface::getNavigationTime().
Definition: CRobot2NavInterfaceForSimulator.h:95
mrpt::kinematics::CVehicleSimulVirtualBase::getCurrentGTVel
const mrpt::math::TTwist2D & getCurrentGTVel() const
Returns the instantaneous, ground truth velocity vector (vx,vy,omega) in world coordinates.
Definition: CVehicleSimulVirtualBase.h:65
mrpt::kinematics::CVehicleSimulVirtualBase::getCurrentGTPose
const mrpt::math::TPose2D & getCurrentGTPose() const
Returns the instantaneous, ground truth pose in world coordinates.
Definition: CVehicleSimulVirtualBase.h:46
mrpt::nav::CRobot2NavInterfaceForSimulator_DiffDriven::m_simul_time_start
double m_simul_time_start
for getNavigationTime
Definition: CRobot2NavInterfaceForSimulator.h:119
mrpt::math::TPose2D
Lightweight 2D pose.
Definition: lightweight_geom_data.h:186
mrpt::nav::CRobot2NavInterfaceForSimulator_Holo::getStopCmd
mrpt::kinematics::CVehicleVelCmd::Ptr getStopCmd() override
Gets the emergency stop command for the current robot.
Definition: CRobot2NavInterfaceForSimulator.h:74
mrpt::nav::CRobot2NavInterfaceForSimulator_Holo::getAlignCmd
mrpt::kinematics::CVehicleVelCmd::Ptr getAlignCmd(const double relative_heading_radians) override
Gets a motion command to make the robot to align with a given relative heading, without translating.
Definition: CRobot2NavInterfaceForSimulator.h:80
mrpt::nav::CRobot2NavInterfaceForSimulator_DiffDriven::changeSpeeds
bool changeSpeeds(const mrpt::kinematics::CVehicleVelCmd &vel_cmd) override
Sends a velocity command to the robot.
Definition: CRobot2NavInterfaceForSimulator.h:140
mrpt::nav::CRobot2NavInterfaceForSimulator_Holo::stop
bool stop(bool isEmergencyStop) override
Stop the robot right now.
Definition: CRobot2NavInterfaceForSimulator.h:60
mrpt::kinematics::CVehicleVelCmd::Ptr
std::shared_ptr< CVehicleVelCmd > Ptr
Definition: CVehicleVelCmd.h:24
mrpt::nav::CRobot2NavInterfaceForSimulator_Holo::changeSpeeds
virtual bool changeSpeeds(const mrpt::kinematics::CVehicleVelCmd &vel_cmd) override
Sends a velocity command to the robot.
Definition: CRobot2NavInterfaceForSimulator.h:53
mrpt::kinematics::CVehicleSimulVirtualBase::getTime
double getTime() const
Get the current simulation time.
Definition: CVehicleSimulVirtualBase.h:81
CVehicleSimul_Holo.h
mrpt::kinematics::CVehicleSimul_DiffDriven
Simulates the kinematics of a differential-driven planar mobile robot/vehicle, including odometry err...
Definition: CVehicleSimul_DiffDriven.h:23
mrpt::nav::CRobot2NavInterfaceForSimulator_DiffDriven::getEmergencyStopCmd
mrpt::kinematics::CVehicleVelCmd::Ptr getEmergencyStopCmd() override
Gets the emergency stop command for the current robot.
Definition: CRobot2NavInterfaceForSimulator.h:161
CVehicleSimul_DiffDriven.h
mrpt::nav::CRobot2NavInterfaceForSimulator_DiffDriven::getNavigationTime
double getNavigationTime() override
See CRobot2NavInterface::getNavigationTime().
Definition: CRobot2NavInterfaceForSimulator.h:168
mrpt::kinematics::CVehicleVelCmd_Holo
Kinematic model for.
Definition: CVehicleVelCmd_Holo.h:21
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::nav::CRobot2NavInterfaceForSimulator_Holo::m_simul
mrpt::kinematics::CVehicleSimul_Holo & m_simul
Definition: CRobot2NavInterfaceForSimulator.h:30
mrpt::kinematics::CVehicleVelCmd
Virtual base for velocity commands of different kinematic models of planar mobile robot.
Definition: CVehicleVelCmd.h:22
mrpt::nav::CRobot2NavInterfaceForSimulator_DiffDriven::resetNavigationTimer
void resetNavigationTimer() override
See CRobot2NavInterface::resetNavigationTimer()
Definition: CRobot2NavInterfaceForSimulator.h:173
mrpt::kinematics::CVehicleVelCmd_DiffDriven
Kinematic model for Ackermann-like or differential-driven vehicles.
Definition: CVehicleVelCmd_DiffDriven.h:21
mrpt::math::TTwist2D
2D twist: 2D velocity vector (vx,vy) + planar angular velocity (omega)
Definition: lightweight_geom_data.h:2145
mrpt::kinematics::CVehicleSimul_Holo::sendVelRampCmd
void sendVelRampCmd(double vel, double dir, double ramp_time, double rot_speed)
Sends a velocity cmd to the holonomic robot.
Definition: CVehicleSimul_Holo.cpp:73
mrpt::DEG2RAD
double DEG2RAD(const double x)
Degrees to radians.
Definition: core/include/mrpt/core/bits_math.h:42



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST