bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
bitsim::sensors::UltrasoundMessage Struct Reference

Models a message from an ultrasound sensor: More...

#include <ultrasound.h>

Inheritance diagram for bitsim::sensors::UltrasoundMessage:
Collaboration diagram for bitsim::sensors::UltrasoundMessage:

Public Member Functions

real_t metres () const

Static Public Member Functions

static std::optional< UltrasoundMessage > parse (const std::string &msg)
Static Public Member Functions inherited from bitsim::sensors::MessageBase
static auto unix_seconds_since_epoch (std::chrono::system_clock::time_point point)
static auto unix_milliseconds_since_epoch (std::chrono::system_clock::time_point point)
static std::chrono::system_clock::time_point parse_utc_timestamp (const std::string &ts)

Public Attributes

real_t distance {0.0}
 The distance as the message gives it, in unit_str.
std::string unit_str {"m"}
 The unit of distance.
Public Attributes inherited from bitsim::sensors::MessageBase
std::chrono::system_clock::time_point source_timestamp
std::chrono::system_clock::time_point received_timestamp {std::chrono::system_clock::now()}

Detailed Description

Models a message from an ultrasound sensor:

{"distance": 62.0, "unit": "cm", "timestamp": "2026-11-18 10:15:02"}

unit is m, cm or mm, m if it is missing. timestamp, in UTC, is optional.

Member Function Documentation

◆ metres()

real_t bitsim::sensors::UltrasoundMessage::metres ( ) const
Returns
The distance in metres

◆ parse()

std::optional< UltrasoundMessage > bitsim::sensors::UltrasoundMessage::parse ( const std::string & msg)
static
Returns
The message, or nothing if the text is not a valid message

Member Data Documentation

◆ distance

real_t bitsim::sensors::UltrasoundMessage::distance {0.0}

The distance as the message gives it, in unit_str.

◆ unit_str

std::string bitsim::sensors::UltrasoundMessage::unit_str {"m"}

The unit of distance.


The documentation for this struct was generated from the following files: