JaiaBot 3.0.0
JaiaBot micro-AUV software
Loading...
Searching...
No Matches
jaiabot::utils Namespace Reference

Classes

struct  Point
 Simple 2D point used to represent a parsed data row during downsampling. More...
class  HampelFilter
struct  PolarCoordinate
class  RollingStatsAccumulator
 Maintains a circular buffer of n samples of some boost::units::quantity and allows for computation of statistics on the contents of this buffer. More...

Enumerations

enum class  VarianceNorm { UNBIASED , BIASED }

Functions

std::vector< size_t > downsampleIndices (const std::vector< Point > &data, size_t target_size)
 Selects representative point indices while preserving the overall curve shape.
bool parseDataRowValues (const std::string &line, std::vector< double > &values_out, size_t min_value_count=2)
 Parses a data row into its numeric columns after the integer row index.
bool parseDataRow (const std::string &line, Point &point_out)
 Parses a data row into a point using the first and last numeric columns.
size_t joinedSizeBytes (const std::vector< std::string > &lines)
 Computes the serialized byte size of lines joined with newline separators.
std::vector< std::string > buildOutputWithSelectedRows (const std::vector< std::string > &input_lines, const std::vector< size_t > &data_line_positions, const std::vector< size_t > &selected_row_indices)
 Rebuilds the output while preserving metadata lines and selected data rows.
template<typename XSelector, typename YSelector>
std::vector< std::string > downsampleDatasetToMaxBytes (const std::vector< std::string > &input_lines, size_t max_bytes, size_t min_value_count, XSelector x_selector, YSelector y_selector)
 Downsamples data rows to fit within a maximum serialized byte budget.
jaiabot::protobuf::GeographicCoordinate calculate_position_from_offset (const goby::util::UTMGeodesy &geodesy, const jaiabot::protobuf::GeographicCoordinate &start_location, double distance_meters, double heading_degrees)
PolarCoordinate convert_cartesian_to_polar (double start_x, double start_y, double end_x, double end_y)
jaiabot::protobuf::GeographicCoordinate find_dive_end_location (const goby::util::UTMGeodesy &geodesy, double duration_to_acquire_gps, const jaiabot::protobuf::GeographicCoordinate &drift_start_location, double drift_speed, double drift_heading)
float haversine (float lat1, float lon1, float lat2, float lon2)
float calculateHeading (double sx, double sy, double ex, double ey)
template<typename Quantity>
std::ostream & operator<< (std::ostream &os, const RollingStatsAccumulator< Quantity > &acc)

Enumeration Type Documentation

◆ VarianceNorm

enum class jaiabot::utils::VarianceNorm
strong
Enumerator
UNBIASED 
BIASED 

Definition at line 19 of file stats.h.

Function Documentation

◆ buildOutputWithSelectedRows()

std::vector< std::string > jaiabot::utils::buildOutputWithSelectedRows ( const std::vector< std::string > & input_lines,
const std::vector< size_t > & data_line_positions,
const std::vector< size_t > & selected_row_indices )
inline

Rebuilds the output while preserving metadata lines and selected data rows.

Non-data lines are always retained. Data lines are kept only when their position in the parsed data-row sequence is listed in selected_row_indices.

Parameters
input_linesOriginal input lines.
data_line_positionsPositions of parsed data rows within input_lines.
selected_row_indicesIndices of data rows to keep.
Returns
Filtered output lines with metadata preserved.

Definition at line 235 of file downsample.h.

◆ calculate_position_from_offset()

jaiabot::protobuf::GeographicCoordinate jaiabot::utils::calculate_position_from_offset ( const goby::util::UTMGeodesy & geodesy,
const jaiabot::protobuf::GeographicCoordinate & start_location,
double distance_meters,
double heading_degrees )
inline

Definition at line 21 of file mission_manager_utils.h.

◆ calculateHeading()

float jaiabot::utils::calculateHeading ( double sx,
double sy,
double ex,
double ey )
inline

Definition at line 123 of file mission_manager_utils.h.

◆ convert_cartesian_to_polar()

PolarCoordinate jaiabot::utils::convert_cartesian_to_polar ( double start_x,
double start_y,
double end_x,
double end_y )
inline

