PX4 Firmware
PX4 Autopilot Software http://px4.io
TERARANGER Class Reference
Inheritance diagram for TERARANGER:
Collaboration diagram for TERARANGER:

Public Member Functions

 TERARANGER (const int bus=TERARANGER_BUS_DEFAULT, const uint8_t rotation=distance_sensor_s::ROTATION_DOWNWARD_FACING, const int address=TERARANGER_ONE_BASEADDR)
 
virtual ~TERARANGER ()
 
virtual int init () override
 
void print_info ()
 Diagnostics - print some basic information about the driver. More...
 
void start ()
 Initialise the automatic measurement state machine and start it. More...
 
void stop ()
 Stop the automatic measurement state machine. More...
 

Protected Member Functions

virtual int probe () override
 

Private Member Functions

int collect ()
 Collects the most recent sensor measurement data from the i2c bus. More...
 
int measure ()
 Sends an i2c measure command to the sensors. More...
 
int probe_address (const uint8_t address)
 Test whether the device supported by the driver is present at a specific address. More...
 
void Run () override
 Perform a poll cycle; collect from the previous measurement and start a new one. More...
 

Private Attributes

bool _collect_phase {false}
 
int _orb_class_instance {-1}
 
uint8_t _orientation {0}
 
float _max_distance {0}
 
float _min_distance {0}
 
orb_advert_t _distance_sensor_topic {nullptr}
 
perf_counter_t _comms_errors {perf_alloc(PC_COUNT, "tr1_comm_err")}
 
perf_counter_t _sample_perf {perf_alloc(PC_ELAPSED, "tr1_read")}
 

Detailed Description

Definition at line 80 of file teraranger.cpp.

Constructor & Destructor Documentation

◆ TERARANGER()

TERARANGER::TERARANGER ( const int  bus = TERARANGER_BUS_DEFAULT,
const uint8_t  rotation = distance_sensor_s::ROTATION_DOWNWARD_FACING,
const int  address = TERARANGER_ONE_BASEADDR 
)

Definition at line 194 of file teraranger.cpp.

Referenced by teraranger::start_bus().

Here is the caller graph for this function:

◆ ~TERARANGER()

TERARANGER::~TERARANGER ( )
virtual

Definition at line 203 of file teraranger.cpp.

References _comms_errors, _distance_sensor_topic, _sample_perf, orb_unadvertise(), perf_free(), and stop().

Here is the call graph for this function:

Member Function Documentation

◆ collect()

int TERARANGER::collect ( )
private

Collects the most recent sensor measurement data from the i2c bus.

Definition at line 219 of file teraranger.cpp.

References _collect_phase, _comms_errors, _distance_sensor_topic, _max_distance, _min_distance, _orientation, _sample_perf, crc8(), distance_sensor_s::current_distance, f(), hrt_absolute_time(), measure(), ORB_ID, ORB_PRIO_DEFAULT, orb_publish_auto(), perf_begin(), perf_count(), and perf_end().

Referenced by Run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

int TERARANGER::init ( )
overridevirtual

Definition at line 270 of file teraranger.cpp.

References _max_distance, _min_distance, ToneAlarmInterface::init(), OK, param_find(), param_get(), TERARANGER_EVO_3M_MAX_DISTANCE, TERARANGER_EVO_3M_MIN_DISTANCE, TERARANGER_EVO_600HZ_MAX_DISTANCE, TERARANGER_EVO_600HZ_MIN_DISTANCE, TERARANGER_EVO_60M_MAX_DISTANCE, TERARANGER_EVO_60M_MIN_DISTANCE, TERARANGER_EVO_BASEADDR, TERARANGER_ONE_BASEADDR, TERARANGER_ONE_MAX_DISTANCE, and TERARANGER_ONE_MIN_DISTANCE.

Referenced by teraranger::start_bus().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ measure()

int TERARANGER::measure ( )
private

Sends an i2c measure command to the sensors.

Definition at line 358 of file teraranger.cpp.

References _collect_phase, _comms_errors, perf_count(), and TERARANGER_MEASURE_REG.

Referenced by collect(), and probe().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_info()

void TERARANGER::print_info ( )

Diagnostics - print some basic information about the driver.

Definition at line 397 of file teraranger.cpp.

References _comms_errors, _sample_perf, perf_print_counter(), and TERARANGER_MEASUREMENT_INTERVAL.

Referenced by teraranger::status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ probe()

int TERARANGER::probe ( )
overrideprotectedvirtual

Definition at line 375 of file teraranger.cpp.

References measure(), OK, TERARANGER_WHO_AM_I_REG, and TERARANGER_WHO_AM_I_REG_VAL.

Here is the call graph for this function:

◆ probe_address()

int TERARANGER::probe_address ( const uint8_t  address)
private

Test whether the device supported by the driver is present at a specific address.

Parameters
addressThe I2C bus address to probe.
Returns
True if the device is present.

◆ Run()

void TERARANGER::Run ( )
overrideprivate

Perform a poll cycle; collect from the previous measurement and start a new one.

Definition at line 405 of file teraranger.cpp.

References collect().

Here is the call graph for this function:

◆ start()

void TERARANGER::start ( )

Initialise the automatic measurement state machine and start it.

Note
This function is called at open and error time. It might make sense to make it more aggressive about resetting the bus in case of errors.

Definition at line 412 of file teraranger.cpp.

References _collect_phase, and TERARANGER_MEASUREMENT_INTERVAL.

Referenced by teraranger::start_bus().

Here is the caller graph for this function:

◆ stop()

void TERARANGER::stop ( )

Stop the automatic measurement state machine.

Definition at line 421 of file teraranger.cpp.

Referenced by ~TERARANGER().

Here is the caller graph for this function:

Member Data Documentation

◆ _collect_phase

bool TERARANGER::_collect_phase {false}
private

Definition at line 140 of file teraranger.cpp.

Referenced by collect(), measure(), and start().

◆ _comms_errors

perf_counter_t TERARANGER::_comms_errors {perf_alloc(PC_COUNT, "tr1_comm_err")}
private

Definition at line 151 of file teraranger.cpp.

Referenced by collect(), measure(), print_info(), and ~TERARANGER().

◆ _distance_sensor_topic

orb_advert_t TERARANGER::_distance_sensor_topic {nullptr}
private

Definition at line 149 of file teraranger.cpp.

Referenced by collect(), and ~TERARANGER().

◆ _max_distance

float TERARANGER::_max_distance {0}
private

Definition at line 146 of file teraranger.cpp.

Referenced by collect(), and init().

◆ _min_distance

float TERARANGER::_min_distance {0}
private

Definition at line 147 of file teraranger.cpp.

Referenced by collect(), and init().

◆ _orb_class_instance

int TERARANGER::_orb_class_instance {-1}
private

Definition at line 142 of file teraranger.cpp.

◆ _orientation

uint8_t TERARANGER::_orientation {0}
private

Definition at line 144 of file teraranger.cpp.

Referenced by collect().

◆ _sample_perf

perf_counter_t TERARANGER::_sample_perf {perf_alloc(PC_ELAPSED, "tr1_read")}
private

Definition at line 152 of file teraranger.cpp.

Referenced by collect(), print_info(), and ~TERARANGER().


The documentation for this class was generated from the following file: