bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
chrono_diff_drive_robot.h
Go to the documentation of this file.
1#ifndef CHRONO_DIFF_DRIVE_ROBOT_H
2#define CHRONO_DIFF_DRIVE_ROBOT_H
3
4#include "bitrl/bitrl_config.h"
5
6#ifdef BITRL_CHRONO
7
8#include "bitrl/bitrl_types.h"
11
12
13#include <chrono/physics/ChSystemSMC.h>
14#include <chrono/physics/ChLinkMotorRotationSpeed.h>
15
16
17#include <string>
18#include <memory>
19#include <utility>
20
21namespace bitrl
22{
23namespace rb::bitrl_chrono
24{
40class CHRONO_DiffDriveRobotBase
41{
42public:
43
44 typedef CHRONO_RobotPose pose_type;
45
49 struct MotorHandle {
50 std::shared_ptr<chrono::ChLinkMotorRotationSpeed> motor;
51 std::shared_ptr<chrono::ChFunctionConst> speed;
52 };
53
54
72 void load_from_json(const std::string& filename);
73
78 void step(real_t time_step);
79
85 void set_motor_speed(const std::string& motor_name, real_t speed);
86
91 void set_motor_speed(real_t speed);
92
97 const std::string& get_name() const noexcept{return name_;}
98
103 uint_t n_wheels()const noexcept{return 3;}
104
109 uint_t n_motors()const noexcept{return 2;}
110
115 void set_sensors(sensors::SensorManager& sensor_manager){sensor_manager_ptr_ = &sensor_manager;}
116
120 chrono::ChSystemSMC& CHRONO_sys() noexcept{return sys_;}
121
122
123 std::shared_ptr<chrono::ChBody> CHRONO_chassis()noexcept{return chassis_;}
124
128 std::shared_ptr<pose_type> pose()noexcept{return pose_;}
129
130protected:
131
132
140 chrono::ChSystemSMC sys_;
141
145 std::shared_ptr<chrono::ChBody> chassis_;
146
150 std::shared_ptr<pose_type> pose_;
151
155 sensors::SensorManager* sensor_manager_ptr_;
156
162 std::pair<MotorHandle, MotorHandle> motors_;
163
167 std::string name_;
168
169};
170
171inline void CHRONO_DiffDriveRobotBase::set_motor_speed(real_t speed)
172{
173 set_motor_speed("left_motor", speed);
174 set_motor_speed("right_motor", speed);
175}
176}
177}
178#endif
179#endif //DIFF_DRIVE_ROBOT_H
Definition bitrl_consts.h:14
std::size_t uint_t
uint_t
Definition bitrl_types.h:43