PX4FLOW optical flow sensor connected over i2c bus
No detailed description...
Example for airframe file
Add to your firmware section: This example contains all possible configuration options, not all of them are mandatory!
<module name="px4flow_i2c">
b'<configure name="PX4FLOW_I2C_DEV" value="i2c2" />\n '
b'<configure name="PX4FLOW_I2C_ADDR" value="0x84" />\n '
b'<configure name="REQUEST_INT_FRAME" value="1" />\n '
b'<configure name="PX4FLOW_NOISE_STDDEV" value="1.0" />\n '
b'<configure name="USE_PX4FLOW_AGL" value="1" />\n '
b'<configure name="PX4FLOW_COMPENSATE_ROTATION" value="1" />\n '
b'<configure name="PX4FLOW_MEDIAN_LENGTH" value="7" />\n '
</module>
Module configuration options
Configure Options
- name:
PX4FLOW_I2C_DEV
value: i2c2
Description: I2C device to use for px4flow
- name:
PX4FLOW_I2C_ADDR
value: 0x84
Description: slave address of px4flow
- name:
REQUEST_INT_FRAME
value: 1
Description: request i2c_integral_frame, default TRUE
- name:
PX4FLOW_NOISE_STDDEV
value: 1.0
Description: standard deviation of the flow measurement (if known)
- name:
USE_PX4FLOW_AGL
value: 1
Description: update AGL measurements from onboard sonar
- name:
PX4FLOW_COMPENSATE_ROTATION
value: 1
Description: compensate AGL measurements for body rotation
- name:
PX4FLOW_MEDIAN_LENGTH
value: 7
Description: Median filter length for the px4flow measurements
Module functions
Init Functions
These initialization functions are called once on startup.
Periodic Functions
These functions are called periodically at the specified frequency from the module periodic loop.
- px4flow_i2c_downlink()
- Frequency in Hz: 4
- Autorun: FALSE
Periodic function is started by user command.
- px4flow_i2c_periodic()
- Frequency in Hz: 50
- Autorun: LOCK
Periodic function automatically starts after init and can't be stopped.
Files
Header Files
The following headers are automatically included in modules.h
Source Files
Raw px4flow_i2c.xml file:
<!DOCTYPE module SYSTEM "module.dtd">
<module name="px4flow_i2c" dir="optical_flow">
<doc>
<description>PX4FLOW optical flow sensor connected over i2c bus</description>
<configure name="PX4FLOW_I2C_DEV" value="i2c2" description="I2C device to use for px4flow"/>
<configure name="PX4FLOW_I2C_ADDR" value="0x84" description="slave address of px4flow"/>
<configure name="REQUEST_INT_FRAME" value="1" description="request i2c_integral_frame, default TRUE"/>
<configure name="PX4FLOW_NOISE_STDDEV" value="1.0" description="standard deviation of the flow measurement (if known)"/>
<configure name="USE_PX4FLOW_AGL" value="1" description="update AGL measurements from onboard sonar"/>
<configure name="PX4FLOW_COMPENSATE_ROTATION" value="1" description="compensate AGL measurements for body rotation"/>
<configure name="PX4FLOW_MEDIAN_LENGTH" value="7" description="Median filter length for the px4flow measurements"/>
</doc>
<settings>
<dl_settings NAME="optical flow">
<dl_settings NAME="px4flow">
<dl_setting MAX="1" MIN="0" STEP="1" VAR="px4flow.compensate_rotation" shortname="derotate_agl"/>
<dl_setting MAX="1" MIN="0" STEP="1" VAR="px4flow.update_agl" shortname="update_agl"/>
<dl_setting MAX="10" MIN="0" STEP="0.1" VAR="px4flow.stddev" shortname="stddev"/>
</dl_settings>
</dl_settings>
</settings>
<header>
<file name="px4flow_i2c.h"/>
</header>
<init fun="px4flow_i2c_init()"/>
<periodic fun="px4flow_i2c_downlink()" freq="4" autorun="FALSE"/>
<periodic fun="px4flow_i2c_periodic()" freq="50"/>
<makefile>
<configure name="PX4FLOW_I2C_DEV" default="i2c1" case="lower|upper"/>
<configure name="PX4FLOW_I2C_ADDR" default="0x84"/>
<configure name="REQUEST_INT_FRAME" default="1"/>
<configure name="PX4FLOW_NOISE_STDDEV" default="1.0"/>
<configure name="USE_PX4FLOW_AGL" default="1"/>
<configure name="PX4FLOW_COMPENSATE_ROTATION" default="1"/>
<configure name="PX4FLOW_MEDIAN_LENGTH" default="7"/>
<define name="PX4FLOW_I2C_DEV" value="$(PX4FLOW_I2C_DEV_LOWER)"/>
<define name="USE_$(PX4FLOW_I2C_DEV_UPPER)"/>
<define name="PX4FLOW_I2C_ADDR" value="$(PX4FLOW_I2C_ADDR)"/>
<define name="REQUEST_INT_FRAME" value="$(REQUEST_INT_FRAME)"/>
<define name="PX4FLOW_NOISE_STDDEV" value="$(PX4FLOW_NOISE_STDDEV)"/>
<define name="USE_PX4FLOW_AGL" value="$(USE_PX4FLOW_AGL)"/>
<define name="PX4FLOW_COMPENSATE_ROTATION" value="$(PX4FLOW_COMPENSATE_ROTATION)"/>
<define name="PX4FLOW_MEDIAN_LENGTH" value="$(PX4FLOW_MEDIAN_LENGTH)"/>
<file name="px4flow_i2c.c"/>
</makefile>
</module>