Skip to content

ParamUpdate Module Documentation

Toolbox: Miscellaneous Utility Blocks

ParamUpdate Module Appearance

Introduction

One-sentence Description: Updates PX4 Custom Storage Class (CSC) parameters during Simulink simulation, synchronizing numerical changes of PX4 parameters in the base workspace.

This module belongs to the PX4 parameter development auxiliary tools in the RflySim toolchain, targeting custom flight control algorithm development based on PX4 firmware. When PX4-associated custom storage class parameters are stored outside the base workspace (e.g., in data dictionaries or model workspaces), they must first be copied into the base workspace. This module then updates parameter values at a specified sampling frequency during simulation, ensuring consistency between simulation parameter values and the latest settings in the workspace.

This module is typically used in conjunction with RflySim’s PX4 code generation toolchain, aligning with PX4 firmware’s custom parameter development workflow. It enables users to dynamically adjust PX4 parameters during simulation debugging and quickly synchronize updated parameter values in the simulation environment. It can be integrated with CopterSim and RflySim3D for co-simulation workflows, enhancing the efficiency of flight control algorithm debugging.

Port Descriptions

Input Ports

This module has no input ports.

Output Ports

This module has no output ports.

Parameter Configuration

The following parameters can be configured in the Mask dialog box opened by double-clicking the module:

Parameter Name Type Default Value Available Values/Range Description
List of PX4 Custom Storage Class objects cell array Empty Any PX4 CSC objects in the base workspace List of PX4 custom storage class objects to be updated
Auto-populate List of CSC variables Button N/A N/A Automatically detects and adds all CSC objects in the base workspace to the list
Remove selected CSC Button N/A N/A Removes the selected CSC object from the list
Sample Time double -1 Any non-zero real number, or -1 Module sampling time; -1 indicates inheriting the upstream sampling time

Parameter Settings Description

List of PX4 Custom Storage Class objects

This list stores the PX4 custom storage class (CSC) objects to be updated by the module. All selected CSC objects must exist in the MATLAB base workspace; the module updates corresponding parameters at the configured sampling frequency.

Auto-populate List of CSC variables

After clicking this button, the module automatically scans the MATLAB base workspace, identifies all custom storage class objects conforming to PX4 specifications, and adds them to the parameter list.

Remove selected CSC

After selecting unwanted CSC objects in the list, clicking this button removes the corresponding objects from the update list.

Sample Time

Sets the frequency at which the module executes parameter updates. The default value -1 inherits the sampling time of the parent subsystem in the Simulink model, eliminating the need for manual configuration.

Module Characteristics

Characteristic Value
Supported Data Types double, single, int8, int16, int32, uint8, uint16, uint32, boolean
Direct Feedthrough No
Sample Time Inherited / Configurable Discrete
Code Generation Support Yes

Data Communication Protocol

This module does not involve network communication.

Module Name Description
PX4ParamRead Reads parameters from the PX4 flight controller into the Simulink workspace
PX4ParamWrite Writes parameters from the Simulink workspace to the PX4 flight controller

Usage Example

For related usage examples, refer to the following path:

[RflySim Installation Path]/RflySimAPIs/5.RflySimFlyCtrl/0.ApiExps/2.PSPOfficialExps/Readme.pdf

Please refer to Readme.pdf in the above path for complete example descriptions and operational steps.

Notes and Common Issues

  • Initialization Order: This module can only recognize and update PX4 custom storage class (CSC) objects in the base workspace. If your CSC objects are stored in a data dictionary or model workspace, you must manually copy the corresponding CSC variables into the base workspace before clicking Auto-populate List of CSC variables to populate the list; otherwise, the module will fail to detect the target CSC objects.
  • Sample Time Matching: The default sample time is -1, inheriting the parent system’s sample time. If fixed-frequency updates of PX4 parameters are required, manually set the sample time to match the flight controller’s parameter update frequency, avoiding excessive computational resource consumption due to overly frequent updates or parameter desynchronization due to insufficient update frequency.
  • List Update Rules: If you add or delete CSC objects in the base workspace, you must re-click Auto-populate List of CSC variables to refresh the module’s internal CSC list; otherwise, the module will continue using the outdated list, potentially resulting in missed parameter updates or errors indicating missing objects.
  • Simulation Runtime Limitations: Do not modify the CSC list or parameter configuration within the module during simulation runtime. Pause the simulation first, complete modifications, and then restart the simulation to prevent abnormal parameter update logic.

Changelog

  • v4.1.0 (2024-08-13): Initial release, implementing PX4 custom storage class parameter update functionality, supporting automatic detection of CSC objects, selective removal, and configurable sample time.