Monitor and Tune PX4 Host Target Flight Controller with Simulink-Based Plant Model: Mismatched TCP Node

17 visualizaciones (últimos 30 días)
Hi, I'm following the Tutorial here and I'm getting stuck at the last step where the two MATLAB instances are failing to communicate with each other presumably due to mismatched TCP ports. I can't determine where I may be able to set what ports to sned/receive from.
The following is the Simulink diagnostics output for the first MATLAB instance where I am running PX4Demo_FlightController_top
Updating Model Reference Code Generation Targets
### Starting serial model reference code generation build.
Building FlightController
### Checking status of model reference code generation target for model 'FlightController' used in 'px4Demo_FlightController_top'.
### Model reference code generation target (FlightController.cpp) for model FlightController must be recompiled because FlightController.cpp changed since last build, or it was not compiled.
### Starting build procedure for: FlightController
### Generating code and artifacts to 'Model specific' folder structure
### Code for the model reference code generation target for model FlightController is up to date because no functional changes were found in referenced model.
Removing old px4_simulink_app directory: /home/USERNAME/Documents/PX4_Source/Firmware/src/modules/px4_simulink_app.
### Successful completion of build procedure for: FlightController
### Model reference code generation target for FlightController is up to date.
Top Model Build
### Starting build procedure for: px4Demo_FlightController_top
### Generating code and artifacts to 'Model specific' folder structure
### Generating code into build folder: /home/USERNAME/MATLAB/Projects/examples/Px4DemoHostTargetWithSimulinkPlant6/work/code/px4Demo_FlightController_top_ert_rtw
Warning: The Simulink model contains a PX4 PWM Output block and the algorithm to be designed is set as "Design Path Follower in Simulink".
The PWM block output might conflict with the PWM values generated by the default PX4 Controllers in this case.
### Generated code for 'px4Demo_FlightController_top' is up to date because no structural, parameter or code replacement library changes were found.
### Saving binary information cache.
Removing old px4_simulink_app directory: /home/USERNAME/Documents/PX4_Source/Firmware/src/modules/px4_simulink_app.
Build path: /home/USERNAME/MATLAB/Projects/examples/Px4DemoHostTargetWithSimulinkPlant6/work/code/px4Demo_FlightController_top_ert_rtw
### Successful completion of build procedure for: px4Demo_FlightController_top
Build process completed successfully
Build Summary
0 of 2 models built (2 models already up to date)
Build duration: 0h 0m 18.507s
action: EXT_INIT
Creating Target Handler (XCP on TCP/IP)...
Build directory: /home/USERNAME/MATLAB/Projects/examples/Px4DemoHostTargetWithSimulinkPlant6/work/code/px4Demo_FlightController_top_ert_rtw
Target name: 127.0.0.1
Target port: 17725
Warning: The Simulink model contains a PX4 PWM Output block and the algorithm to be designed is set as "Design Path Follower in Simulink".
The PWM block output might conflict with the PWM values generated by the default PX4 Controllers in this case.
### Starting serial model reference code generation build.
### Checking status of model reference code generation target for model 'FlightController' used in 'px4Demo_FlightController_top'.
### Model reference code generation target (FlightController.cpp) for model FlightController must be recompiled because FlightController.cpp changed since last build, or it was not compiled.
### Starting build procedure for: FlightController
### Generating code and artifacts to 'Model specific' folder structure
### Checking the status of code in build folder: /home/USERNAME/MATLAB/Projects/examples/Px4DemoHostTargetWithSimulinkPlant6/work/code/slprj/ert/FlightController
### Code for the model reference code generation target for model FlightController is up to date because no functional changes were found in referenced model.
Removing old px4_simulink_app directory: /home/USERNAME/Documents/PX4_Source/Firmware/src/modules/px4_simulink_app.
### Successful completion of build procedure for: FlightController
### Model reference code generation target for FlightController is up to date.
Build Summary
0 of 1 models built (1 models already up to date)
Build duration: 0h 0m 3.612s
For referenced models, external mode simulations do not support the following:
The use of blocks to view signals from the target application.
Tuning or uploading of model parameters.
Component:Simulink | Category:Model warning
action: EXT_CONNECT
Connecting to the target...
External Mode Open Protocol Connect command failed
Caused by:
Could not connect to target application: XCP TCP/IP error: Connect failed
Component:Simulink | Category:Block diagram error
Unable to connect to the 'PX4 Host Target' target for 'px4Demo_FlightController_top'.
As you might be able to tell, the code generation and compilation works just fine and I get the popup window saying that "the monitor and tune build is complete". The problematic bit I want to highlight is "Target port: 17725", which is in contrast with the port 4560 specified in Quad_Plant_top.slx. Here is the Simulink Diagnostics output from the Second MATLAB instance where I am running Quad_Plant_top:
An error occurred while running the simulation and the simulation was terminated
Caused by:
MATLAB System block 'Quad_Plant_top/MATLAB System1' error occurred when invoking 'stepImpl' method of 'px4HostTarget_TCPIP_Write'. The error was thrown from '
'/home/USERNAME/Documents/MATLAB/SupportPackages/R2022b/toolbox/target/supportpackages/px4/px4examples/exampleTCPFiles/px4HostTarget_TCPIP_Write.m' at line 42'.
Failed to write from the server. A TCP/IP client must be connected to the server.
Am I just timing things wrong when starting one and resuming (hitting "ok") on the other? Or is there perhaps some setup step I may have forgotten? I could use some guidance.
I am on Ubuntu 18.04.6, using MATLAB/Simulink 2022b, and PX4 firmware v1.12.3.

Respuestas (1)

Arun Mathamkode
Arun Mathamkode el 27 de Jul. de 2023
As per the documentation you need to run the Plant model first and then run the Controller model in another instance of MATLAB (clicking OK in the dialog box). Ensure that you have followed the same. The TCP port 17725 is used to communicate between the Simulink and the PX4 Host Target that is launched. The port 4560 is used between the PX4 host target and the plant model. So It not really a port mismatch as you doubt. I would suggets to observe the following, when launching the PX4 Host Target from Simulink using Monitor and Tune simulation, see if your Host Target window have any errors thrown out. I would also suggest to try 'Build ,Deploy and Start' option also instead of the Monitor and Tune simulation.
  2 comentarios
Jae Woo Kim
Jae Woo Kim el 28 de Jul. de 2023
Editada: Jae Woo Kim el 1 de Ag. de 2023
Error output is still the same as what I listed above but it appears there is a terminal window that temporarily opens then automatically closes when running Monitor and Tune simulation for the controller. As far as I can see, nothing is written in said terminal window while it is available. How could I troubleshoot from here?
Build Deploy and Start option also doesn't seem to actually start the controller. I don't get that build completed text box that I have to hit "ok" on.
teklot
teklot el 31 de Mayo de 2024
Experiencing the same issue. It is trying to connect to 127.0.0.1:17725
I am using WSL and provided WSL IP but no luck!
Could it be because of the WSL?
Thanks!

Iniciar sesión para comentar.

Categorías

Más información sobre System on Chip (SoC) en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by