Main MRPT website > C++ reference for MRPT 1.9.9
CVehicleSimulVirtualBase.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 
11 #include <mrpt/poses/CPose2D.h>
13 #include <mrpt/system/datetime.h>
15 
16 namespace mrpt
17 {
18 namespace kinematics
19 {
20 /** This class can be used to simulate the kinematics and dynamics of a
21  * differential driven planar mobile robot, including odometry errors and
22  * dynamics limitations.
23  * Main API methods are:
24  * - movementCommand: Call this for send a command to the robot. This comamnd
25  * will be
26  * delayed and passed throught a first order low-pass filter to simulate
27  * robot dynamics.
28  * - simulateInterval: Call this for run the simulator for the desired time
29  * period.
30  *
31  * \ingroup mrpt_kinematics_grp
32  */
34 {
35  public:
37  virtual ~CVehicleSimulVirtualBase();
38 
39  /** @name Kinematic simulation and control interface
40  * @{ */
41  /** Runs the simulator during "dt" seconds. It will be split into periods of
42  * "m_firmware_control_period". */
43  void simulateOneTimeStep(const double dt);
44 
45  /** Returns the instantaneous, ground truth pose in world coordinates */
46  const mrpt::math::TPose2D& getCurrentGTPose() const { return m_GT_pose; }
47  /** Brute-force move robot to target coordinates ("teleport") */
48  void setCurrentGTPose(const mrpt::math::TPose2D& pose);
49 
50  /** Returns the current pose according to (noisy) odometry \sa
51  * setOdometryErrors */
53  {
54  return m_odometry;
55  }
56  /** Brute-force overwrite robot odometry */
57  template <typename T>
58  void setCurrentOdometricPose(const T& pose)
59  {
61  }
62 
63  /** Returns the instantaneous, ground truth velocity vector (vx,vy,omega) in
64  * world coordinates */
65  const mrpt::math::TTwist2D& getCurrentGTVel() const { return m_GT_vel; }
66  /** Returns the instantaneous, ground truth velocity vector (vx,vy,omega) in
67  * the robot local frame */
69 
70  /** Returns the instantaneous, odometric velocity vector (vx,vy,omega) in
71  * world coordinates */
73  {
74  return m_odometric_vel;
75  }
76  /** Returns the instantaneous, odometric velocity vector (vx,vy,omega) in
77  * the robot local frame */
79 
80  /** Get the current simulation time */
81  double getTime() const { return m_time; }
82  /** Sends a velocity command to the robot. The number of components and
83  * their meaning depends
84  * on the vehicle-kinematics derived class */
85  virtual void sendVelCmd(const CVehicleVelCmd& cmd_vel) = 0;
86  /** Gets an empty velocity command object that can be queried to find out
87  * the number of velcmd components,... */
88  virtual CVehicleVelCmd::Ptr getVelCmdType() const = 0;
89 
90  /** Enable/Disable odometry errors. Errors in odometry are 1 sigma Gaussian
91  * values per second */
93  bool enabled, double Ax_err_bias = 1e-3, double Ax_err_std = 10e-3,
94  double Ay_err_bias = 1e-3, double Ay_err_std = 10e-3,
95  double Aphi_err_bias = mrpt::DEG2RAD(1e-3),
96  double Aphi_err_std = mrpt::DEG2RAD(10e-3))
97  {
98  m_use_odo_error = enabled;
99  m_Ax_err_bias = Ax_err_bias;
100  m_Ax_err_std = Ax_err_std;
101  m_Ay_err_bias = Ay_err_bias;
102  m_Ay_err_std = Ay_err_std;
103  m_Aphi_err_bias = Aphi_err_bias;
104  m_Aphi_err_std = Aphi_err_std;
105  }
106 
107  void resetStatus(); //! Reset all simulator variables to 0 (except the
108  //! simulation time). \sa resetTime
109  /** Reset time counter \sa resetStatus */
110  void resetTime();
111 
112  /** @} */
113 
114  protected:
115  /** @name State vector
116  * @{ */
117  /** simulation running time */
118  double m_time;
119  /** ground truth pose in world coordinates. */
121  /** Velocity in (x,y,omega) */
123  /** Velocity in (x,y,omega) */
126  /** @} */
127  /** The period at which the low-level controller updates velocities
128  * (Default: 0.5 ms) */
130 
131  /** Whether to corrupt odometry with noise */
136 
137  virtual void internal_simulControlStep(const double dt) = 0;
138  /** Resets all pending cmds */
139  virtual void internal_clear() = 0;
140 
141  private:
142 };
143 
144 } // End of namespace
145 } // End of namespace
mrpt::kinematics::CVehicleSimulVirtualBase::m_firmware_control_period
double m_firmware_control_period
The period at which the low-level controller updates velocities (Default: 0.5 ms)
Definition: CVehicleSimulVirtualBase.h:129
mrpt::kinematics::CVehicleSimulVirtualBase::~CVehicleSimulVirtualBase
virtual ~CVehicleSimulVirtualBase()
Definition: CVehicleSimulVirtualBase.cpp:23
mrpt::kinematics::CVehicleSimulVirtualBase
This class can be used to simulate the kinematics and dynamics of a differential driven planar mobile...
Definition: CVehicleSimulVirtualBase.h:33
mrpt::kinematics::CVehicleSimulVirtualBase::m_Aphi_err_std
double m_Aphi_err_std
Definition: CVehicleSimulVirtualBase.h:135
mrpt::kinematics::CVehicleSimulVirtualBase::m_Ay_err_std
double m_Ay_err_std
Definition: CVehicleSimulVirtualBase.h:134
mrpt::kinematics::CVehicleSimulVirtualBase::getCurrentOdometricVel
const mrpt::math::TTwist2D & getCurrentOdometricVel() const
Returns the instantaneous, odometric velocity vector (vx,vy,omega) in world coordinates.
Definition: CVehicleSimulVirtualBase.h:72
mrpt::kinematics::CVehicleSimulVirtualBase::setCurrentOdometricPose
void setCurrentOdometricPose(const T &pose)
Brute-force overwrite robot odometry
Definition: CVehicleSimulVirtualBase.h:58
mrpt::kinematics::CVehicleSimulVirtualBase::getCurrentOdometricPose
const mrpt::math::TPose2D & getCurrentOdometricPose() const
Returns the current pose according to (noisy) odometry.
Definition: CVehicleSimulVirtualBase.h:52
mrpt::kinematics::CVehicleSimulVirtualBase::resetStatus
void resetStatus()
Definition: CVehicleSimulVirtualBase.cpp:79
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
CPose2D.h
lightweight_geom_data.h
mrpt::kinematics::CVehicleSimulVirtualBase::m_GT_pose
mrpt::math::TPose2D m_GT_pose
ground truth pose in world coordinates.
Definition: CVehicleSimulVirtualBase.h:120
mrpt::kinematics::CVehicleSimulVirtualBase::CVehicleSimulVirtualBase
CVehicleSimulVirtualBase()
Definition: CVehicleSimulVirtualBase.cpp:18
mrpt::kinematics::CVehicleSimulVirtualBase::resetTime
void resetTime()
Reset all simulator variables to 0 (except the.
Definition: CVehicleSimulVirtualBase.cpp:88
mrpt::kinematics::CVehicleSimulVirtualBase::m_Aphi_err_bias
double m_Aphi_err_bias
Definition: CVehicleSimulVirtualBase.h:135
mrpt::kinematics::CVehicleSimulVirtualBase::internal_simulControlStep
virtual void internal_simulControlStep(const double dt)=0
mrpt::kinematics::CVehicleSimulVirtualBase::m_GT_vel
mrpt::math::TTwist2D m_GT_vel
Velocity in (x,y,omega)
Definition: CVehicleSimulVirtualBase.h:122
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::kinematics::CVehicleSimulVirtualBase::setCurrentGTPose
void setCurrentGTPose(const mrpt::math::TPose2D &pose)
Brute-force move robot to target coordinates ("teleport")
Definition: CVehicleSimulVirtualBase.cpp:24
mrpt::math::TPose2D
Lightweight 2D pose.
Definition: lightweight_geom_data.h:186
mrpt::kinematics::CVehicleSimulVirtualBase::m_Ax_err_std
double m_Ax_err_std
Definition: CVehicleSimulVirtualBase.h:133
mrpt::kinematics::CVehicleSimulVirtualBase::getCurrentOdometricVelLocal
mrpt::math::TTwist2D getCurrentOdometricVelLocal() const
Returns the instantaneous, odometric velocity vector (vx,vy,omega) in the robot local frame.
Definition: CVehicleSimulVirtualBase.cpp:96
mrpt::kinematics::CVehicleSimulVirtualBase::setOdometryErrors
void setOdometryErrors(bool enabled, double Ax_err_bias=1e-3, double Ax_err_std=10e-3, double Ay_err_bias=1e-3, double Ay_err_std=10e-3, double Aphi_err_bias=mrpt::DEG2RAD(1e-3), double Aphi_err_std=mrpt::DEG2RAD(10e-3))
Enable/Disable odometry errors.
Definition: CVehicleSimulVirtualBase.h:92
mrpt::kinematics::CVehicleSimulVirtualBase::getVelCmdType
virtual CVehicleVelCmd::Ptr getVelCmdType() const =0
Gets an empty velocity command object that can be queried to find out the number of velcmd components...
mrpt::kinematics::CVehicleSimulVirtualBase::sendVelCmd
virtual void sendVelCmd(const CVehicleVelCmd &cmd_vel)=0
Sends a velocity command to the robot.
mrpt::kinematics::CVehicleVelCmd::Ptr
std::shared_ptr< CVehicleVelCmd > Ptr
Definition: CVehicleVelCmd.h:24
mrpt::kinematics::CVehicleSimulVirtualBase::getTime
double getTime() const
Get the current simulation time.
Definition: CVehicleSimulVirtualBase.h:81
mrpt::kinematics::CVehicleSimulVirtualBase::getCurrentGTVelLocal
mrpt::math::TTwist2D getCurrentGTVelLocal() const
Returns the instantaneous, ground truth velocity vector (vx,vy,omega) in the robot local frame.
Definition: CVehicleSimulVirtualBase.cpp:89
mrpt::kinematics::CVehicleSimulVirtualBase::internal_clear
virtual void internal_clear()=0
Resets all pending cmds.
mrpt::kinematics::CVehicleSimulVirtualBase::m_odometric_vel
mrpt::math::TTwist2D m_odometric_vel
Velocity in (x,y,omega)
Definition: CVehicleSimulVirtualBase.h:124
mrpt::kinematics::CVehicleSimulVirtualBase::m_odometry
mrpt::math::TPose2D m_odometry
Definition: CVehicleSimulVirtualBase.h:125
mrpt::kinematics::CVehicleSimulVirtualBase::m_Ay_err_bias
double m_Ay_err_bias
Definition: CVehicleSimulVirtualBase.h:134
mrpt::kinematics::CVehicleVelCmd
Virtual base for velocity commands of different kinematic models of planar mobile robot.
Definition: CVehicleVelCmd.h:22
mrpt::kinematics::CVehicleSimulVirtualBase::m_Ax_err_bias
double m_Ax_err_bias
Definition: CVehicleSimulVirtualBase.h:133
mrpt::kinematics::CVehicleSimulVirtualBase::simulateOneTimeStep
void simulateOneTimeStep(const double dt)
Runs the simulator during "dt" seconds.
Definition: CVehicleSimulVirtualBase.cpp:29
mrpt::kinematics::CVehicleSimulVirtualBase::m_time
double m_time
simulation running time
Definition: CVehicleSimulVirtualBase.h:118
CVehicleVelCmd.h
datetime.h
mrpt::math::TTwist2D
2D twist: 2D velocity vector (vx,vy) + planar angular velocity (omega)
Definition: lightweight_geom_data.h:2145
mrpt::kinematics::CVehicleSimulVirtualBase::m_use_odo_error
bool m_use_odo_error
Whether to corrupt odometry with noise.
Definition: CVehicleSimulVirtualBase.h:132
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