MRPT  2.0.4
CVehicleSimul_DiffDriven.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
13 
14 namespace mrpt::kinematics
15 {
16 /** Simulates the kinematics of a differential-driven planar mobile
17  * robot/vehicle, including odometry errors and dynamics limitations.
18  *
19  * \ingroup mrpt_kinematics_grp
20  */
22 {
23  public:
25 
27  ~CVehicleSimul_DiffDriven() override;
28 
29  /** Change the model of delays used for the orders sent to the robot \sa
30  * movementCommand */
32  double TAU_delay_sec = 1.8, double CMD_delay_sec = 0.)
33  {
34  cTAU = TAU_delay_sec;
35  cDELAY = CMD_delay_sec;
36  }
37 
38  void setV(double v) { m_v = v; }
39  void setW(double w) { m_w = w; }
40  double getV() { return m_v; }
41  double getW() { return m_w; }
42  /** Used to command the robot a desired movement:
43  * \param lin_vel Linar velocity (m/s)
44  * \param ang_vel Angular velocity (rad/s)
45  */
46  void movementCommand(double lin_vel, double ang_vel);
47 
48  void sendVelCmd(const CVehicleVelCmd& cmd_vel) override
49  {
50  const auto* cmd = dynamic_cast<const kinematic_cmd_t*>(&cmd_vel);
51  ASSERTMSG_(
52  cmd,
53  "Wrong vehicle kinematic class, expected "
54  "`CVehicleVelCmd_DiffDriven`");
55  movementCommand(cmd->lin_vel, cmd->ang_vel);
56  }
58  {
60  }
61 
62  private:
63  /** lin & angular velocity in the robot local frame. */
64  double m_v{0}, m_w{0};
65 
66  /** Dynamic limitations of the robot.
67  * Approximation to non-infinity motor forces: A first order low-pass
68  * filter, using:
69  * Command_Time: Time "t" when the last order was received.
70  * Command_v, Command_w: The user-desired velocities.
71  * Command_v0, Command_w0: Actual robot velocities at the moment of
72  * user request.
73  */
74  double Command_Time{0}, Command_v{0}, Command_w{0}, Command_v0{0},
76 
77  /** The time-constants for the first order low-pass filter for the
78  * velocities changes. */
79  double cTAU{.0};
80  /** The delay constant for the velocities changes */
81  double cDELAY{.0};
82 
83  void internal_simulControlStep(const double dt) override;
84  void internal_clear() override;
85 };
86 
87 } // namespace mrpt::kinematics
double cDELAY
The delay constant for the velocities changes.
double m_v
lin & angular velocity in the robot local frame.
This class can be used to simulate the kinematics and dynamics of a differential driven planar mobile...
double cTAU
The time-constants for the first order low-pass filter for the velocities changes.
double Command_Time
Dynamic limitations of the robot.
Virtual base for velocity commands of different kinematic models of planar mobile robot...
void movementCommand(double lin_vel, double ang_vel)
Used to command the robot a desired movement:
Simulates the kinematics of a differential-driven planar mobile robot/vehicle, including odometry err...
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
Definition: exceptions.h:108
TCLAP::CmdLine cmd("system_control_rate_timer_example")
void internal_clear() override
Resets all pending cmds.
void setDelayModelParams(double TAU_delay_sec=1.8, double CMD_delay_sec=0.)
Change the model of delays used for the orders sent to the robot.
std::shared_ptr< CVehicleVelCmd > Ptr
CVehicleVelCmd::Ptr getVelCmdType() const override
Gets an empty velocity command object that can be queried to find out the number of velcmd components...
Kinematic model for Ackermann-like or differential-driven vehicles.
void internal_simulControlStep(const double dt) override
void sendVelCmd(const CVehicleVelCmd &cmd_vel) override
Sends a velocity command to the robot.



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 33de1d0ad Sat Jun 20 11:02:42 2020 +0200 at sáb jun 20 17:35:17 CEST 2020