Monitor and Tune PX4 Host Target Flight Controller with Simulink-Based Plant Model: Mismatched TCP Node
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.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. 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. px4 MATLAB Answers — New Questions