ArduPilot / ArduPilot/ardupilot

AP_OpticalFlow: Add initialization support for UPixels UPFLOW optical flow sensor

Open
#23,720 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
15.9k
Forks
21.4k
Avg merge
3d 17h
Merged PRs (30d)
119

Description

## Feature request

Currently, Ardupilot already supports Upflow `LC302-3C` optical flow sensor, but some other models such as `LC306` and `LC302-8B` boards require an initialization step after power on. The difference is identified by checking the silk screen on the PCB.

After the optical flow module is powered on, it needs to be initialized by the host computer through the UART interface before it can work normally. There should be a delay of at least 100ms between the power-on of the optical flow module and the initialization by the host computer.

UART initialization is divided into four processes, each of which contains an instruction: 0xAA, 0xAB, 0xBB, and 0xDD. The single-byte instructions 0xAA and 0xDD have no response from the module. The instructions 0xAB and 0xBB start with the instruction word and end with XOR check. The parameters passed by the instruction are in the middle. After receiving the instructions 0xAB and 0xBB, the module will automatically return the status to the host computer. The host computer needs to send the instructions corresponding to the four processes to the module in order to complete initialization.

```
(0xAA)start --> (0xAB)internal parameter configuration
--> (0xBB)sensor parameter configuration (Loop) --> (0xDD)End
^--------------------------------------/
```

The module’s instructions and status are shown in table below.

```
| command sent | returned status |
| ------------ | --------------- |
| 0xAA | none | 1. Start flag
| ------------ | --------------- |
| 0xAB | 0xAB | 2. internal parameter configuration flag
| 0x96 | | status code: 0x00 == success
| 0x26 | status code | 0x01 == IIC no response
| 0xbc | | 0x02 == XOR error
| 0x50 | | send: 0xAB, 0x96, 0x26, 0xbc, 0x50, 0x5c(BCC without 0xAB)
| BCC(0x5c) | 0xAB xor status | success response: 0xAB, 0x00, 0xAB
| ------------ | --------------- |
| 0xBB | 0xBB | 3. sensor parameter configuration
| 0xdc | | sending data in upflow_sensor_cfg
| address | status code | same status code above
| data | | send: 0xBB, 0xdc, 0xXX, 0xXX, 0xXX(BCC without 0xBB)
| BCC | 0xBB xor status | success response: 0xBB, 0x00, 0xBB
| ------------ | --------------- |
| 0xDD | none | 4. Stop flag
```

Step 3 will run repeatedly until the sending is complete.

Each time the module receives an 0xBB instruction, it will return a corresponding status.

I have modified the current driver and conducted flight tests.

Contributor guide

Open the contributing guide

Research direction

Start by locating the existing Upflow LC302-3C optical-flow driver and its UART and power-on initialization path. Compare the requested LC306 and LC302-8B sequence with the existing sensor handling, then verify the 100 ms delay, command order, XOR/status responses, repeated 0xBB configuration, and completion behavior using the available hardware tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
embedded-iot
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.