MVSim
Lightweight simulator for 2.5D vehicles and robots
Wheel.h
1 /*+-------------------------------------------------------------------------+
2  | MultiVehicle simulator (libmvsim) |
3  | |
4  | Copyright (C) 2014-2026 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 <mrpt/math/TPoint2D.h>
14 #include <mrpt/math/TPolygon2D.h>
15 #include <mrpt/math/TPose3D.h>
16 #include <mrpt/poses/CPose2D.h>
17 #include <mvsim/TParameterDefinitions.h>
18 #include <mvsim/VisualObject.h>
19 #include <mvsim/basic_types.h>
20 
21 namespace mvsim
22 {
23 class DefaultFriction;
24 class VehicleBase;
25 class DynamicsDifferential;
26 class World;
27 
33 class Wheel : public VisualObject
34 {
35  public:
36  Wheel(World* world);
37 
40  double x = 0, y = -0.5, yaw = 0;
41 
43  mrpt::math::TPose3D pose() const { return {x, y, 0, yaw, 0, 0}; }
44 
46  double diameter = .4, width = .2;
47  double mass = 2.0;
48 
51  double Iyy = 1.0;
52 
54  mrpt::img::TColor color{0xff323232};
55 
61  double linked_yaw_offset = .0;
62 
63  const TParameterDefinitions params_ = {
64  {"mass", {"%lf", &mass}},
65  {"width", {"%lf", &width}},
66  {"diameter", {"%lf", &diameter}},
67  {"color", {"%color", &color}},
68  {"inertia", {"%lf", &Iyy}},
69  {"linked_yaw", {"%s", &linked_yaw_object_name}},
70  {"linked_yaw_offset_deg", {"%lf_deg", &linked_yaw_offset}}};
71 
74  std::string asString() const;
75 
76  // methods ----
77 
78  void getAs3DObject(mrpt::opengl::CSetOfObjects& obj, bool isPhysicalScene);
79  void loadFromXML(const rapidxml::xml_node<char>* xml_node);
80 
81  void internalGuiUpdate(
82  const mrpt::optional_ref<mrpt::opengl::COpenGLScene>& viz,
83  const mrpt::optional_ref<mrpt::opengl::COpenGLScene>& physical, bool childrenOnly) override;
84 
85  double getPhi() const { return phi; }
86  void setPhi(double val) { phi = val; }
87  double getW() const { return w; }
88  void setW(double val) { w = val; }
89  void recalcInertia();
90  protected:
93  double phi = 0, w = 0;
94 };
95 } // namespace mvsim
Definition: VisualObject.h:36
Definition: Wheel.h:34
double getW() const
Spinning velocity (rad/s) wrt shaft.
Definition: Wheel.h:87
double mass
[kg]
Definition: Wheel.h:47
double x
Definition: Wheel.h:40
double getPhi() const
Orientation (rad) wrt vehicle local frame.
Definition: Wheel.h:85
void recalcInertia()
Recompute Iyy from mass, diameter and height.
void setW(double val)
Spinning velocity (rad/s) wrt shaft.
Definition: Wheel.h:88
mrpt::math::TPose3D pose() const
Definition: Wheel.h:43
std::string asString() const
double diameter
Definition: Wheel.h:46
mrpt::img::TColor color
Definition: Wheel.h:54
std::string linked_yaw_object_name
Definition: Wheel.h:60
void setPhi(double val)
Orientation (rad) wrt vehicle local frame.
Definition: Wheel.h:86
double Iyy
Definition: Wheel.h:51
double phi
Definition: Wheel.h:93
Definition: World.h:132