Definition at line 57 of file mission_manager_utils.h.

◆ downsampleDatasetToMaxBytes()

template<typename XSelector, typename YSelector>
std::vector< std::string > jaiabot::utils::downsampleDatasetToMaxBytes ( const std::vector< std::string > & input_lines,
size_t max_bytes,
size_t min_value_count,
XSelector x_selector,
YSelector y_selector )
inline

Downsamples data rows to fit within a maximum serialized byte budget.

Metadata lines are preserved, while parsed data rows are reduced by binary searching for the largest representative subset whose serialized size does not exceed max_bytes. The x and y coordinates are selected from each parsed row via caller-provided selectors.

Each data row is expected to begin with an integer row index followed by numeric values. The selectors receive the numeric values after that index, so they can map arbitrary columns to x/y coordinates without needing to parse the row themselves.

Since the selectors index those values directly, min_value_count must cover the widest column they read; narrower rows are left as metadata instead of being selected on.

Template Parameters
XSelectorCallable with signature compatible with double(const std::vector<double>& values).
YSelectorCallable with signature compatible with double(const std::vector<double>& values).
Parameters
input_linesFull input dataset, including metadata and data rows.
max_bytesMaximum allowed serialized size for the returned dataset.
min_value_countMinimum numeric columns a data row must contain.
x_selectorSelects the x coordinate from parsed numeric columns.
y_selectorSelects the y coordinate from parsed numeric columns.
Returns
A dataset constrained to the requested byte budget.

Definition at line 299 of file downsample.h.

◆ downsampleIndices()

std::vector< size_t > jaiabot::utils::downsampleIndices ( const std::vector< Point > & data,
size_t target_size )
inline

Selects representative point indices while preserving the overall curve shape.

Uses bucketed triangle-area sampling to retain the first and last points and choose intermediate points that best capture local changes in the dataset.

Parameters
dataOrdered input points to sample.
target_sizeNumber of points to retain.
Returns
Indices into data for the selected representative points.

Definition at line 55 of file downsample.h.

◆ find_dive_end_location()

jaiabot::protobuf::GeographicCoordinate jaiabot::utils::find_dive_end_location ( const goby::util::UTMGeodesy & geodesy,
double duration_to_acquire_gps,
const jaiabot::protobuf::GeographicCoordinate & drift_start_location,
double drift_speed,
double drift_heading )
inline

Definition at line 83 of file mission_manager_utils.h.

◆ haversine()

float jaiabot::utils::haversine ( float lat1,
float lon1,
float lat2,
float lon2 )
inline

Definition at line 99 of file mission_manager_utils.h.

◆ joinedSizeBytes()

size_t jaiabot::utils::joinedSizeBytes ( const std::vector< std::string > & lines)
inline

Computes the serialized byte size of lines joined with newline separators.

Parameters
linesLines to measure.
Returns
Total byte count including newline separators between lines.

Definition at line 208 of file downsample.h.

◆ operator<<()

template<typename Quantity>
std::ostream & jaiabot::utils::operator<< ( std::ostream & os,
const RollingStatsAccumulator< Quantity > & acc )
inline

Definition at line 28 of file stats.h.

◆ parseDataRow()

bool jaiabot::utils::parseDataRow ( const std::string & line,
Point & point_out )
inline

Parses a data row into a point using the first and last numeric columns.

Parameters
lineInput row to parse.
point_outParsed point written on success.
Returns
True when the row matches the expected shape and contains enough numeric data.

Definition at line 188 of file downsample.h.

◆ parseDataRowValues()

bool jaiabot::utils::parseDataRowValues ( const std::string & line,
std::vector< double > & values_out,
size_t min_value_count = 2 )
inline

Parses a data row into its numeric columns after the integer row index.

The row is expected to begin with an integer index followed by at least min_value_count numeric values.

Parameters
lineInput row to parse.
values_outParsed numeric columns written on success.
min_value_countMinimum numeric columns the row must contain to be accepted.
Returns
True when the row matches the expected shape and contains enough numeric data.

Definition at line 157 of file downsample.h.