|
bitsim
Model, simulate, estimate and control robots in C++
|
A simulated ultrasonic sensor: it casts rays into the Chrono world. More...
#include <chrono_ultrasound_backend.h>


Public Member Functions | |
| CHRONO_UltrasonicBackend () | |
| Constructor. Attach a body with set_chrono_body() before reading; the system is the one the body is in. | |
| CHRONO_UltrasonicBackend (chrono::ChSystem &sys, std::shared_ptr< chrono::ChBody > body) | |
| Constructor. | |
| std::vector< real_t > | read_values () override |
| Read the distance to the nearest obstacle. | |
| void | load (const nlohmann::json &j) override |
| Read the settings, see RangeSensorBackendBase::load(). Also yaw, where the sensor points about the body's z axis [deg], 0 ahead; and reads, all optional: | |
| void | set_position (const chrono::ChVector3d &pos) |
| Set the position of the sensor on its body. | |
| const chrono::ChVector3d & | position () const |
| void | set_beam (real_t beam_angle, uint_t n_rays) |
| Set the cone the sensor hears echoes from. | |
| real_t | beam_angle () const noexcept |
| uint_t | n_rays () const noexcept |
| 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, looks ahead and pi behind. | |
| real_t | yaw () const noexcept |
| Public Member Functions inherited from bitsim::sensors::backends::RangeSensorBackendBase | |
| real_t | max_distance () const noexcept |
| void | set_max_distance (real_t max_distance) noexcept |
| Set the maximum distance the range sensor can read. | |
| real_t | min_distance () const noexcept |
| void | set_min_distance (real_t min_distance) noexcept |
| Set the minimum distance the range sensor can read. | |
| virtual std::string | sensor_units () const |
| void | set_sensor_units (const std::string &units) |
| Set the sensor units. | |
| void | load_from_json (const std::string &filename) override |
| Read the settings from a JSON file, see load(). | |
| virtual void | add_visual_shape (const std::unordered_map< std::string, std::any > &shape_properties) override |
| Add a visual shape for the sensor in order to be visualized with Irrlicht. Concrete classes may choose not to implement this. In this case the sensor will not be visible. | |
| Public Member Functions inherited from bitsim::sensors::backends::SensorBackendBase | |
| virtual | ~SensorBackendBase ()=default |
| Destructor. | |
| real_t | sampling_period () const noexcept |
| Returns the sampling period of the sensor. | |
| void | set_sampling_period (real_t period) |
| Set the sampling period of the backend. | |
| uint_t | n_read_values () const noexcept |
| std::string | backend_type_str () const noexcept |
| Return a string that specifies the type of the backend. | |
| void | set_chrono_body (std::shared_ptr< chrono::ChBody > body) |
| Set the pointer to the body that this sensor is attached. | |
Static Public Attributes | |
| static const std::string | BACKEND_TYPE = "SIMULATION" |
| The type of the backend. | |
Additional Inherited Members | |
| Static Public Member Functions inherited from bitsim::sensors::backends::RangeSensorBackendBase | |
| static std::shared_ptr< RangeSensorBackendBase > | create (const std::string &backend_type) |
| Create a backend by the name a robot file gives it. | |
| Protected Member Functions inherited from bitsim::sensors::backends::RangeSensorBackendBase | |
| RangeSensorBackendBase (const std::string &backend_type) | |
| Constructor. | |
| real_t | clamp_distance (real_t distance) const noexcept |
| Protected Member Functions inherited from bitsim::sensors::backends::SensorBackendBase | |
| SensorBackendBase (const std::string &backend_type) | |
| Constructor. | |
| void | set_n_read_values (uint_t n) noexcept |
| Set how many values the implementation returns. | |
| Protected Attributes inherited from bitsim::sensors::backends::SensorBackendBase | |
| std::shared_ptr< chrono::ChBody > | body_ {nullptr} |
| The body on which the sensor sits. | |
A simulated ultrasonic sensor: it casts rays into the Chrono world.
The sensor sits at position() on the body it is attached to and looks along the body's x axis. A real ultrasonic sensor hears echoes from a cone, about 15 degrees wide for an HC-SR04, so the backend casts n_rays() rays fanned across beam_angle() in the body's x-y plane and reports the nearest hit. With one ray, the default, it looks straight ahead only.
Only bodies with collision enabled reflect the rays. The body the sensor is attached to never does.
| bitsim::sensors::backends::CHRONO_UltrasonicBackend::CHRONO_UltrasonicBackend | ( | ) |
Constructor. Attach a body with set_chrono_body() before reading; the system is the one the body is in.
| bitsim::sensors::backends::CHRONO_UltrasonicBackend::CHRONO_UltrasonicBackend | ( | chrono::ChSystem & | sys, |
| std::shared_ptr< chrono::ChBody > | body ) |
Constructor.
| sys | The system the rays are cast in |
| body | The body the sensor is attached to |
|
inlinenoexcept |
|
overridevirtual |
Read the settings, see RangeSensorBackendBase::load(). Also yaw, where the sensor points about the body's z axis [deg], 0 ahead; and reads, all optional:
Reimplemented from bitsim::sensors::backends::RangeSensorBackendBase.
|
inlinenoexcept |
|
inline |
|
overridevirtual |
Read the distance to the nearest obstacle.
| std::logic_error | If no body is attached, or the body is in no system |
Implements bitsim::sensors::backends::SensorBackendBase.
| void bitsim::sensors::backends::CHRONO_UltrasonicBackend::set_beam | ( | real_t | beam_angle, |
| uint_t | n_rays ) |
Set the cone the sensor hears echoes from.
| beam_angle | The full width of the cone [rad] |
| n_rays | How many rays to cast across it, at least 1 |
|
inline |
Set the position of the sensor on its body.
| pos |
|
inlinenoexcept |
Point the sensor yaw [rad] about the body's z axis from its x axis; 0, the default, looks ahead and pi behind.
|
inlinenoexcept |
|
static |
The type of the backend.