PX4 Firmware
PX4 Autopilot Software http://px4.io
|
Public Member Functions | |
MB12XX (const int bus=MB12XX_BUS_DEFAULT) | |
virtual | ~MB12XX () |
virtual int | init () override |
void | print_info () |
Diagnostics - print some basic information about the driver. More... | |
int | set_address (const uint8_t address=MB12XX_BASE_ADDR) |
Sets a new device address. More... | |
void | start () |
Initialise the automatic measurement state machine and start it. More... | |
void | stop () |
Stop the automatic measurement state machine. More... | |
Private Member Functions | |
int | collect () |
Collects the most recent sensor measurement data from the i2c bus. More... | |
int | get_sensor_rotation (const size_t index) |
Gets the current sensor rotation value. More... | |
int | measure () |
Sends an i2c measure command to start the next sonar ping. More... | |
void | Run () override |
Perform a poll cycle; collect from the previous measurement and start a new one. More... | |
DEFINE_PARAMETERS ((ParamInt< px4::params::SENS_EN_MB12XX >) _p_sensor_enabled,(ParamInt< px4::params::SENS_MB12_0_ROT >) _p_sensor0_rot,(ParamInt< px4::params::SENS_MB12_1_ROT >) _p_sensor1_rot,(ParamInt< px4::params::SENS_MB12_2_ROT >) _p_sensor2_rot,(ParamInt< px4::params::SENS_MB12_3_ROT >) _p_sensor3_rot,(ParamInt< px4::params::SENS_MB12_4_ROT >) _p_sensor4_rot,(ParamInt< px4::params::SENS_MB12_5_ROT >) _p_sensor5_rot,(ParamInt< px4::params::SENS_MB12_6_ROT >) _p_sensor6_rot,(ParamInt< px4::params::SENS_MB12_7_ROT >) _p_sensor7_rot,(ParamInt< px4::params::SENS_MB12_8_ROT >) _p_sensor8_rot,(ParamInt< px4::params::SENS_MB12_9_ROT >) _p_sensor9_rot,(ParamInt< px4::params::SENS_MB12_10_ROT >) _p_sensor10_rot,(ParamInt< px4::params::SENS_MB12_11_ROT >) _p_sensor11_rot) | |
Private Attributes | |
px4::Array< uint8_t, RANGE_FINDER_MAX_SENSORS > | _sensor_addresses {} |
px4::Array< uint8_t, RANGE_FINDER_MAX_SENSORS > | _sensor_rotations {} |
int | _measure_interval {MB12XX_MEASURE_INTERVAL} |
int | _orb_class_instance {-1} |
size_t | _sensor_index {0} |
size_t | _sensor_count {0} |
orb_advert_t | _distance_sensor_topic {nullptr} |
perf_counter_t | _comms_error {perf_alloc(PC_ELAPSED, "mb12xx_comms_error")} |
perf_counter_t | _sample_perf {perf_alloc(PC_COUNT, "mb12xx_sample_perf")} |
Definition at line 91 of file mb12xx.cpp.
MB12XX::MB12XX | ( | const int | bus = MB12XX_BUS_DEFAULT | ) |
Definition at line 181 of file mb12xx.cpp.
Referenced by mb12xx::start_bus().
|
virtual |
Definition at line 188 of file mb12xx.cpp.
References _comms_error, _distance_sensor_topic, _sample_perf, orb_unadvertise(), perf_free(), and stop().
|
private |
Collects the most recent sensor measurement data from the i2c bus.
Definition at line 204 of file mb12xx.cpp.
References _comms_error, _distance_sensor_topic, _sample_perf, _sensor_addresses, _sensor_count, _sensor_index, _sensor_rotations, distance_sensor_s::current_distance, f(), hrt_absolute_time(), distance_sensor_s::id, distance_sensor_s::max_distance, MB12XX_MAX_DISTANCE, MB12XX_MIN_DISTANCE, measure(), distance_sensor_s::min_distance, ORB_ID, ORB_PRIO_DEFAULT, orb_publish_auto(), distance_sensor_s::orientation, perf_begin(), perf_count(), perf_end(), distance_sensor_s::signal_quality, distance_sensor_s::timestamp, distance_sensor_s::type, and distance_sensor_s::variance.
Referenced by Run().
|
private |
|
private |
Gets the current sensor rotation value.
Definition at line 256 of file mb12xx.cpp.
Referenced by init().
|
overridevirtual |
Definition at line 288 of file mb12xx.cpp.
References _measure_interval, _sensor_addresses, _sensor_count, _sensor_rotations, get_sensor_rotation(), ToneAlarmInterface::init(), MB12XX_BASE_ADDR, MB12XX_INTERVAL_BETWEEN_SUCCESIVE_FIRES, MB12XX_MIN_ADDR, measure(), OK, and RANGE_FINDER_MAX_SENSORS.
Referenced by mb12xx::start_bus().
|
private |
Sends an i2c measure command to start the next sonar ping.
Definition at line 337 of file mb12xx.cpp.
References MB12XX_TAKE_RANGE_REG.
Referenced by collect(), and init().
void MB12XX::print_info | ( | ) |
Diagnostics - print some basic information about the driver.
Definition at line 347 of file mb12xx.cpp.
References _comms_error, _measure_interval, _sample_perf, _sensor_addresses, _sensor_count, and perf_print_counter().
Referenced by mb12xx::status().
|
overrideprivate |
Perform a poll cycle; collect from the previous measurement and start a new one.
Definition at line 359 of file mb12xx.cpp.
References collect().
int MB12XX::set_address | ( | const uint8_t | address = MB12XX_BASE_ADDR | ) |
Sets a new device address.
address | The new sensor address to be set: 200-224 even addresses only. |
Definition at line 368 of file mb12xx.cpp.
References _sensor_count, MB12XX_SET_ADDRESS_1, and MB12XX_SET_ADDRESS_2.
Referenced by mb12xx::set_address().
void MB12XX::start | ( | ) |
Initialise the automatic measurement state machine and start it.
Definition at line 399 of file mb12xx.cpp.
References _measure_interval.
Referenced by mb12xx::reset(), and mb12xx::start_bus().
void MB12XX::stop | ( | ) |
Stop the automatic measurement state machine.
Definition at line 409 of file mb12xx.cpp.
Referenced by mb12xx::reset(), and ~MB12XX().
|
private |
Definition at line 161 of file mb12xx.cpp.
Referenced by collect(), print_info(), and ~MB12XX().
|
private |
Definition at line 159 of file mb12xx.cpp.
|
private |
Definition at line 152 of file mb12xx.cpp.
Referenced by init(), print_info(), and start().
|
private |
Definition at line 153 of file mb12xx.cpp.
|
private |
Definition at line 162 of file mb12xx.cpp.
Referenced by collect(), print_info(), and ~MB12XX().
|
private |
Definition at line 149 of file mb12xx.cpp.
Referenced by collect(), init(), and print_info().
|
private |
Definition at line 157 of file mb12xx.cpp.
Referenced by collect(), init(), print_info(), and set_address().
|
private |
Definition at line 155 of file mb12xx.cpp.
Referenced by collect().
|
private |
Definition at line 150 of file mb12xx.cpp.