MRPT  2.0.3
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
mrpt::kinematics::CVehicleSimul_DiffDriven::cDELAY
double cDELAY
The delay constant for the velocities changes.
Definition: CVehicleSimul_DiffDriven.h:81
mrpt::kinematics::CVehicleSimul_DiffDriven::kinematic_cmd_t
CVehicleVelCmd_DiffDriven kinematic_cmd_t
Definition: CVehicleSimul_DiffDriven.h:24
mrpt::kinematics::CVehicleSimulVirtualBase
This class can be used to simulate the kinematics and dynamics of a differential driven planar mobile...
Definition: CVehicleSimulVirtualBase.h:32
mrpt::kinematics::CVehicleSimul_DiffDriven::Command_v0
double Command_v0
Definition: CVehicleSimul_DiffDriven.h:74
mrpt::kinematics::CVehicleSimul_DiffDriven::getW
double getW()
Definition: CVehicleSimul_DiffDriven.h:41
mrpt::kinematics::CVehicleSimul_DiffDriven::sendVelCmd
void sendVelCmd(const CVehicleVelCmd &cmd_vel) override
Sends a velocity command to the robot.
Definition: CVehicleSimul_DiffDriven.h:48
mrpt::kinematics::CVehicleSimul_DiffDriven::Command_v
double Command_v
Definition: CVehicleSimul_DiffDriven.h:74
mrpt::kinematics::CVehicleSimul_DiffDriven::m_w
double m_w
Definition: CVehicleSimul_DiffDriven.h:64
CVehicleSimulVirtualBase.h
mrpt::kinematics::CVehicleSimul_DiffDriven::setV
void setV(double v)
Definition: CVehicleSimul_DiffDriven.h:38
mrpt::kinematics::CVehicleSimul_DiffDriven::cTAU
double cTAU
The time-constants for the first order low-pass filter for the velocities changes.
Definition: CVehicleSimul_DiffDriven.h:79
mrpt::kinematics::CVehicleSimul_DiffDriven::Command_Time
double Command_Time
Dynamic limitations of the robot.
Definition: CVehicleSimul_DiffDriven.h:74
mrpt::kinematics::CVehicleSimul_DiffDriven::internal_clear
void internal_clear() override
Resets all pending cmds.
Definition: CVehicleSimul_DiffDriven.cpp:22
mrpt::kinematics::CVehicleSimul_DiffDriven::CVehicleSimul_DiffDriven
CVehicleSimul_DiffDriven()
Definition: CVehicleSimul_DiffDriven.cpp:16
mrpt::kinematics::CVehicleSimul_DiffDriven::getVelCmdType
CVehicleVelCmd::Ptr getVelCmdType() const override
Gets an empty velocity command object that can be queried to find out the number of velcmd components...
Definition: CVehicleSimul_DiffDriven.h:57
mrpt::kinematics::CVehicleSimul_DiffDriven::getV
double getV()
Definition: CVehicleSimul_DiffDriven.h:40
mrpt::kinematics::CVehicleSimul_DiffDriven::Command_w0
double Command_w0
Definition: CVehicleSimul_DiffDriven.h:75
mrpt::kinematics::CVehicleSimul_DiffDriven::Command_w
double Command_w
Definition: CVehicleSimul_DiffDriven.h:74
CVehicleVelCmd_DiffDriven.h
mrpt::kinematics::CVehicleSimul_DiffDriven::internal_simulControlStep
void internal_simulControlStep(const double dt) override
Definition: CVehicleSimul_DiffDriven.cpp:30
ASSERTMSG_
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
Definition: exceptions.h:108
mrpt::kinematics::CVehicleVelCmd::Ptr
std::shared_ptr< CVehicleVelCmd > Ptr
Definition: CVehicleVelCmd.h:22
mrpt::kinematics::CVehicleSimul_DiffDriven::movementCommand
void movementCommand(double lin_vel, double ang_vel)
Used to command the robot a desired movement:
Definition: CVehicleSimul_DiffDriven.cpp:62
mrpt::kinematics::CVehicleSimul_DiffDriven
Simulates the kinematics of a differential-driven planar mobile robot/vehicle, including odometry err...
Definition: CVehicleSimul_DiffDriven.h:21
mrpt::kinematics::CVehicleSimul_DiffDriven::~CVehicleSimul_DiffDriven
~CVehicleSimul_DiffDriven() override
mrpt::kinematics
Definition: CKinematicChain.h:18
mrpt::kinematics::CVehicleSimul_DiffDriven::setW
void setW(double w)
Definition: CVehicleSimul_DiffDriven.h:39
mrpt::kinematics::CVehicleSimul_DiffDriven::setDelayModelParams
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.
Definition: CVehicleSimul_DiffDriven.h:31
mrpt::kinematics::CVehicleVelCmd
Virtual base for velocity commands of different kinematic models of planar mobile robot.
Definition: CVehicleVelCmd.h:20
mrpt::kinematics::CVehicleSimul_DiffDriven::m_v
double m_v
lin & angular velocity in the robot local frame.
Definition: CVehicleSimul_DiffDriven.h:64
mrpt::kinematics::CVehicleVelCmd_DiffDriven
Kinematic model for Ackermann-like or differential-driven vehicles.
Definition: CVehicleVelCmd_DiffDriven.h:19



Page generated by Doxygen 1.8.17 for MRPT 2.0.3 at Fri May 15 23:51:15 UTC 2020