> For the complete documentation index, see [llms.txt](https://agamrobotics.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://agamrobotics.gitbook.io/docs/sensors/agam-florange-sensor/setup-instructions.md).

# Setup Instructions

#### Connection Diagram <a href="#connection-diagram" id="connection-diagram"></a>

First, Twist the provided 4 pin CAN cables as this will cancels out electromagnetic interference (noise) and reduces crosstalk by ensuring external fields affect both wires equally, allowing receivers to filter it out, leading to cleaner signals, better reliability, and efficient data transmission in noisy environments. It also helps manage physical aspects like stability, preventing tangles, and ensuring even stress distribution.&#x20;

### Mounting

Below is the recommended mounting orientation. The connectors on the board should point towards the back of the vehicle with the sensors facing downwards.

![](/files/C0Mn2SUKi788fcU5q5kb)\
\
The above mounting is the default value (0) of the parameter SENS\_FLOW\_ROT. If you want to mount in a different orientation, change this parameter accordingly.&#x20;

### PX4 Configuration <a href="#px4-configuration" id="px4-configuration"></a>

Agam FloRange Sensor is a CAN based device. The CAN device needs to be powered for certain parameters to show up. So, the recommended way is to power the device through USB port from Autopilot or external battery and then open QGroundControl.

* Enable the UAVCAN driver by setting parameter [UAVCAN\_ENABLE](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#UAVCAN_ENABLE) to `2` for dynamic node allocation (or `3` if using [DroneCAN ESCs](https://docs.px4.io/main/en/dronecan/escs.html))
* Connect Agam Florange Sensor to CAN port
  * Set the following parameters
  * Enable [EKF2\_OF\_CTRL](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_CTRL)
    * To optionally disable GPS aiding, set [EKF2\_GPS\_CTRL](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_GPS_CTRL) to `0`&#x20;
  * Set [EKF2\_RNG\_CTRL ](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_RNG_CTRL)to Enable(Conditional mode). This enables the range finder to be used during low speed (< EKF2\_RNG\_A\_VMAX) and low altitude (< EKF2\_RNG\_A\_HMAX) operation, eg takeoff and landing, where baro interference from rotor wash is excessive and can corrupt EKF state estimates. It is intended to be used where a vertical takeoff and landing is performed, and horizontal flight does not occur until above EKF2\_RNG\_A\_HMAX.
  * Enable [UAVCAN\_SUB\_FLOW](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#UAVCAN_SUB_FLOW)
  * Enable [UAVCAN\_SUB\_RNG](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#UAVCAN_SUB_RNG)
  * Set [UAVCAN\_RNG\_MIN](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#UAVCAN_RNG_MIN) to `0.08` (minimum range is 80mm)
  * Set [UAVCAN\_RNG\_MAX](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#UAVCAN_RNG_MAX) to `30` (max range is 30m)
  * Set [EKF2\_RNG\_A\_HMAX](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_RNG_A_HMAX) to `10`
  * Set [EKF2\_RNG\_QLTY\_T](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_RNG_QLTY_T) to `0.2`
  * Set [SENS\_FLOW\_MINHGT](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#SENS_FLOW_MINHGT) to `0.08`
  * Set [SENS\_FLOW\_MAXHGT](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#SENS_FLOW_MAXHGT) to `30`
  * Set [SENS\_FLOW\_MAXR](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#SENS_FLOW_MAXR) to `7.4` to match the PAW3902 maximum angular flow rate
  * The sensor can be mounted anywhere on the frame, but you will need to specify the focal point position, relative to the vehicle's center of gravity, during PX4 configuration. The below parameters can be set to account for the offset of the Agam FloRange Sensor from the vehicle center of gravity.&#x20;
    * &#x20;[EKF2\_OF\_POS\_X](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_POS_X), [EKF2\_OF\_POS\_Y](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_POS_Y), and [EKF2\_OF\_POS\_Z](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_POS_Z)&#x20;
    * [EKF2\_RNG\_POS\_X](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_POS_X), [EKF2\_](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_POS_Y)[RNG](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_POS_X)[\_POS\_Y](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_POS_Y), and [EKF2\_](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_POS_Z)[RNG](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_POS_X)[\_POS\_Z](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_POS_Z)&#x20;
  * When optical flow is the only source of horizontal position/velocity, then lowering the gain for controller response to horizontal position error [MPC\_XY\_P](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#MPC_XY_P) (e.g. to 0.5) is recommended to reduce oscillations.
* Reboot

After connecting the sensor to the autopilot, connect the autopilot using QGroundControl. Open the MAVLink Inspector screen for DISTANCE\_SENSOR. If the sensor is OK, you can see that the current\_distance number is non-zero.

<figure><img src="/files/bZEd37RQeLjQbfwtRJ8L" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/RIh6BcGDiYQS1eGtwCcM" alt=""><figcaption></figcaption></figure>

Refer the latest PX4 Optical Flow sensor setup in the link below:

<https://docs.px4.io/main/en/sensor/optical_flow.html>

### Ardupilot Configuration <a href="#px4-configuration" id="px4-configuration"></a>

Connect Agam Florange to CAN port. Set the following parameters:

* Set [FLOW\_TYPE](https://ardupilot.org/copter/docs/parameters.html#flow-type) = 6&#x20;
* Set [CAN\_P1\_DRIVER](https://ardupilot.org/copter/docs/parameters.html#can-p1-driver) = 1
* Set [CAN\_D1\_PROTOCOL](https://ardupilot.org/copter/docs/parameters.html#can-d1-protocol) = 1

To use the onboard lidar:

* Set [RNGFND1\_TYPE](https://ardupilot.org/copter/docs/parameters.html#rngfnd1-type) = 24
* Set [RNGFND1\_MAX](https://ardupilot.org/copter/docs/parameters.html#rngfnd1-max) = 3000
* EK3\_SRC\_OPTIONS = 0
* EK3\_FLOW\_DELAY
* EK3\_SRC1\_POSXY = 0 (use optical flow)
* EK3\_SRC1\_VELXY = 5
* EK3\_SRC1\_POSZ = 1
* EK3\_SRC1\_VELZ = 0
* EK3\_SRC1\_YAW = 1
* The sensor can be mounted anywhere on the frame, but you will need to specify the focal point position, relative to the vehicle's center of gravity, during PX4 configuration. The below parameters can be set to account for the offset of the Agam FloRange Sensor from the vehicle center of gravity.&#x20;
  * FLOW\_POS\_X, FLOW\_POS\_Y, FLOW\_POS\_Z

### **UART Version Setup**

* Set [MAV\_X\_CONFIG ](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#MAV_0_CONFIG)to the port the sensor is connected to(eg: TELEM 3)
* Reboot
* Set [MAV\_X\_FORWARD ](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#MAV_0_FORWARD)to Disabled
* Set [MAV\_X\_MODE ](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#MAV_0_MODE)to Minimal or Low Bandwidth
* Set [SER\_TELx\_BAUD](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#SER_TEL1_BAUD) to 115200 8N1
* Reboot
* Set [EKF2\_RNG\_A\_HMAX](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_RNG_A_HMAX) to `10`
* Set [EKF2\_RNG\_QLTY\_T](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_RNG_QLTY_T) to `0.2`
* Set [SENS\_FLOW\_MINHGT](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#SENS_FLOW_MINHGT) to `0.08`
* Set [SENS\_FLOW\_MAXHGT](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#SENS_FLOW_MAXHGT) to `30`
* Set [SENS\_FLOW\_MAXR](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#SENS_FLOW_MAXR) to `7.4`&#x20;
* The sensor can be mounted anywhere on the frame, but you will need to specify the focal point position, relative to the vehicle's center of gravity, during PX4 configuration. The below parameters can be set to account for the offset of the Agam FloRange Sensor from the vehicle center of gravity.&#x20;
  * &#x20;[EKF2\_OF\_POS\_X](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_POS_X), [EKF2\_OF\_POS\_Y](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_POS_Y), and [EKF2\_OF\_POS\_Z](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_POS_Z)&#x20;
  * [EKF2\_RNG\_POS\_X](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_POS_X), [EKF2\_](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_POS_Y)[RNG](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_POS_X)[\_POS\_Y](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_POS_Y), and [EKF2\_](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_POS_Z)[RNG](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_POS_X)[\_POS\_Z](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#EKF2_OF_POS_Z)&#x20;
* When optical flow is the only source of horizontal position/velocity, then lowering the gain for controller response to horizontal position error [MPC\_XY\_P](https://docs.px4.io/main/en/advanced_config/parameter_reference.html#MPC_XY_P) (e.g. to 0.5) is recommended to reduce oscillations.
* Reboot

### **UART Port** <a href="#telem1-telem2-telem3-ports" id="telem1-telem2-telem3-ports"></a>

| **Pin**  | **Signal** | **Volt** |
| -------- | ---------- | -------- |
| 1(red)   | VCC        | +5V      |
| 2(black) | TX (out)   | +3.3V    |
| 3(black) | RX (in)    | +3.3V    |
| 4(black) | SWDIO      | +3.3V    |
| 5(black) | SWCLK      | +3.3V    |
| 6(black) | GND        | GND      |

### **CAN port** <a href="#can1-can2-ports" id="can1-can2-ports"></a>

| **Pin**  | **Signal** | **Volt** |
| -------- | ---------- | -------- |
| 1(red)   | VCC        | +5V      |
| 2(black) | CAN\_P     | +3.3V    |
| 3(black) | CAN\_N     | +3.3V    |
| 4(black) | GND        | GND      |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://agamrobotics.gitbook.io/docs/sensors/agam-florange-sensor/setup-instructions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
