> For the complete documentation index, see [llms.txt](https://docs.theseus.us/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.theseus.us/cyclops/autopilot-integration/ardupilot/cyclops-v1.x.x/dead-reckoning-switch.md).

# Dead Reckoning Switch

Theseus provides a Lua script that allows pilots to disable GPS position in the EKF with a 2- or 3-position RC switch. Disabling this position input allows your UAV to dead reckon using the EKF sensor data with Cyclops providing localized position updates. The script does this by setting the value of the `EK3_SRC1_POSXY` parameter to 3 (GPS) or 0 (Disabled).

Upload the script below to ArduPilot to enable this functionality:

{% file src="/files/nngOs64ezxqeXdTFK1WT" %}

{% file src="/files/SoOfhT0id4zoWCXqKfT3" %}

{% hint style="info" %}
Second script also toggles EK3\_SRC1\_VELXY / EK3\_SRC1\_VELZ params from 3 to 0.
{% endhint %}

### Configuring an RC Switch

Select which switch on your controller you want to use and identify its corresponding RC channel in your mixing model. On your GCS software, set the corresponding RC option to Scripting 4 (value 303). *For example, if your switch is on RC channel 7, set* `RC7_OPTION = 303`.

{% hint style="info" %}
To enable this script in ArduPilot, set `SCR_USER2=1` in the Full Parameters List. To prevent the script from running, set this parameter to 0.
{% endhint %}

{% hint style="warning" %}
Note: The script functionality is hardcoded to Scripting 4 (value 303) within the provided Lua script. If you are using multiple Lua scripts on the same flight controller, make sure that those scripts do not use Scripting 4.
{% endhint %}

### Switch Positions

* **LOW / MID**: GPS position source **enabled** (`EK3_SRC1_POSXY = 3`)
* **HIGH**: GPS position source **disabled** (`EK3_SRC1_POSXY = 0`)

### Startup Behavior

On boot, the script reads the current switch position and immediately sets EK3\_SRC1\_POSXY to match. If the switch is in the HIGH position when the flight controller boots, GPS position will be disabled as soon as the script initializes. If SCR\_USER2 is set to 0, the script will not run and EK3\_SRC1\_POSXY will remain at whatever value is set in your parameters.

{% hint style="success" %}
The script prints a status message to the GCS every 5 seconds indicating the current GPS position source state, so you can confirm the active configuration at a glance during flight.
{% endhint %}
