|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
29 #include "generated/airframe.h"
33 #if PERIODIC_TELEMETRY
35 #include "pprzlink/messages.h"
38 #ifdef SENSOR_SYNC_SEND
46 #ifndef AGL_LIDAR_TFMINI_I2C_ID
47 #define AGL_LIDAR_TFMINI_I2C_ID AGL_LIDAR_TFMINI_ID
51 #ifndef TFMINI_I2C_DEV
52 #error TFMINI_I2C_DEV needs to be defined
54 PRINT_CONFIG_VAR(TFMINI_I2C_DEV)
59 #ifndef TFMINI_I2C_ADDR
60 #define TFMINI_I2C_ADDR 0x10
63 #define TFMINI_I2C_REG_ADDR 0x26
64 #define TFMINI_I2C_REG_VAL 0x10
65 #define TFMINI_I2C_READ_ADDR 0x10
67 #define DISTANCE_MODE_REG_ADDR 0x50
68 #define DISTANCE_MODE_SHORT 0x00 // for 0.3-2m
69 #define DISTANCE_MODE_MIDDLE 0x03 // for 0.5-5m
70 #define DISTANCE_MODE_LONG 0x07 // for 1-12m
72 #define DETECTION_PATTERN_REG_ADDR 0x51
73 #define AUTOMATIC_DETECTION_PATTERN 0x00
74 #define FIXED_DETECTION_PATTERN 0x01
76 #define SETTING_OF_RANGE_LIMIT_REG_ADDR 0x55
77 #define RANGE_LIMIT_DISABLED 0x00
78 #define RANGE_LIMIT_ENABLED 0x01
80 #define RANGE_OUTPUT_LIMIT_THRESHOLD_REG_ADDR_L 0x56
81 #define RANGE_OUTPUT_LIMIT_THRESHOLD_REG_ADDR_H 0x57
85 #define LOWER_LIMIT_OF_SIGNAL_STRENGTH_THRESHOLD_REG_ADDR_L 0x58
86 #define LOWER_LIMIT_OF_SIGNAL_STRENGTH_THRESHOLD_REG_ADDR_H 0x59
90 #define UPPER_LIMIT_OF_SIGNAL_STRENGTH_THRESHOLD_REG_ADDR_L 0x5A
91 #define UPPER_LIMIT_OF_SIGNAL_STRENGTH_THRESHOLD_REG_ADDR_H 0x5B
94 #define OUTPUT_VALUE_OF_SIGNAL_STRENGTH_THRESHOLD_AT_THE_HIGHEST_POINT_REG_ADDR_L 0x5C
95 #define OUTPUT_VALUE_OF_SIGNAL_STRENGTH_THRESHOLD_AT_THE_HIGHEST_POINT_REG_ADDR_H 0x5D
98 #define UNIT_OF_DISTANCE_REG_ADDR 0x66
99 #define UNIT_OF_DISTANCE_MM 0x00 //output millimeter (mm)
100 #define UNIT_OF_DISTANCE_CM 0x01 // outout centimeter (cm)
102 #define SLAVE_ADDRESS_REG_ADDR 0x26 //settable 0x10~0x78 default 0x10
104 #define TRIGGER_MODE_REG_ADDR 0x27
105 #define USE_EXTERNAL_TRIGGER 0 // max100Hz default 0
106 #define EXTERNAL_TRIGGER_REG_ADDR 0x01 //set to 0x01 Command for one single measurement
108 #define DEVICE_RESET_ADDR 0x70 //setable 0x02 //All settings are reset to the default(excluding slave address and trigger mode)
111 #ifndef TFMINI_I2C_OFFSET
112 #define TFMINI_I2C_OFFSET 0.0f
116 #ifndef TFMINI_I2C_MIN_RANGE
117 #define TFMINI_I2C_MIN_RANGE 0.3f //Default for TFMini is 30cm(old firmware?), for TFMini Plus 10cm, sensors cannot measure a range closer than that
121 #ifndef TFMINI_I2C_MAX_RANGE
122 #define TFMINI_I2C_MAX_RANGE 6.0f //Reasonable default for it is maximum value for both inside and outside lighting conditions in day environment
133 pprz_msg_send_LIDAR(
trans,
dev, AC_ID,
156 #if PERIODIC_TELEMETRY
224 float gain = (float)fabs((
double)(cosf(phi) * cosf(theta)));
249 #ifdef SENSOR_SYNC_SEND
volatile uint8_t buf[I2C_BUF_LEN]
Transaction buffer With I2C_BUF_LEN number of bytes.
enum TFMiniI2CStatus status
#define TFMINI_I2C_OFFSET
Ranger offset value for what considered the distance should be zero, e.g. high landing gear to tarmac...
static void tfmini_i2c_send_lidar(struct transport_tx *trans, struct link_device *dev)
Send measured value and status information so it can be read back in e.g.
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
struct TFMiniI2C tfmini_i2c
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
bool update_agl
Do or don't update AGL ABI message.
@ I2CTransFailed
transaction failed
uint16_t raw_dist
raw non scaled value from sensor
bool i2c_blocking_transceive(struct i2c_periph *p, struct i2c_transaction *t, uint8_t s_addr, uint8_t len_w, uint16_t len_r)
Submit a write/read transaction and wait for it to complete.
Driver for the TFMini ranging device when used via I2C bus.
@ I2CTransSuccess
transaction successfully finished by I2C driver
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
uint16_t strength
strength of reflect signal, not implemented ATM
static const struct usb_device_descriptor dev
struct i2c_transaction trans
@ I2CTransRunning
transaction is currently ongoing
#define AGL_LIDAR_TFMINI_I2C_ID
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
enum I2CTransactionStatus status
Transaction status.
void tfmini_i2c_event(void)
Ranger event function Basically just check the progress of the transation to prevent overruns during ...
uint16_t f
Camera baseline, in meters (i.e. horizontal distance between the two cameras of the stereo setup)
Common code for AP and FBW telemetry.
void tfmini_i2c_init(void)
Set the default values at initialization.
#define TFMINI_I2C_MAX_RANGE
The maximum range for the device to be able to measure.
@ I2CTransPending
transaction is pending in queue
void tfmini_i2c_periodic(void)
Get the ranger current distance value.
@ I2CTransDone
transaction set to done by user level
float offset
offset to what one considers a zero distance to sensor in [m]
void tfmini_i2c_downlink(void)
#define TFMINI_I2C_MIN_RANGE
The minimum range for the device to be able to measure.
#define DefaultPeriodic
Set default periodic telemetry.
float dist
Sacled distance measured in [m].