bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
infrared_backend_base.h
Go to the documentation of this file.
1#ifndef BITSIM_SENSORS_BACKENDS_INFRARED_BACKEND_BASE_H
2#define BITSIM_SENSORS_BACKENDS_INFRARED_BACKEND_BASE_H
3
4#include "bitsim/bitsim_config.h"
6#include "bitsim/extern/nlohmann/json/json.hpp"
8
9#include <array>
10#include <memory>
11#include <string>
12#include <vector>
13
14#ifdef BITSIM_CHRONO
15#include <any>
16#include <unordered_map>
17#endif
18
19namespace bitsim
20{
21namespace sensors::backends
22{
23
37{
38 public:
42 using Position = std::array<real_t, 3>;
43
51 static std::shared_ptr<InfraredBackendBase> create(const std::string &backend_type);
52
57 const std::vector<Position> &elements() const noexcept { return elements_; }
58
63 void set_elements(const std::vector<Position> &elements);
64
68 uint_t n_elements() const noexcept { return elements_.size(); }
69
73 std::string sensor_units() const override { return "REFLECTANCE"; }
74
85 virtual void load(const nlohmann::json &j);
86
90 void load_from_json(const std::string &filename) override;
91
92#ifdef BITSIM_CHRONO
97 void
98 add_visual_shape(const std::unordered_map<std::string, std::any> &shape_properties) override;
99#endif
100
101 protected:
102 explicit InfraredBackendBase(const std::string &backend_type);
103
104 private:
105 std::vector<Position> elements_;
106};
107
108inline InfraredBackendBase::InfraredBackendBase(const std::string &backend_type)
109 : SensorBackendBase(backend_type)
110{
111 set_elements({Position{0.0, 0.0, 0.0}});
112}
113
114} // namespace sensors::backends
115} // namespace bitsim
116
117#endif // BITSIM_SENSORS_BACKENDS_INFRARED_BACKEND_BASE_H
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
void load_from_json(const std::string &filename) override
Read the settings from a JSON file, see load().
Definition infrared_backend_base.cpp:77
void set_elements(const std::vector< Position > &elements)
Set the positions of the elements on the body. One value is read per element.
Definition infrared_backend_base.cpp:43
static std::shared_ptr< InfraredBackendBase > create(const std::string &backend_type)
Create a backend by the name a robot file gives it.
Definition infrared_backend_base.cpp:19
std::string sensor_units() const override
Definition infrared_backend_base.h:73
uint_t n_elements() const noexcept
Definition infrared_backend_base.h:68
void add_visual_shape(const std::unordered_map< std::string, std::any > &shape_properties) override
Draw each element as a small box on the body. The properties are x_length, y_length,...
Definition infrared_backend_base.cpp:88
virtual void load(const nlohmann::json &j)
Read the settings of the sensor from its section of a robot or sensor file:
Definition infrared_backend_base.cpp:53
const std::vector< Position > & elements() const noexcept
Definition infrared_backend_base.h:57
std::array< real_t, 3 > Position
The position of an element on the robot's body [m].
Definition infrared_backend_base.h:42
InfraredBackendBase(const std::string &backend_type)
Definition infrared_backend_base.h:108
SensorBackendBase(const std::string &backend_type)
Constructor.
Definition sensor_backend_base.h:140
Definition camera_backend_base.h:19
Definition dc_motor_backend_base.h:9
std::size_t uint_t
uint_t
Definition bitsim_types.h:40