bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
robot.h
Go to the documentation of this file.
1#ifndef ROBOT_H
2#define ROBOT_H
3
5#include <chrono/functions/ChFunctionConst.h>
6#include <chrono/physics/ChBodyEasy.h>
7#include <chrono/physics/ChLinkMotorRotationSpeed.h>
8#include <chrono/physics/ChSystemNSC.h>
9
10#include <memory>
11namespace chrono_smc_system
12{
13
14using namespace bitsim;
15
16const real_t WHEEL_RADIUS = 0.1;
18const real_t WHEEL_WIDTH = 0.05;
19const real_t CASTER_RADIUS = 0.05;
20
21auto build_wheel(std::shared_ptr<chrono::ChContactMaterialNSC> material,
22 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, const chrono::ChVector3d &pos);
26
27class Robot
28{
29 public:
30 // constructor
31 Robot() = default;
32
33 // add the components of this robot to the system we simulate
34 void add_to_sys(chrono::ChSystemNSC &sys) const;
35
36 // build the robot
37 void build(std::shared_ptr<chrono::ChContactMaterialNSC> material);
38
39 // set the speeds of the motors
40 void set_speed(real_t speed);
41
42 // reset the robot
43 void reset();
44
45 // the pose of the robot
46 chrono::ChVector3d position() noexcept { return chassis_->GetPos(); }
47
48 private:
49 std::shared_ptr<chrono::ChBodyEasyBox> chassis_;
50 std::shared_ptr<chrono::ChBodyEasyCylinder> left_wheel_;
51 std::shared_ptr<chrono::ChBodyEasyCylinder> right_wheel_;
52 std::shared_ptr<chrono::ChLinkMotorRotationSpeed> left_wheel_motor_;
53 std::shared_ptr<chrono::ChLinkMotorRotationSpeed> right_wheel_motor_;
54 std::shared_ptr<chrono::ChBodyEasySphere> caster_wheel_;
55 std::shared_ptr<chrono::ChLinkLockRevolute> caster_link_joint_;
56};
57} // namespace chrono_smc_system
58
59#endif // ROBOT_H
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
chrono::ChVector3d position() noexcept
Definition robot.h:46
void add_to_sys(chrono::ChSystemNSC &sys) const
Definition chrono_smc_system.cpp:126
void reset()
Definition chrono_smc_system.cpp:143
void set_speed(real_t speed)
Definition chrono_smc_system.cpp:137
void build(std::shared_ptr< chrono::ChContactMaterialNSC > material)
Definition chrono_smc_system.cpp:111
double real_t
real_t
Definition bitsim_types.h:20
Definition chrono_smc_system.cpp:17
const real_t WHEEL_RADIUS
Definition robot.h:16
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)
Definition chrono_smc_system.cpp:99
const real_t CHASSIS_HEIGHT
Definition robot.h:17
const real_t WHEEL_WIDTH
Definition robot.h:18
const real_t CASTER_RADIUS
Definition robot.h:19
auto build_wheel(std::shared_ptr< chrono::ChContactMaterialNSC > material, const chrono::ChVector3d &pos)
Definition chrono_smc_system.cpp:63