bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
chrono_ultrasound_backend.h
Go to the documentation of this file.
1#ifndef BITSIM_SENSORS_BACKENDS_CHRONO_ULTRASOUND_BACKEND_H
2#define BITSIM_SENSORS_BACKENDS_CHRONO_ULTRASOUND_BACKEND_H
3
4#include "bitsim/bitsim_config.h"
5
6#ifdef BITSIM_CHRONO
7
9
10#include <chrono/physics/ChBody.h>
11#include <chrono/physics/ChSystem.h>
12
13#include <memory>
14#include <string>
15
16namespace bitsim
17{
18namespace sensors::backends
19{
20
36{
37 public:
41 static const std::string BACKEND_TYPE;
42
48
54 CHRONO_UltrasonicBackend(chrono::ChSystem &sys, std::shared_ptr<chrono::ChBody> body);
55
62 std::vector<real_t> read_values() override;
63
73 void load(const nlohmann::json &j) override;
74
79 void set_position(const chrono::ChVector3d &pos) { position_ = pos; }
80
84 const chrono::ChVector3d &position() const { return position_; }
85
92
96 real_t beam_angle() const noexcept { return beam_angle_; }
97
101 uint_t n_rays() const noexcept { return n_rays_; }
102
107 void set_yaw(real_t yaw) noexcept { yaw_ = yaw; }
108
112 real_t yaw() const noexcept { return yaw_; }
113
114 private:
119 real_t cast_(const chrono::ChCollisionSystem &collision_sys, const chrono::ChVector3d &start,
120 const chrono::ChVector3d &dir) const;
121
125 chrono::ChSystem *sys_ptr_{nullptr};
126
130 chrono::ChVector3d position_{0.0, 0.0, 0.0};
131
132 real_t beam_angle_{0.0};
133 uint_t n_rays_{1};
134 real_t yaw_{0.0};
135};
136} // namespace sensors::backends
137} // namespace bitsim
138
139#endif
140#endif // BITSIM_SENSORS_BACKENDS_CHRONO_ULTRASOUND_BACKEND_H
real_t yaw() const noexcept
Definition chrono_ultrasound_backend.h:112
void set_position(const chrono::ChVector3d &pos)
Set the position of the sensor on its body.
Definition chrono_ultrasound_backend.h:79
void set_yaw(real_t yaw) noexcept
Point the sensor yaw [rad] about the body's z axis from its x axis; 0, the default,...
Definition chrono_ultrasound_backend.h:107
CHRONO_UltrasonicBackend()
Constructor. Attach a body with set_chrono_body() before reading; the system is the one the body is i...
Definition chrono_ultrasound_backend.cpp:33
void set_beam(real_t beam_angle, uint_t n_rays)
Set the cone the sensor hears echoes from.
Definition chrono_ultrasound_backend.cpp:45
uint_t n_rays() const noexcept
Definition chrono_ultrasound_backend.h:101
real_t beam_angle() const noexcept
Definition chrono_ultrasound_backend.h:96
void load(const nlohmann::json &j) override
Read the settings, see RangeSensorBackendBase::load(). Also yaw, where the sensor points about the bo...
Definition chrono_ultrasound_backend.cpp:55
static const std::string BACKEND_TYPE
The type of the backend.
Definition chrono_ultrasound_backend.h:41
const chrono::ChVector3d & position() const
Definition chrono_ultrasound_backend.h:84
std::vector< real_t > read_values() override
Read the distance to the nearest obstacle.
Definition chrono_ultrasound_backend.cpp:107
RangeSensorBackendBase(const std::string &backend_type)
Constructor.
Definition range_sensor_backend_base.h:128
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
double real_t
real_t
Definition bitsim_types.h:20