bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
irrlicht_scene.h
Go to the documentation of this file.
1#ifndef BITSIM_UTILS_RENDER_IRRLICHT_SCENE_H
2#define BITSIM_UTILS_RENDER_IRRLICHT_SCENE_H
3
11
12#include "bitsim/bitsim_config.h"
13
14#if defined(BITSIM_IRRLICHT) && defined(BITSIM_CHRONO)
15
16#include "bitsim/bitsim_types.h"
17
18#include <chrono/physics/ChBody.h>
19#include <chrono_irrlicht/ChVisualSystemIrrlicht.h>
20
21#include <string>
22#include <vector>
23
24namespace bitsim
25{
26namespace utils
27{
28namespace render
29{
30
39void add_floor_texture(chrono::ChBody &ground, real_t width, real_t height, real_t z,
40 const std::string &texture);
41
47class Trail
48{
49 public:
54 explicit Trail(real_t min_step = 0.02, real_t height = 0.01);
55
59 void add(real_t x, real_t y);
60
65 void add(const chrono::ChVector3d &p);
66
70 void draw(chrono::irrlicht::ChVisualSystemIrrlicht &vis, const chrono::ChColor &colour,
71 real_t thickness = 2.0) const;
72
73 std::size_t size() const noexcept { return points_.size(); }
74 void clear() { points_.clear(); }
75
76 private:
77 real_t min_step_;
78 real_t height_;
79 std::vector<chrono::ChVector3d> points_;
80};
81
88{
89 public:
97 InsetCamera(chrono::irrlicht::ChVisualSystemIrrlicht &vis, real_t fov, int width, int height,
98 const std::string &label = "robot camera");
99
104 void draw(const chrono::ChVector3d &eye, const chrono::ChVector3d &target);
105
106 private:
107 chrono::irrlicht::ChVisualSystemIrrlicht &vis_;
108 chrono::irrlicht::RTSCamera *camera_{nullptr};
109 irr::scene::ICameraSceneNode *main_camera_{nullptr};
110 int width_;
111 int height_;
112 std::wstring label_;
113};
114
121{
122 public:
127 FrameRecorder(const std::string &dir, real_t rate = 10.0);
128
133 void record(chrono::irrlicht::ChVisualSystemIrrlicht &vis, real_t time);
134
135 bool is_recording() const noexcept { return !dir_.empty(); }
136 uint_t n_recorded() const noexcept { return n_recorded_; }
137
138 private:
139 std::string dir_;
140 real_t rate_;
141 real_t next_{0.0};
142 uint_t n_recorded_{0};
143};
144
149void draw_status_bar(chrono::irrlicht::ChVisualSystemIrrlicht &vis, const std::string &text);
150
151} // namespace render
152} // namespace utils
153} // namespace bitsim
154
155#endif
156#endif // BITSIM_UTILS_RENDER_IRRLICHT_SCENE_H
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
void record(chrono::irrlicht::ChVisualSystemIrrlicht &vis, real_t time)
Write the window if it is time to, at simulation time time [s]. Call this after EndScene()....
Definition irrlicht_scene.cpp:129
bool is_recording() const noexcept
Definition irrlicht_scene.h:135
uint_t n_recorded() const noexcept
Definition irrlicht_scene.h:136
FrameRecorder(const std::string &dir, real_t rate=10.0)
Definition irrlicht_scene.cpp:121
void draw(const chrono::ChVector3d &eye, const chrono::ChVector3d &target)
Render the scene into the corner, from eye looking at target, both in world coordinates....
Definition irrlicht_scene.cpp:94
InsetCamera(chrono::irrlicht::ChVisualSystemIrrlicht &vis, real_t fov, int width, int height, const std::string &label="robot camera")
Definition irrlicht_scene.cpp:77
void clear()
Definition irrlicht_scene.h:74
void add(real_t x, real_t y)
Add a point, if it is further than min_step from the last one.
Definition irrlicht_scene.cpp:48
std::size_t size() const noexcept
Definition irrlicht_scene.h:73
Trail(real_t min_step=0.02, real_t height=0.01)
Definition irrlicht_scene.cpp:46
void draw(chrono::irrlicht::ChVisualSystemIrrlicht &vis, const chrono::ChColor &colour, real_t thickness=2.0) const
Draw the path. Call this between Render() and EndScene().
Definition irrlicht_scene.cpp:64
Definition irrlicht_scene.cpp:20
void add_floor_texture(chrono::ChBody &ground, real_t width, real_t height, real_t z, const std::string &texture)
Put a picture on the ground: a rectangle of width x height [m] centred on the origin of the world,...
Definition irrlicht_scene.cpp:22
void draw_status_bar(chrono::irrlicht::ChVisualSystemIrrlicht &vis, const std::string &text)
Write text on a light bar along the bottom of the window. Call this between Render() and EndScene().
Definition irrlicht_scene.cpp:151
Definition bitsim_utils.h:11
Definition dc_motor_backend_base.h:9
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
double real_t
real_t
Definition bitsim_types.h:20