bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
Loading...
Searching...
No Matches
robot.h
Go to the documentation of this file.
1#ifndef ROBOT_H
2#define ROBOT_H
3
4#include "bitrl/bitrl_types.h"
5#include <chrono/physics/ChSystemNSC.h>
6#include <chrono/physics/ChBodyEasy.h>
7#include <chrono/functions/ChFunctionConst.h>
8#include <chrono/physics/ChLinkMotorRotationSpeed.h>
9
10
11#include <memory>
12namespace example_13
13{
14
15using namespace bitrl;
16
17const real_t WHEEL_RADIUS = 0.1;
19const real_t WHEEL_WIDTH = 0.05;
20const real_t CASTER_RADIUS = 0.05;
21
22auto build_wheel(std::shared_ptr<chrono::ChContactMaterialNSC> material, const chrono::ChVector3d& pos);
23auto build_motor(std::shared_ptr<chrono::ChBodyEasyCylinder> wheel,
24 std::shared_ptr<chrono::ChFunctionConst> speed_func,
25 std::shared_ptr<chrono::ChBodyEasyBox> chassis,
26 const chrono::ChVector3d& pos);
27
28class Robot
29{
30public:
31
32 // constructor
33 Robot()=default;
34
35 // add the components of this robot to the system we simulate
36 void add_to_sys(chrono::ChSystemNSC& sys) const;
37
38 // build the robot
39 void build(std::shared_ptr<chrono::ChContactMaterialNSC> material);
40
41 // set the speeds of the motors
42 void set_speed(real_t speed);
43
44 // reset the robot
45 void reset();
46
47 // the pose of the robot
48 chrono::ChVector3d position()noexcept{return chassis_ -> GetPos();}
49
50private:
51
52 std::shared_ptr<chrono::ChBodyEasyBox> chassis_;
53 std::shared_ptr<chrono::ChBodyEasyCylinder> left_wheel_;
54 std::shared_ptr<chrono::ChBodyEasyCylinder> right_wheel_;
55 std::shared_ptr<chrono::ChLinkMotorRotationSpeed> left_wheel_motor_;
56 std::shared_ptr<chrono::ChLinkMotorRotationSpeed> right_wheel_motor_;
57 std::shared_ptr<chrono::ChBodyEasySphere> caster_wheel_;
58 std::shared_ptr<chrono::ChLinkLockRevolute> caster_link_joint_;
59
60};
61}
62
63
64#endif //ROBOT_H
Definition robot.h:29
chrono::ChVector3d position() noexcept
Definition robot.h:48
void set_speed(real_t speed)
void add_to_sys(chrono::ChSystemNSC &sys) const
void build(std::shared_ptr< chrono::ChContactMaterialNSC > material)
Definition bitrl_consts.h:14
double real_t
real_t
Definition bitrl_types.h:23
Definition robot.h:13
const real_t WHEEL_WIDTH
Definition robot.h:19
auto build_wheel(std::shared_ptr< chrono::ChContactMaterialNSC > material, const chrono::ChVector3d &pos)
const real_t CASTER_RADIUS
Definition robot.h:20
const real_t CHASSIS_HEIGHT
Definition robot.h:18
auto build_motor(std::shared_ptr< chrono::ChBodyEasyCylinder > wheel, std::shared_ptr< chrono::ChFunctionConst > speed_func, std::shared_ptr< chrono::ChBodyEasyBox > chassis, const chrono::ChVector3d &pos)
const real_t WHEEL_RADIUS
Definition robot.h:17