UE4CtrlAPI Interface Documentation¶
Introduction¶
Brief: This file defines various data structures for communicating with the Unreal Engine 4 (UE4) simulation environment, enabling drone state requests, sensor data acquisition, camera parameter configuration, and SIL model data exchange.
Within the RflySim simulation platform, UE4 provides a high-fidelity 3D visualization and physical simulation environment. This module encapsulates all protocol structures required for data exchange with UE4, including drone pose and collision request data (CoptReqData, reqVeCrashData), object state queries (ObjReqData), visual sensor configuration (VisionSensorReqNew, CameraData), and PX4 SIL model interface data (PX4SILIntFloat). Through these structure definitions, developers can precisely construct and parse UE4 communication messages in a Python environment, enabling advanced functionalities such as sensor simulation, image acquisition, and hardware-in-the-loop testing within simulation scenarios.
Quick Start¶
Minimal working example; copy and modify minimal configuration to run.
# Import UE4CtrlAPI class for communication with RflySim3D/UE4
from RflySimSDK.ue import UE4CtrlAPI
# Initialize UE4 control interface, connect to local UE4 (default IP: 127.0.0.1)
# To connect to a remote PC, modify ip parameter, e.g., ip="192.168.1.100"
ue = UE4CtrlAPI(ip="127.0.0.1")
# Send command: display text "Hello RflySim" in UE4 for 5 seconds
# Available commands refer to documentation, e.g., map switching, camera control, etc.
ue.sendUE4Cmd('RflyShowTextTime "Hello RflySim" 5')
# Send command: switch map to ID 0 (default map)
ue.sendUE4Cmd("RflyChangeMapbyID 0")
Environment and Dependencies¶
- Python Environment:
>= 3.8.10 - Dependencies:
atexit,contextlib,copy,ctrl.IpManager,ctypes,cv2,math,numpy,os,platform,select,socket,struct,subprocess,sys,threading,time,typing,xml.etree.ElementTree - Prerequisites: Before calling this interface, the Unreal Engine simulation environment must be started, and RflySim3D or UE4 application must be running.
Core Interface Description¶
The module UE4CtrlAPI.py includes configuration variables, helper functions, and core business classes.
Global Constants and Enumerations¶
This section lists all globally accessible constants and enumeration definitions.
Standalone Constants¶
None
Global/Standalone Functions¶
None
PX4SILIntFloat Class¶
Data structure for SILints and SILFloats output to the CopterSim DLL model. This class encapsulates the integer and floating-point data transmission structure for the PX4 simulation interface, enabling SIL (Software In the Loop) simulation data exchange with CopterSim.
Data structure definition:
struct PX4SILIntFloat{
int checksum; // 1234567897
int CopterID;
int inSILInts[8]; // 8 integer inputs
float inSILFLoats[20]; // 20 floating-point inputs
};
__init__(iv=None)¶
Function Description: Initializes a PX4SILIntFloat instance, setting the checksum, CopterID, and integer/float array data.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
any |
No | None |
Input data used to initialize integer and float arrays. If an iterable is provided, the first 8 elements are mapped to inSILInts, and the next 20 elements are mapped to inSILFLoats |
Returns:
PX4SILIntFloatinstance object
Raises:
- None
reqVeCrashData Class¶
UE4 UAV collision detection data structure, used to receive and store collision event information from the Unreal Engine 4 simulation environment. This structure includes the aircraft state at collision, collision object information, and spatial position data, suitable for collision analysis, incident replay, and safety validation scenarios.
__init__(iv=None)¶
Function Description: Initializes a collision data structure instance. Can be initialized from byte data or another instance of the same class; if no parameter is provided, an empty structure is created.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
bytes | reqVeCrashData |
No | None |
Initialization data, either a byte string or another instance of the same class |
Returns:
reqVeCrashDatainstance object
Raises:
- None
CopyData(iv)¶
Function Description: Copies collision data from an external data source into the current structure instance. Supports parsing and copying all fields from a byte string or another instance of the same class.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
bytes | reqVeCrashData |
Yes | - | Data source, either a byte string or another instance of the same class |
Returns:
- None
Raises:
- None
Example:
from RflySimSDK.ue import reqVeCrashData
# Create empty structure
crash_data = reqVeCrashData()
# Assume raw_bytes is raw data received via UDP
raw_bytes = b'...' # Collision data packet from UE4
crash_data.CopyData(raw_bytes)
# Access collision information
print(f"Collision aircraft ID: {crash_data.copterID}")
print(f"Collision type: {crash_data.CrashType}") # -2=ground, -1=static object, 0=no collision, >0=collided aircraft ID
print(f"Collision position: ({crash_data.CrashPos[0]}, {crash_data.CrashPos[1]}, {crash_data.CrashPos[2]})")
CoptReqData Class¶
Structure for storing UAV state request data, containing aircraft ID, position, attitude, geometric bounding box, and other information, totaling 80 bytes. Primarily used to transmit complete aircraft state data during communication with the UE4 engine.
__init__(iv=None)¶
Function Description: Initializes a CoptReqData instance, optionally populating data from a source object.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
CoptReqData |
No | None |
Source object for initialization; if None, creates an empty instance |
Returns:
CoptReqDatainstance object
Raises:
- None
Example:
# Create empty instance
data = CoptReqData()
# Create copy from existing data
new_data = CoptReqData(existing_data)
CopyData(iv)¶
Function Description: Copies data from the source object to the current instance, used for data synchronization or backup. Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
CoptReqData |
Yes | - | Source data object; all its field values will be copied to the current instance |
Returns:
- None
Raises:
- None
Example:
source = CoptReqData()
source.CopterID = 1
source.PosUE = [0.0, 0.0, 0.0]
target = CoptReqData()
target.CopyData(source) # Copies data from source to target
CopyDataOld(iv)¶
Function Description: Copies data from the source object to the current instance using the legacy format, ensuring compatibility with historical data structure parsing. Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
CoptReqData |
Yes | - | Source data object; fields are mapped and copied according to the legacy format |
Returns:
- None
Raises:
- None
ObjReqData Class¶
Used to store and transmit the complete state information of objects in a UE4 scene, including position, orientation, geometric properties, and metadata. This class corresponds to the memory layout of a C struct and is commonly used for data exchange between the RflySim simulation system and the UE4 engine.
__init__(iv=None)¶
Function Description: Initializes an ObjReqData instance; optionally initializes from existing data.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
ObjReqData / None |
No | None |
Source data object; if None, creates an empty instance |
Returns:
ObjReqDatainstance object
Raises:
- None
CopyData(iv)¶
Function Description: Copies all field data from the source object to the current instance (new version format). Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
ObjReqData |
Yes | - | Source data object |
Returns:
- None
Raises:
- None
CopyDataOld(iv)¶
Function Description: Copies all field data from the source object to the current instance (legacy format compatibility). Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
ObjReqData |
Yes | - | Source data object |
Returns:
- None
Raises:
- None
Example:
# Create an empty instance and populate data
obj = ObjReqData()
obj.PosUE = [100.0, 200.0, 50.0]
obj.angEuler = [0.0, 0.0, 1.57]
obj.ObjName = b"TargetDrone\x00"
# Create a new instance by copying from an existing object
obj_copy = ObjReqData(obj)
# Or use the CopyData method
another_copy = ObjReqData()
another_copy.CopyData(obj)
VisionSensorReqNew Class¶
Used to send requests and set camera parameters to UE4. This class encapsulates the data structure for visual sensor requests, supporting camera parameter configuration, image acquisition, and sensor data exchange with the UE4 simulation environment.
__init__(iv=None)¶
Function Description: Initializes a VisionSensorReqNew instance, optionally initializing from existing data.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
VisionSensorReqNew / None |
No | None |
Source data object; if None, creates an empty instance |
Returns:
VisionSensorReqNewinstance object
Raises:
- None
CopyData(iv)¶
Function Description: Copies all field data from the source object to the current instance. Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
VisionSensorReqNew |
Yes | - | Source data object |
Returns:
- None
Raises:
- None
CopyDataOld(iv)¶
Function Description: Copies all field data from the source object to the current instance (legacy format compatibility). Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
VisionSensorReqNew |
Yes | - | Source data object |
Returns:
- None
Raises:
- None
setCamPara(camID, camType, camPos, camAngle, camFOV, camWidth, camHeight, camNear, camFar, camFrameRate, camAutoExposureSpeed, camExposureMin, camExposureMax, camCalib, camCalibFile, camDistortion, camDistortionFile, camLensFile, camNoise, camBlur, camRollingShutter, camMotionBlur)¶
Function Description: Sets camera parameters, configuring the visual sensor's position, orientation, field of view, resolution, and other properties. Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
camID |
int | Yes | - | Camera ID |
camType |
int | Yes | - | Camera type |
camPos |
list[float] | Yes | - | Camera position [x, y, z] |
camAngle |
list[float] | Yes | - | Camera angle [roll, pitch, yaw] |
camFOV |
float | Yes | - | Field of view (degrees) |
camWidth |
int | Yes | - | Image width (pixels) |
camHeight |
int | Yes | - | Image height (pixels) |
camNear |
float | Yes | - | Near clipping plane |
camFar |
float | Yes | - | Far clipping plane |
camFrameRate |
float | Yes | - | Frame rate (fps) |
camAutoExposureSpeed |
float | Yes | - | Auto exposure speed |
camExposureMin |
float | Yes | - | Minimum exposure |
camExposureMax |
float | Yes | - | Maximum exposure |
camCalib |
int | Yes | - | Calibration flag |
camCalibFile |
str | Yes | - | Calibration file path |
camDistortion |
int | Yes | - | Distortion flag |
camDistortionFile |
str | Yes | - | Distortion file path |
camLensFile |
str | Yes | - | Lens file path |
camNoise |
float | Yes | - | Noise level |
camBlur |
float | Yes | - | Blur level |
camRollingShutter |
float | Yes | - | Rolling shutter effect |
camMotionBlur |
float | Yes | - | Motion blur level |
Returns:
- None
Raises:
- None
setCamParaSimple(camID, camType, camPos, camAngle, camFOV, camWidth, camHeight)¶
Function Description: Sets simplified camera parameters, configuring the visual sensor's basic properties. Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
camID |
int | Yes | - | Camera ID |
camType |
int | Yes | - | Camera type |
camPos |
list[float] | Yes | - | Camera position [x, y, z] |
camAngle |
list[float] | Yes | - | Camera angle [roll, pitch, yaw] |
camFOV |
float | Yes | - | Field of view (degrees) |
camWidth |
int | Yes | - | Image width (pixels) |
camHeight |
int | Yes | - | Image height (pixels) |
Returns:
- None
Raises:
- None
getCamPara()¶
Function Description: Retrieves the current camera parameter settings. Arguments (Args): None Returns:
- Camera parameter dictionary
Raises:
- None
sendReq()¶
Function Description: Sends the camera parameter request to the UE4 simulation environment. Arguments (Args): None Returns:
- None
Raises:
- None
sendReqSimple()¶
Function Description: Sends a simplified camera parameter request to the UE4 simulation environment. Arguments (Args): None Returns:
- None
Raises:
- None
CameraData Class¶
Camera data structure, used to receive and store image data and camera state information from the UE4 simulation environment. This structure includes image data, camera pose, timestamp, and other information, suitable for visual sensor simulation and image acquisition scenarios.
__init__(iv=None)¶
Function Description: Initializes a CameraData instance, optionally initializing from existing data.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
CameraData / None |
No | None |
Source data object; if None, creates an empty instance |
Returns:
CameraDatainstance object
Raises:
- None
CopyData(iv)¶
Function Description: Copies all field data from the source object to the current instance. Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
CameraData |
Yes | - | Source data object |
Returns:
- None
Raises:
- None
CopyDataOld(iv)¶
Function Description: Copies all field data from the source object to the current instance (legacy format compatibility). Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
CameraData |
Yes | - | Source data object |
Returns:
- None
Raises:
- None
getImage()¶
Function Description: Retrieves the image data from the camera data structure. Arguments (Args): None Returns:
- Image data (numpy array)
Raises:
- None
getDepth()¶
Function Description: Retrieves the depth data from the camera data structure. Arguments (Args): None Returns:
- Depth data (numpy array)
Raises:
- None
getSegmentation()¶
Function Description: Retrieves the segmentation data from the camera data structure. Arguments (Args): None Returns:
- Segmentation data (numpy array)
Raises:
- None
UE4CtrlAPI Class¶
Main control class for communicating with the UE4 simulation environment. This class provides all core functionalities for interacting with RflySim3D/UE4, including sending control commands, managing drone states, configuring cameras, handling collision detection, and managing scene objects.
__init__(ip="127.0.0.1")¶
Function Description: Initializes the UE4 control interface, establishing a UDP communication connection with the RflySim3D simulation environment.
Arguments (Args):
| Parameter Name | Type | Default | Description |
|---|---|---|---|
| ip | str | "127.0.0.1" | IP address of the target PC, used to establish a UDP communication connection with RflySim3D |
Returns: None Raises: None
sendUE4Cmd(cmd, windowID=-1)¶
Function Description: Sends a command to control the display style of RflySim3D. Available command strings take the form 'RflyShowTextTime "txt" time', supporting various display control functions including text display, map switching, camera control, and vehicle model operations.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| cmd | Any | Yes | None | Command string; for detailed command formats, refer to the function description |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Returns: None Raises: None
fillList(data, inLen)¶
Function Description: Internal helper method for populating list data. (No detailed documentation available.)
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| data | Any | Yes | None | Data to be filled |
| inLen | Any | Yes | None | Target length |
Returns: None Raises: None
sendUE4CmdNet(cmd)¶
Function Description: Sends control commands to all RflySim3D instances over the local network using multicast address 224.0.0.10:20009, supporting up to 92 bytes of command data. Command types are automatically checked and converted: strings are encoded into byte sequences, and those exceeding 91 bytes are truncated. After sending the command, if it is a "RflyChangeMap" command, an additional 0.5-second wait is performed to ensure scene switching completes.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| cmd | Any | Yes | None | Command string or byte sequence; maximum length is 91 bytes |
Returns: None Raises: None
sendUE4LabelID(CopterID=0, Txt='', fontSize=30, RGB=[255, 0, 0], windowID=-1)¶
Function Description: Sends a label ID display command to RflySim3D to display a text label on a specified aircraft.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| CopterID | Any | No | 0 | Target aircraft ID |
| Txt | Any | No | "" | Text content to display |
| fontSize | Any | No | 30 | Font size |
| RGB | Any | No | [255, 0, 0] | Text color in [R, G, B] format, range 0–255 |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Returns: None Raises: None
sendUE4LabelMsg(CopterID=0, Txt='', fontSize=30, RGB=[255, 0, 0], dispTime=0, dispFlag=-1, windowID=-1)¶
Function Description: Sends a label message display command to RflySim3D, supporting a more sophisticated message management mechanism. Message display behavior is jointly controlled by dispFlag and dispTime:
- When dispFlag < 0 and dispTime >= 0, additive mode is used;
- When dispFlag < 0 and dispTime < 0, all messages are cleared;
- When dispFlag = 0 and dispTime >= 0, row 0 is updated;
- When 1 <= dispFlag < 5, the corresponding row is updated; if dispTime < 0, the message is deleted;
- If dispFlag exceeds the current number of messages, additive mode is automatically activated.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| CopterID | Any | No | 0 | Target aircraft ID; ≤0 indicates all aircraft |
| Txt | Any | No | "" | Text content to display, maximum 120 bytes |
| fontSize | Any | No | 30 | Font size |
| RGB | Any | No | [255, 0, 0] | Text color in [R, G, B] format, range 0–255 |
| dispTime | Any | No | 0 | Display duration in seconds; <0 for immediate disappearance, =0 for permanent display, >0 for disappearance after specified seconds |
| dispFlag | Any | No | -1 | Display flag controlling message update mode |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Returns: None Raises: None
sendUE4Attatch(CopterIDs, AttatchIDs, AttatchTypes, windowID=-1)¶
Function Description: Sends a message to RflySim3D to attach one or more aircraft to other objects (supports up to 25 aircraft). Accepts three list-type arguments, each with a maximum length of 25. Attachment types include: 0—Normal mode, 1—Relative position but not relative attitude, 2—Relative position + yaw (not relative to pitch and roll), 3—Relative position + full attitude (pitch, roll, and yaw).
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| CopterIDs | Any | Yes | None | List of aircraft IDs, max length 25 |
| AttatchIDs | Any | Yes | None | List of target object IDs to attach to, max length 25 |
| AttatchTypes | Any | Yes | None | List of attachment types, values 0–3, max length 25 |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Returns: None
Raises: None
circle_traj(t, center=(0.0, 0.0), radius=1.0, W=5.0)¶
Function Description: Generates a point on a circular trajectory; computes the coordinates on the circle based on the time parameter.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| t | float | Yes | None | Time (seconds) |
| center | Any | No | (0.0, 0.0) | Center coordinates of the circle (x_c, y_c) |
| radius | float | No | 1.0 | Radius (meters) |
| W | float | No | 5.0 | Trajectory period (seconds); default is 5 seconds per circle |
Returns: Tuple (x, y), coordinates of the point on the circle
Raises: None
sendUE4Pos(copterID=1, vehicleType=3, MotorRPMSMean=0, PosE=[0, 0, 0], AngEuler=[0, 0, 0], windowID=-1)¶
Function Description: Sends position and attitude information to RflySim3D to create a new 3D model or update the state of an existing one.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | Any | No | 1 | Aircraft ID |
| vehicleType | Any | No | 3 | Vehicle type |
| MotorRPMSMean | Any | No | 0 | Mean motor RPM |
| PosE | Any | No | [0, 0, 0] | Position in Earth-fixed frame [x, y, z] (meters, NED) |
| AngEuler | Any | No | [0, 0, 0] | Euler angles [roll, pitch, yaw] (radians) |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Returns: None
Raises: None
sendUE4Pos2Ground(copterID=1, vehicleType=3, MotorRPMSMean=0, PosE=[0, 0, 0], AngEuler=[0, 0, 0], windowID=-1)¶
Function Description: Sends position and attitude information to RflySim3D to create or update a 3D model, ensuring the model remains always grounded. Uses checksum = 1
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | Any | No | 1 | Aircraft ID |
| vehicleType | Any | No | 3 | Vehicle type |
| MotorRPMSMean | Any | No | 0 | Mean motor RPM |
| PosE | Any | No | [0, 0, 0] | Position in Earth coordinate frame [x, y, z] (meters, NED) |
| AngEuler | Any | No | [0, 0, 0] | Euler angles [roll, pitch, yaw] (radians) |
| Scale | Any | No | [1, 1, 1] | Scale factor [x, y, z] |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Returns: None Raises: None
sendUE4PosFull(copterID, vehicleType, MotorRPMS=[0] * 8, VelE=[0, 0, 0], PosE=[0, 0, 0], RateB=[0, 0, 0], AngEuler=[0, 0, 0], windowID=-1)¶
Function Description: Sends complete position, attitude, and motion state information to RflySim3D for creating new 3D models or updating existing models with full state data. Includes full state information such as velocity, angular velocity, and motor RPMs.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | Any | Yes | None | Aircraft ID |
| vehicleType | Any | Yes | None | Vehicle type |
| MotorRPMS | Any | No | [0,0,0,0,0,0,0,0] | RPMs of 8 motors |
| VelE | Any | No | [0, 0, 0] | Velocity in Earth coordinate frame [Vx, Vy, Vz] (m/s, NED) |
| PosE | Any | No | [0, 0, 0] | Position in Earth coordinate frame [x, y, z] (m, NED) |
| RateB | Any | No | [0, 0, 0] | Angular rate in body frame [p, q, r] (rad/s) |
| AngEuler | Any | No | [0, 0, 0] | Euler angles [roll, pitch, yaw] (radians) |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Returns: None Raises: None
sendUE4ExtAct(copterID=1, ActExt=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], windowID=-1)¶
Function Description: Sends extended actuation data to RflySim3D to control 16 additional floating-point parameters of the aircraft. Uses checksum = 1234567894 and includes a runtime timestamp along with 16 extended parameters.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | Any | No | 1 | Aircraft ID |
| ActExt | Any | No | [0,...0] (16 zeros) | 16 extended actuation parameters |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Returns: None Raises: None
sendUE4PosSimple(copterID, vehicleType, PWMs, VelE, PosE, AngEuler, runnedTime=-1, windowID=-1)¶
Function Description: Sends simplified position and attitude information to RflySim3D, including a timestamp and PWM control signals. Used for creating new 3D models or updating existing models; fewer parameters than the full version, resulting in lower communication overhead.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | Any | Yes | None | Aircraft ID |
| vehicleType | Any | Yes | None | Vehicle type |
| PWMs | Any | Yes | None | 8 PWM control signals |
| VelE | Any | Yes | None | Velocity in Earth coordinate system [Vx, Vy, Vz] (m/s, NED) |
| PosE | Any | Yes | None | Position in Earth coordinate system [x, y, z] (m, NED) |
| AngEuler | Any | Yes | None | Euler angles [roll, pitch, yaw] (radians) |
| runnedTime | Any | No | -1 | Timestamp of elapsed time (seconds); -1 indicates using current time |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Returns: None Raises: None
sendUE4PosNew(copterID=1, vehicleType=3, PosE=[0, 0, 0], AngEuler=[0, 0, 0], VelE=[0, 0, 0], PWMs=[0] * 8, runnedTime=-1, windowID=-1)¶
Function Description: Sends position, attitude, and other information to RflySim3D to create new 3D models or update existing ones. This function constructs an SOut2SimulatorSimpleTime structure and transmits it via UDP to UE4.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | No | 1 | Aircraft/object ID |
| vehicleType | int | No | 3 | Vehicle type; 3 for quadcopter |
| PosE | list[float] | No | [0, 0, 0] | Position [x, y, z] in ENU coordinate system (meters) |
| AngEuler | list[float] | No | [0, 0, 0] | Euler angles [roll, pitch, yaw] (radians) |
| VelE | list[float] | No | [0, 0, 0] | Velocity [vx, vy, vz] in ENU coordinate system (m/s) |
| PWMs | list[float] | No | [0] * 8 | Motor speeds / PWM values (up to 8 values) |
| runnedTime | float | No | -1 | Current timestamp (seconds); -1 indicates using system current time |
| windowID | int | No | -1 | Target RflySim3D window ID; -1 indicates broadcasting to all windows |
Returns: None Raises: None
sendUE4PosScale100(copterID, vehicleType, PosE, AngEuler, MotorRPMSMean, Scale, isFitGround=False, windowID=-1)¶
Function Description: Sends position, attitude, scaling, and other information for up to 100 aircraft to RflySim3D in a single batch, enabling simultaneous creation or update of 100 3D models. This function constructs a Multi3DData100New structure and transmits it via UDP.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | list[int] | Yes | None | Array of 100 aircraft IDs (1–100); 0 indicates the model should not be displayed |
| vehicleType | list[int] | Yes | None | Array of 100 vehicle types; 3 for quadcopters |
| PosE | list[float] | Yes | None | 300-element position array [x1,y1,z1,x2,y2,z2,...] (meters) |
| AngEuler |
source = CoptReqData()
source.CopterID = 1
source.PosUE = [0.0, 0.0, 0.0]
target = CoptReqData()
target.CopyData(source) # Copies data from source to target
CopyDataOld(iv)¶
Function Description: Copies data from the source object to the current instance using the legacy format, ensuring compatibility with historical data structure parsing.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
CoptReqData |
Yes | - | Source data object; fields are mapped and copied according to the legacy format |
Return Value (Returns):
- None
Exceptions (Raises):
- None
ObjReqData Class¶
Used to store and transmit the complete state information of objects in a UE4 scene, including position, orientation, geometric properties, and metadata. This class corresponds to the memory layout of a C struct and is commonly used for data exchange between the RflySim simulation system and the UE4 engine.
__init__(iv=None)¶
Function Description: Initializes an ObjReqData instance; optionally initializes from existing data.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
ObjReqData / None |
No | None |
Source data object; if None, creates an empty instance |
Return Value (Returns):
ObjReqDatainstance object
Exceptions (Raises):
- None
CopyData(iv)¶
Function Description: Copies all field data from the source object to the current instance (new version format).
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
ObjReqData |
Yes | - | Source data object |
Return Value (Returns):
- None
Exceptions (Raises):
- None
CopyDataOld(iv)¶
Function Description: Copies all field data from the source object to the current instance (legacy format compatibility).
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
ObjReqData |
Yes | - | Source data object |
Return Value (Returns):
- None
Exceptions (Raises):
- None
Example:
# Create an empty instance and populate data
obj = ObjReqData()
obj.PosUE = [100.0, 200.0, 50.0]
obj.angEuler = [0.0, 0.0, 1.57]
obj.ObjName = b"TargetDrone\x00"
# Create a new instance by copying from an existing object
obj_copy = ObjReqData(obj)
# Or use the CopyData method
another_copy = ObjReqData()
another_copy.CopyData(obj)
VisionSensorReqNew Class¶
This class corresponds to the C++ struct VisionSensorReq, used to send requests and set camera parameters to UE4. It contains complete configuration fields including data checksum, memory sequence ID, sensor type, target aircraft binding, image resolution, transport protocol, camera field of view, installation position and attitude.
__init__(iv=None)¶
Function Description: Initializes a vision sensor request object, optionally from an existing object for data copying. Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
VisionSensorReqNew |
No | None |
Source object for initialization; if None, creates an instance with default parameters |
Return Value (Returns):
VisionSensorReqNewinstance object
Exceptions (Raises):
- None
Example:
# Create a vision sensor request with default configuration
sensor_req = VisionSensorReqNew()
# Create a copy from an existing instance
existing_req = VisionSensorReqNew()
new_req = VisionSensorReqNew(existing_req)
CopyData(iv)¶
Function Description: Copies data fields from the specified vision sensor request object to the current instance. Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
VisionSensorReqNew |
Yes | - | Source vision sensor request object from which to copy all configuration data |
Return Value (Returns):
- None
Exceptions (Raises):
- None
Example:
# Create two instances
source_sensor = VisionSensorReqNew()
target_sensor = VisionSensorReqNew()
# Copy data from source_sensor to target_sensor
target_sensor.CopyData(source_sensor)
CameraData Class¶
Represents the camera data structure, used to store camera metadata information, including camera sequence ID, type, resolution, field of view, position and attitude, timestamp, etc. The total size of this structure is 72 bytes.
__init__(iv=None)¶
Function Description: Initializes a camera data object. Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
CameraData |
No | None |
Source object for data copying; if None, initializes with default values |
Return Value (Returns):
CameraDatainstance object
Exceptions (Raises):
- None
CopyData(iv)¶
Function Description: Copies data from the source object to the current object. Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
CameraData |
Yes | - | Source data object; its field values will be copied to the current object |
Return Value (Returns):
- None
Exceptions (Raises):
- None
Example:
cam1 = CameraData()
cam1.SeqID = 1
cam1.TypeID = 0
cam1.DataHeight = 480
cam1.DataWidth = 640
cam2 = CameraData()
cam2.CopyData(cam1) # cam2's field values are the same as cam1's
CopyDataOld(iv)¶
Function Description: Copies data from the source object to the current object using the legacy format. Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
iv |
CameraData |
Yes | - | Source data object; data is copied using the legacy format |
Return Value (Returns):
- None
Exceptions (Raises):
- None
UE4CtrlAPI Class¶
RflySim3D scene control and communication interface class. This class provides UDP communication capabilities with the UE4/UE5 simulation environment, supporting the transmission and reception of aircraft data, object data, and camera data, as well as sending scene control commands.
__init__(ip="127.0.0.1")¶
Function Description: Initializes a UE4CtrlAPI instance, establishing a communication connection with RflySim3D. Creates a UDP socket, initializes data storage vectors, sets control flags, and prepares an event mechanism for multi-threaded message processing.
Arguments (Args):
| Parameter Name | Type | Default Value | Description |
|---|---|---|---|
| ip | str | "127.0.0.1" | IP address of the target PC, used to establish a UDP communication connection with RflySim3D |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4Cmd(cmd, windowID=-1)¶
Function Description: Sends a command to control the display style of RflySim3D. Available command strings take the form 'RflyShowTextTime "txt" time', supporting various display control functions including text display, map switching, camera control, and vehicle model operations.
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| cmd | Any | Yes | None | Command string; for detailed command formats, refer to the function description |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Return Value (Returns): None
Exceptions (Raises): None
fillList(data, inLen)¶
Function Description: Internal helper method for populating list data. (No detailed documentation available.)
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| data | Any | Yes | None | Data to be filled |
| inLen | Any | Yes | None | Target length |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4CmdNet(cmd)¶
Function Description: Sends control commands to all RflySim3D instances over the local network using multicast address 224.0.0.10:20009, supporting up to 92 bytes of command data. Command types are automatically checked and converted: strings are encoded into byte sequences, and those exceeding 91 bytes are truncated. After sending the command, if it is a "RflyChangeMap" command, an additional 0.5-second wait is performed to ensure scene switching completes.
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| cmd | Any | Yes | None | Command string or byte sequence; maximum length is 91 bytes |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4LabelID(CopterID=0, Txt='', fontSize=30, RGB=[255, 0, 0], windowID=-1)¶
Function Description: Sends a label ID display command to RflySim3D to display a text label on a specified aircraft.
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| CopterID | Any | No | 0 | Target aircraft ID |
| Txt | Any | No | "" | Text content to display |
| fontSize | Any | No | 30 | Font size |
| RGB | Any | No | [255, 0, 0] | Text color in [R, G, B] format, range 0–255 |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4LabelMsg(CopterID=0, Txt='', fontSize=30, RGB=[255, 0, 0], dispTime=0, dispFlag=-1, windowID=-1)¶
Function Description: Sends a label message display command to RflySim3D, supporting a more sophisticated message management mechanism. Message display behavior is jointly controlled by dispFlag and dispTime:
- When dispFlag < 0 and dispTime >= 0, additive mode is used;
- When dispFlag < 0 and dispTime < 0, all messages are cleared;
- When dispFlag = 0 and dispTime >= 0, row 0 is updated;
- When 1 <= dispFlag < 5, the corresponding row is updated; if dispTime < 0, the message is deleted;
- If dispFlag exceeds the current number of messages, additive mode is automatically activated.
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| CopterID | Any | No | 0 | Target aircraft ID; ≤0 indicates all aircraft |
| Txt | Any | No | "" | Text content to display, maximum 120 bytes |
| fontSize | Any | No | 30 | Font size |
| RGB | Any | No | [255, 0, 0] | Text color in [R, G, B] format, range 0–255 |
| dispTime | Any | No | 0 | Display duration in seconds; <0 for immediate disappearance, =0 for permanent display, >0 for disappearance after specified seconds |
| dispFlag | Any | No | -1 | Display flag controlling message update mode |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4Attatch(CopterIDs, AttatchIDs, AttatchTypes, windowID=-1)¶
Function Description: Sends a message to RflySim3D to attach one or more aircraft to other objects (supports up to 25 aircraft). Accepts three list-type arguments, each with a maximum length of 25. Attachment types include: 0—Normal mode, 1—Relative position but not relative attitude, 2—Relative position + yaw (not relative to pitch and roll), 3—Relative position + full attitude (pitch, roll, and yaw).
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| CopterIDs | Any | Yes | None | List of aircraft IDs, max length 25 |
| AttatchIDs | Any | Yes | None | List of target object IDs to attach to, max length 25 |
| AttatchTypes | Any | Yes | None | List of attachment types, values 0–3, max length 25 |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Return Value (Returns): None
Exceptions (Raises): None
circle_traj(t, center=(0.0, 0.0), radius=1.0, W=5.0)¶
Function Description: Generates a point on a circular trajectory; computes the coordinates on the circle based on the time parameter.
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| t | float | Yes | None | Time (seconds) |
| center | Any | No | (0.0, 0.0) | Center coordinates of the circle (x_c, y_c) |
| radius | float | No | 1.0 | Radius (meters) |
| W | float | No | 5.0 | Trajectory period (seconds); default is 5 seconds per circle |
Return Value (Returns): Tuple (x, y), coordinates of the point on the circle
Exceptions (Raises): None
sendUE4Pos(copterID=1, vehicleType=3, MotorRPMSMean=0, PosE=[0, 0, 0], AngEuler=[0, 0, 0], windowID=-1)¶
Function Description: Sends position and attitude information to RflySim3D to create a new 3D model or update the state of an existing one.
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| copterID | Any | No | 1 | Aircraft ID |
| vehicleType | Any | No | 3 | Vehicle type |
| MotorRPMSMean | Any | No | 0 | Mean motor RPM |
| PosE | Any | No | [0, 0, 0] | Position in Earth-fixed frame [x, y, z] (meters, NED) |
| AngEuler | Any | No | [0, 0, 0] | Euler angles [roll, pitch, yaw] (radians) |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4Pos2Ground(copterID=1, vehicleType=3, MotorRPMSMean=0, PosE=[0, 0, 0], AngEuler=[0, 0, 0], windowID=-1)¶
Function Description: Sends position and attitude information to RflySim3D to create or update a 3D model, ensuring the model remains always grounded. Uses checksum = 1234567891 to instruct UE4 to generate an object that always stays on the ground.
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| copterID | Any | No | 1 | Aircraft ID |
| vehicleType | Any | No | 3 | Vehicle type |
| MotorRPMSMean | Any | No | 0 | Mean motor RPM |
| PosE | Any | No | [0, 0, 0] | Position in Earth-fixed frame [x, y, z] (meters, NED) |
| AngEuler | Any | No | [0, 0, 0] | Euler angles [roll, pitch, yaw] (radians) |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4Destroy(copterID, windowID=-1)¶
Function Description: Sends a command to RflySim3D to destroy a specified aircraft. When vehicleType == -3, the corresponding Copter is deleted based on the specified ID. Uses the sending logic of sendUE4PosNew.
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| copterID | Any | Yes | None | ID of the aircraft to destroy |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4PosScale(copterID=1, vehicleType=3, MotorRPMSMean=0, PosE=[0, 0, 0], AngEuler=[0, 0, 0], Scale=[1, 1, 1], windowID=-1)¶
Function Description: Sends position, attitude, and scaling information to RflySim3D to create or update a 3D model, with support for modifying the model's scale.
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| copterID | Any | No | 1 | Aircraft ID |
| vehicleType | Any | No | 3 | Vehicle type |
| MotorRPMSMean | Any | No | 0 | Mean motor RPM |
| PosE | Any | No | [0, 0, 0] | Position in Earth-fixed frame [x, y, z] (meters, NED) |
| AngEuler | Any | No | [0, 0, 0] | Euler angles [roll, pitch, yaw] (radians) |
| Scale | Any | No | [1, 1, 1] | Scale factor [x, y, z] |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4PosScale2Ground(copterID=1, vehicleType=3, MotorRPMSMean=0, PosE=[0, 0, 0], AngEuler=[0, 0, 0], Scale=[1, 1, 1], windowID=-1)¶
Function Description: Sends position, attitude, and scaling information to RflySim3D to create or update a 3D model, with support for modifying the model's scale, and ensures the model remains always grounded. Uses checksum = 1234567891 to instruct UE4 to generate an object that always stays on the ground.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | Any | No | 1 | Aircraft ID |
| vehicleType | Any | No | 3 | Vehicle type |
| MotorRPMSMean | Any | No | 0 | Mean motor RPM |
| PosE | Any | No | [0, 0, 0] | Position in Earth coordinate frame [x, y, z] (meters, NED) |
| AngEuler | Any | No | [0, 0, 0] | Euler angles [roll, pitch, yaw] (radians) |
| Scale | Any | No | [1, 1, 1] | Scale factor [x, y, z] |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4PosFull(copterID, vehicleType, MotorRPMS=[0] * 8, VelE=[0, 0, 0], PosE=[0, 0, 0], RateB=[0, 0, 0], AngEuler=[0, 0, 0], windowID=-1)¶
Function Description: Sends complete position, attitude, and motion state information to RflySim3D for creating new 3D models or updating existing models with full state data. Includes full state information such as velocity, angular velocity, and motor RPMs.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | Any | Yes | None | Aircraft ID |
| vehicleType | Any | Yes | None | Vehicle type |
| MotorRPMS | Any | No | [0,0,0,0,0,0,0,0] | RPMs of 8 motors |
| VelE | Any | No | [0, 0, 0] | Velocity in Earth coordinate frame [Vx, Vy, Vz] (m/s, NED) |
| PosE | Any | No | [0, 0, 0] | Position in Earth coordinate frame [x, y, z] (m, NED) |
| RateB | Any | No | [0, 0, 0] | Angular rate in body frame [p, q, r] (rad/s) |
| AngEuler | Any | No | [0, 0, 0] | Euler angles [roll, pitch, yaw] (radians) |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4ExtAct(copterID=1, ActExt=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], windowID=-1)¶
Function Description: Sends extended actuation data to RflySim3D to control 16 additional floating-point parameters of the aircraft. Uses checksum = 1234567894 and includes a runtime timestamp along with 16 extended parameters.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | Any | No | 1 | Aircraft ID |
| ActExt | Any | No | [0,...0] (16 zeros) | 16 extended actuation parameters |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4PosSimple(copterID, vehicleType, PWMs, VelE, PosE, AngEuler, runnedTime=-1, windowID=-1)¶
Function Description: Sends simplified position and attitude information to RflySim3D, including a timestamp and PWM control signals. Used for creating new 3D models or updating existing models; fewer parameters than the full version, resulting in lower communication overhead.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | Any | Yes | None | Aircraft ID |
| vehicleType | Any | Yes | None | Vehicle type |
| PWMs | Any | Yes | None | 8 PWM control signals |
| VelE | Any | Yes | None | Velocity in Earth coordinate system [Vx, Vy, Vz] (m/s, NED) |
| PosE | Any | Yes | None | Position in Earth coordinate system [x, y, z] (m, NED) |
| AngEuler | Any | Yes | None | Euler angles [roll, pitch, yaw] (radians) |
| runnedTime | Any | No | -1 | Timestamp of elapsed time (seconds); -1 indicates using current time |
| windowID | Any | No | -1 | Target window ID; -1 indicates all windows |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4PosNew(copterID=1, vehicleType=3, PosE=[0, 0, 0], AngEuler=[0, 0, 0], VelE=[0, 0, 0], PWMs=[0] * 8, runnedTime=-1, windowID=-1)¶
Function Description: Sends position, attitude, and other information to RflySim3D to create new 3D models or update existing ones. This function constructs an SOut2SimulatorSimpleTime structure and transmits it via UDP to UE4.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | No | 1 | Aircraft/object ID |
| vehicleType | int | No | 3 | Vehicle type; 3 for quadcopter |
| PosE | list[float] | No | [0, 0, 0] | Position [x, y, z] in ENU coordinate system (meters) |
| AngEuler | list[float] | No | [0, 0, 0] | Euler angles [roll, pitch, yaw] (radians) |
| VelE | list[float] | No | [0, 0, 0] | Velocity [vx, vy, vz] in ENU coordinate system (m/s) |
| PWMs | list[float] | No | [0] * 8 | Motor speeds / PWM values (up to 8 values) |
| runnedTime | float | No | -1 | Current timestamp (seconds); -1 indicates using system current time |
| windowID | int | No | -1 | Target RflySim3D window ID; -1 indicates broadcasting to all windows |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4PosScale100(copterID, vehicleType, PosE, AngEuler, MotorRPMSMean, Scale, isFitGround=False, windowID=-1)¶
Function Description: Sends position, attitude, scaling, and other information for up to 100 aircraft to RflySim3D in a single batch, enabling simultaneous creation or update of 100 3D models. This function constructs a Multi3DData100New structure and transmits it via UDP.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | list[int] | Yes | None | Array of 100 aircraft IDs (1–100); 0 indicates the model should not be displayed |
| vehicleType | list[int] | Yes | None | Array of 100 vehicle types; 3 for quadcopters |
| PosE | list[float] | Yes | None | 300-element position array [x1,y1,z1,x2,y2,z2,...] (meters) |
| AngEuler | list[float] | Yes | None | 300-element Euler angle array [r1,p1,y1,r2,p2,y2,...] (radians) |
| MotorRPMSMean | list[float] | Yes | None | 100-element array of average motor speeds (RPM) |
| Scale | list[int] | Yes | None | 300-element scaling array [sx1,sy1,sz1,sx2,sy2,sz2,...]; values equal actual dimensions × 100 |
| isFitGround | bool | No | False | Whether to force aircraft to conform to ground level; when True, validation flag is set to 1234567891 |
| windowID | int | No | -1 | Target RflySim3D window ID; -1 indicates broadcasting to all windows |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4PosScalePwm20(copterID, vehicleType, PosE, AngEuler, Scale, PWMs, isFitGround=False, windowID=-1)¶
Function Description: Sends position, attitude, scaling, and PWM information for up to 20 aircraft to RflySim3D in a single batch, enabling simultaneous creation or update of 20 3D models. This function constructs a Multi3DData2New structure and transmits it via UDP.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | list[int] | Yes | None | Array of 20 aircraft IDs (1–20); 0 indicates the model should not be displayed |
| vehicleType | list[int] | Yes | None | Array of 20 vehicle types; 3 for quadcopters |
| PosE | list[float] | Yes | None | 60-element position array [x1,y1,z1,x2,y2,z2,...] (meters) |
| AngEuler | list[float] | Yes | None | 60-element Euler angle array [r1,p1,y1,r2,p2,y2,...] (radians) |
| Scale | list[int] | Yes | None | 60-element scaling array [sx1,sy1,sz1,sx2,sy2,sz2,...]; values equal actual dimensions × 100 |
| PWMs | list[float] | Yes | None | 160-element PWM/motor speed array, corresponding to 8 motors for each of the 20 aircraft (RPM) |
| isFitGround | bool | No | False | Whether to force aircraft to conform to ground level; when True, validation flag is set to 1234567891 |
| windowID | int | No | -1 | Target RflySim3D window ID; -1 indicates broadcasting to all windows |
Return Value (Returns): None
Exceptions (Raises): None
getUE4Pos(CopterID=1)¶
Function Description: Retrieves the position data of a specified aircraft in UE4. This method queries the internal data cache and returns the position information for the specified CopterID.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| CopterID | int | No | 1 | Target aircraft ID |
Return Value (Returns): Position data of the specified aircraft; the exact format depends on the internal data structure definition.
Exceptions (Raises): None
getUE4Data(CopterID=1)¶
Function Description: Retrieves the complete data of a specified aircraft in UE4. This method queries the internal data cache and returns all relevant data for the specified CopterID, providing more comprehensive information than getUE4Pos.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| CopterID | int | No | 1 | Target aircraft ID |
Return Value (Returns): Complete data of the specified aircraft; the exact format depends on the internal data structure definition.
Exceptions (Raises): None
initUE4MsgRec()¶
Function Description: Initializes the listening mechanism for receiving UDP data from UE4. Currently used primarily for listening to crash data. It creates a UDP receiving thread and starts listening on the specified port.
Arguments (Args): None
Return Value (Returns): None
Exceptions (Raises): None
endUE4MsgRec()¶
Function Description: Stops the UE4 message listener. Terminates the UDP receiving thread, cleans up related resources, and stops the message listening mechanism started by initUE4MsgRec.
Arguments (Args): None
Return Value (Returns): None
Exceptions (Raises): None
UE4MsgRecLoop()¶
Function Description: UE4 message listener blocking loop function. Listens on 224.0.0.10:20006 and local port 20006, processing messages returned by RflySim3D or CopterSim. It supports six message types:
- CopterSimCrash (12 bytes): Collision detection data; returned by RflySim3D upon collision occurrence after collision detection mode is enabled via key 'P'.
- PX4SILIntFloat (120 bytes): A composite data structure containing checksum, CopterID, integer array, and float array.
- reqVeCrashData (160 bytes): Complete aircraft state data, including position, velocity, attitude, collision information, etc.
- CameraData (56 bytes): Camera data; stored in
self.CamDataVectupon reception. - CoptReqData (64 bytes): Target data associated with a copter_id; stored in
self.CoptDataVectupon reception. - ObjReqData (96 bytes): Data for built-in scene objects; stored in
self.ObjDataVectupon reception.
Received data can be retrieved using the getCamCoptObj function.
Arguments (Args): None
Return Value (Returns): None
Exceptions (Raises): None
getCamCoptObj(type_id=1, objName=1)¶
Function Description: Retrieves camera, target, or object data based on type and name. The meaning of objName varies depending on type_id:
type=0: Camera;objNamecorresponds to the camera'sseqIDtype=1: Manually created target withcopter_id;objNamecorresponds toCopterIDtype=2: Built-in scene object;objNamecorresponds to the object's name (string)
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| type_id | int | No | 1 | Request type: 0=Camera, 1=Target with copter_id, 2=Built-in scene object |
| objName | int/str | No | 1 | Target identifier: seqID for camera, CopterID for target, or name string for object |
Return Value (Returns): Data object corresponding to the specified type; the exact format depends on type_id
Exceptions (Raises): None
sendRflyShowTextTime(txt, time)¶
Function Description: Sends a command to RflySim3D to display a specified text message for a given duration within the simulation environment.
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| txt | str | Yes | None | Text content to be displayed |
| time | float | Yes | None | Duration for text display, in seconds |
Return Value (Returns): None
Exceptions (Raises):
| Exception Type | Description |
|---|---|
| TypeError | Raised when argument types are incorrect |
| ValueError | Raised when argument values are invalid |
reqCamCoptObj(type_id=1, objName=1, windowID=0)¶
Function Description: Requests data for cameras, targets with copter_id, or scene-embedded objects from RflySim3D. The meaning of objName varies depending on type_id:
type=0: Camera;objNamecorresponds to the camera'sseqIDtype=1: Manually created target withcopter_id;objNamecorresponds toCopterIDtype=2: Scene-embedded object;objNamecorresponds to the object's name (string)
Internally invokes the RflyReqObjData(int opFlag, FString objName, FString colorflag) function command, where opFlag: 0=create camera, 1=create target corresponding to copter_id, 2=create object.
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| type_id | int | No | 1 | Request type: 0=Camera, 1=Target with copter_id, 2=Scene-embedded object |
| objName | int/str | No | 1 | Target identifier: seqID for camera, CopterID for target, or object name string |
| windowID | int | No | 0 | Target RflySim3D window ID; default is window 0 |
Return Value (Returns): None
Exceptions (Raises): None
reqCam(SeqIDList=[0], windowID=0)¶
Function Description: Requests data for specified cameras from RflySim3D. After sending the request, RflySim3D periodically returns CameraData structures, which are stored in self.CamDataVect upon receipt and can be retrieved using getCamCoptObj.
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| SeqIDList | list[int] | No | [0] | List of camera sequence IDs |
| windowID | int | No | 0 | Target RflySim3D window ID; default is window 0 |
Return Value (Returns): None
Exceptions (Raises): None
reqCopt(CopterIDList=[0], windowID=0)¶
Function Description: Requests data for specified targets with copter_id from RflySim3D. After sending the request, RflySim3D periodically returns CoptReqData structures, which are stored in self.CoptDataVect upon receipt and can be retrieved using getCamCoptObj.
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| CopterIDList | list[int] | No | [0] | List of copter_id IDs |
| windowID | int | No | 0 | Target RflySim3D window ID; default is window 0 |
Return Value (Returns): None
Exceptions (Raises): None
reqObj(ObjNameList=[''], windowID=0)¶
Function Description: Requests data for scene-embedded objects from RflySim3D. After sending the request, RflySim3D periodically returns ObjReqData structures, which are stored in self.ObjDataVect upon receipt and can be retrieved using getCamCoptObj.
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| ObjNameList | list[str] | No | [''] | List of object names |
| windowID | int | No | 0 | Target RflySim3D window ID; default is window 0 |
Return Value (Returns): None
Exceptions (Raises): None
SetUE4RadianceValue(UEObjectName, windows=-1)¶
Function Description: Sets the radiance/luminance value of a specified object in UE4, used to adjust lighting or emissive effects of objects in the scene.
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| UEObjectName | str | Yes | None | Name of the object in the UE4 scene |
| windows | int | No | -1 | Target RflySim3D window ID; -1 indicates broadcasting to all windows |
Return Value (Returns): None
Exceptions (Raises): None
SetUE4RadianceValue__All(windows=-1)¶
Function Description: Sets the radiance/luminance value for all windows.
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| windows | int | No | -1 | Window ID; -1 indicates all windows |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4SetStencilValueByActorName(Actorname, StencilValue, is_name_regex=False, windowID=-1)¶
Function Description: Sets the stencil value (template buffer value) of the scene via Actor name, used for masking or contour extraction in post-processing.
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| Actorname | str | Yes | None | Actor name |
| StencilValue | int | Yes | None | Stencil value (0–255) |
| is_name_regex | bool | No | False | Whether to use regex for name matching |
| windowID | int | No | -1 | Window ID; -1 indicates all windows |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4SetStencilValueByMeshComponentName(Meshname, StencilValue, is_name_regex=False, windowID=-1)¶
Function Description: Sets the stencil value of the scene via mesh component name, used for masking or contour extraction in post-processing.
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| Meshname | str | Yes | None | Mesh component name |
| StencilValue | int | Yes | None | Stencil value (0–255) |
| is_name_regex | bool | No | False | Whether to use regex for name matching |
| windowID | int | No | -1 | Window ID; -1 indicates all windows |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4SetStencilValueByCopterID(CopterID, StencilValue, windowID=-1)¶
Function Description: Sets the stencil value of the corresponding Actor via CopterID (drone ID), used for masking or contour extraction in post-processing.
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| CopterID | int | Yes | None | Drone ID |
| StencilValue | int | Yes | None | Stencil value (0–255) |
| windowID | int | No | -1 | Window ID; -1 indicates all windows |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4VariableMessage(copterID, vehicleType, settingType, pointIndex, vehicleSetting, messageType, messageDatas, windowID=-1)¶
Function Description: Sends a variable-length pipeline/line message for creating or modifying visualization objects such as pipes and lines in UE4. Supports operation types including create, modify, and delete, and allows setting properties such as pipe radius, transparency, and color.
Arguments (Args):
| Parameter Name | Type | Required | Default Value | Description |
|---|---|---|---|---|
| copterID | int | Yes | None | Object ID, used to uniquely identify a pipeline/tube object |
| vehicleType | int | Yes | None | Object type (ClassID) |
| settingType | int | Yes | None | Edit type: 0 = add, 1 = modify, 2 = delete |
| pointIndex | list | Yes | None | Array of point indices: -1 = all points, 0 = no modification, other values = specific point indices |
| vehicleSetting | list | Yes | None | Parameter settings array (16 elements): [radius (m), opacity, emissive intensity, color R, G, B, A, UI visibility flag, ...]; -1 = retain original data, -2 = use default data |
| messageType | int | Yes | None | Message type: 0 = unknown, 1 = int32, 2 = float, 3 = string, 4 = Vector2D, 5 = Vector3D |
| messageDatas | list | Yes | None | Message content array; coordinate units are meters |
| windowID | int | No | -1 | Window ID; -1 indicates all windows |
Return Value (Returns): None
Exceptions (Raises): None
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | Yes | None | Object ID, used to uniquely identify a pipeline/tube object |
| vehicleType | int | Yes | None | Object type (ClassID) |
| settingType | int | Yes | None | Edit type: 0 = add, 1 = modify, 2 = delete |
| pointIndex | list | Yes | None | Array of point indices: -1 = all points, 0 = no modification, other values = specific point indices |
| vehicleSetting | list | Yes | None | Parameter settings array (16 elements): [radius (m), opacity, emissive intensity, color R, G, B, A, UI visibility flag, ...]; -1 = retain original data, -2 = use default data |
| messageType | int | Yes | None | Message type: 0 = unknown, 1 = int32, 2 = float, 3 = string, 4 = Vector2D, 5 = Vector3D |
| messageDatas | list | Yes | None | Message content array; coordinate units are meters |
| windowID | int | No | -1 | Window ID; -1 indicates all windows |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4CreatePipelineMsg(copterID, settingParam, messageDatas)¶
Function Description: Sends a pipeline creation message to create a new pipeline/tube object in UE4.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | Yes | None | Pipeline object ID |
| settingParam | list | Yes | None | Pipeline parameter settings array |
| messageDatas | list | Yes | None | Pipeline point coordinate data |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4CoverPipelineMsg(copterID, settingParam, messageDatas)¶
Function Description: Sends a pipeline overwrite message to completely replace an existing pipeline/tube object with new data.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | Yes | None | Pipeline object ID |
| settingParam | list | Yes | None | Pipeline parameter settings array |
| messageDatas | list | Yes | None | Pipeline point coordinate data |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4AddPointToPipelineMsg(copterID, messageDatas)¶
Function Description: Sends a message to append new points to an existing pipeline/tube object.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | Yes | None | Pipeline object ID |
| messageDatas | list | Yes | None | Point coordinate data to be appended |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4DeletePointMsg(copterID, pointIndexs)¶
Function Description: Sends a message to delete specific points from a pipeline.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | Yes | None | Pipeline object ID |
| pointIndexs | list | Yes | None | Array of indices of points to be deleted |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4SetPipelineScaleMsg(copterID, pointIndexs, size)¶
Function Description: Sends a message to set the pipeline thickness, modifying the radius/thickness of specified points.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | Yes | None | Pipeline object ID |
| pointIndexs | list | Yes | None | Array of point indices to be modified; -1 indicates all points |
| size | float | Yes | None | Pipeline radius in meters |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4SetPipelineDiaphaneityMsg(copterID, pointIndexs, diaphaneity)¶
Function Description: Sends a message to set the pipeline transparency, modifying the material transparency of specified points.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | Yes | None | Pipeline object ID |
| pointIndexs | list | Yes | None | Array of point indices to be modified; -1 indicates all points |
| diaphaneity | float | Yes | None | Transparency value, typically in the range [0, 1] |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4SetPipelineLightMsg(copterID, pointIndexs, light)¶
Function Description: Sends a message to set the pipeline emissive intensity, modifying the self-illumination effect of specified points.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | Yes | None | Pipeline object ID |
| pointIndexs | list | Yes | None | Array of point indices to be modified; -1 indicates all points |
| light | float | Yes | None | Emissive intensity value |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4SetPipelineColorMsg(copterID, pointIndexs, Color_R, Color_G, Color_B, Color_A)¶
Function Description: Sends a message to set the pipeline color, modifying the material color (RGBA) of specified points.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | Yes | None | Pipeline object ID |
| pointIndexs | list | Yes | None | Array of point indices to be modified; -1 indicates all points |
| Color_R | float | Yes | None | Red channel value (0–1 or 0–255) |
| Color_G | float | Yes | None | Green channel value (0–1 or 0–255) |
| Color_B | float | Yes | None | Blue channel value (0–1 or 0–255) |
| Color_A | float | Yes | None | Alpha channel value (0–1 or 0–255) |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4SetPipelinePosMsg(copterID, pointIndexs, messageDatas)¶
Function Description: Sends a message to set the position of pipeline points, modifying the spatial coordinates of specified points.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | Yes | None | Pipeline object ID |
| pointIndexs | list | Yes | None | Array of point indices to be modified |
| messageDatas | list | Yes | None | New point coordinate data in meters |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4SetWidgetVisble(copterID, isShowUI)¶
Function Description: Sends a message to set widget visibility, controlling the display or hiding of UI widgets related to pipelines/lines.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | Yes | None | Pipeline/widget object ID |
| isShowUI | bool | Yes | None | Whether to show the UI widget; True to show, False to hide |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4RobotExtAct(copterID=1, ActExt=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], windowID=-1)¶
Function Description: Sends extended action control commands for the quadruped robot (robot dog) to the UE4 simulation environment. Control item activation is managed via a TypeMask bitmask, supporting multiple control modes including action commands, obstacle avoidance settings, target position, attitude control, and velocity vectors.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | No | 1 | CopterID identifier of the robot dog |
| ActExt | list[float] | No | [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0] | Extended action parameter array, 16 elements total: 0.TypeMask (bitmask) 1.Robot dog action command (1 stand up, 2 jump, etc.) 2.Obstacle avoidance radius 3-5.Destination position x,y,z 6-8.Robot dog's own Roll, Pitch, Yaw 9-11.Robot dog forward vector X,Y,Z 12.Robot dog speed setting 13.Coordinate system used (1:NED, 2:FRD) |
| windowID | int | No | -1 | Target window ID; -1 indicates all windows |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4MassMovement(robotDogID, childUAVID, isCombined)¶
Function Description: Sends a command to combine or separate a robot dog and a UAV, enabling coordinated motion control of a UAV carried by the robot dog.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| robotDogID | int | Yes | - | ID of the robot dog |
| childUAVID | int | Yes | - | ID of the child UAV (the one being carried) |
| isCombined | bool/int | Yes | - | Whether to combine; True/1 means combine, False/0 means separate |
Return Value (Returns): None
Exceptions (Raises): None
sendDogPosENoAltYaw(copterID, pos_x, pos_y, yaw)¶
Function Description: Sends horizontal position (XY plane) and yaw angle control commands for the robot dog, while maintaining constant altitude.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | Yes | - | CopterID of the robot dog |
| pos_x | float | Yes | - | Target X coordinate (ENU coordinate system, unit: meters) |
| pos_y | float | Yes | - | Target Y coordinate (ENU coordinate system, unit: meters) |
| yaw | float | Yes | - | Target yaw angle (unit: radians) |
Return Value (Returns): None
Exceptions (Raises): None
sendDogPosENoAlt(copterID, pos_x, pos_y)¶
Function Description: Sends horizontal position (XY plane) control commands for the robot dog, while maintaining constant altitude and yaw angle.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | Yes | - | CopterID of the robot dog |
| pos_x | float | Yes | - | Target X coordinate (ENU coordinate system, unit: meters) |
| pos_y | float | Yes | - | Target Y coordinate (ENU coordinate system, unit: meters) |
Return Value (Returns): None
Exceptions (Raises): None
sendDogRateNoAltYaw(copterID, yaw_rate, speed_x, speed_y, axis)¶
Function Description: Sends rate control commands for the robot dog (yaw rate + horizontal velocity), while maintaining constant altitude.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | Yes | - | CopterID of the robot dog |
| yaw_rate | float | Yes | - | Yaw rate (unit: radians/second) |
| speed_x | float | Yes | - | Velocity in X direction (unit: meters/second) |
| speed_y | float | Yes | - | Velocity in Y direction (unit: meters/second) |
| axis | int | Yes | - | Coordinate system selection (1: NED, 2: FRD/body-fixed frame) |
Return Value (Returns): None
Exceptions (Raises): None
sendDogVelENoAltYaw(copterID, yaw, speed_x, speed_y, axis)¶
Function Description: Sends velocity and feedforward yaw angle control commands for the robot dog, while maintaining constant altitude.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | Yes | - | CopterID of the robot dog |
| yaw | float | Yes | - | Target yaw angle (unit: radians) |
| speed_x | float | Yes | - | Velocity in X direction (unit: meters/second) |
| speed_y | float | Yes | - | Velocity in Y direction (unit: meters/second) |
| axis | int | Yes | - | Coordinate system selection (1: NED, 2: FRD/body-fixed frame) |
Return Value (Returns): None
Exceptions (Raises): None
sendDogVelENoAlt(copterID, speed_x, speed_y, axis)¶
Function Description: Sends horizontal velocity control commands for the robot dog, while maintaining constant altitude and yaw angle.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | Yes | - | CopterID of the robot dog |
| speed_x | float | Yes | - | Velocity in X direction (unit: m/s) |
| speed_y | float | Yes | - | Velocity in Y direction (unit: m/s) |
| axis | int | Yes | - | Coordinate system selection (1: NED, 2: FRD/body-fixed frame) |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4DogSpeed(copterID, speed)¶
Function Description: Sends a command to set the scalar motion speed of the robot dog.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | Yes | - | CopterID of the robot dog |
| speed | float | Yes | - | Target speed value (unit: m/s) |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4DogObstacleAvoidance(copterID, radius)¶
Function Description: Sends a command to set the obstacle avoidance radius of the robot dog, enabling or disabling autonomous obstacle avoidance.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | Yes | - | CopterID of the robot dog |
| radius | float | Yes | - | Obstacle avoidance radius (unit: m); obstacle avoidance is disabled when radius < 0; default is 0.05 |
Return Value (Returns): None
Exceptions (Raises): None
sendUE4DogPlayAction(copterID, actionNum)¶
Function Description: Sends a command to play a predefined action of the robot dog, triggering a specific behavioral motion.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| copterID | int | Yes | - | CopterID of the robot dog |
| actionNum | int | Yes | - | Action number; valid values: 1: Damp, 2: BalanceStand, 3: StopMove, 4: PStandUp, 5: StandDown, 6: RecoveryStand, 7: Sit, 8: RiseSit, 9: SwitchGait, 10: BodyHeight, 11: FootRaiseHeight, 12: SpeedLevel, 13: Hello, 14: Stretch, 15: SwitchJoystick, 16: ContinuousGait, 17: Wallow, 18: Pose, 19: Scrape, 20: FrontFlip, 21: FrontJump, 22: FrontPounce, 23: Dance |
Return Value (Returns): None
Exceptions (Raises): None
startMulticastListener()¶
Function Description: Starts the multicast listener to receive multicast data from the UE4 simulation environment.
Arguments (Args): None
Return Value (Returns): None
Exceptions (Raises): None
stopMulticastListener()¶
Function Description: Stops the multicast listener, terminating the reception of multicast data from the UE4 simulation environment.
Arguments (Args): None
Return Value (Returns): None
Exceptions (Raises): None
getRflyStatusMap()¶
Function Description: Retrieves the RflySim simulation status map, containing the current simulation runtime status and related information.
Arguments (Args): None
Return Value (Returns): Returns a dictionary storing various status information in key-value pairs.
Exceptions (Raises): None
getRflyIP(user)¶
Function Description: Retrieves the RflySim simulation IP address for a specified user.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| user | str | Yes | - | User identifier |
Return Value (Returns): Returns the IP address string corresponding to the specified user.
Exceptions (Raises): None
getRflyStartTime(user)¶
Function Description: Retrieves the RflySim simulation start time for a specified user.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| user | str | Yes | - | User identifier |
Return Value (Returns): Returns the simulation start timestamp (unit: seconds).
Exceptions (Raises): None
getRflyMapName(user)¶
Function Description: Retrieves the RflySim map name for a specified user.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| user | Any | Yes | - | Target user identifier |
Return Value (Returns): Map name
Exceptions (Raises): None
getRflyHeartbeat(user)¶
Function Description: Retrieves the RflySim heartbeat status for a specified user.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| user | Any | Yes | - | Target user identifier |
Return Value (Returns): Heartbeat status
Exceptions (Raises): None
getLocalUserName()¶
Function Description: Retrieves the local username.
Arguments (Args): None
Return Value (Returns): Local username
Exceptions (Raises): None
getCurIP()¶
Function Description: Retrieves the current IP address.
Arguments (Args): None
Return Value (Returns): Current IP address
Exceptions (Raises): None
getCurMapName()¶
Function Description: Retrieves the current map name.
Arguments (Args): None
Return Value (Returns): Current map name
Exceptions (Raises): None
getCurStartTime()¶
Function Description: Retrieves the current startup time.
Arguments (Args): None
Return Value (Returns): Current startup time
Exceptions (Raises): None
getCurHeartbeat()¶
Function Description: Retrieves the current heartbeat status.
Arguments (Args): None
Return Value (Returns): Current heartbeat status
Exceptions (Raises): None
getAllIPAndUserName()¶
Function Description: Retrieves all IP addresses and corresponding usernames.
Arguments (Args): None
Return Value (Returns): Mapping of all IP addresses and usernames
Exceptions (Raises): None
getAllUEMaps(is_ue5=False)¶
Function Description: Retrieves all valid map names (.umap files) from the Content directory of the specified UE project. Automatically excludes maps starting with '_' or containing 'LogicMap' in their name.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| is_ue5 | bool | No | False | Whether it is a UE5 project |
Return Value (Returns): List of valid map names
Exceptions (Raises): None
getAllUECopters(is_ue5=False, sort_by_custom=True)¶
Function Description: Retrieves all placeable Copter entries in the current UE/UE5 project. This interface traverses XML resources under the project Content and plugin Content, extracts fields such as MeshClass and Name, processes them according to rules, and returns the result.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| is_ue5 | bool | No | False | Whether to read according to UE5 project paths and resource rules |
| sort_by_custom | bool | No | True | Whether to sort by custom rules; when False, sorts by ClassID |
Return Value (Returns): List of placeable Copter entries, each element typically a dictionary containing name, category, class ID, and other information.
Exceptions (Raises): None
getAllUEVehicles(is_ue5=False, sort_by_custom=True)¶
Function Description: Retrieves all vehicle entries in the current UE/UE5 project. This interface first reads the list of vehicle names, then filters vehicle-related XML items from the original resource list.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| is_ue5 | bool | No | False | Whether to read according to UE5 project path and resource rules |
| sort_by_custom | bool | No | True | Whether to sort by custom rules; when False, sort by ClassID |
Returns: A list of vehicle entries, each element typically a dictionary containing name, category, ClassID, and other information.
Raises: None
getAllUEItems(is_ue5=False, sort_by_custom=True)¶
Function Description: Retrieves all placeable items other than vehicles in the current UE/UE5 project. This interface traverses .xml files under the project Content and plugin Content directories, excludes items in the vehicle name list, and processes categories and sorting according to predefined rules.
Arguments (Args):
| Parameter Name | Type | Required | Default | Description |
|---|---|---|---|---|
| is_ue5 | bool | No | False | Whether it is a UE5 project |
| sort_by_custom | bool | No | True | Whether to sort by custom rules; when False, sort by ClassID |
Returns: A list of placeable items other than vehicles, each element typically a dictionary containing name, category, ClassID, and other information.
Raises: None
Advanced Usage Examples¶
Demonstrates complex combined scenarios (e.g., multi-type collaboration, asynchronous control, batch operations)
from RflySimSDK.ue import UE4CtrlAPI, VisionSensorReqNew, CameraData
import time
import threading
# Initialize UE4 control API
ue = UE4CtrlAPI()
# Batch create multiple drones and assign circular trajectories
def batch_create_drones(count, center_pos, radius, height):
"""Batch create drones and assign circular formation trajectories"""
drones = []
for i in range(count):
angle = (2 * 3.14159 * i) / count
drone_id = 100 + i # Starting ID
# Compute target position
target_x = center_pos[0] + radius * __import__('math').cos(angle)
target_y = center_pos[1] + radius * __import__('math').sin(angle)
# Send initial position to ground
ue.sendUE4Pos2Ground(drone_id, 1,
[target_x, target_y, height, 0, 0, 0])
drones.append({
'id': drone_id,
'angle': angle,
'radius': radius
})
return drones
# Asynchronous vision sensor data acquisition
def async_vision_sensor(sensor_id, callback):
"""Asynchronously fetch vision sensor data"""
sensor = VisionSensorReqNew()
def fetch_data():
while True:
# Copy latest data
sensor.CopyData()
callback(sensor_id, sensor)
time.sleep(0.033) # 30Hz refresh rate
thread = threading.Thread(target=fetch_data)
thread.daemon = True
thread.start()
return thread
# Complex scenario: Formation flight + dynamic obstacle avoidance + visual tracking
def complex_scenario():
# 1. Batch create 6 drones in a circular formation
formation = batch_create_drones(
count=6,
center_pos=[0, 0, 0],
radius=50,
height=30
)
# 2. Add dynamic circular trajectories to the formation
for drone in formation:
ue.circle_traj(
drone['id'],
center=[0, 0, 30],
radius=drone['radius'],
speed=10,
height=30
)
# 3. Asynchronously start visual sensor for target tracking
def on_vision_data(sensor_id, data):
# Process vision data and dynamically adjust the formation
print(f"Sensor {sensor_id} captured frame")
async_vision_sensor(201, on_vision_data)
# 4. Dynamic destruction and reconstruction (simulating fault recovery)
time.sleep(10)
ue.sendUE4Destroy(102) # Destroy drone #2
time.sleep(2)
ue.sendUE4Pos2Ground(102, 1, [30, 30, 30, 0, 0, 0]) # Reconstruct
# Execute the complex scenario
if __name__ == "__main__":
complex_scenario()
Notes and Pitfall Avoidance Guide¶
-
ID Conflict Management: The
copIDparameter in methods such assendUE4PosandsendUE4Pos2Groundmust be globally unique. Reusing the same ID for different positions will cause object flickering or abnormal control in UE4. It is recommended to establish an ID allocation table (e.g., 100–199 for multirotors, 200–299 for fixed-wing aircraft). -
Coordinate System Confusion:
sendUE4Posuses the NED (North-East-Down) coordinate system, whereassendUE4Pos2Groundforces the height to zero relative to the ground. Mixing these two withincircle_trajwill result in incorrect height calculations. It is recommended to consistently usesendUE4Posthroughout and manually implement ground collision detection. -
Asynchronous Data Race:
VisionSensorReqNew.CopyData()andCameraData.CopyData()are not thread-safe. Concurrent calls across threads may cause memory alignment errors. Mutex locks must be used for protection, orCopyDataOldcan be used as a fallback to retrieve cached data from the previous frame. -
Uncontrolled Object Lifecycle:
sendUE4Destroyonly destroys the UE4 visual object and does not clean up lingeringCoptReqDataorObjReqDatainstances on the Python side. Long-running simulations will suffer from memory leaks. It is recommended to implement an object pool and explicitly calldelor reconstruct theUE4CtrlAPIinstance. -
Network Timeout Blind Spot:
sendUE4CmdNetrelies on UDP transmission without acknowledgment. If the UE4 side is not running or firewall rules block the traffic, the call will fail silently. In production environments, this must be paired withreqVeCrashDataor a custom heartbeat detection mechanism. Upon timeout, a reconnection logic should be triggered instead of continuing to queue commands.
Changelog¶
2026-04-10: Added interfaces for retrieving the UE map and list of placeable items.2026-03-06: Added interface for overriding pipe creation.2026-03-03: feat: SDK added IP handling mechanism to support local deployment on cloud.2026-03-02: Added interface to delete a copter by ID.2026-02-28: Added API to toggle visibility of waypoint ID labels in the UI.2026-01-20: Fixed multicast interface and WSL environment bugs inUE4CtrlAPI.2026-01-14: Modified multicast port.2026-01-06: Added new interfaces for multicast-based IP retrieval and retrieving the RflySim-opened map.2025-12-18: Added new UE control interfaces.2025-09-11: fix: Added support for port reuse on Linux.2025-08-19: fix: Updated vision and UE interfaces.2025-07-14: fix2025-07-11: fix2024-07-30: Added gimbal interface documentation.2024-07-10: Integrated interface content used by the gimbal program.