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-2017, 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::utils::DEG2RAD(1e-3),
96  double Aphi_err_std = mrpt::utils::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::math::TTwist2D m_odometric_vel
Velocity in (x,y,omega)
This class can be used to simulate the kinematics and dynamics of a differential driven planar mobile...
double DEG2RAD(const double x)
Degrees to radians.
void simulateOneTimeStep(const double dt)
Runs the simulator during "dt" seconds.
mrpt::math::TPose2D m_GT_pose
ground truth pose in world coordinates.
const mrpt::math::TTwist2D & getCurrentOdometricVel() const
Returns the instantaneous, odometric velocity vector (vx,vy,omega) in world coordinates.
void setCurrentOdometricPose(const T &pose)
Brute-force overwrite robot odometry.
virtual void internal_simulControlStep(const double dt)=0
mrpt::math::TTwist2D m_GT_vel
Velocity in (x,y,omega)
const mrpt::math::TTwist2D & getCurrentGTVel() const
Returns the instantaneous, ground truth velocity vector (vx,vy,omega) in world coordinates.
const mrpt::math::TPose2D & getCurrentGTPose() const
Returns the instantaneous, ground truth pose in world coordinates.
Virtual base for velocity commands of different kinematic models of planar mobile robot...
2D twist: 2D velocity vector (vx,vy) + planar angular velocity (omega)
mrpt::math::TTwist2D getCurrentOdometricVelLocal() const
Returns the instantaneous, odometric velocity vector (vx,vy,omega) in the robot local frame...
virtual CVehicleVelCmd::Ptr getVelCmdType() const =0
Gets an empty velocity command object that can be queried to find out the number of velcmd components...
virtual void sendVelCmd(const CVehicleVelCmd &cmd_vel)=0
Sends a velocity command to the robot.
double getTime() const
Get the current simulation time.
mrpt::math::TTwist2D getCurrentGTVelLocal() const
Returns the instantaneous, ground truth velocity vector (vx,vy,omega) in the robot local frame...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void resetTime()
Reset all simulator variables to 0 (except the.
Lightweight 2D pose.
void setCurrentGTPose(const mrpt::math::TPose2D &pose)
Brute-force move robot to target coordinates ("teleport")
bool m_use_odo_error
Whether to corrupt odometry with noise.
double m_firmware_control_period
The period at which the low-level controller updates velocities (Default: 0.5 ms) ...
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::utils::DEG2RAD(1e-3), double Aphi_err_std=mrpt::utils::DEG2RAD(10e-3))
Enable/Disable odometry errors.
std::shared_ptr< CVehicleVelCmd > Ptr
const mrpt::math::TPose2D & getCurrentOdometricPose() const
Returns the current pose according to (noisy) odometry.
virtual void internal_clear()=0
Resets all pending cmds.



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