VehicleAckermann_Drivetrain.h
Go to the documentation of this file.
1 /*+-------------------------------------------------------------------------+
2  | MultiVehicle simulator (libmvsim) |
3  | |
4  | Copyright (C) 2014-2020 Jose Luis Blanco Claraco |
5  | Copyright (C) 2017 Borys Tymchenko (Odessa Polytechnic University) |
6  | Distributed under 3-clause BSD License |
7  | See COPYING |
8  +-------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
12 #include <mrpt/img/TColor.h>
13 #include <mvsim/PID_Controller.h>
14 #include <mvsim/VehicleBase.h>
15 
16 namespace mvsim
17 {
27 {
29  public:
30  // Wheels: [0]:rear-left, [1]:rear-right, [2]: front-left, [3]: front-right
31  enum
32  {
33  WHEEL_RL = 0,
34  WHEEL_RR = 1,
35  WHEEL_FL = 2,
37  };
38 
40  {
44 
48 
50  };
51 
53 
55  double getMaxSteeringAngle() const { return m_max_steer_ang; }
56  void setMaxSteeringAngle(double val) { m_max_steer_ang = val; }
61  {
63  };
65  {
66  double drive_torque;
67  double steer_ang;
68  TControllerOutput() : drive_torque(0), steer_ang(0) {}
69  };
70 
74  typedef std::shared_ptr<ControllerBase> ControllerBasePtr;
75 
76  class ControllerRawForces : public ControllerBase
77  {
78  public:
80  static const char* class_name() { return "raw"; }
83  double setpoint_wheel_torque, setpoint_steer_ang;
84  virtual void control_step(
87  virtual void load_config(const rapidxml::xml_node<char>& node) override;
88  virtual void teleop_interface(
89  const TeleopInput& in, TeleopOutput& out) override;
90  };
91 
94  class ControllerTwistFrontSteerPID : public ControllerBase
95  {
96  public:
98  static const char* class_name() { return "twist_front_steer_pid"; }
102  setpoint_ang_speed;
103  virtual void control_step(
106  virtual void load_config(const rapidxml::xml_node<char>& node) override;
107  virtual void teleop_interface(
108  const TeleopInput& in, TeleopOutput& out) override;
109 
110  double KP, KI, KD;
111  double max_torque;
112 
113  // See base docs.
114  virtual bool setTwistCommand(const double vx, const double wz) override
115  {
116  setpoint_lin_speed = vx;
117  setpoint_ang_speed = wz;
118  return true;
119  }
120 
121  private:
122  double m_dist_fWheels, m_r2f_L;
124  };
125 
126  class ControllerFrontSteerPID : public ControllerBase
127  {
128  public:
130  static const char* class_name() { return "front_steer_pid"; }
133  double setpoint_lin_speed, setpoint_steer_ang;
134  virtual void control_step(
139  virtual void load_config(const rapidxml::xml_node<char>& node) override;
140  virtual void teleop_interface(
141  const TeleopInput& in, TeleopOutput& out) override;
142 
143  double KP, KI, KD;
144  double max_torque;
145  private:
147  double m_r2f_L;
148  };
149 
150  const ControllerBasePtr& getController() const { return m_controller; }
151  ControllerBasePtr& getController() { return m_controller; }
153  {
154  return m_controller.get();
155  }
156  // end controllers
158 
159  virtual mrpt::math::TTwist2D getVelocityLocalOdoEstimate() const override;
160 
167  const double desired_equiv_steer_ang, double& out_fl_ang,
168  double& out_fr_ang) const;
169 
173  const double w1, const double w2, const double diffBias,
174  const double defaultSplitRatio, double& t1, double& t2);
175 
176  protected:
177  // See base class docs
178  virtual void dynamics_load_params_from_xml(
179  const rapidxml::xml_node<char>* xml_node) override;
180  // See base class doc
181  virtual void invoke_motor_controllers(
182  const TSimulContext& context,
183  std::vector<double>& out_force_per_wheel) override;
184 
185  private:
186  ControllerBasePtr m_controller;
187 
189 
192 
196 
199  double m_RearLRBias;
200 };
201 } // namespace mvsim
DifferentialType m_diff_type
min turning radius
virtual mrpt::math::TTwist2D getVelocityLocalOdoEstimate() const override
double max_torque
Maximum abs. value torque (for clamp) [Nm].
virtual void dynamics_load_params_from_xml(const rapidxml::xml_node< char > *xml_node) override
virtual void invoke_motor_controllers(const TSimulContext &context, std::vector< double > &out_force_per_wheel) override
GLuint in
virtual ControllerBaseInterface * getControllerInterface() override
ControllerBaseTempl< DynamicsAckermannDrivetrain > ControllerBase
void computeDiffTorqueSplit(const double w1, const double w2, const double diffBias, const double defaultSplitRatio, double &t1, double &t2)
const ControllerBasePtr & getController() const
#define DECLARES_REGISTER_VEHICLE_DYNAMICS(CLASS_NAME)
Definition: VehicleBase.h:249
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble GLdouble w2
std::shared_ptr< ControllerBase > ControllerBasePtr
double steer_ang
Equivalent ackerman steering angle.
virtual bool setTwistCommand(const double vx, const double wz) override
ControllerBasePtr m_controller
The installed controller.
GLuint GLfloat * val
double max_torque
Maximum abs. value torque (for clamp) [Nm].
void computeFrontWheelAngles(const double desired_equiv_steer_ang, double &out_fl_ang, double &out_fr_ang) const
GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint GLdouble w1


mvsim
Author(s):
autogenerated on Fri May 7 2021 03:05:51