bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
diff_drive_robot_part.h
Go to the documentation of this file.
1
2#ifndef DIFF_DRIVE_ROBOT_PART_H
3#define DIFF_DRIVE_ROBOT_PART_H
4
5#include "bitrl/bitrl_config.h"
6
7#ifdef BITRL_CHRONO
8
9#include <string>
10#include <memory>
11
12#include "bitrl/bitrl_types.h"
13#include "chrono/assets/ChColor.h"
14#include "chrono/physics/ChSystem.h"
15#include "chrono/physics/ChLinkMotorRotationSpeed.h"
16
17namespace bitrl{
18namespace rb::bitrl_chrono{
19
20enum class CollisionFamily : int_t
21{
22 CHASSIS = 1,
23 ACTIVE_WHEEL = 2,
24 PASSIVE_WHEEL = 3,
25 ROD = 4,
26 BOTTOM_PLATE = 5,
27 MIDDLE_PLATE = 6,
28 TOP_PLATE = 7
29};
30
41class CHRONO_DiffDriveRobot_Part {
42public:
43
44
46 virtual ~CHRONO_DiffDriveRobot_Part()=default;
47
49 virtual void init()=0;
50
52 const std::string& get_name() const { return name_; }
53
55 void set_name(const std::string& name) { name_ = name; }
56
58 void set_mesh_name(const std::string& name) { mesh_name_ = name; }
59
61 std::string get_mesh_name() const { return mesh_name_; }
62
65 std::string get_vis_mesh_file()const;
66
68 real_t get_density()const{return density_; }
69
71 void set_density(real_t density) { density_ = density; }
72
74 std::shared_ptr<chrono::ChBodyAuxRef> get_body_ptr() const { return body_; }
75
77 std::shared_ptr<chrono::ChBodyAuxRef> get_chassis_ptr() const { return chassis_; }
78
80 const chrono::ChVector3d& get_pos() const { return body_->GetFrameRefToAbs().GetPos(); }
81
83 const chrono::ChQuaternion<>& get_rotation() const { return body_->GetFrameRefToAbs().GetRot(); }
84
86 void enable_collision(bool state);
87
88protected:
89
90 CHRONO_DiffDriveRobot_Part(const std::string& name,
91 bool fixed,
92 std::shared_ptr<chrono::ChContactMaterial> mat,
93 chrono::ChSystem* system,
94 const chrono::ChVector3d& body_pos,
95 const chrono::ChQuaternion<>& body_rot,
96 std::shared_ptr<chrono::ChBodyAuxRef> chassis_body,
97 bool collide);
98
99 // Initialize the body_ Called upon constructing
100 // an instance of this class
101 void do_init_(const std::string& mesh_name, const chrono::ChVector3d& offset,
102 const chrono::ChColor& color, real_t density);
103
105 void add_visualization_assets();
106
108 void add_collision_shapes();
109
110 std::shared_ptr<chrono::ChBodyAuxRef> body_;
111 std::shared_ptr<chrono::ChContactMaterial> contact_material_;
112 std::shared_ptr<chrono::ChBodyAuxRef> chassis_;
113
114 chrono::ChVector3d pos_;
115 chrono::ChVector3d offset_;
116 chrono::ChColor color_;
117 chrono::ChSystem* system_;
118
119 chrono::ChQuaternion<> rot_;
120
121 std::string name_;
122 std::string mesh_name_;
123 real_t density_;
124
125 bool collide_;
126 bool fixed_;
127 bool is_initialized_{false};
128};
129
130}
131}
132
133
134
135#endif
136#endif //DIFF_DRIVE_ROBOT_PART_H
Definition bitrl_consts.h:14
int int_t
integer type
Definition bitrl_types.h:33
double real_t
real_t
Definition bitrl_types.h:23