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