Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
lidar_sf11 module

Parallax SF11-A/B/C Laser Rangefinder connected over i2c bus.

The update rate is 16 readings per second, so don't poll the lidar faster than 32Hz. In practice lidar_sf11_periodic() can run at most at freq=32. The i2c address can be reconfigured.

Example for airframe file

Add to your firmware section: This example contains all possible configuration options, not all of them are mandatory!

<module name="lidar_sf11">
b'<configure name="LIDAR_SF11_I2C_DEV" value="i2c2" />\n '
b'<configure name="LIDAR_SF11_I2C_ADDR" value="0x50" />\n '
b'<configure name="USE_LIDAR_SF11_AGL" value="1" />\n '
b'<configure name="LIDAR_SF11_COMPENSATE_ROTATION" value="1" />\n '
</module>

Module configuration options

Configure Options

  • name: LIDAR_SF11_I2C_DEV value: i2c2
    Description: I2C device to use for lidar
  • name: LIDAR_SF11_I2C_ADDR value: 0x50
    Description: default slave address of lidar
  • name: USE_LIDAR_SF11_AGL value: 1
    Description: use this lidar for AGL measurements. On by deafult
  • name: LIDAR_SF11_COMPENSATE_ROTATION value: 1
    Description: compensate AGL measurements for body rotation

Module functions

Init Functions

These initialization functions are called once on startup.

Event Functions

These event functions are called in each cycle of the module event loop.

Periodic Functions

These functions are called periodically at the specified frequency from the module periodic loop.

  • lidar_sf11_downlink()
    • Frequency in Hz: 4
    • Autorun: FALSE
      Periodic function is started by user command.
  • lidar_sf11_periodic()
    • Frequency in Hz: 32
    • 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 lidar_sf11.xml file:

<!DOCTYPE module SYSTEM "module.dtd">
<module name="lidar_sf11" dir="lidar">
<doc>
<description>
Parallax SF11-A/B/C Laser Rangefinder connected over i2c bus.
The update rate is 16 readings per second, so don't poll the lidar faster than 32Hz.
In practice lidar_sf11_periodic() can run at most at freq=32.
The i2c address can be reconfigured.
</description>
<configure name="LIDAR_SF11_I2C_DEV" value="i2c2" description="I2C device to use for lidar"/>
<configure name="LIDAR_SF11_I2C_ADDR" value="0x50" description="default slave address of lidar"/>
<configure name="USE_LIDAR_SF11_AGL" value="1" description="use this lidar for AGL measurements. On by deafult"/>
<configure name="LIDAR_SF11_COMPENSATE_ROTATION" value="1" description="compensate AGL measurements for body rotation"/>
</doc>
<settings>
<dl_settings NAME="Lidar SF11">
<dl_settings NAME="Lidar">
<dl_setting MAX="1" MIN="0" STEP="1" VAR="lidar_sf11.compensate_rotation" shortname="derotate_agl"/>
<dl_setting MAX="1" MIN="0" STEP="1" VAR="lidar_sf11.update_agl" shortname="update_agl"/>
</dl_settings>
</dl_settings>
</settings>
<dep>
<depends>i2c</depends>
<provides>sonar</provides>
</dep>
<header>
<file name="lidar_sf11.h"/>
</header>
<init fun="lidar_sf11_init()"/>
<periodic fun="lidar_sf11_downlink()" freq="4" autorun="FALSE"/> <!-- for debug -->
<periodic fun="lidar_sf11_periodic()" freq="32"/> Õž¯søU
by 2 to get the actual number of readings per second. For example 32Hz = 16 range readings, which is the maximum (per the datasheet) -->
<event fun="lidar_sf11_event()"/>
<makefile>
<configure name="LIDAR_SF11_I2C_DEV" default="i2c1" case="lower|upper"/>
<configure name="LIDAR_SF11_I2C_ADDR" default="0x50"/>
<configure name="USE_LIDAR_SF11_AGL" default="1"/>
<configure name="LIDAR_SF11_COMPENSATE_ROTATION" default="1"/>
<define name="LIDAR_SF11_I2C_DEV" value="$(LIDAR_SF11_I2C_DEV_LOWER)"/>
<define name="USE_$(LIDAR_SF11_I2C_DEV_UPPER)"/>
<define name="LIDAR_SF11_I2C_ADDR" value="$(LIDAR_SF11_I2C_ADDR)"/>
<define name="USE_LIDAR_SF11_AGL" value="$(USE_LIDAR_SF11_AGL)"/>
<define name="LIDAR_SF11_COMPENSATE_ROTATION" value="$(LIDAR_SF11_COMPENSATE_ROTATION)"/>
<file name="lidar_sf11.c"/>
</makefile>
<makefile target="nps">
<define name="USE_SONAR" value="1"/><!-- in NPS use a virtual sonar to simulate lidar measurements -->
</makefile>
</module>