NaN values when attempting Motion Read for a UAV Scenario
2 次查看(过去 30 天)
显示 更早的评论
I'm currently attempting to get platform or sensor related motion data from my UAV 3d scenario Simulink Model. Attached is the current block diagram:

I have the UAV scenario configuration block, the SImulation 3D scene configuration block, and the UAV Scenario Motion Read block, connected to my workspace as shown above. The UAV scenario block is configured for the singleUAVScenario function, which spawns a single quadrotor. The control part and this configuration were taken from an example in MATLAB's documentation, so all bus, signal, and data blocks' names are unchanged. When I run the model, initially the values are updating, as shown:

However, more or less after a single second passes in my simulation, for some reason, my data goes to NaN values for the rest of the simulation, no matter how long it is, as shown here:

Obviously, when I take the data to MATLAB using a To Workspace block, I have the same issue.
I've tried running another MATLAB example; quick access for that is this:
openExample('uav/SimulateUAVScenarioUsingScenarioBlocksExample')
In that simulink model, the displays constantly update and there are no nan issues. Can anyone provide any answers? Sorry if it's an easy fix, I don't have too much experience in this particular area. Is it the sampling time, some inherent issue? I'm assuming that, according to the matlab documentation for the UAV scenario configuration block...
This block internally stores motion states from platforms and sensors in a global data store memory block as buses within a bus with a name specified in the Scenario motion bus name parameter.
That the motion parameters are automatically stored in this global data store memory block, and by using the read block, I can simply get the motion data. Do let me know if any additional information is needed, I can provide.
Note: Data goes to NaN after an exact second in simulation time has elapsed. No matter what the simulation step size is, the data seems constant except for the Position data for the first second, but instantly after, everything goes to NaN (except platform ID). The constant data also may be wrong, I suspect.
1 个评论
回答(1 个)
Jianxin Sun
2025-1-24
Hi Hasan,
I observe that you are using blocks from both Simulation 3D Scene Configuration and UAV Scenario Configuration. They are two different simulation environment. You can refer to the documentation page https://www.mathworks.com/help/uav/scenario-simulation.html to see that they are in two different category: Unreal Engine 3D Simulation and UAV Cuboid Scenario Simulation.
Following examples are good starting place to understand more about these two environments:
Unreal Engine: https://www.mathworks.com/help/uav/ug/simulate-a-simple-flight-scenario-and-sensor-in-3d-environment.html
If you need to retreive position of your vehicle from Unreal, you can use Simulation 3D Actor Tranform Get block, but you'll need to pay attention to the coordinate systems differences used by Simulation 3D Actor Transform Get block and SImulation 3D UAV Vehicle block. In general, the position and rotation you set in Simulation 3D UAV block will be exactly reflected in Unreal Engine, and you don't need to read from Unreal Engine to get vehicle position
Jianxin
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!